Subject: 31.0.50; w32 drag-n-dropping multiple files is broken
From: Cecilio Pardo <[email-masked]>
To: [email-masked]
Date: Sat, 14 Sep 2024 21:33:00 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

dnd-handle-multiple-urls is called once for each file. This brings 
problems, such that when dropping two directories, emacs open the first 
one on dired, then tries to copy the contents of the second to the 
first. The attached patch fixes this. -- Cecilio Pardo
diff --git a/lisp/term/w32-win.el b/lisp/term/w32-win.el
index 3c0acf368f4..29629c9072c 100644
--- a/lisp/term/w32-win.el
+++ b/lisp/term/w32-win.el
@@ -100,7 +100,7 @@ w32-color-map
 ;;   (interactive "e")
 ;;   (princ event))
 
-(defun w32-handle-dropped-file (window file-name)
+(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 +117,12 @@ w32-handle-dropped-file
                      (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 +144,11 @@ w32-drag-n-drop
       (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.