X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/a8e7d6d783219972c08fd49a3a2afaf26eb139c2..2d0504232eab9deb2b09d47d39ceb76a369dc922:/lisp/select.el diff --git a/lisp/select.el b/lisp/select.el index 3948fcc545..58fbe5f0f5 100644 --- a/lisp/select.el +++ b/lisp/select.el @@ -1,6 +1,6 @@ ;;; select.el --- lisp portion of standard selection support -;; Copyright (C) 1993-1994, 2001-2012 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)