aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2017-01-10 20:02:37 +0200
committerEli Zaretskii2017-01-10 20:02:37 +0200
commit0e35405a92be502ab3851890fc4eb660842fd3a9 (patch)
tree058b4ee76a6b4aef7b5fd04e85a8723bc4ed3f31
parentc2fd04c8d504b601471fe7c13011bc39abc6b921 (diff)
downloademacs-0e35405a92be502ab3851890fc4eb660842fd3a9.tar.gz
emacs-0e35405a92be502ab3851890fc4eb660842fd3a9.zip
Improve documentation of coding-systems
* doc/lispref/nonascii.texi (Coding System Basics): Mention 'prefer-utf-8'. Index it and 'undecided'. (Encoding and I/O): Fix a typo. (User-Chosen Coding Systems): Improve the documentation of ACCEPT-DEFAULT-P argument to select-safe-coding-system. Document select-safe-coding-system-function. (Specifying Coding Systems): Document coding-system-require-warning.
-rw-r--r--doc/lispref/nonascii.texi65
1 files changed, 51 insertions, 14 deletions
diff --git a/doc/lispref/nonascii.texi b/doc/lispref/nonascii.texi
index ab8f2fc94fb..e3cb5d0d369 100644
--- a/doc/lispref/nonascii.texi
+++ b/doc/lispref/nonascii.texi
@@ -1002,10 +1002,14 @@ alternative encodings for the same characters; for example, there are
1002three coding systems for the Cyrillic (Russian) alphabet: ISO, 1002three coding systems for the Cyrillic (Russian) alphabet: ISO,
1003Alternativnyj, and KOI8. 1003Alternativnyj, and KOI8.
1004 1004
1005@vindex undecided@r{ coding system}
1006@vindex prefer-utf-8@r{ coding system}
1005 Every coding system specifies a particular set of character code 1007 Every coding system specifies a particular set of character code
1006conversions, but the coding system @code{undecided} is special: it 1008conversions, but the coding system @code{undecided} is special: it
1007leaves the choice unspecified, to be chosen heuristically for each 1009leaves the choice unspecified, to be chosen heuristically for each
1008file, based on the file's data. 1010file, based on the file's data. The coding system @code{prefer-utf-8}
1011is like @code{undecided}, but it prefers to choose @code{utf-8} when
1012possible.
1009 1013
1010 In general, a coding system doesn't guarantee roundtrip identity: 1014 In general, a coding system doesn't guarantee roundtrip identity:
1011decoding a byte sequence using coding system, then encoding the 1015decoding a byte sequence using coding system, then encoding the
@@ -1109,7 +1113,7 @@ encode the buffer contents.
1109(@pxref{Specifying Coding Systems}), or implicitly using a default 1113(@pxref{Specifying Coding Systems}), or implicitly using a default
1110mechanism (@pxref{Default Coding Systems}). But these methods may not 1114mechanism (@pxref{Default Coding Systems}). But these methods may not
1111completely specify what to do. For example, they may choose a coding 1115completely specify what to do. For example, they may choose a coding
1112system such as @code{undefined} which leaves the character code 1116system such as @code{undecided} which leaves the character code
1113conversion to be determined from the data. In these cases, the I/O 1117conversion to be determined from the data. In these cases, the I/O
1114operation finishes the job of choosing a coding system. Very often 1118operation finishes the job of choosing a coding system. Very often
1115you will want to find out afterwards which coding system was chosen. 1119you will want to find out afterwards which coding system was chosen.
@@ -1411,19 +1415,21 @@ Otherwise, it asks the user to choose from a list of coding systems
1411which can encode all the text, and returns the user's choice. 1415which can encode all the text, and returns the user's choice.
1412 1416
1413@var{default-coding-system} can also be a list whose first element is 1417@var{default-coding-system} can also be a list whose first element is
1414t and whose other elements are coding systems. Then, if no coding 1418@code{t} and whose other elements are coding systems. Then, if no coding
1415system in the list can handle the text, @code{select-safe-coding-system} 1419system in the list can handle the text, @code{select-safe-coding-system}
1416queries the user immediately, without trying any of the three 1420queries the user immediately, without trying any of the three
1417alternatives described above. 1421alternatives described above. This is handy for checking only the
1418 1422coding systems in the list.
1419The optional argument @var{accept-default-p}, if non-@code{nil}, 1423
1420should be a function to determine whether a coding system selected 1424The optional argument @var{accept-default-p} determines whether a
1421without user interaction is acceptable. @code{select-safe-coding-system} 1425coding system selected without user interaction is acceptable. If
1422calls this function with one argument, the base coding system of the 1426it's omitted or @code{nil}, such a silent selection is always
1423selected coding system. If @var{accept-default-p} returns @code{nil}, 1427acceptable. If it is non-@code{nil}, it should be a function;
1424@code{select-safe-coding-system} rejects the silently selected coding 1428@code{select-safe-coding-system} calls this function with one
1425system, and asks the user to select a coding system from a list of 1429argument, the base coding system of the selected coding system. If
1426possible candidates. 1430the function returns @code{nil}, @code{select-safe-coding-system}
1431rejects the silently selected coding system, and asks the user to
1432select a coding system from a list of possible candidates.
1427 1433
1428@vindex select-safe-coding-system-accept-default-p 1434@vindex select-safe-coding-system-accept-default-p
1429If the variable @code{select-safe-coding-system-accept-default-p} is 1435If the variable @code{select-safe-coding-system-accept-default-p} is
@@ -1444,6 +1450,18 @@ similar functions). If it detects an apparent inconsistency,
1444coding system. 1450coding system.
1445@end defun 1451@end defun
1446 1452
1453@defvar select-safe-coding-system-function
1454This variable names the function to be called to request the user to
1455select a proper coding system for encoding text when the default
1456coding system for an output operation cannot safely encode that text.
1457The default value of this variable is @code{select-safe-coding-system}.
1458Emacs primitives that write text to files, such as
1459@code{write-region}, or send text to other processes, such as
1460@code{process-send-region}, normally call the value of this variable,
1461unless @code{coding-system-for-write} is bound to a non-@code{nil}
1462value (@pxref{Specifying Coding Systems}).
1463@end defvar
1464
1447 Here are two functions you can use to let the user specify a coding 1465 Here are two functions you can use to let the user specify a coding
1448system, with completion. @xref{Completion}. 1466system, with completion. @xref{Completion}.
1449 1467
@@ -1704,7 +1722,9 @@ including @code{file-coding-system-alist},
1704@defvar coding-system-for-write 1722@defvar coding-system-for-write
1705This works much like @code{coding-system-for-read}, except that it 1723This works much like @code{coding-system-for-read}, except that it
1706applies to output rather than input. It affects writing to files, 1724applies to output rather than input. It affects writing to files,
1707as well as sending output to subprocesses and net connections. 1725as well as sending output to subprocesses and net connections. It
1726also applies to encoding command-line arguments with which Emacs
1727invokes subprocesses.
1708 1728
1709When a single operation does both input and output, as do 1729When a single operation does both input and output, as do
1710@code{call-process-region} and @code{start-process}, both 1730@code{call-process-region} and @code{start-process}, both
@@ -1712,6 +1732,23 @@ When a single operation does both input and output, as do
1712affect it. 1732affect it.
1713@end defvar 1733@end defvar
1714 1734
1735@defvar coding-system-require-warning
1736Binding @code{coding-system-for-write} to a non-@code{nil} value
1737prevents output primitives from calling the function specified by
1738@code{select-safe-coding-system-function} (@pxref{User-Chosen Coding
1739Systems}). This is because @kbd{C-x RET c}
1740(@code{universal-coding-system-argument}) works by binding
1741@code{coding-system-for-write}, and Emacs should obey user selection.
1742If a Lisp program binds @code{coding-system-for-write} to a value that
1743might not be safe for encoding the text to be written, it can also bind
1744@code{coding-system-require-warning} to a non-@code{nil} value, which
1745will force the output primitives to check the encoding by calling the
1746value of @code{select-safe-coding-system-function} even though
1747@code{coding-system-for-write} is non-@code{nil}. Alternatively, call
1748@code{select-safe-coding-system} explicitly before using the specified
1749encoding.
1750@end defvar
1751
1715@defopt inhibit-eol-conversion 1752@defopt inhibit-eol-conversion
1716When this variable is non-@code{nil}, no end-of-line conversion is done, 1753When this variable is non-@code{nil}, no end-of-line conversion is done,
1717no matter which coding system is specified. This applies to all the 1754no matter which coding system is specified. This applies to all the