From 808a6f8f5f86f5c2356585dcf4b495916ed8bf6d Mon Sep 17 00:00:00 2001 From: Po Lu Date: Sat, 19 Mar 2022 10:27:19 +0800 Subject: [PATCH] Fix some glitches when dragging files from dired * lisp/dired.el (dired-mouse-drag-files): Fix initial values. (dired-mouse-drag): Clear mark if active and only make button release events unread. --- lisp/dired.el | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lisp/dired.el b/lisp/dired.el index da3c3c80cc1..2fe30d2a4e2 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -257,7 +257,7 @@ creating a copy of it . If the value is `link', then a symbolic link will be created to the file instead by the other program (usually a file manager)." :type '(choice (const :tag "Don't allow dragging" nil) - (const :tag "Copy file to other window" tx) + (const :tag "Copy file to other window" t) (const :tag "Create symbolic link to file" link))) (defcustom dired-copy-preserve-time t @@ -1689,15 +1689,17 @@ see `dired-use-ls-dired' for more details.") (declare-function x-begin-drag "xfns.cx") (defun dired-mouse-drag (event) - "Begin a drag-and-drop operation for the file at EVENT. -If we get a mouse motion event right " + "Begin a drag-and-drop operation for the file at EVENT." (interactive "e") + (when mark-active + (deactivate-mark)) (save-excursion (goto-char (posn-point (event-end event))) (track-mouse (let ((new-event (read-event))) (if (not (eq (event-basic-type new-event) 'mouse-movement)) - (push new-event unread-command-events) + (when (eq (event-basic-type new-event) 'mouse-1) + (push new-event unread-command-events)) ;; We can get an error if there's by some chance no file ;; name at point. (condition-case nil @@ -1709,7 +1711,8 @@ If we get a mouse motion event right " (if (eq 'dired-mouse-drag-files 'link) 'XdndActionLink 'XdndActionCopy))) - (error (push new-event unread-command-events)))))))) + (error (when (eq (event-basic-type new-event) 'mouse-1) + (push new-event unread-command-events))))))))) (defvar dired-mouse-drag-files-map (let ((keymap (make-sparse-keymap))) (define-key keymap [down-mouse-1] #'dired-mouse-drag) -- 2.39.2