From 1a41df947bcf102e0884f295d8f394ade8d9eb18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=ADn?= Date: Sat, 19 Sep 2020 14:13:53 +0200 Subject: [PATCH] Give ns-drag-operation-copy preference when handling drag and drop Some applications like Firefox send NSDragOperationEvery when dragging URLs or images. That constant means "every possible operation (copy, link, move)". When there's more than one operation, we want to consider specialized actions like ns-drag-operation-copy before generic ones like ns-drag-operation-generic. This change brings back the same drag and drop behavior as in Emacs 26.3. (Bug#43470). * lisp/term/ns-win.el (ns-drag-n-drop): Move the check for ns-drag-operation-copy before ns-drag-operation-generic. --- lisp/term/ns-win.el | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lisp/term/ns-win.el b/lisp/term/ns-win.el index 90024b001f..fc20de5a05 100644 --- a/lisp/term/ns-win.el +++ b/lisp/term/ns-win.el @@ -513,19 +513,19 @@ ns-drag-n-drop (set-frame-selected-window nil window) (raise-frame) (setq window (selected-window)) - (cond ((memq 'ns-drag-operation-generic operations) - ;; Perform the default action for the type. - (if (eq type 'file) - (dolist (data objects) - (dnd-handle-one-url window 'private (concat "file:" data))) - (dnd-insert-text window 'private string))) - ((memq 'ns-drag-operation-copy operations) + (cond ((memq 'ns-drag-operation-copy operations) ;; Try to open the file/URL. If type is nil, try to open ;; it as a URL anyway. (dolist (data objects) (dnd-handle-one-url window 'private (if (eq type 'file) (concat "file:" data) data)))) + ((memq 'ns-drag-operation-generic operations) + ;; Perform the default action for the type. + (if (eq type 'file) + (dolist (data objects) + (dnd-handle-one-url window 'private (concat "file:" data))) + (dnd-insert-text window 'private string))) (t ;; Insert the text as is. (dnd-insert-text window 'private string))))) -- 2.28.0