changeset 94205:e60145f49fea

(xselect-convert-to-string): Send a C_STRING only if the polymorphic target TEXT is requested.
author Chong Yidong <cyd@stupidchicken.com>
date Mon, 21 Apr 2008 02:02:01 +0000
parents ea2997c29fb2
children 10db3330138c
files lisp/select.el
diffstat 1 files changed, 28 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/select.el	Mon Apr 21 02:01:44 2008 +0000
+++ b/lisp/select.el	Mon Apr 21 02:02:01 2008 +0000
@@ -241,13 +241,12 @@
 	(let ((inhibit-read-only t))
 	  ;; Suppress producing escape sequences for compositions.
 	  (remove-text-properties 0 (length str) '(composition nil) str)
-	  (if (not (multibyte-string-p str))
-	      ;; Don't have to encode unibyte string.
-	      (setq type 'C_STRING)
-	    (if (eq type 'TEXT)
-		;; TEXT is a polimorphic target.  We must select the
-		;; actual type from `UTF8_STRING', `COMPOUND_TEXT',
-		;; `STRING', and `C_STRING'.
+	  (if (eq type 'TEXT)
+	      ;; TEXT is a polymorphic target.  We must select the
+	      ;; actual type from `UTF8_STRING', `COMPOUND_TEXT',
+	      ;; `STRING', and `C_STRING'.
+	      (if (not (multibyte-string-p str))
+		  (setq type 'C_STRING)
 		(let (non-latin-1 non-unicode eight-bit)
 		  (mapc #'(lambda (x)
 			    (if (>= x #x100)
@@ -259,32 +258,32 @@
 			str)
 		  (setq type (if non-unicode 'COMPOUND_TEXT
 			       (if non-latin-1 'UTF8_STRING
-				 (if eight-bit 'C_STRING 'STRING))))))
-	    (cond
-	     ((eq type 'UTF8_STRING)
-	      (if (or (not coding)
-		      (not (eq (coding-system-type coding) 'utf-8)))
-		  (setq coding 'utf-8))
-	      (setq str (encode-coding-string str coding)))
+				 (if eight-bit 'C_STRING 'STRING)))))))
+	  (cond
+	   ((eq type 'UTF8_STRING)
+	    (if (or (not coding)
+		    (not (eq (coding-system-type coding) 'utf-8)))
+		(setq coding 'utf-8))
+	    (setq str (encode-coding-string str coding)))
 
-	     ((eq type 'STRING)
-	      (if (or (not coding)
-		      (not (eq (coding-system-type coding) 'charset)))
-		  (setq coding 'iso-8859-1))
-	      (setq str (encode-coding-string str coding)))
+	   ((eq type 'STRING)
+	    (if (or (not coding)
+		    (not (eq (coding-system-type coding) 'charset)))
+		(setq coding 'iso-8859-1))
+	    (setq str (encode-coding-string str coding)))
 
-	     ((eq type 'COMPOUND_TEXT)
-	      (if (or (not coding)
-		      (not (eq (coding-system-type coding) 'iso-2022)))
-		  (setq coding 'compound-text-with-extensions))
-	      (setq str (encode-coding-string str coding)))
+	   ((eq type 'COMPOUND_TEXT)
+	    (if (or (not coding)
+		    (not (eq (coding-system-type coding) 'iso-2022)))
+		(setq coding 'compound-text-with-extensions))
+	    (setq str (encode-coding-string str coding)))
 
-	     ((eq type 'C_STRING)
-	      (setq str (string-make-unibyte str)))
+	   ((eq type 'C_STRING)
+	    (setq str (string-make-unibyte str)))
 
-	     (t
-	      (error "Unknow selection type: %S" type))
-	     ))))
+	   (t
+	    (error "Unknow selection type: %S" type))
+	   )))
 
       (setq next-selection-coding-system nil)
       (cons type str))))