emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Copy and paste from Emacs 29 to Thunderbird doesn’t work


From: Po Lu
Subject: Re: Copy and paste from Emacs 29 to Thunderbird doesn’t work
Date: Wed, 03 May 2023 13:57:18 +0800
User-agent: Gnus/5.13 (Gnus v5.13)

Tobias Bading <tbading@web.de> writes:

> On 03.05.23 07:20, Po Lu wrote:
>> OK, would you please run:
>>
>>   M-x trace-function RET x-dnd-convert-to-text-uri-list RET
>>
>> copy something to Firefox, and show what trace output is printed?
>
> Sorry, there’s no x-dnd-convert-to-text-uri-list, only Zuul. ;-)
>
> (trace-function 'xselect-convert-to-text-uri-list), selecting
> “nopers” in Emacs 29 and then a paste in Thunderbird’s mail composition area
> produces
>
> 1 -> (xselect-convert-to-text-uri-list CLIPBOARD text/uri-list "nopers")
> 1 <- xselect-convert-to-text-uri-list: (text/uri-list . "nopers\n")

Thanks.  Would you please try this change?

diff --git a/lisp/select.el b/lisp/select.el
index 7f089c62dd5..09c678867d0 100644
--- a/lisp/select.el
+++ b/lisp/select.el
@@ -807,19 +807,24 @@ xselect-convert-to-save-targets
 (defun xselect-convert-to-username (_selection _type _value)
   (user-real-login-name))
 
-(defun xselect-convert-to-text-uri-list (_selection _type value)
-  (let ((string
-         (if (stringp value)
-             (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")))
-               (xselect--encode-string 'TEXT (buffer-string)))))))
-    (cons 'text/uri-list (cdr string))))
+(defun xselect-convert-to-text-uri-list (selection _type value)
+  ;; While `xselect-uri-list-available-p' ensures that this target
+  ;; will not be reported in the TARGETS of non-drag-and-drop
+  ;; selections, Firefox stupidly converts to it anyway.  Check that
+  ;; the conversion request is being made for the correct selection.
+  (and (eq selection 'XdndSelection)
+       (let ((string
+              (if (stringp value)
+                  (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")))
+                    (xselect--encode-string 'TEXT (buffer-string)))))))
+         (cons 'text/uri-list (cdr string)))))
 
 (defun xselect-convert-to-xm-file (selection _type value)
   (when (and (stringp value)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]