Variable: selection-coding-system
selection-coding-system is a customizable variable defined in
select.el.gz.
Value
nil
Documentation
Coding system for communicating with other programs.
For MS-Windows and MS-DOS:
When sending or receiving text via selection and clipboard, the text
is encoded or decoded by this coding system. The default value is
the current system default encoding on 9x/Me, utf-16le-dos
(Unicode) on NT/W2K/XP, and iso-latin-1-dos on MS-DOS.
For X Windows: When sending text via selection and clipboard, if the target 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 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 proper coding system is used according to the data-type as above.
See also the documentation of the variable x-select-request-type how
to control which data-type to request for receiving text.
The default value is nil.
This variable was added, or its default value changed, in Emacs 23.1.
Probably introduced at or before Emacs version 21.2.
Source Code
;; Defined in /usr/src/emacs/lisp/select.el.gz
;;; select.el --- lisp portion of standard selection support -*- lexical-binding:t -*-
;; Copyright (C) 1993-1994, 2001-2024 Free Software Foundation, Inc.
;; Maintainer: emacs-devel@gnu.org
;; Keywords: internal
;; This file is part of GNU Emacs.
;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;; Based partially on earlier release by Lucid.
;; The functionality here is divided in two parts:
;; - Low-level: gui-backend-get-selection, gui-backend-set-selection,
;; gui-backend-selection-owner-p, gui-backend-selection-exists-p are
;; the backend-dependent functions meant to access various kinds of
;; selections (CLIPBOARD, PRIMARY, SECONDARY).
;; - Higher-level: gui-select-text and gui-selection-value go together to
;; access the general notion of "GUI selection" for interoperation with other
;; applications. This can use either the clipboard or the primary selection,
;; or both or none according to select-enable-clipboard/primary. These are
;; the default values of interprogram-cut/paste-function.
;; Additionally, there's gui-get-primary-selection which is used to get the
;; PRIMARY selection, specifically for mouse-yank-primary.
;;; Code:
(defcustom selection-coding-system nil
"Coding system for communicating with other programs.
For MS-Windows and MS-DOS:
When sending or receiving text via selection and clipboard, the text
is encoded or decoded by this coding system. The default value is
the current system default encoding on 9x/Me, `utf-16le-dos'
\(Unicode) on NT/W2K/XP, and `iso-latin-1-dos' on MS-DOS.
For X Windows:
When sending text via selection and clipboard, if the target
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 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
proper coding system is used according to the data-type as above.
See also the documentation of the variable `x-select-request-type' how
to control which data-type to request for receiving text.
The default value is nil."
:type 'coding-system
:group 'mule
;; Default was compound-text-with-extensions in 22.x (pre-unicode).
:version "23.1"
:set (lambda (symbol value)
(set-selection-coding-system value)
(set symbol value)))