emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 7a5f2b79e9: ; * lisp/dired.el (dired-mouse-drag): Create local co


From: Po Lu
Subject: master 7a5f2b79e9: ; * lisp/dired.el (dired-mouse-drag): Create local copy if file is remote.
Date: Wed, 30 Mar 2022 02:21:06 -0400 (EDT)

branch: master
commit 7a5f2b79e9d75e4fd67844bdb8325a32b011383d
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    ; * lisp/dired.el (dired-mouse-drag): Create local copy if file is remote.
---
 lisp/dired.el | 30 +++++++++++++++++++-----------
 1 file changed, 19 insertions(+), 11 deletions(-)

diff --git a/lisp/dired.el b/lisp/dired.el
index 409a312d0d..41313f5eb9 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)))))))))
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]