From: Cecilio Pardo Date: Sat, 21 Sep 2024 13:30:27 +0000 (+0200) Subject: Fix multi-file drag-and-drop on MS-Windows X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=7951eac41e3982049436282498b1d6d7c2890b8f;p=emacs.git Fix multi-file drag-and-drop on MS-Windows Pass all dropped files to 'dnd-handle-multiple-urls' in one call instead on doing multiple calls (Bug#73258). * lisp/term/w32-win.el (w32-dropped-file-to-url): New function to convert file name to a url for dnd. (w32-handle-dropped-file): Changed to use 'w32-dropped-file-to-url'. (w32-drag-n-drop): Changed to pass all files to 'dnd-handle-multiple-urls'/ (cherry picked from commit e8f0baf354b117837fd686e2bf6ca8df15bd1cd4) --- diff --git a/lisp/term/w32-win.el b/lisp/term/w32-win.el index 3c0acf368f4..b57b3dd3bef 100644 --- a/lisp/term/w32-win.el +++ b/lisp/term/w32-win.el @@ -101,6 +101,13 @@ ;; (princ event)) (defun w32-handle-dropped-file (window file-name) + (dnd-handle-multiple-urls + window + (list + (w32-dropped-file-to-url file-name)) + 'private)) + +(defun w32-dropped-file-to-url (file-name) (let ((f (if (eq system-type 'cygwin) (cygwin-convert-file-name-from-windows file-name t) (subst-char-in-string ?\\ ?/ file-name))) @@ -117,14 +124,11 @@ (split-string (encode-coding-string f coding) "/") "/"))) - ;; FIXME: is the W32 build capable only of receiving a single file - ;; from each drop? - (dnd-handle-multiple-urls window (list (concat - (if (eq system-type 'cygwin) - "file://" - "file:") - file-name)) - 'private)) + (concat + (if (eq system-type 'cygwin) + "file://" + "file:") + file-name)) (defun w32-drag-n-drop (event &optional new-frame) "Edit the files listed in the drag-n-drop EVENT. @@ -146,8 +150,11 @@ Switch to a buffer editing the last file dropped." (raise-frame) (setq window (selected-window)) - (mapc (apply-partially #'w32-handle-dropped-file window) - (car (cdr (cdr event))))))) + (dnd-handle-multiple-urls + window + (mapcar #'w32-dropped-file-to-url + (car (cdr (cdr event)))) + 'private)))) (defun w32-drag-n-drop-other-frame (event) "Edit the files listed in the drag-n-drop EVENT, in other frames.