]> git.eshelyaron.com Git - emacs.git/commitdiff
(x-get-selection): If the string returned by
authorKenichi Handa <handa@m17n.org>
Tue, 17 Jun 2003 10:54:39 +0000 (10:54 +0000)
committerKenichi Handa <handa@m17n.org>
Tue, 17 Jun 2003 10:54:39 +0000 (10:54 +0000)
x-get-selection-internal has text property `foreign-selection',
decode it while preserving that property.

lisp/select.el

index 618e10f40219192302e8f4f4c7cd347f2e05839f..f679b27805a9aba342af9a23f8e3547e7ba57f67 100644 (file)
@@ -38,7 +38,18 @@ how to convert the data.
 TYPE may be `SECONDARY' or `CLIPBOARD', in addition to `PRIMARY'.
 DATA-TYPE is usually `STRING', but can also be one of the symbols
 in `selection-converter-alist', which see."
-  (x-get-selection-internal (or type 'PRIMARY) (or data-type 'STRING)))
+  (let ((data (x-get-selection-internal (or type 'PRIMARY)
+                                       (or data-type 'STRING)))
+       coding)
+    (when (and (stringp data)
+              (setq data-type (get-text-property 0 'foreign-selection data)))
+      (setq coding (if (eq data-type 'UTF8_STRING)
+                      'utf-8
+                    (or next-selection-coding-system
+                        selection-coding-system))
+           data (decode-coding-string data coding))
+      (put-text-property 0 (length data) 'foreign-selection data-type data))
+    data))
 
 (defun x-get-clipboard ()
   "Return text pasted to the clipboard."