]> code.delx.au - gnu-emacs/blobdiff - lisp/select.el
subr.el (buffer-file-type, default-buffer-file-type): Remove.
[gnu-emacs] / lisp / select.el
index 3948fcc5456efdcc04ab110d1af4e0a8b88ef2a3..58fbe5f0f5119e257a57b7478cec8535d7c2d0b2 100644 (file)
@@ -1,6 +1,6 @@
 ;;; select.el --- lisp portion of standard selection support
 
-;; Copyright (C) 1993-1994, 2001-201 Free Software Foundation, Inc.
+;; Copyright (C) 1993-1994, 2001-2013 Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
 ;; Keywords: internal
@@ -228,24 +228,40 @@ two markers or an overlay.  Otherwise, it is nil."
          ;; But avoid modifying the string if it's a buffer name etc.
          (unless can-modify (setq str (substring str 0)))
          (remove-text-properties 0 (length str) '(composition nil) str)
-         ;; TEXT is a polymorphic target.  Select the actual type
-         ;; from `UTF8_STRING', `COMPOUND_TEXT', `STRING', and
-         ;; `C_STRING'.
-         (if (eq type 'TEXT)
-             (if (not (multibyte-string-p str))
-                 (setq type 'C_STRING)
-               (let (non-latin-1 non-unicode eight-bit)
-                 (mapc #'(lambda (x)
-                           (if (>= x #x100)
-                               (if (< x #x110000)
-                                   (setq non-latin-1 t)
-                                 (if (< x #x3FFF80)
-                                     (setq non-unicode t)
-                                   (setq eight-bit t)))))
-                       str)
-                 (setq type (if non-unicode 'COMPOUND_TEXT
-                              (if non-latin-1 'UTF8_STRING
-                                (if eight-bit 'C_STRING 'STRING)))))))
+         ;; For X selections, TEXT is a polymorphic target; choose
+         ;; the actual type from `UTF8_STRING', `COMPOUND_TEXT',
+         ;; `STRING', and `C_STRING'.  On Nextstep, always use UTF-8
+         ;; (see ns_string_to_pasteboard_internal in nsselect.m).
+         (when (eq type 'TEXT)
+           (cond
+            ((featurep 'ns)
+             (setq type 'UTF8_STRING))
+            ((not (multibyte-string-p str))
+             (setq type 'C_STRING))
+            (t
+             (let (non-latin-1 non-unicode eight-bit)
+               (mapc #'(lambda (x)
+                         (if (>= x #x100)
+                             (if (< x #x110000)
+                                 (setq non-latin-1 t)
+                               (if (< x #x3FFF80)
+                                   (setq non-unicode t)
+                                 (setq eight-bit t)))))
+                     str)
+               (setq type (if (or non-unicode
+                                  (and
+                                   non-latin-1
+                                   ;; If a coding is specified for
+                                   ;; selection, and that is
+                                   ;; compatible with COMPOUND_TEXT,
+                                   ;; use it.
+                                   coding
+                                   (eq (coding-system-get coding :mime-charset)
+                                       'x-ctext)))
+                              'COMPOUND_TEXT
+                            (if non-latin-1 'UTF8_STRING
+                              (if eight-bit 'C_STRING
+                                'STRING))))))))
          (cond
           ((eq type 'UTF8_STRING)
            (if (or (not coding)