]> git.eshelyaron.com Git - emacs.git/commitdiff
; * lisp/dired.el (dired-mouse-drag): Create local copy if file is remote.
authorPo Lu <luangruo@yahoo.com>
Wed, 30 Mar 2022 06:20:13 +0000 (14:20 +0800)
committerPo Lu <luangruo@yahoo.com>
Wed, 30 Mar 2022 06:20:13 +0000 (14:20 +0800)
lisp/dired.el

index 409a312d0dd6b65fbd9d00a3ba7868ab9553a1a1..41313f5eb9ffc3270fadb8834ba193ecf4c5aa0b 100644 (file)
@@ -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)))))))))