summaryrefslogtreecommitdiff
path: root/devdocs/elisp/specifying-coding-systems.html
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
committerCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
commit754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch)
treef1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/elisp/specifying-coding-systems.html
new repository
Diffstat (limited to 'devdocs/elisp/specifying-coding-systems.html')
-rw-r--r--devdocs/elisp/specifying-coding-systems.html28
1 files changed, 28 insertions, 0 deletions
diff --git a/devdocs/elisp/specifying-coding-systems.html b/devdocs/elisp/specifying-coding-systems.html
new file mode 100644
index 00000000..23ac7c56
--- /dev/null
+++ b/devdocs/elisp/specifying-coding-systems.html
@@ -0,0 +1,28 @@
+ <h4 class="subsection">Specifying a Coding System for One Operation</h4> <p>You can specify the coding system for a specific operation by binding the variables <code>coding-system-for-read</code> and/or <code>coding-system-for-write</code>. </p> <dl> <dt id="coding-system-for-read">Variable: <strong>coding-system-for-read</strong>
+</dt> <dd>
+<p>If this variable is non-<code>nil</code>, it specifies the coding system to use for reading a file, or for input from a synchronous subprocess. </p> <p>It also applies to any asynchronous subprocess or network stream, but in a different way: the value of <code>coding-system-for-read</code> when you start the subprocess or open the network stream specifies the input decoding method for that subprocess or network stream. It remains in use for that subprocess or network stream unless and until overridden. </p> <p>The right way to use this variable is to bind it with <code>let</code> for a specific I/O operation. Its global value is normally <code>nil</code>, and you should not globally set it to any other value. Here is an example of the right way to use the variable: </p> <div class="example"> <pre class="example">;; <span class="roman">Read the file with no character code conversion.</span>
+(let ((coding-system-for-read 'no-conversion))
+ (insert-file-contents filename))
+</pre>
+</div> <p>When its value is non-<code>nil</code>, this variable takes precedence over all other methods of specifying a coding system to use for input, including <code>file-coding-system-alist</code>, <code>process-coding-system-alist</code> and <code>network-coding-system-alist</code>. </p>
+</dd>
+</dl> <dl> <dt id="coding-system-for-write">Variable: <strong>coding-system-for-write</strong>
+</dt> <dd>
+<p>This works much like <code>coding-system-for-read</code>, except that it applies to output rather than input. It affects writing to files, as well as sending output to subprocesses and net connections. It also applies to encoding command-line arguments with which Emacs invokes subprocesses. </p> <p>When a single operation does both input and output, as do <code>call-process-region</code> and <code>start-process</code>, both <code>coding-system-for-read</code> and <code>coding-system-for-write</code> affect it. </p>
+</dd>
+</dl> <dl> <dt id="coding-system-require-warning">Variable: <strong>coding-system-require-warning</strong>
+</dt> <dd><p>Binding <code>coding-system-for-write</code> to a non-<code>nil</code> value prevents output primitives from calling the function specified by <code>select-safe-coding-system-function</code> (see <a href="user_002dchosen-coding-systems">User-Chosen Coding Systems</a>). This is because <kbd>C-x <span class="key">RET</span> c</kbd> (<code>universal-coding-system-argument</code>) works by binding <code>coding-system-for-write</code>, and Emacs should obey user selection. If a Lisp program binds <code>coding-system-for-write</code> to a value that might not be safe for encoding the text to be written, it can also bind <code>coding-system-require-warning</code> to a non-<code>nil</code> value, which will force the output primitives to check the encoding by calling the value of <code>select-safe-coding-system-function</code> even though <code>coding-system-for-write</code> is non-<code>nil</code>. Alternatively, call <code>select-safe-coding-system</code> explicitly before using the specified encoding. </p></dd>
+</dl> <dl> <dt id="inhibit-eol-conversion">User Option: <strong>inhibit-eol-conversion</strong>
+</dt> <dd><p>When this variable is non-<code>nil</code>, no end-of-line conversion is done, no matter which coding system is specified. This applies to all the Emacs I/O and subprocess primitives, and to the explicit encoding and decoding functions (see <a href="explicit-encoding">Explicit Encoding</a>). </p></dd>
+</dl> <p>Sometimes, you need to prefer several coding systems for some operation, rather than fix a single one. Emacs lets you specify a priority order for using coding systems. This ordering affects the sorting of lists of coding systems returned by functions such as <code>find-coding-systems-region</code> (see <a href="lisp-and-coding-systems">Lisp and Coding Systems</a>). </p> <dl> <dt id="coding-system-priority-list">Function: <strong>coding-system-priority-list</strong> <em>&amp;optional highestp</em>
+</dt> <dd><p>This function returns the list of coding systems in the order of their current priorities. Optional argument <var>highestp</var>, if non-<code>nil</code>, means return only the highest priority coding system. </p></dd>
+</dl> <dl> <dt id="set-coding-system-priority">Function: <strong>set-coding-system-priority</strong> <em>&amp;rest coding-systems</em>
+</dt> <dd><p>This function puts <var>coding-systems</var> at the beginning of the priority list for coding systems, thus making their priority higher than all the rest. </p></dd>
+</dl> <dl> <dt id="with-coding-priority">Macro: <strong>with-coding-priority</strong> <em>coding-systems &amp;rest body</em>
+</dt> <dd><p>This macro executes <var>body</var>, like <code>progn</code> does (see <a href="sequencing">progn</a>), with <var>coding-systems</var> at the front of the priority list for coding systems. <var>coding-systems</var> should be a list of coding systems to prefer during execution of <var>body</var>. </p></dd>
+</dl><div class="_attribution">
+ <p class="_attribution-p">
+ Copyright &copy; 1990-1996, 1998-2022 Free Software Foundation, Inc. <br>Licensed under the GNU GPL license.<br>
+ <a href="https://www.gnu.org/software/emacs/manual/html_node/elisp/Specifying-Coding-Systems.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Specifying-Coding-Systems.html</a>
+ </p>
+</div>