User-Chosen Coding Systems
--------------------------
- Function: select-safe-coding-system from to &optional
default-coding-system accept-default-p
This function selects a coding system for encoding specified text,
asking the user to choose if necessary. Normally the specified
text is the text in the current buffer between FROM and TO,
defaulting to the whole buffer if they are `nil'. If FROM is a
string, the string is the specified text, and TO is ignored.
If DEFAULT-CODING-SYSTEM is non-`nil', that is the first coding
system to try; if that can handle the text,
`select-safe-coding-system' returns that coding system. It can
also be a list of coding systems; then the function tries each of
them one by one. After trying all of them, it next tries the
user's most preferred coding system (*note prefer-coding-system:
(emacs)Recognize Coding.), and after that the current buffer's
value of `buffer-file-coding-system' (if it is not `undecided').
If one of those coding systems can safely encode all the specified
text, `select-safe-coding-system' chooses it and returns it.
Otherwise, it asks the user to choose from a list of coding systems
which can encode all the text, and returns the user's choice.
The optional argument ACCEPT-DEFAULT-P, if non-`nil', should be a
function to determine whether the coding system selected without
user interaction is acceptable. If this function returns `nil',
the silently selected coding system is rejected, and the user is
asked to select a coding system from a list of possible candidates.
If the variable `select-safe-coding-system-accept-default-p' is
non-`nil', its value overrides the value of ACCEPT-DEFAULT-P.
Here are two functions you can use to let the user specify a coding
system, with completion. Note:Completion.
- Function: read-coding-system prompt &optional default
This function reads a coding system using the minibuffer,
prompting with string PROMPT, and returns the coding system name
as a symbol. If the user enters null input, DEFAULT specifies
which coding system to return. It should be a symbol or a string.
- Function: read-non-nil-coding-system prompt
This function reads a coding system using the minibuffer,
prompting with string PROMPT, and returns the coding system name
as a symbol. If the user tries to enter null input, it asks the
user to try again. Note:Coding Systems.