ErgoEmacsEmacsLispBlogEmacsLispBuy Tutorial

26.11 Coding Systems for Interprocess Communication

This section explains how to specify coding systems for use in communication with other processes.

C-x <RET> x coding <RET>
Use coding system coding for transferring selections to and from other window-based applications.
C-x <RET> X coding <RET>
Use coding system coding for transferring one selection—the next one—to or from another window-based application.
C-x <RET> p input-coding <RET> output-coding <RET>
Use coding systems input-coding and output-coding for subprocess input and output in the current buffer.
C-x <RET> c coding <RET>
Specify coding system coding for the immediately following command.

The command C-x <RET> x (set-selection-coding-system) specifies the coding system for sending selected text to other windowing applications, and for receiving the text of selections made in other applications. This command applies to all subsequent selections, until you override it by using the command again. The command C-x <RET> X (set-next-selection-coding-system) specifies the coding system for the next selection made in Emacs or read by Emacs.

The variable x-select-request-type specifies the data type to request from the X Window System for receiving text selections from other applications. If the value is nil (the default), Emacs tries COMPOUND_TEXT and UTF8_STRING, in this order, and uses various heuristics to choose the more appropriate of the two results; if none of these succeed, Emacs falls back on STRING. If the value of x-select-request-type is one of the symbols COMPOUND_TEXT, UTF8_STRING, STRING, or TEXT, Emacs uses only that request type. If the value is a list of some of these symbols, Emacs tries only the request types in the list, in order, until one of them succeeds, or until the list is exhausted.

The command C-x <RET> p (set-buffer-process-coding-system) specifies the coding system for input and output to a subprocess. This command applies to the current buffer; normally, each subprocess has its own buffer, and thus you can use this command to specify translation to and from a particular subprocess by giving the command in the corresponding buffer.

You can also use C-x <RET> c just before the command that runs or starts a subprocess, to specify the coding system to use for communication with that subprocess.

The default for translation of process input and output depends on the current language environment.

The variable locale-coding-system specifies a coding system to use when encoding and decoding system strings such as system error messages and format-time-string formats and time stamps. That coding system is also used for decoding non-ASCII keyboard input on X Window systems. You should choose a coding system that is compatible with the underlying system's text representation, which is normally specified by one of the environment variables LC_ALL, LC_CTYPE, and LANG. (The first one, in the order specified above, whose value is nonempty is the one that determines the text representation.)

The variable x-select-request-type specifies a selection data type of selection to request from the X server. The default value is nil, which means Emacs tries COMPOUND_TEXT and UTF8_STRING, and uses whichever result seems more appropriate. You can explicitly specify the data type by setting the variable to one of the symbols COMPOUND_TEXT, UTF8_STRING, STRING and TEXT.

blog comments powered by Disqus