]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix multi-file drag-and-drop on MS-Windows
authorCecilio Pardo <cpardo@imayhem.com>
Sat, 21 Sep 2024 13:30:27 +0000 (15:30 +0200)
committerEshel Yaron <me@eshelyaron.com>
Mon, 23 Sep 2024 11:59:15 +0000 (13:59 +0200)
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)

lisp/term/w32-win.el

index 3c0acf368f42e53eba4c454ae5ee0cf8581eb5ba..b57b3dd3bef3aea1d0a56b314721f1f3af734697 100644 (file)
 ;;   (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)))
                      (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.