aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2015-08-24 23:37:18 -0700
committerPaul Eggert2015-08-24 23:57:21 -0700
commit68280c5ee9b87d874ffa7c111b3cac7e634cee22 (patch)
tree955f3f692c7254074cac682c4e7e64b6f1361a35 /src
parent0db4992d2778a2da4dee8ca07cde8c5e206f5250 (diff)
downloademacs-68280c5ee9b87d874ffa7c111b3cac7e634cee22.tar.gz
emacs-68280c5ee9b87d874ffa7c111b3cac7e634cee22.zip
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')
-rw-r--r--src/doc.c25
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).
731Each substring of the form \\=\\<MAPVAR> specifies the use of MAPVAR 731Each substring of the form \\=\\<MAPVAR> specifies the use of MAPVAR
732as the keymap for future \\=\\[COMMAND] substrings. 732as the keymap for future \\=\\[COMMAND] substrings.
733 733
734Each \\=‘ and \\=’ are replaced by left and right quote. Each \\=` is 734Each \\=‘ and \\=` is replaced by left quote, and each \\=’ and \\='
735replaced by left quote, and each ' preceded by \\=` and without 735is replaced by right quote. Left and right quote characters are
736intervening ' is replaced by right quote. Left and right quote 736specified by ‘text-quoting-style’.
737characters are specified by ‘text-quoting-style’.
738 737
739\\=\\= quotes the following character and is discarded; thus, 738\\=\\= quotes the following character and is discarded; thus,
740\\=\\=\\=\\= puts \\=\\= into the output, \\=\\=\\=\\[ puts \\=\\[ into the output, and 739\\=\\=\\=\\= puts \\=\\= into the output, \\=\\=\\=\\[ puts \\=\\[ into the output, and
@@ -746,7 +745,6 @@ Otherwise, return a new string. */)
746{ 745{
747 char *buf; 746 char *buf;
748 bool changed = false; 747 bool changed = false;
749 bool in_quote = false;
750 unsigned char *strp; 748 unsigned char *strp;
751 char *bufp; 749 char *bufp;
752 ptrdiff_t idx; 750 ptrdiff_t idx;
@@ -971,11 +969,10 @@ Otherwise, return a new string. */)
971 strp = SDATA (string) + idx; 969 strp = SDATA (string) + idx;
972 } 970 }
973 } 971 }
974 else if (strp[0] == '`' && quoting_style == CURVE_QUOTING_STYLE) 972 else if ((strp[0] == '`' || strp[0] == '\'')
973 && quoting_style == CURVE_QUOTING_STYLE)
975 { 974 {
976 in_quote = true; 975 start = strp[0] == '`' ? LSQM : RSQM;
977 start = LSQM;
978 subst_quote:
979 length = 1; 976 length = 1;
980 length_byte = 3; 977 length_byte = 3;
981 idx = strp - SDATA (string) + 1; 978 idx = strp - SDATA (string) + 1;
@@ -988,12 +985,6 @@ Otherwise, return a new string. */)
988 nchars++; 985 nchars++;
989 changed = true; 986 changed = true;
990 } 987 }
991 else if (strp[0] == '\'' && in_quote)
992 {
993 in_quote = false;
994 start = RSQM;
995 goto subst_quote;
996 }
997 else if (strp[0] == uLSQM0 && strp[1] == uLSQM1 988 else if (strp[0] == uLSQM0 && strp[1] == uLSQM1
998 && (strp[2] == uLSQM2 || strp[2] == uRSQM2) 989 && (strp[2] == uLSQM2 || strp[2] == uRSQM2)
999 && quoting_style != CURVE_QUOTING_STYLE) 990 && quoting_style != CURVE_QUOTING_STYLE)
@@ -1108,8 +1099,8 @@ syms_of_doc (void)
1108 DEFVAR_LISP ("text-quoting-style", Vtext_quoting_style, 1099 DEFVAR_LISP ("text-quoting-style", Vtext_quoting_style,
1109 doc: /* Style to use for single quotes when generating text. 1100 doc: /* Style to use for single quotes when generating text.
1110‘curve’ means quote with curved single quotes \\=‘like this\\=’. 1101‘curve’ means quote with curved single quotes \\=‘like this\\=’.
1111‘straight’ means quote with straight apostrophes 'like this'. 1102‘straight’ means quote with straight apostrophes \\='like this\\='.
1112‘grave’ means quote with grave accent and apostrophe \\=`like this'. 1103‘grave’ means quote with grave accent and apostrophe \\=`like this\\='.
1113The default value nil acts like ‘curve’ if curved single quotes are 1104The default value nil acts like ‘curve’ if curved single quotes are
1114displayable, and like ‘grave’ otherwise. */); 1105displayable, and like ‘grave’ otherwise. */);
1115 Vtext_quoting_style = Qnil; 1106 Vtext_quoting_style = Qnil;