1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-28 07:45:00 +00:00

(xselect-convert-to-string): Send a C_STRING only if the polymorphic

target TEXT is requested.
This commit is contained in:
Chong Yidong 2008-04-21 02:02:01 +00:00
parent 9ba76e6b5f
commit 569ac23f8a

View File

@ -241,13 +241,12 @@ Cut buffers are considered obsolete; you should use selections instead."
(let ((inhibit-read-only t)) (let ((inhibit-read-only t))
;; Suppress producing escape sequences for compositions. ;; Suppress producing escape sequences for compositions.
(remove-text-properties 0 (length str) '(composition nil) str) (remove-text-properties 0 (length str) '(composition nil) str)
(if (not (multibyte-string-p str)) (if (eq type 'TEXT)
;; Don't have to encode unibyte string. ;; TEXT is a polymorphic target. We must select the
(setq type 'C_STRING) ;; actual type from `UTF8_STRING', `COMPOUND_TEXT',
(if (eq type 'TEXT) ;; `STRING', and `C_STRING'.
;; TEXT is a polimorphic target. We must select the (if (not (multibyte-string-p str))
;; actual type from `UTF8_STRING', `COMPOUND_TEXT', (setq type 'C_STRING)
;; `STRING', and `C_STRING'.
(let (non-latin-1 non-unicode eight-bit) (let (non-latin-1 non-unicode eight-bit)
(mapc #'(lambda (x) (mapc #'(lambda (x)
(if (>= x #x100) (if (>= x #x100)
@ -259,32 +258,32 @@ Cut buffers are considered obsolete; you should use selections instead."
str) str)
(setq type (if non-unicode 'COMPOUND_TEXT (setq type (if non-unicode 'COMPOUND_TEXT
(if non-latin-1 'UTF8_STRING (if non-latin-1 'UTF8_STRING
(if eight-bit 'C_STRING 'STRING)))))) (if eight-bit 'C_STRING 'STRING)))))))
(cond (cond
((eq type 'UTF8_STRING) ((eq type 'UTF8_STRING)
(if (or (not coding) (if (or (not coding)
(not (eq (coding-system-type coding) 'utf-8))) (not (eq (coding-system-type coding) 'utf-8)))
(setq coding 'utf-8)) (setq coding 'utf-8))
(setq str (encode-coding-string str coding))) (setq str (encode-coding-string str coding)))
((eq type 'STRING) ((eq type 'STRING)
(if (or (not coding) (if (or (not coding)
(not (eq (coding-system-type coding) 'charset))) (not (eq (coding-system-type coding) 'charset)))
(setq coding 'iso-8859-1)) (setq coding 'iso-8859-1))
(setq str (encode-coding-string str coding))) (setq str (encode-coding-string str coding)))
((eq type 'COMPOUND_TEXT) ((eq type 'COMPOUND_TEXT)
(if (or (not coding) (if (or (not coding)
(not (eq (coding-system-type coding) 'iso-2022))) (not (eq (coding-system-type coding) 'iso-2022)))
(setq coding 'compound-text-with-extensions)) (setq coding 'compound-text-with-extensions))
(setq str (encode-coding-string str coding))) (setq str (encode-coding-string str coding)))
((eq type 'C_STRING) ((eq type 'C_STRING)
(setq str (string-make-unibyte str))) (setq str (string-make-unibyte str)))
(t (t
(error "Unknow selection type: %S" type)) (error "Unknow selection type: %S" type))
)))) )))
(setq next-selection-coding-system nil) (setq next-selection-coding-system nil)
(cons type str)))) (cons type str))))