From: Po Lu Date: Wed, 30 Mar 2022 06:20:13 +0000 (+0800) Subject: ; * lisp/dired.el (dired-mouse-drag): Create local copy if file is remote. X-Git-Tag: emacs-29.0.90~1931^2~864 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=7a5f2b79e9d75e4fd67844bdb8325a32b011383d;p=emacs.git ; * lisp/dired.el (dired-mouse-drag): Create local copy if file is remote. --- diff --git a/lisp/dired.el b/lisp/dired.el index 409a312d0dd..41313f5eb9f 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -1717,17 +1717,25 @@ see `dired-use-ls-dired' for more details.") ;; We can get an error if there's by some chance no file ;; name at point. (condition-case nil - (progn - (gui-backend-set-selection 'XdndSelection - (with-selected-window (posn-window - (event-end event)) - (dired-file-name-at-point))) - (x-begin-drag '("text/uri-list" - "text/x-dnd-username") - (if (eq 'dired-mouse-drag-files 'link) - 'XdndActionLink - 'XdndActionCopy) - nil nil t)) + (let ((filename (with-selected-window (posn-window + (event-end event)) + (dired-file-name-at-point)))) + (when filename + ;; In theory x-dnd-username combined with a proper + ;; file URI containing the hostname of the remote + ;; server could be used here instead of creating a + ;; local copy of the remote file, but no program + ;; actually implements file DND according to the + ;; spec. + (when (file-remote-p filename) + (setq filename (file-local-copy filename))) + (gui-backend-set-selection 'XdndSelection filename) + (x-begin-drag '("text/uri-list" + "text/x-dnd-username") + (if (eq 'dired-mouse-drag-files 'link) + 'XdndActionLink + 'XdndActionCopy) + nil nil t))) (error (when (eq (event-basic-type new-event) 'mouse-1) (push new-event unread-command-events)))))))))