]> git.eshelyaron.com Git - emacs.git/commitdiff
(gui-get-selection): Avoid using `string-to-multibyte'
authorLars Ingebrigtsen <larsi@gnus.org>
Fri, 17 May 2019 03:42:12 +0000 (05:42 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Fri, 17 May 2019 03:42:12 +0000 (05:42 +0200)
* lisp/select.el (gui-get-selection): Avoid using
`string-to-multibyte' -- instead encode as `eight-bit' if the
string is unibyte.

lisp/select.el

index c79e923b743310e5c84487c4bae78ddc19d9af45..3ea741d383ec0265f9b50302c3f5e70bbae124c2 100644 (file)
@@ -308,8 +308,15 @@ the formats available in the clipboard if TYPE is `CLIPBOARD'."
                           ('STRING 'iso-8859-1)
                           (_ (error "Unknown selection data type: %S"
                                     type))))))
-        (setq data (if coding (decode-coding-string data coding)
-                     (string-to-multibyte data))))
+        (setq data (cond
+                    (coding
+                     (decode-coding-string data coding))
+                    ;; The last two cases are only possible in the
+                    ;; C_STRING case.
+                    ((multibyte-string-p data)
+                     data)
+                    (t
+                     (encode-coding-string data 'eight-bit)))))
       (setq next-selection-coding-system nil)
       (put-text-property 0 (length data) 'foreign-selection data-type data))
     data))