diff options
| author | Paul Eggert | 2015-08-17 12:00:54 -0700 |
|---|---|---|
| committer | Paul Eggert | 2015-08-17 12:01:26 -0700 |
| commit | 7f2b98d09d113e0f9b1fffb0524622adfafe3ac4 (patch) | |
| tree | 0bf33b3ebf47f3fcbec56119f043dde60227efcd /src/doc.c | |
| parent | 481859ba71253725f4aed4877b89123e11aaef0c (diff) | |
| download | emacs-7f2b98d09d113e0f9b1fffb0524622adfafe3ac4.tar.gz emacs-7f2b98d09d113e0f9b1fffb0524622adfafe3ac4.zip | |
Curved quotes in --batch diagnostics in non-UTF-8
When run with --batch, check that curved quotes are compatible with
the system locale before outputting them in diagnostics.
Problem reported by Eli Zaretskii in:
http://lists.gnu.org/archive/html/emacs-devel/2015-08/msg00594.html
* lisp/startup.el (command-line): Set internal--text-quoting-flag
after the standard display table is initialized.
* src/doc.c (default_to_grave_quoting_style): New function.
(text_quoting_style): Use it.
(text_quoting_flag): New static var, visible to Lisp as
internal--text-quoting-flag.
* src/emacs.c: Include <wchar.h> if available.
(using_utf8): New function.
(main): Use it to initialize text_quoting_flag.
* src/regex.h (btowc) [WIDE_CHAR_SUPPORT && emacs]:
Don't define, as it's not needed and it clashes with wchar.h.
Diffstat (limited to 'src/doc.c')
| -rw-r--r-- | src/doc.c | 33 |
1 files changed, 22 insertions, 11 deletions
| @@ -688,24 +688,31 @@ the same file name is found in the `doc-directory'. */) | |||
| 688 | static unsigned char const LSQM[] = { uLSQM0, uLSQM1, uLSQM2 }; | 688 | static unsigned char const LSQM[] = { uLSQM0, uLSQM1, uLSQM2 }; |
| 689 | static unsigned char const RSQM[] = { uRSQM0, uRSQM1, uRSQM2 }; | 689 | static unsigned char const RSQM[] = { uRSQM0, uRSQM1, uRSQM2 }; |
| 690 | 690 | ||
| 691 | static bool | ||
| 692 | default_to_grave_quoting_style (void) | ||
| 693 | { | ||
| 694 | if (!text_quoting_flag) | ||
| 695 | return true; | ||
| 696 | if (! DISP_TABLE_P (Vstandard_display_table)) | ||
| 697 | return false; | ||
| 698 | Lisp_Object dv = DISP_CHAR_VECTOR (XCHAR_TABLE (Vstandard_display_table), | ||
| 699 | LEFT_SINGLE_QUOTATION_MARK); | ||
| 700 | return (VECTORP (dv) && ASIZE (dv) == 1 | ||
| 701 | && EQ (AREF (dv, 0), make_number ('`'))); | ||
| 702 | } | ||
| 703 | |||
| 691 | /* Return the current effective text quoting style. */ | 704 | /* Return the current effective text quoting style. */ |
| 692 | enum text_quoting_style | 705 | enum text_quoting_style |
| 693 | text_quoting_style (void) | 706 | text_quoting_style (void) |
| 694 | { | 707 | { |
| 695 | if (EQ (Vtext_quoting_style, Qgrave)) | 708 | if (NILP (Vtext_quoting_style) |
| 709 | ? default_to_grave_quoting_style () | ||
| 710 | : EQ (Vtext_quoting_style, Qgrave)) | ||
| 696 | return GRAVE_QUOTING_STYLE; | 711 | return GRAVE_QUOTING_STYLE; |
| 697 | else if (EQ (Vtext_quoting_style, Qstraight)) | 712 | else if (EQ (Vtext_quoting_style, Qstraight)) |
| 698 | return STRAIGHT_QUOTING_STYLE; | 713 | return STRAIGHT_QUOTING_STYLE; |
| 699 | else if (NILP (Vtext_quoting_style) | 714 | else |
| 700 | && DISP_TABLE_P (Vstandard_display_table)) | 715 | return CURVE_QUOTING_STYLE; |
| 701 | { | ||
| 702 | Lisp_Object dv = DISP_CHAR_VECTOR (XCHAR_TABLE (Vstandard_display_table), | ||
| 703 | LEFT_SINGLE_QUOTATION_MARK); | ||
| 704 | if (VECTORP (dv) && ASIZE (dv) == 1 | ||
| 705 | && EQ (AREF (dv, 0), make_number ('`'))) | ||
| 706 | return GRAVE_QUOTING_STYLE; | ||
| 707 | } | ||
| 708 | return CURVE_QUOTING_STYLE; | ||
| 709 | } | 716 | } |
| 710 | 717 | ||
| 711 | DEFUN ("substitute-command-keys", Fsubstitute_command_keys, | 718 | DEFUN ("substitute-command-keys", Fsubstitute_command_keys, |
| @@ -1045,6 +1052,10 @@ The default value nil acts like ‘curve’ if curved single quotes are | |||
| 1045 | displayable, and like ‘grave’ otherwise. */); | 1052 | displayable, and like ‘grave’ otherwise. */); |
| 1046 | Vtext_quoting_style = Qnil; | 1053 | Vtext_quoting_style = Qnil; |
| 1047 | 1054 | ||
| 1055 | DEFVAR_BOOL ("internal--text-quoting-flag", text_quoting_flag, | ||
| 1056 | doc: /* If nil, a nil ‘text-quoting-style’ is treated as ‘grave’. */); | ||
| 1057 | /* Initialized by ‘main’. */ | ||
| 1058 | |||
| 1048 | defsubr (&Sdocumentation); | 1059 | defsubr (&Sdocumentation); |
| 1049 | defsubr (&Sdocumentation_property); | 1060 | defsubr (&Sdocumentation_property); |
| 1050 | defsubr (&Ssnarf_documentation); | 1061 | defsubr (&Ssnarf_documentation); |