]> git.eshelyaron.com Git - emacs.git/commitdiff
Make translation of quotes to curly in doc strings optional.
authorAlan Mackenzie <acm@muc.de>
Thu, 18 Jun 2015 21:00:20 +0000 (21:00 +0000)
committerAlan Mackenzie <acm@muc.de>
Thu, 18 Jun 2015 21:08:02 +0000 (21:08 +0000)
src/doc.c (traditional, prefer-unicode): new symbols.
(help-quote-translation): new variable.
(Fsubstitute_command_keys): make translation of quotes dependent on
`help-quote-translation'; also translate curly quotes back to ASCII
ones.

lisp/cus-start.el (top-level): Add a customization entry for
`help-quote-translation'.

lisp/cus-start.el
src/doc.c

index 8740f0756214e6fca3c7fbccc9675effb45829f3..5dd36811436d55d3479e89a0c4b9e7be61f7af87 100644 (file)
@@ -220,7 +220,14 @@ Leaving \"Default\" unchecked is equivalent with specifying a default of
             (visible-bell display boolean)
             (no-redraw-on-reenter display boolean)
 
-            ;; dosfns.c
+            ;; doc.c
+             (help-quote-translation help
+                                     (choice
+                                      (const :tag "No translation" nil)
+                                      (const :tag "Translate curly single quotes to ASCII" traditional)
+                                      (const :tag "Translate ASCII single quotes to curly" prefer-unicode)))
+
+             ;; dosfns.c
             (dos-display-scancodes display boolean)
             (dos-hyper-key keyboard integer)
             (dos-super-key keyboard integer)
index f1ba64359a61a680bcc2c0b9f6ef07e4a0ab8552..6794ec777ae79ba28a5cc2450f95994a3a47f470 100644 (file)
--- a/src/doc.c
+++ b/src/doc.c
@@ -932,7 +932,8 @@ Otherwise, return a new string.  */)
            strp = SDATA (string) + idx;
          }
        }
-      else if (strp[0] == '`')
+      else if ((Vhelp_quote_translation == Qprefer_unicode)
+               && (strp[0] == '`'))
        {
          in_quote = true;
          start = (unsigned char *) "\xE2\x80\x98"; /* ‘ */
@@ -942,12 +943,27 @@ Otherwise, return a new string.  */)
          idx = strp - SDATA (string) + 1;
          goto subst;
        }
-      else if (strp[0] == '\'' && in_quote)
+      else if ((Vhelp_quote_translation == Qprefer_unicode)
+               && (strp[0] == '\'' && in_quote))
        {
          in_quote = false;
          start = (unsigned char *) "\xE2\x80\x99"; /* ’ */
          goto subst_quote;
        }
+
+      else if ((Vhelp_quote_translation == Qtraditional)
+               && (strp[0] == 0xE2)
+               && (strp[1] == 0x80)
+               && ((strp[2] == 0x98)      /* curly opening quote */
+                   || (strp[2] == 0x99))) /* curly closing quote */
+        {
+          start = (strp[2] == 0x98) ? "`" : "'";
+          length = 1;
+          length_byte = 1;
+          idx = strp - SDATA (string) + 3;
+          goto subst;
+        }
+
       else if (! multibyte)            /* just copy other chars */
        *bufp++ = *strp++, nchars++;
       else
@@ -977,6 +993,8 @@ void
 syms_of_doc (void)
 {
   DEFSYM (Qfunction_documentation, "function-documentation");
+  DEFSYM (Qtraditional, "traditional");
+  DEFSYM (Qprefer_unicode, "prefer-unicode");
 
   DEFVAR_LISP ("internal-doc-file-name", Vdoc_file_name,
               doc: /* Name of file containing documentation strings of built-in symbols.  */);
@@ -986,6 +1004,18 @@ 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: /* How to translate quotes for display in *Help*.
+If the value is nil (default), no translation is done.
+If it's the symbol `traditional', any occurrences of the curly quotes
+are translated to their ASCII "equivalents", GRAVE and APOSTROPHE.
+If it's the symbol `prefer-unicode', any matched pairs of GRAVE and
+APOSTROPHE will get translated into the "equivalent" curly quotes.
+
+Note that any translation done is done in a fresh copy of the doc
+string, and doesn't overwrite the original characters. */);
+  Vhelp_quote_translation = Qnil;
+
   defsubr (&Sdocumentation);
   defsubr (&Sdocumentation_property);
   defsubr (&Ssnarf_documentation);