diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2015-08-24 23:37:18 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2015-08-24 23:57:21 -0700 |
commit | 68280c5ee9b87d874ffa7c111b3cac7e634cee22 (patch) | |
tree | 955f3f692c7254074cac682c4e7e64b6f1361a35 /src/doc.c | |
parent | 0db4992d2778a2da4dee8ca07cde8c5e206f5250 (diff) | |
download | emacs-68280c5ee9b87d874ffa7c111b3cac7e634cee22.tar.gz |
Treat ' like ’ even when not matching `
This is simpler and easier to explain, and should encourage better
typography. Do this in Electric Quote mode and when translating
quotes in docstrings. Inspired by a suggestion by Dmitry Gutov in:
https://lists.gnu.org/archive/html/emacs-devel/2015-08/msg00806.html
* doc/emacs/text.texi (Quotation Marks):
* doc/lispref/help.texi (Keys in Documentation):
* etc/NEWS:
Document this.
* lisp/electric.el (electric-quote-post-self-insert-function):
* src/doc.c (Fsubstitute_command_keys):
Always treat ' like ’ even when not matched by an open quote.
Diffstat (limited to 'src/doc.c')
-rw-r--r-- | src/doc.c | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/src/doc.c b/src/doc.c index 3c8b11d73f3..7a298e28631 100644 --- a/src/doc.c +++ b/src/doc.c @@ -731,10 +731,9 @@ summary). Each substring of the form \\=\\<MAPVAR> specifies the use of MAPVAR 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 ‘text-quoting-style’. +Each \\=‘ and \\=` is replaced by left quote, and each \\=’ and \\=' +is replaced by right quote. Left and right quote characters are +specified by ‘text-quoting-style’. \\=\\= quotes the following character and is discarded; thus, \\=\\=\\=\\= puts \\=\\= into the output, \\=\\=\\=\\[ puts \\=\\[ into the output, and @@ -746,7 +745,6 @@ Otherwise, return a new string. */) { char *buf; bool changed = false; - bool in_quote = false; unsigned char *strp; char *bufp; ptrdiff_t idx; @@ -971,11 +969,10 @@ Otherwise, return a new string. */) strp = SDATA (string) + idx; } } - else if (strp[0] == '`' && quoting_style == CURVE_QUOTING_STYLE) + else if ((strp[0] == '`' || strp[0] == '\'') + && quoting_style == CURVE_QUOTING_STYLE) { - in_quote = true; - start = LSQM; - subst_quote: + start = strp[0] == '`' ? LSQM : RSQM; length = 1; length_byte = 3; idx = strp - SDATA (string) + 1; @@ -988,12 +985,6 @@ Otherwise, return a new string. */) nchars++; changed = true; } - else if (strp[0] == '\'' && in_quote) - { - in_quote = false; - start = RSQM; - goto subst_quote; - } else if (strp[0] == uLSQM0 && strp[1] == uLSQM1 && (strp[2] == uLSQM2 || strp[2] == uRSQM2) && quoting_style != CURVE_QUOTING_STYLE) @@ -1108,8 +1099,8 @@ syms_of_doc (void) 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'. +‘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; |