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:

This coding system replaces that of the default coding system selection text is encoded by in reaction to a request for the polymorphic TEXT selection target when its base coding system is compatible with compound-text and the text being encoded cannot be rendered Latin-1 without loss of information.

It also replaces the coding system by which calls to gui-get-selection decode selection requests for text data types, which are enumerated below beside their respective coding systems otherwise used.

DATA TYPE CODING SYSTEM
-------------------------- -------------
UTF8_STRING utf-8
text/plain\;charset=utf-8 utf-8
COMPOUND_TEXT compound-text-with-extensions
STRING iso-latin-1
C_STRING raw-text-unix

See also the documentation of the variable x-select-request-type how to control which data-type to request for receiving text.

This variable was added, or its default value changed, in Emacs 23.1.

View in manual

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-2025 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:

This coding system replaces that of the default coding system
selection text is encoded by in reaction to a request for the
polymorphic `TEXT' selection target when its base coding system
is compatible with `compound-text' and the text being encoded
cannot be rendered Latin-1 without loss of information.

It also replaces the coding system by which calls to
`gui-get-selection' decode selection requests for text data
types, which are enumerated below beside their respective coding
systems otherwise used.

DATA TYPE			CODING SYSTEM
--------------------------      -------------
UTF8_STRING			utf-8
text/plain\\;charset=utf-8	utf-8
COMPOUND_TEXT			compound-text-with-extensions
STRING				iso-latin-1
C_STRING			raw-text-unix

See also the documentation of the variable `x-select-request-type' how
to control which data-type to request for receiving text."
  :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)))