diff options
| author | Alan Mackenzie | 2017-09-21 20:31:06 +0000 |
|---|---|---|
| committer | Alan Mackenzie | 2017-10-01 11:27:15 +0000 |
| commit | d5e4e004fa134cb81989bcf40c5d6c79b837301f (patch) | |
| tree | 7588a351b8bd89612cdb457979f84b5f9f90c826 | |
| parent | 1ba3471b9b443f0617662f4a50439bec211162ba (diff) | |
| download | emacs-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.texi | 15 | ||||
| -rw-r--r-- | doc/lispref/control.texi | 3 | ||||
| -rw-r--r-- | doc/lispref/display.texi | 3 | ||||
| -rw-r--r-- | doc/lispref/help.texi | 31 | ||||
| -rw-r--r-- | doc/lispref/strings.texi | 7 | ||||
| -rw-r--r-- | etc/NEWS | 13 | ||||
| -rw-r--r-- | lisp/cus-start.el | 9 | ||||
| -rw-r--r-- | src/doc.c | 36 |
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 | |||
| 1552 | Emacs tries to determine if the curved quotes @samp{‘} and @samp{’} | ||
| 1553 | can be displayed on the current display. By default, if this seems to | ||
| 1554 | be so, then Emacs will translate the @acronym{ASCII} quotes (@samp{`} | ||
| 1555 | and @samp{'}), when they appear in messages and help texts, to these | ||
| 1556 | curved quotes. You can influence or inhibit this translation by | ||
| 1557 | customizing the user option @code{text-quoting-style} (@pxref{Keys in | ||
| 1558 | Documentation,,, 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 |
| 1552 | known to look just like @acronym{ASCII} characters, they are shown | 1561 | known to look just like @acronym{ASCII} characters, they are shown |
| 1553 | with the @code{homoglyph} face. Curved quotes that cannot be | 1562 | with the @code{homoglyph} face. Curved quotes that are known not to |
| 1554 | displayed are shown as their @acronym{ASCII} approximations @samp{`}, | 1563 | be 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 | |||
| 1108 | quotes. In contrast, a call using a format like @t{"Missing '%s'"} | 1108 | quotes. In contrast, a call using a format like @t{"Missing '%s'"} |
| 1109 | with only apostrophes typically generates a message like @t{"Missing | 1109 | with 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. |
| 1111 | One 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 |
| 1113 | verbatim, don't just write @code{(error @var{string})}. If @var{string} | 1116 | verbatim, 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 | |||
| 272 | quotes. In contrast, a call using a format like @t{"Missing '%s'"} | 272 | quotes. In contrast, a call using a format like @t{"Missing '%s'"} |
| 273 | with only apostrophes typically generates a message like @t{"Missing | 273 | with 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. |
| 275 | One 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 | ||
| 276 | In batch mode, the message is printed to the standard error stream, | 279 | In batch mode, the message is printed to the standard error stream, |
| 277 | followed by a newline. | 280 | followed 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 |
| 352 | string in Emacs Lisp. | 352 | string 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 |
| 357 | The value of this variable is a symbol that specifies the style Emacs | 357 | The value of this variable is a symbol that specifies the style Emacs |
| 358 | should use for single quotes in the wording of help and messages. | 358 | should use for single quotes in the wording of help and messages. If |
| 359 | If the variable's value is @code{curve}, the style is | 359 | the variable's value is @code{curve}, the style is @t{‘like this’} |
| 360 | @t{‘like this’} with curved single quotes. If the value is | 360 | with curved single quotes. If the value is @code{straight}, the style |
| 361 | @code{straight}, the style is @t{'like this'} with straight | 361 | is @t{'like this'} with straight apostrophes. If the value is |
| 362 | apostrophes. If the value is @code{grave}, | 362 | @code{nil} or @code{grave}, quotes are not translated and the style is |
| 363 | quotes are not translated and the style is @t{`like | 363 | @t{`like this'} with grave accent and apostrophe, the standard style |
| 364 | this'} with grave accent and apostrophe, the standard style | 364 | before Emacs version 25. The default value @code{t} acts like |
| 365 | before Emacs version 25. The default value @code{nil} | 365 | @code{curve} if curved single quotes seem to be displayable, and like |
| 366 | acts like @code{curve} if curved single quotes are displayable, and | 366 | @code{nil} otherwise. |
| 367 | like @code{grave} otherwise. | 367 | |
| 368 | 368 | This option is useful on platforms that have problems with curved | |
| 369 | This variable can be used by experts on platforms that have problems | 369 | quotes. You can customize it freely according to your personal |
| 370 | with curved quotes. As it is not intended for casual use, it is not a | 370 | preference. |
| 371 | user option. | 371 | @end defopt |
| 372 | @end defvar | ||
| 373 | 372 | ||
| 374 | @defun substitute-command-keys string | 373 | @defun substitute-command-keys string |
| 375 | This function scans @var{string} for the above special sequences and | 374 | This 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 | |||
| 835 | this'} typically generates curved quotes @t{‘like this’}. In | 835 | this'} typically generates curved quotes @t{‘like this’}. In |
| 836 | contrast, a format that quotes with only apostrophes @t{'like this'} | 836 | contrast, a format that quotes with only apostrophes @t{'like this'} |
| 837 | typically generates two closing curved quotes @t{’like this’}, an | 837 | typically generates two closing curved quotes @t{’like this’}, an |
| 838 | unusual style in English. @xref{Keys in Documentation}, for how the | 838 | unusual 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 | ||
| 841 | characters to be output unchanged. @xref{Keys in Documentation}, for | ||
| 842 | how 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 |
| @@ -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 |
| 1248 | of curved quotes in format arguments to functions like 'message' and | 1248 | controls whether to and how to translate ASCII quotes in messages and |
| 1249 | 'format-message'. In particular, when this variable's value is | 1249 | help output. The value nil now means "no translation", and the value |
| 1250 | 'grave', all quotes in formats are output as-is. | 1250 | t, the default, means "use curved quotes if displayable" (as nil did |
| 1251 | in Emacs 25). The other possible values remain unchanged. | ||
| 1252 | `text-quoting-style' no longer affects the treatment of curved quotes | ||
| 1253 | in format arguments to functions like `message' and `format-message'. | ||
| 1254 | In particular, when this variable's value is `grave', all quotes in | ||
| 1255 | formats 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) |
| @@ -690,8 +690,9 @@ enum text_quoting_style | |||
| 690 | text_quoting_style (void) | 690 | text_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. |
| 1022 | Its value should be a symbol. It works by substituting certain single | 1023 | Its value should be a symbol, and describes the style of quote |
| 1023 | quotes for grave accent and apostrophe. This is done in help output | 1024 | substituted for ASCII quote characters GRAVE ACCENT (\\=`, \\=\\x60) and |
| 1024 | and in functions like `message' and `format-message'. It is not done | 1025 | APOSTROPHE (\\=', \\=\\x27). This is done in help output and in functions |
| 1025 | in `format'. | 1026 | like `message' and `format-message'. It is not done in `format'. |
| 1026 | 1027 | ||
| 1027 | `curve' means quote with curved single quotes ‘like this’. | 1028 | The 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\\='; | 1030 | displayable, and like nil otherwise. `curve' means quote with curved |
| 1030 | i.e., do not alter quote marks. The default value nil acts like | 1031 | single 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 |
| 1032 | otherwise. */); | 1033 | now 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 | ||
| 1036 | meant 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); |