summaryrefslogtreecommitdiff
path: root/lisp/select.el
diff options
context:
space:
mode:
authorLars Ingebrigtsen <larsi@gnus.org>2021-11-08 12:22:56 +0100
committerLars Ingebrigtsen <larsi@gnus.org>2021-11-08 12:22:56 +0100
commit10b4cbb2fc3ff8d36bfba006bab7f4df2344465d (patch)
tree5cc26c1a9fde494d42b2232297eecd5ee17650f9 /lisp/select.el
parent990aad47bd1344fe7fabf8e202005cc63a4b4636 (diff)
downloademacs-10b4cbb2fc3ff8d36bfba006bab7f4df2344465d.tar.gz
Revert "Fix charset issues when yanking non-plain-text elements"
This reverts commit 5e66c75e0b6b91b6f5d9aa46c824e8209ade8f2a. This apparently led to problems on Windows. The issues have to be examined first before attempting a new fix.
Diffstat (limited to 'lisp/select.el')
-rw-r--r--lisp/select.el22
1 files changed, 8 insertions, 14 deletions
diff --git a/lisp/select.el b/lisp/select.el
index 8412405834d..3c9f961f6db 100644
--- a/lisp/select.el
+++ b/lisp/select.el
@@ -303,29 +303,23 @@ addition to `STRING'; MS-Windows supports `TARGETS', which reports
the formats available in the clipboard if TYPE is `CLIPBOARD'."
(let ((data (gui-backend-get-selection (or type 'PRIMARY)
(or data-type 'STRING))))
- (when (stringp data)
+ (when (and (stringp data)
+ (setq data-type (get-text-property 0 'foreign-selection data)))
(let ((coding (or next-selection-coding-system
selection-coding-system
(pcase data-type
('UTF8_STRING 'utf-8)
('COMPOUND_TEXT 'compound-text-with-extensions)
('C_STRING nil)
- ('STRING 'iso-8859-1)))))
- (setq data
- (cond (coding (decode-coding-string data coding))
+ ('STRING 'iso-8859-1)
+ (_ (error "Unknown selection data type: %S"
+ type))))))
+ (setq data (if coding (decode-coding-string data coding)
+ ;; This is for C_STRING case.
;; We want to convert each non-ASCII byte to the
;; corresponding eight-bit character, which has
;; a codepoint >= #x3FFF00.
- ((eq data-type 'C_STRING)
- (string-to-multibyte data))
- ;; Guess at the charset for types like text/html
- ;; -- it can be anything, and different
- ;; applications use different encodings.
- ((string-match-p "\\`text/" (symbol-name data-type))
- (decode-coding-string
- data (car (detect-coding-string data))))
- ;; Do nothing.
- (t data))))
+ (string-to-multibyte data))))
(setq next-selection-coding-system nil)
(put-text-property 0 (length data) 'foreign-selection data-type data))
data))