summaryrefslogtreecommitdiff
path: root/lisp/select.el
diff options
context:
space:
mode:
authorPo Lu <luangruo@yahoo.com>2022-06-05 15:34:49 +0800
committerPo Lu <luangruo@yahoo.com>2022-06-05 15:38:23 +0800
commit6011d39b6a4bc659da364255bcae22c4e6ef3a3f (patch)
tree785eefe49cab4047016696287f4788be55e2a424 /lisp/select.el
parent993853531aebb303870d6ff1ba7db2007d464b63 (diff)
downloademacs-6011d39b6a4bc659da364255bcae22c4e6ef3a3f.tar.gz
Fix drag-and-drop of files with multibyte filenames
* lisp/dired.el (dired-mouse-drag): Fix re-signalling of errors. * lisp/select.el (xselect-convert-to-filename): (xselect-convert-to-text-uri-list): (xselect-convert-to-dt-netfile): Encode in raw-text-unix. * src/xgselect.c (suppress_xg_select, release_xg_select): New functions. (xg_select): Respect xg_select suppression by delegating to pselect. * src/xgselect.h: Update prototypes. * src/xterm.c (x_dnd_begin_drag_and_drop): Suppress xg_select during the nested event loop. (handle_one_xevent): Handle cases where hold_quit is nil inside a selection event handler during DND.
Diffstat (limited to 'lisp/select.el')
-rw-r--r--lisp/select.el22
1 files changed, 12 insertions, 10 deletions
diff --git a/lisp/select.el b/lisp/select.el
index df1d4026552..c5412f2a73b 100644
--- a/lisp/select.el
+++ b/lisp/select.el
@@ -630,20 +630,20 @@ two markers or an overlay. Otherwise, it is nil."
(xselect--encode-string 'TEXT (buffer-file-name (nth 2 value))))
(if (and (stringp value)
(file-exists-p value))
- (xselect--encode-string 'TEXT (expand-file-name value)
- nil t)
+ ;; Motif expects this to be STRING, but it treats the data as
+ ;; a sequence of bytes instead of a Latin-1 string.
+ (cons 'STRING (encode-coding-string (expand-file-name value)
+ 'raw-text-unix))
(when (vectorp value)
(with-temp-buffer
(cl-loop for file across value
- do (progn (insert (encode-coding-string
- (expand-file-name file)
- file-name-coding-system))
- (insert "\0")))
+ do (insert (expand-file-name file) "\0"))
;; Get rid of the last NULL byte.
(when (> (point) 1)
(delete-char -1))
;; Motif wants STRING.
- (cons 'STRING (buffer-string)))))))
+ (cons 'STRING (encode-coding-string (buffer-string)
+ 'raw-text-unix)))))))
(defun xselect-convert-to-charpos (_selection _type value)
(when (setq value (xselect--selection-bounds value))
@@ -710,14 +710,15 @@ This function returns the string \"emacs\"."
(defun xselect-convert-to-text-uri-list (_selection _type value)
(if (stringp value)
- (concat (url-encode-url value) "\n")
+ (xselect--encode-string 'TEXT
+ (concat (url-encode-url value) "\n"))
(when (vectorp value)
(with-temp-buffer
(cl-loop for tem across value
do (progn
(insert (url-encode-url tem))
(insert "\n")))
- (buffer-string)))))
+ (xselect--encode-string 'TEXT (buffer-string))))))
(defun xselect-convert-to-xm-file (selection _type value)
(when (and (stringp value)
@@ -770,7 +771,8 @@ VALUE should be SELECTION's local value."
(stringp value)
(file-exists-p value)
(not (file-remote-p value)))
- (xselect-tt-net-file value)))
+ (encode-coding-string (xselect-tt-net-file value)
+ 'raw-text-unix t)))
(setq selection-converter-alist
'((TEXT . xselect-convert-to-string)