From fa10e77790a207aeabf354c9f5667b3dbde55bb2 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 2 Aug 2015 15:58:02 -0700 Subject: [PATCH] Redo text-quoting-style variable Rename help-quote-translation to text-quoting-style, and use symbols rather than characters as values. This follows suggestions along these lines by Alan Mackenzie in: http://lists.gnu.org/archive/html/emacs-devel/2015-06/msg00343.html and by Drew Adams in: http://lists.gnu.org/archive/html/emacs-devel/2015-08/msg00048.html * doc/lispref/help.texi (Keys in Documentation) * etc/NEWS: * lisp/cus-start.el (standard): * src/doc.c (Fsubstitute_command_keys, syms_of_doc): Document and/or implement the new behavior instead of the old. (syms_of_doc): New symbols 'grave' and 'straight'. --- doc/lispref/help.texi | 16 ++++++++-------- etc/NEWS | 20 ++++++++++---------- lisp/cus-start.el | 18 ++++++++++-------- src/doc.c | 27 ++++++++++++++------------- 4 files changed, 42 insertions(+), 39 deletions(-) diff --git a/doc/lispref/help.texi b/doc/lispref/help.texi index 779a0d581e2..ca8ae3f314a 100644 --- a/doc/lispref/help.texi +++ b/doc/lispref/help.texi @@ -347,18 +347,18 @@ and @samp{\=\=} puts @samp{\=} into the output. @strong{Please note:} Each @samp{\} must be doubled when written in a string in Emacs Lisp. -@defvar help-quote-translation +@defvar text-quoting-style @cindex curved quotes @cindex curly quotes The value of this variable specifies the style @code{substitute-command-keys} uses when generating left and right -quotes. If the variable's value is @code{?‘} (U+2018 LEFT SINGLE -QUOTATION MARK), the style is @t{‘like this’} with curved single -quotes. If the value is @code{?'} (apostrophe), the style is @t{'like -this'} with apostrophes. If the value is @code{?`} (grave accent), -the style is @t{`like this'} with grave accent and apostrophe. The -default value @code{nil} means to use curved single quotes if -displayable, and grave accent and apostrophe otherwise. +quotes. If the variable's value is @code{curve}, the style is +@t{‘like this’} with curved single quotes. If the value is +@code{straight}, the style is @t{'like this'} with straight +apostrophes. If the value is @code{grave}, the style is @t{`like +this'} with grave accent and apostrophe. The default value @code{nil} +acts like @code{curve} if curved single quotes are displayable, and +like @code{grave} otherwise. @end defvar @defun substitute-command-keys string diff --git a/etc/NEWS b/etc/NEWS index 85df71607ee..e384d17e395 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -889,14 +889,14 @@ in languages like German where downcasing rules depend on grammar. +++ ** substitute-command-keys now replaces quotes. That is, it converts documentation strings' quoting style as per the -value of the new custom variable ‘help-quote-translation’: ?‘ means -use curved quotes (also known as curly quotes) ‘like this’, ?' means -use apostrophes 'like this', ?` means use grave accent and apostrophe -`like this', and nil (default) means use curved quotes if displayable -and grave accent and apostrophe otherwise. Doc strings in source code -can use either curved quotes or grave accent and apostrophe. As -before, isolated apostrophes and characters preceded by \= are output -as-is. +value of the new custom variable ‘text-quoting-style’: ‘curve’ means +use curved quotes (also known as curly quotes) ‘like this’, ‘straight’ +means use straight apostrophes 'like this', ‘grave’ means use grave +accent and apostrophe `like this', and nil (default) means use curved +quotes if displayable and grave accent and apostrophe otherwise. Doc +strings in source code can use either curved quotes or grave accent +and apostrophe. As before, isolated apostrophes and characters +preceded by \= are output as-is. +++ ** The character classes [:alpha:] and [:alnum:] in regular expressions @@ -1017,8 +1017,8 @@ In the new Electric Quote mode, you can enter curved single quotes into documentation by typing ` and '. Outside Electric Quote mode, you can enter them by typing ‘C-x 8 [’ and ‘C-x 8 ]’, or (if your Alt key works) by typing ‘A-[’ and ‘A-]’. As described above under -‘help-quote-translation’, the user can specify how to display doc -string quotes. +‘text-quoting-style’, the user can specify how to display doc string +quotes. +++ ** show-help-function's arg is converted via substitute-command-keys diff --git a/lisp/cus-start.el b/lisp/cus-start.el index 69dbf0d0c57..7a37198fb2c 100644 --- a/lisp/cus-start.el +++ b/lisp/cus-start.el @@ -221,14 +221,16 @@ Leaving \"Default\" unchecked is equivalent with specifying a default of (no-redraw-on-reenter display boolean) ;; doc.c - (help-quote-translation help - (choice - (character :tag "Quote with curved quotes" - :value ?‘) - (character :tag "Quote 'like this'" :value ?\') - (character :tag "Quote `like this'" :value ?\`) - (const :tag "Quote with curved quotes if displayable, 'like this' otherwise" nil)) - "25.1") + (text-quoting-style + help + (choice + (const :tag "Quote with curved single quotes" curve) + (const :tag "Quote with straight apostrophes 'like this'" + straight) + (const :tag "Quote with grave accent and apostrophe `like this'" + grave) + (const :tag "Use curved quotes if displayable, grave accent and apostrophe otherwise" nil)) + "25.1") ;; dosfns.c (dos-display-scancodes display boolean) (dos-hyper-key keyboard integer) diff --git a/src/doc.c b/src/doc.c index 78a7815aade..36619e1142e 100644 --- a/src/doc.c +++ b/src/doc.c @@ -715,7 +715,7 @@ as the keymap for future \\=\\[COMMAND] substrings. Each \\=‘ and \\=’ are replaced by left and right quote. Each \\=` is replaced by left quote, and each ' preceded by \\=` and without intervening ' is replaced by right quote. Left and right quote -characters are specified by ‘help-quote-translation’. +characters are specified by ‘text-quoting-style’. \\=\\= quotes the following character and is discarded; thus, \\=\\=\\=\\= puts \\=\\= into the output, \\=\\=\\=\\[ puts \\=\\[ into the output, and @@ -751,11 +751,11 @@ Otherwise, return a new string. */) GCPRO4 (string, tem, keymap, name); enum { unicode, grave_accent, apostrophe } quote_translation = unicode; - if (EQ (Vhelp_quote_translation, make_number ('`'))) + if (EQ (Vtext_quoting_style, Qgrave)) quote_translation = grave_accent; - else if (EQ (Vhelp_quote_translation, make_number ('\''))) + else if (EQ (Vtext_quoting_style, Qstraight)) quote_translation = apostrophe; - else if (NILP (Vhelp_quote_translation) + else if (NILP (Vtext_quoting_style) && DISP_TABLE_P (Vstandard_display_table)) { Lisp_Object dv = DISP_CHAR_VECTOR (XCHAR_TABLE (Vstandard_display_table), @@ -1024,6 +1024,8 @@ void syms_of_doc (void) { DEFSYM (Qfunction_documentation, "function-documentation"); + DEFSYM (Qgrave, "grave"); + DEFSYM (Qstraight, "straight"); DEFVAR_LISP ("internal-doc-file-name", Vdoc_file_name, doc: /* Name of file containing documentation strings of built-in symbols. */); @@ -1033,15 +1035,14 @@ syms_of_doc (void) doc: /* A list of files used to build this Emacs binary. */); Vbuild_files = Qnil; - DEFVAR_LISP ("help-quote-translation", Vhelp_quote_translation, - doc: /* Style to use for single quotes in help. -The value is a left single quote character of some style. -Quote \\=‘like this\\=’ if the value is ?\\=‘ (left single quotation mark). -Quote 'like this' if the value is ?' (apostrophe). -Quote \\=`like this' if the value is ?\\=` (grave accent). -The default value is nil, which means quote with left single quotation mark -if displayable, and with grave accent otherwise. */); - Vhelp_quote_translation = Qnil; + DEFVAR_LISP ("text-quoting-style", Vtext_quoting_style, + doc: /* Style to use for single quotes when generating text. +‘curve’ means quote with curved single quotes \\=‘like this\\=’. +‘straight’ means quote with straight apostrophes 'like this'. +‘grave’ means quote with grave accent and apostrophe \\=`like this'. +The default value nil acts like ‘curve’ if curved single quotes are +displayable, and like ‘grave’ otherwise. */); + Vtext_quoting_style = Qnil; defsubr (&Sdocumentation); defsubr (&Sdocumentation_property); -- 2.39.2