Commit d5e4e004 authored by Alan Mackenzie's avatar Alan Mackenzie

Make text-quoting-style customizable. Introduce t and new meaning for nil.

A value of nil for text-quoting-style now means "no translation".  t means
"Use curved quotes if displayable".

* src/doc.c (text-quoting-style (function)): modify for new semantics.
(text-quoting-style (variable)): Amend the doc string, set the default value
to t.

* lisp/cus-start.el: (top level): Create a customize entry for
text-quoting-style in group display.

* etc/NEWS: Amend the entry for text-quoting-style.

* doc/emacs/display.texi (Text Display): Describe the translation of ASCII
quotes to curved quotes, and how to influence or inhibit it.

* doc/lispref/control.texi (Signalling Errors)
* doc/lispref/display.texi (Displaying Messages)
* doc/lispref/strings.texi (Formatting Strings): Describe binding
text-quoting-style to nil to inhibit unwanted quote translation.

* doc/lispref/help.texi (Keys in Documentation): Change text-quoting-style
from a variable to a user option.  Describe its changed set of values.  State
that it can be customized freely.
parent 1ba3471b
...@@ -1548,11 +1548,20 @@ for details. ...@@ -1548,11 +1548,20 @@ for details.
@cindex curly quotes @cindex curly quotes
@cindex curved quotes @cindex curved quotes
@cindex homoglyph face @cindex homoglyph face
Emacs tries to determine if the curved quotes @samp{‘} and @samp{’}
can be displayed on the current display. By default, if this seems to
be so, then Emacs will translate the @acronym{ASCII} quotes (@samp{`}
and @samp{'}), when they appear in messages and help texts, to these
curved quotes. You can influence or inhibit this translation by
customizing the user option @code{text-quoting-style} (@pxref{Keys in
Documentation,,, elisp, The Emacs Lisp Reference Manual}).
If the curved quotes @samp{‘}, @samp{’}, @samp{“}, and @samp{”} are If the curved quotes @samp{‘}, @samp{’}, @samp{“}, and @samp{”} are
known to look just like @acronym{ASCII} characters, they are shown known to look just like @acronym{ASCII} characters, they are shown
with the @code{homoglyph} face. Curved quotes that cannot be with the @code{homoglyph} face. Curved quotes that are known not to
displayed are shown as their @acronym{ASCII} approximations @samp{`}, be displayable are shown as their @acronym{ASCII} approximations
@samp{'}, and @samp{"} with the @code{homoglyph} face. @samp{`}, @samp{'}, and @samp{"} with the @code{homoglyph} face.
@node Cursor Display @node Cursor Display
@section Displaying the Cursor @section Displaying the Cursor
......
...@@ -1108,6 +1108,9 @@ generates a message like @t{"Missing ‘foo’"} with matching curved ...@@ -1108,6 +1108,9 @@ generates a message like @t{"Missing ‘foo’"} with matching curved
quotes. In contrast, a call using a format like @t{"Missing '%s'"} quotes. In contrast, a call using a format like @t{"Missing '%s'"}
with only apostrophes typically generates a message like @t{"Missing with only apostrophes typically generates a message like @t{"Missing
’foo’"} with only closing curved quotes, an unusual style in English. ’foo’"} with only closing curved quotes, an unusual style in English.
One way around this problem is to bind @code{text-quoting-style} to
@code{nil} around the call to @code{error}; this causes the
@acronym{ASCII} quote characters to be output unchanged.
@strong{Warning:} If you want to use your own string as an error message @strong{Warning:} If you want to use your own string as an error message
verbatim, don't just write @code{(error @var{string})}. If @var{string} verbatim, don't just write @code{(error @var{string})}. If @var{string}
......
...@@ -272,6 +272,9 @@ generates a message like @t{"Missing ‘foo’"} with matching curved ...@@ -272,6 +272,9 @@ generates a message like @t{"Missing ‘foo’"} with matching curved
quotes. In contrast, a call using a format like @t{"Missing '%s'"} quotes. In contrast, a call using a format like @t{"Missing '%s'"}
with only apostrophes typically generates a message like @t{"Missing with only apostrophes typically generates a message like @t{"Missing
’foo’"} with only closing curved quotes, an unusual style in English. ’foo’"} with only closing curved quotes, an unusual style in English.
One way around this problem is to bind @code{text-quoting-style} to
@code{nil} around calls to @code{message}; this causes the
@acronym{ASCII} quote characters to be output unchanged.
In batch mode, the message is printed to the standard error stream, In batch mode, the message is printed to the standard error stream,
followed by a newline. followed by a newline.
......
...@@ -351,25 +351,24 @@ and @samp{\=\=} puts @samp{\=} into the output. ...@@ -351,25 +351,24 @@ and @samp{\=\=} puts @samp{\=} into the output.
@strong{Please note:} Each @samp{\} must be doubled when written in a @strong{Please note:} Each @samp{\} must be doubled when written in a
string in Emacs Lisp. string in Emacs Lisp.
@defvar text-quoting-style @defopt text-quoting-style
@cindex curved quotes @cindex curved quotes
@cindex curly quotes @cindex curly quotes
The value of this variable is a symbol that specifies the style Emacs The value of this variable is a symbol that specifies the style Emacs
should use for single quotes in the wording of help and messages. should use for single quotes in the wording of help and messages. If
If the variable's value is @code{curve}, the style is the variable's value is @code{curve}, the style is @t{‘like this’}
@t{‘like this’} with curved single quotes. If the value is with curved single quotes. If the value is @code{straight}, the style
@code{straight}, the style is @t{'like this'} with straight is @t{'like this'} with straight apostrophes. If the value is
apostrophes. If the value is @code{grave}, @code{nil} or @code{grave}, quotes are not translated and the style is
quotes are not translated and the style is @t{`like @t{`like this'} with grave accent and apostrophe, the standard style
this'} with grave accent and apostrophe, the standard style before Emacs version 25. The default value @code{t} acts like
before Emacs version 25. The default value @code{nil} @code{curve} if curved single quotes seem to be displayable, and like
acts like @code{curve} if curved single quotes are displayable, and @code{nil} otherwise.
like @code{grave} otherwise.
This option is useful on platforms that have problems with curved
This variable can be used by experts on platforms that have problems quotes. You can customize it freely according to your personal
with curved quotes. As it is not intended for casual use, it is not a preference.
user option. @end defopt
@end defvar
@defun substitute-command-keys string @defun substitute-command-keys string
This function scans @var{string} for the above special sequences and This function scans @var{string} for the above special sequences and
......
...@@ -835,8 +835,11 @@ A format that quotes with grave accents and apostrophes @t{`like ...@@ -835,8 +835,11 @@ A format that quotes with grave accents and apostrophes @t{`like
this'} typically generates curved quotes @t{‘like this’}. In this'} typically generates curved quotes @t{‘like this’}. In
contrast, a format that quotes with only apostrophes @t{'like this'} contrast, a format that quotes with only apostrophes @t{'like this'}
typically generates two closing curved quotes @t{’like this’}, an typically generates two closing curved quotes @t{’like this’}, an
unusual style in English. @xref{Keys in Documentation}, for how the unusual style in English. One way around such problems is to bind
@code{text-quoting-style} variable affects generated quotes. @code{text-quoting-style} to @code{nil} around calls to
@code{format-message}; this causes the @acronym{ASCII} quoting
characters to be output unchanged. @xref{Keys in Documentation}, for
how the @code{text-quoting-style} variable affects generated quotes.
@end defun @end defun
@cindex @samp{%} in format @cindex @samp{%} in format
......
...@@ -1244,10 +1244,15 @@ change FOO, respectively. The exhaustive list of removed variables is: ...@@ -1244,10 +1244,15 @@ change FOO, respectively. The exhaustive list of removed variables is:
*** Many variables obsoleted in 22.1 referring to face symbols *** Many variables obsoleted in 22.1 referring to face symbols
+++ +++
** The variable 'text-quoting-style' no longer affects the treatment ** The variable `text-quoting-style' is now a customizable option. It
of curved quotes in format arguments to functions like 'message' and controls whether to and how to translate ASCII quotes in messages and
'format-message'. In particular, when this variable's value is help output. The value nil now means "no translation", and the value
'grave', all quotes in formats are output as-is. t, the default, means "use curved quotes if displayable" (as nil did
in Emacs 25). The other possible values remain unchanged.
`text-quoting-style' no longer affects the treatment of curved quotes
in format arguments to functions like `message' and `format-message'.
In particular, when this variable's value is `grave', all quotes in
formats are output as-is.
--- ---
** Functions like 'check-declare-file' and 'check-declare-directory' ** Functions like 'check-declare-file' and 'check-declare-directory'
......
...@@ -223,6 +223,15 @@ Leaving \"Default\" unchecked is equivalent with specifying a default of ...@@ -223,6 +223,15 @@ Leaving \"Default\" unchecked is equivalent with specifying a default of
(visible-bell display boolean) (visible-bell display boolean)
(no-redraw-on-reenter display boolean) (no-redraw-on-reenter display boolean)
;; doc.c
(text-quoting-style display
(choice
(const :tag "No translation" nil)
(const :tag "Prefer \\=curved\\= quotes, if possible" t)
(const :tag "\\=Curved\\= quotes" curved)
(const :tag "\\='Straight\\=' quotes" straight)
(const :tag "\\=`Grave\\=' quotes" grave)))
;; dosfns.c ;; dosfns.c
(dos-display-scancodes display boolean) (dos-display-scancodes display boolean)
(dos-hyper-key keyboard integer) (dos-hyper-key keyboard integer)
......
...@@ -690,8 +690,9 @@ enum text_quoting_style ...@@ -690,8 +690,9 @@ enum text_quoting_style
text_quoting_style (void) text_quoting_style (void)
{ {
if (NILP (Vtext_quoting_style) if (NILP (Vtext_quoting_style)
|| (EQ (Vtext_quoting_style, Qt)
? default_to_grave_quoting_style () ? default_to_grave_quoting_style ()
: EQ (Vtext_quoting_style, Qgrave)) : EQ (Vtext_quoting_style, Qgrave)))
return GRAVE_QUOTING_STYLE; return GRAVE_QUOTING_STYLE;
else if (EQ (Vtext_quoting_style, Qstraight)) else if (EQ (Vtext_quoting_style, Qstraight))
return STRAIGHT_QUOTING_STYLE; return STRAIGHT_QUOTING_STYLE;
...@@ -1018,22 +1019,25 @@ syms_of_doc (void) ...@@ -1018,22 +1019,25 @@ syms_of_doc (void)
Vbuild_files = Qnil; Vbuild_files = Qnil;
DEFVAR_LISP ("text-quoting-style", Vtext_quoting_style, DEFVAR_LISP ("text-quoting-style", Vtext_quoting_style,
doc: /* Style to use for single quotes in help and messages. doc: /* How to translate single quotes in help and messages.
Its value should be a symbol. It works by substituting certain single Its value should be a symbol, and describes the style of quote
quotes for grave accent and apostrophe. This is done in help output substituted for ASCII quote characters GRAVE ACCENT (\\=`, \\=\\x60) and
and in functions like `message' and `format-message'. It is not done APOSTROPHE (\\=', \\=\\x27). This is done in help output and in functions
in `format'. like `message' and `format-message'. It is not done in `format'.
`curve' means quote with curved single quotes ‘like this’. The value nil means do not translate the quotes at all. The value t
`straight' means quote with straight apostrophes \\='like this\\='. (the default) acts like `curve' if curved single quotes appear to be
`grave' means quote with grave accent and apostrophe \\=`like this\\='; displayable, and like nil otherwise. `curve' means quote with curved
i.e., do not alter quote marks. The default value nil acts like single quotes ‘like this’. `straight' means quote with apostrophes
`curve' if curved single quotes are displayable, and like `grave' \\='like this\\='. `grave' means do not translate quote marks and is
otherwise. */); now a synonym for nil.
Vtext_quoting_style = Qnil;
(The value t was newly introduced in Emacs 26, and in Emacs 25 nil
meant what t means now.) */);
Vtext_quoting_style = Qt;
DEFVAR_BOOL ("internal--text-quoting-flag", text_quoting_flag, DEFVAR_BOOL ("internal--text-quoting-flag", text_quoting_flag,
doc: /* If nil, a nil `text-quoting-style' is treated as `grave'. */); doc: /* If nil, a `text-quoting-style' value t is treated as `nil'. */);
/* Initialized by ‘main’. */ /* Initialized by ‘main’. */
defsubr (&Sdocumentation); defsubr (&Sdocumentation);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment