diff options
| author | Alan Mackenzie | 2015-06-18 21:00:20 +0000 |
|---|---|---|
| committer | Alan Mackenzie | 2015-06-18 21:08:02 +0000 |
| commit | 52c3946c872c8bd96508f74cdda5cbb90c664306 (patch) | |
| tree | 30c756647f4acea5c8c6d52fe59e9f49778f7541 /src | |
| parent | 711e14ddad7fb1e80a86c79e37a957929e8c01a3 (diff) | |
| download | emacs-52c3946c872c8bd96508f74cdda5cbb90c664306.tar.gz emacs-52c3946c872c8bd96508f74cdda5cbb90c664306.zip | |
Make translation of quotes to curly in doc strings optional.
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'.
Diffstat (limited to 'src')
| -rw-r--r-- | src/doc.c | 34 |
1 files changed, 32 insertions, 2 deletions
| @@ -932,7 +932,8 @@ Otherwise, return a new string. */) | |||
| 932 | strp = SDATA (string) + idx; | 932 | strp = SDATA (string) + idx; |
| 933 | } | 933 | } |
| 934 | } | 934 | } |
| 935 | else if (strp[0] == '`') | 935 | else if ((Vhelp_quote_translation == Qprefer_unicode) |
| 936 | && (strp[0] == '`')) | ||
| 936 | { | 937 | { |
| 937 | in_quote = true; | 938 | in_quote = true; |
| 938 | start = (unsigned char *) "\xE2\x80\x98"; /* ‘ */ | 939 | start = (unsigned char *) "\xE2\x80\x98"; /* ‘ */ |
| @@ -942,12 +943,27 @@ Otherwise, return a new string. */) | |||
| 942 | idx = strp - SDATA (string) + 1; | 943 | idx = strp - SDATA (string) + 1; |
| 943 | goto subst; | 944 | goto subst; |
| 944 | } | 945 | } |
| 945 | else if (strp[0] == '\'' && in_quote) | 946 | else if ((Vhelp_quote_translation == Qprefer_unicode) |
| 947 | && (strp[0] == '\'' && in_quote)) | ||
| 946 | { | 948 | { |
| 947 | in_quote = false; | 949 | in_quote = false; |
| 948 | start = (unsigned char *) "\xE2\x80\x99"; /* ’ */ | 950 | start = (unsigned char *) "\xE2\x80\x99"; /* ’ */ |
| 949 | goto subst_quote; | 951 | goto subst_quote; |
| 950 | } | 952 | } |
| 953 | |||
| 954 | else if ((Vhelp_quote_translation == Qtraditional) | ||
| 955 | && (strp[0] == 0xE2) | ||
| 956 | && (strp[1] == 0x80) | ||
| 957 | && ((strp[2] == 0x98) /* curly opening quote */ | ||
| 958 | || (strp[2] == 0x99))) /* curly closing quote */ | ||
| 959 | { | ||
| 960 | start = (strp[2] == 0x98) ? "`" : "'"; | ||
| 961 | length = 1; | ||
| 962 | length_byte = 1; | ||
| 963 | idx = strp - SDATA (string) + 3; | ||
| 964 | goto subst; | ||
| 965 | } | ||
| 966 | |||
| 951 | else if (! multibyte) /* just copy other chars */ | 967 | else if (! multibyte) /* just copy other chars */ |
| 952 | *bufp++ = *strp++, nchars++; | 968 | *bufp++ = *strp++, nchars++; |
| 953 | else | 969 | else |
| @@ -977,6 +993,8 @@ void | |||
| 977 | syms_of_doc (void) | 993 | syms_of_doc (void) |
| 978 | { | 994 | { |
| 979 | DEFSYM (Qfunction_documentation, "function-documentation"); | 995 | DEFSYM (Qfunction_documentation, "function-documentation"); |
| 996 | DEFSYM (Qtraditional, "traditional"); | ||
| 997 | DEFSYM (Qprefer_unicode, "prefer-unicode"); | ||
| 980 | 998 | ||
| 981 | DEFVAR_LISP ("internal-doc-file-name", Vdoc_file_name, | 999 | DEFVAR_LISP ("internal-doc-file-name", Vdoc_file_name, |
| 982 | doc: /* Name of file containing documentation strings of built-in symbols. */); | 1000 | doc: /* Name of file containing documentation strings of built-in symbols. */); |
| @@ -986,6 +1004,18 @@ syms_of_doc (void) | |||
| 986 | doc: /* A list of files used to build this Emacs binary. */); | 1004 | doc: /* A list of files used to build this Emacs binary. */); |
| 987 | Vbuild_files = Qnil; | 1005 | Vbuild_files = Qnil; |
| 988 | 1006 | ||
| 1007 | DEFVAR_LISP ("help-quote-translation", Vhelp_quote_translation, | ||
| 1008 | doc: /* How to translate quotes for display in *Help*. | ||
| 1009 | If the value is nil (default), no translation is done. | ||
| 1010 | If it's the symbol `traditional', any occurrences of the curly quotes | ||
| 1011 | are translated to their ASCII "equivalents", GRAVE and APOSTROPHE. | ||
| 1012 | If it's the symbol `prefer-unicode', any matched pairs of GRAVE and | ||
| 1013 | APOSTROPHE will get translated into the "equivalent" curly quotes. | ||
| 1014 | |||
| 1015 | Note that any translation done is done in a fresh copy of the doc | ||
| 1016 | string, and doesn't overwrite the original characters. */); | ||
| 1017 | Vhelp_quote_translation = Qnil; | ||
| 1018 | |||
| 989 | defsubr (&Sdocumentation); | 1019 | defsubr (&Sdocumentation); |
| 990 | defsubr (&Sdocumentation_property); | 1020 | defsubr (&Sdocumentation_property); |
| 991 | defsubr (&Ssnarf_documentation); | 1021 | defsubr (&Ssnarf_documentation); |