aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Mackenzie2017-09-21 20:31:06 +0000
committerAlan Mackenzie2017-10-01 11:27:15 +0000
commitd5e4e004fa134cb81989bcf40c5d6c79b837301f (patch)
tree7588a351b8bd89612cdb457979f84b5f9f90c826
parent1ba3471b9b443f0617662f4a50439bec211162ba (diff)
downloademacs-d5e4e004fa134cb81989bcf40c5d6c79b837301f.tar.gz
emacs-d5e4e004fa134cb81989bcf40c5d6c79b837301f.zip
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.
-rw-r--r--doc/emacs/display.texi15
-rw-r--r--doc/lispref/control.texi3
-rw-r--r--doc/lispref/display.texi3
-rw-r--r--doc/lispref/help.texi31
-rw-r--r--doc/lispref/strings.texi7
-rw-r--r--etc/NEWS13
-rw-r--r--lisp/cus-start.el9
-rw-r--r--src/doc.c36
8 files changed, 76 insertions, 41 deletions
diff --git a/doc/emacs/display.texi b/doc/emacs/display.texi
index 6afd8366b25..5860bacb9d8 100644
--- a/doc/emacs/display.texi
+++ b/doc/emacs/display.texi
@@ -1548,11 +1548,20 @@ for details.
1548@cindex curly quotes 1548@cindex curly quotes
1549@cindex curved quotes 1549@cindex curved quotes
1550@cindex homoglyph face 1550@cindex homoglyph face
1551
1552Emacs tries to determine if the curved quotes @samp{‘} and @samp{’}
1553can be displayed on the current display. By default, if this seems to
1554be so, then Emacs will translate the @acronym{ASCII} quotes (@samp{`}
1555and @samp{'}), when they appear in messages and help texts, to these
1556curved quotes. You can influence or inhibit this translation by
1557customizing the user option @code{text-quoting-style} (@pxref{Keys in
1558Documentation,,, elisp, The Emacs Lisp Reference Manual}).
1559
1551 If the curved quotes @samp{‘}, @samp{’}, @samp{“}, and @samp{”} are 1560 If the curved quotes @samp{‘}, @samp{’}, @samp{“}, and @samp{”} are
1552known to look just like @acronym{ASCII} characters, they are shown 1561known to look just like @acronym{ASCII} characters, they are shown
1553with the @code{homoglyph} face. Curved quotes that cannot be 1562with the @code{homoglyph} face. Curved quotes that are known not to
1554displayed are shown as their @acronym{ASCII} approximations @samp{`}, 1563be displayable are shown as their @acronym{ASCII} approximations
1555@samp{'}, and @samp{"} with the @code{homoglyph} face. 1564@samp{`}, @samp{'}, and @samp{"} with the @code{homoglyph} face.
1556 1565
1557@node Cursor Display 1566@node Cursor Display
1558@section Displaying the Cursor 1567@section Displaying the Cursor
diff --git a/doc/lispref/control.texi b/doc/lispref/control.texi
index 401a999cf23..09435f57966 100644
--- a/doc/lispref/control.texi
+++ b/doc/lispref/control.texi
@@ -1108,6 +1108,9 @@ generates a message like @t{"Missing ‘foo’"} with matching curved
1108quotes. In contrast, a call using a format like @t{"Missing '%s'"} 1108quotes. In contrast, a call using a format like @t{"Missing '%s'"}
1109with only apostrophes typically generates a message like @t{"Missing 1109with only apostrophes typically generates a message like @t{"Missing
1110’foo’"} with only closing curved quotes, an unusual style in English. 1110’foo’"} with only closing curved quotes, an unusual style in English.
1111One way around this problem is to bind @code{text-quoting-style} to
1112@code{nil} around the call to @code{error}; this causes the
1113@acronym{ASCII} quote characters to be output unchanged.
1111 1114
1112@strong{Warning:} If you want to use your own string as an error message 1115@strong{Warning:} If you want to use your own string as an error message
1113verbatim, don't just write @code{(error @var{string})}. If @var{string} 1116verbatim, don't just write @code{(error @var{string})}. If @var{string}
diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi
index 3dae984f339..8f58fca506f 100644
--- a/doc/lispref/display.texi
+++ b/doc/lispref/display.texi
@@ -272,6 +272,9 @@ generates a message like @t{"Missing ‘foo’"} with matching curved
272quotes. In contrast, a call using a format like @t{"Missing '%s'"} 272quotes. In contrast, a call using a format like @t{"Missing '%s'"}
273with only apostrophes typically generates a message like @t{"Missing 273with only apostrophes typically generates a message like @t{"Missing
274’foo’"} with only closing curved quotes, an unusual style in English. 274’foo’"} with only closing curved quotes, an unusual style in English.
275One way around this problem is to bind @code{text-quoting-style} to
276@code{nil} around calls to @code{message}; this causes the
277@acronym{ASCII} quote characters to be output unchanged.
275 278
276In batch mode, the message is printed to the standard error stream, 279In batch mode, the message is printed to the standard error stream,
277followed by a newline. 280followed by a newline.
diff --git a/doc/lispref/help.texi b/doc/lispref/help.texi
index cb214113523..e1e98124e08 100644
--- a/doc/lispref/help.texi
+++ b/doc/lispref/help.texi
@@ -351,25 +351,24 @@ and @samp{\=\=} puts @samp{\=} into the output.
351@strong{Please note:} Each @samp{\} must be doubled when written in a 351@strong{Please note:} Each @samp{\} must be doubled when written in a
352string in Emacs Lisp. 352string in Emacs Lisp.
353 353
354@defvar text-quoting-style 354@defopt text-quoting-style
355@cindex curved quotes 355@cindex curved quotes
356@cindex curly quotes 356@cindex curly quotes
357The value of this variable is a symbol that specifies the style Emacs 357The value of this variable is a symbol that specifies the style Emacs
358should use for single quotes in the wording of help and messages. 358should use for single quotes in the wording of help and messages. If
359If the variable's value is @code{curve}, the style is 359the variable's value is @code{curve}, the style is @t{‘like this’}
360@t{‘like this’} with curved single quotes. If the value is 360with curved single quotes. If the value is @code{straight}, the style
361@code{straight}, the style is @t{'like this'} with straight 361is @t{'like this'} with straight apostrophes. If the value is
362apostrophes. If the value is @code{grave}, 362@code{nil} or @code{grave}, quotes are not translated and the style is
363quotes are not translated and the style is @t{`like 363@t{`like this'} with grave accent and apostrophe, the standard style
364this'} with grave accent and apostrophe, the standard style 364before Emacs version 25. The default value @code{t} acts like
365before Emacs version 25. The default value @code{nil} 365@code{curve} if curved single quotes seem to be displayable, and like
366acts like @code{curve} if curved single quotes are displayable, and 366@code{nil} otherwise.
367like @code{grave} otherwise. 367
368 368This option is useful on platforms that have problems with curved
369This variable can be used by experts on platforms that have problems 369quotes. You can customize it freely according to your personal
370with curved quotes. As it is not intended for casual use, it is not a 370preference.
371user option. 371@end defopt
372@end defvar
373 372
374@defun substitute-command-keys string 373@defun substitute-command-keys string
375This function scans @var{string} for the above special sequences and 374This function scans @var{string} for the above special sequences and
diff --git a/doc/lispref/strings.texi b/doc/lispref/strings.texi
index 219225d412b..117a373a190 100644
--- a/doc/lispref/strings.texi
+++ b/doc/lispref/strings.texi
@@ -835,8 +835,11 @@ A format that quotes with grave accents and apostrophes @t{`like
835this'} typically generates curved quotes @t{‘like this’}. In 835this'} typically generates curved quotes @t{‘like this’}. In
836contrast, a format that quotes with only apostrophes @t{'like this'} 836contrast, a format that quotes with only apostrophes @t{'like this'}
837typically generates two closing curved quotes @t{’like this’}, an 837typically generates two closing curved quotes @t{’like this’}, an
838unusual style in English. @xref{Keys in Documentation}, for how the 838unusual style in English. One way around such problems is to bind
839@code{text-quoting-style} variable affects generated quotes. 839@code{text-quoting-style} to @code{nil} around calls to
840@code{format-message}; this causes the @acronym{ASCII} quoting
841characters to be output unchanged. @xref{Keys in Documentation}, for
842how the @code{text-quoting-style} variable affects generated quotes.
840@end defun 843@end defun
841 844
842@cindex @samp{%} in format 845@cindex @samp{%} in format
diff --git a/etc/NEWS b/etc/NEWS
index 2216cfc18ee..d518d5e277e 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1244,10 +1244,15 @@ change FOO, respectively. The exhaustive list of removed variables is:
1244*** Many variables obsoleted in 22.1 referring to face symbols 1244*** Many variables obsoleted in 22.1 referring to face symbols
1245 1245
1246+++ 1246+++
1247** The variable 'text-quoting-style' no longer affects the treatment 1247** The variable `text-quoting-style' is now a customizable option. It
1248of curved quotes in format arguments to functions like 'message' and 1248controls whether to and how to translate ASCII quotes in messages and
1249'format-message'. In particular, when this variable's value is 1249help output. The value nil now means "no translation", and the value
1250'grave', all quotes in formats are output as-is. 1250t, the default, means "use curved quotes if displayable" (as nil did
1251in Emacs 25). The other possible values remain unchanged.
1252`text-quoting-style' no longer affects the treatment of curved quotes
1253in format arguments to functions like `message' and `format-message'.
1254In particular, when this variable's value is `grave', all quotes in
1255formats are output as-is.
1251 1256
1252--- 1257---
1253** Functions like 'check-declare-file' and 'check-declare-directory' 1258** Functions like 'check-declare-file' and 'check-declare-directory'
diff --git a/lisp/cus-start.el b/lisp/cus-start.el
index fd015b70ca3..f5e1431f6bb 100644
--- a/lisp/cus-start.el
+++ b/lisp/cus-start.el
@@ -223,6 +223,15 @@ Leaving \"Default\" unchecked is equivalent with specifying a default of
223 (visible-bell display boolean) 223 (visible-bell display boolean)
224 (no-redraw-on-reenter display boolean) 224 (no-redraw-on-reenter display boolean)
225 225
226 ;; doc.c
227 (text-quoting-style display
228 (choice
229 (const :tag "No translation" nil)
230 (const :tag "Prefer \\=‘curved\\=’ quotes, if possible" t)
231 (const :tag "\\=‘Curved\\=’ quotes" curved)
232 (const :tag "\\='Straight\\=' quotes" straight)
233 (const :tag "\\=`Grave\\=' quotes" grave)))
234
226 ;; dosfns.c 235 ;; dosfns.c
227 (dos-display-scancodes display boolean) 236 (dos-display-scancodes display boolean)
228 (dos-hyper-key keyboard integer) 237 (dos-hyper-key keyboard integer)
diff --git a/src/doc.c b/src/doc.c
index 3286c12675a..e2af39ef07f 100644
--- a/src/doc.c
+++ b/src/doc.c
@@ -690,8 +690,9 @@ enum text_quoting_style
690text_quoting_style (void) 690text_quoting_style (void)
691{ 691{
692 if (NILP (Vtext_quoting_style) 692 if (NILP (Vtext_quoting_style)
693 ? default_to_grave_quoting_style () 693 || (EQ (Vtext_quoting_style, Qt)
694 : EQ (Vtext_quoting_style, Qgrave)) 694 ? default_to_grave_quoting_style ()
695 : EQ (Vtext_quoting_style, Qgrave)))
695 return GRAVE_QUOTING_STYLE; 696 return GRAVE_QUOTING_STYLE;
696 else if (EQ (Vtext_quoting_style, Qstraight)) 697 else if (EQ (Vtext_quoting_style, Qstraight))
697 return STRAIGHT_QUOTING_STYLE; 698 return STRAIGHT_QUOTING_STYLE;
@@ -1018,22 +1019,25 @@ syms_of_doc (void)
1018 Vbuild_files = Qnil; 1019 Vbuild_files = Qnil;
1019 1020
1020 DEFVAR_LISP ("text-quoting-style", Vtext_quoting_style, 1021 DEFVAR_LISP ("text-quoting-style", Vtext_quoting_style,
1021 doc: /* Style to use for single quotes in help and messages. 1022 doc: /* How to translate single quotes in help and messages.
1022Its value should be a symbol. It works by substituting certain single 1023Its value should be a symbol, and describes the style of quote
1023quotes for grave accent and apostrophe. This is done in help output 1024substituted for ASCII quote characters GRAVE ACCENT (\\=`, \\=\\x60) and
1024and in functions like `message' and `format-message'. It is not done 1025APOSTROPHE (\\=', \\=\\x27). This is done in help output and in functions
1025in `format'. 1026like `message' and `format-message'. It is not done in `format'.
1026 1027
1027`curve' means quote with curved single quotes ‘like this’. 1028The value nil means do not translate the quotes at all. The value t
1028`straight' means quote with straight apostrophes \\='like this\\='. 1029(the default) acts like `curve' if curved single quotes appear to be
1029`grave' means quote with grave accent and apostrophe \\=`like this\\='; 1030displayable, and like nil otherwise. `curve' means quote with curved
1030i.e., do not alter quote marks. The default value nil acts like 1031single quotes ‘like this’. `straight' means quote with apostrophes
1031`curve' if curved single quotes are displayable, and like `grave' 1032\\='like this\\='. `grave' means do not translate quote marks and is
1032otherwise. */); 1033now a synonym for nil.
1033 Vtext_quoting_style = Qnil; 1034
1035(The value t was newly introduced in Emacs 26, and in Emacs 25 nil
1036meant what t means now.) */);
1037 Vtext_quoting_style = Qt;
1034 1038
1035 DEFVAR_BOOL ("internal--text-quoting-flag", text_quoting_flag, 1039 DEFVAR_BOOL ("internal--text-quoting-flag", text_quoting_flag,
1036 doc: /* If nil, a nil `text-quoting-style' is treated as `grave'. */); 1040 doc: /* If nil, a `text-quoting-style' value t is treated as `nil'. */);
1037 /* Initialized by ‘main’. */ 1041 /* Initialized by ‘main’. */
1038 1042
1039 defsubr (&Sdocumentation); 1043 defsubr (&Sdocumentation);