summaryrefslogtreecommitdiff
path: root/lisp/select.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/select.el')
-rw-r--r--lisp/select.el31
1 files changed, 22 insertions, 9 deletions
diff --git a/lisp/select.el b/lisp/select.el
index f590025d8b9..59bcf7da664 100644
--- a/lisp/select.el
+++ b/lisp/select.el
@@ -49,16 +49,17 @@ the current system default encoding on 9x/Me, `utf-16le-dos'
For X Windows:
When sending text via selection and clipboard, if the target
-data-type matches with the type of this coding system, it is used
-for encoding the text. Otherwise (including the case that this
-variable is nil), a proper coding system is used as below:
+data-type matches this coding system according to the table
+below, it is used for encoding the text. Otherwise (including
+the case that this variable is nil), a proper coding system is
+selected as below:
data-type coding system
--------- -------------
UTF8_STRING utf-8
COMPOUND_TEXT compound-text-with-extensions
STRING iso-latin-1
-C_STRING no-conversion
+C_STRING raw-text-unix
When receiving text, if this coding system is non-nil, it is used
for decoding regardless of the data-type. If this is nil, a
@@ -86,6 +87,8 @@ After the communication, this variable is set to nil.")
;; Only declared obsolete in 23.3.
(define-obsolete-function-alias 'x-selection 'x-get-selection "at least 19.34")
+(define-obsolete-variable-alias 'x-select-enable-clipboard
+ 'select-enable-clipboard "25.1")
(defcustom select-enable-clipboard t
"Non-nil means cutting and pasting uses the clipboard.
This can be in addition to, but in preference to, the primary selection,
@@ -94,9 +97,9 @@ if applicable (i.e. under X11)."
:group 'killing
;; The GNU/Linux version changed in 24.1, the MS-Windows version did not.
:version "24.1")
-(define-obsolete-variable-alias 'x-select-enable-clipboard
- 'select-enable-clipboard "25.1")
+(define-obsolete-variable-alias 'x-select-enable-primary
+ 'select-enable-primary "25.1")
(defcustom select-enable-primary nil
"Non-nil means cutting and pasting uses the primary selection.
The existence of a primary selection depends on the underlying GUI you use.
@@ -104,8 +107,6 @@ E.g. it doesn't exist under MS-Windows."
:type 'boolean
:group 'killing
:version "25.1")
-(define-obsolete-variable-alias 'x-select-enable-primary
- 'select-enable-primary "25.1")
;; We keep track of the last text selected here, so we can check the
;; current selection against it, and avoid passing back our own text
@@ -309,6 +310,10 @@ the formats available in the clipboard if TYPE is `CLIPBOARD'."
(_ (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.
(string-to-multibyte data))))
(setq next-selection-coding-system nil)
(put-text-property 0 (length data) 'foreign-selection data-type data))
@@ -472,7 +477,15 @@ two markers or an overlay. Otherwise, it is nil."
(setq str (encode-coding-string str coding)))
((eq type 'C_STRING)
- (setq str (string-make-unibyte str)))
+ ;; According to ICCCM Protocol v2.0 (para 2.7.1), C_STRING
+ ;; is a zero-terminated sequence of raw bytes that
+ ;; shouldn't be interpreted as text in any encoding.
+ ;; Therefore, if STR is unibyte (the normal case), we use
+ ;; it as-is; otherwise we assume some of the characters
+ ;; are eight-bit and ensure they are converted to their
+ ;; single-byte representation.
+ (or (null (multibyte-string-p str))
+ (setq str (encode-coding-string str 'raw-text-unix))))
(t
(error "Unknown selection type: %S" type)))))