From: Po Lu Date: Thu, 16 Jun 2022 02:39:01 +0000 (+0800) Subject: Handle OffiX drop of multiple files X-Git-Tag: emacs-29.0.90~1447^2~1730 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=160b22ebf7cc6a3bbe7fb0955179d53f0d02dac0;p=emacs.git Handle OffiX drop of multiple files * lisp/x-dnd.el (x-dnd-types-alist): Register DndTypeFiles. (x-dnd-offix-id-to-name): Fix typo. (x-dnd-handle-offix-files): New function. (x-dnd-convert-to-offix): Fix conversion to DndTypeFiles. --- diff --git a/lisp/x-dnd.el b/lisp/x-dnd.el index 684f8f81551..aa4eb8849f9 100644 --- a/lisp/x-dnd.el +++ b/lisp/x-dnd.el @@ -67,6 +67,7 @@ The default value for this variable is `x-dnd-default-test-function'." (,(purecopy "STRING") . dnd-insert-text) (,(purecopy "TEXT") . dnd-insert-text) (,(purecopy "DndTypeFile") . x-dnd-handle-offix-file) + (,(purecopy "DndTypeFiles") . x-dnd-handle-offix-files) (,(purecopy "DndTypeText") . dnd-insert-text)) "Which function to call to handle a drop of that type. If the type for the drop is not present, or the function is nil, @@ -426,7 +427,7 @@ Currently XDND, Motif and old KDE 1.x protocols are recognized." (3 . DndTypeFiles) (4 . DndTypeText) (5 . DndTypeDir) - (6 . DndTypeLInk) + (6 . DndTypeLink) (7 . DndTypeExe) (8 . DndTypeUrl) (9 . DndTypeMime) @@ -438,10 +439,23 @@ Currently XDND, Motif and old KDE 1.x protocols are recognized." Then, call `x-dnd-handle-file-name'. WINDOW and ACTION mean the same as in `x-dnd-handle-file-name'. -STRING is the raw offiX file name data." +STRING is the raw OffiX file name data." (x-dnd-handle-file-name window action (replace-regexp-in-string "\0$" "" string))) +(defun x-dnd-handle-offix-files (window action string) + "Convert OffiX file name list to a URI list. +Then, call `x-dnd-handle-file-name'. + +WINDOW and ACTION mean the same as in `x-dnd-handle-file-name'. +STRING is the raw OffiX file name data." + (x-dnd-handle-file-name window action + ;; OffiX file name lists contain one extra + ;; NULL byte at the end. + (if (string-suffix-p "\0\0" string) + (substring string 0 (1- (length string))) + string))) + (defun x-dnd-handle-offix (event frame window _message-atom _format data) "Handle OffiX drop event EVENT. FRAME is the frame where the drop happened. @@ -966,7 +980,7 @@ data could not be converted." ;; This means there are multiple file names in ;; XdndSelection. Convert the file name data to a format ;; that OffiX understands. - (cons 'DndTypeFiles (concat file-name-data "\0")) + (cons 'DndTypeFiles (concat file-name-data "\0\0")) (cons 'DndTypeFile (concat file-name-data "\0")))) ((and (member "STRING" targets) (setq string-data