diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/doc.c | 33 | ||||
| -rw-r--r-- | src/emacs.c | 18 | ||||
| -rw-r--r-- | src/regex.h | 4 |
3 files changed, 43 insertions, 12 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); |
diff --git a/src/emacs.c b/src/emacs.c index 80bb70cedeb..1392209f585 100644 --- a/src/emacs.c +++ b/src/emacs.c | |||
| @@ -95,6 +95,10 @@ extern void moncontrol (int mode); | |||
| 95 | #include <locale.h> | 95 | #include <locale.h> |
| 96 | #endif | 96 | #endif |
| 97 | 97 | ||
| 98 | #if HAVE_WCHAR_H | ||
| 99 | # include <wchar.h> | ||
| 100 | #endif | ||
| 101 | |||
| 98 | #ifdef HAVE_SETRLIMIT | 102 | #ifdef HAVE_SETRLIMIT |
| 99 | #include <sys/time.h> | 103 | #include <sys/time.h> |
| 100 | #include <sys/resource.h> | 104 | #include <sys/resource.h> |
| @@ -344,6 +348,19 @@ setlocale (int cat, char const *locale) | |||
| 344 | } | 348 | } |
| 345 | #endif | 349 | #endif |
| 346 | 350 | ||
| 351 | /* True if the current system locale uses UTF-8 encoding. */ | ||
| 352 | static bool | ||
| 353 | using_utf8 (void) | ||
| 354 | { | ||
| 355 | #ifdef HAVE_WCHAR_H | ||
| 356 | wchar_t wc; | ||
| 357 | mbstate_t mbs = { 0 }; | ||
| 358 | return mbrtowc (&wc, "\xc4\x80", 2, &mbs) == 2 && wc == 0x100; | ||
| 359 | #else | ||
| 360 | return false; | ||
| 361 | #endif | ||
| 362 | } | ||
| 363 | |||
| 347 | 364 | ||
| 348 | /* Report a fatal error due to signal SIG, output a backtrace of at | 365 | /* Report a fatal error due to signal SIG, output a backtrace of at |
| 349 | most BACKTRACE_LIMIT lines, and exit. */ | 366 | most BACKTRACE_LIMIT lines, and exit. */ |
| @@ -924,6 +941,7 @@ main (int argc, char **argv) | |||
| 924 | fixup_locale must wait until later, since it builds strings. */ | 941 | fixup_locale must wait until later, since it builds strings. */ |
| 925 | if (do_initial_setlocale) | 942 | if (do_initial_setlocale) |
| 926 | setlocale (LC_ALL, ""); | 943 | setlocale (LC_ALL, ""); |
| 944 | text_quoting_flag = using_utf8 (); | ||
| 927 | 945 | ||
| 928 | inhibit_window_system = 0; | 946 | inhibit_window_system = 0; |
| 929 | 947 | ||
diff --git a/src/regex.h b/src/regex.h index 3dfecf0a7e5..c89ca46d4bd 100644 --- a/src/regex.h +++ b/src/regex.h | |||
| @@ -603,7 +603,9 @@ typedef wchar_t re_wchar_t; | |||
| 603 | # define re_wctype_to_bit(cc) 0 | 603 | # define re_wctype_to_bit(cc) 0 |
| 604 | #else | 604 | #else |
| 605 | # define CHAR_CLASS_MAX_LENGTH 9 /* Namely, `multibyte'. */ | 605 | # define CHAR_CLASS_MAX_LENGTH 9 /* Namely, `multibyte'. */ |
| 606 | # define btowc(c) c | 606 | # ifndef emacs |
| 607 | # define btowc(c) c | ||
| 608 | # endif | ||
| 607 | 609 | ||
| 608 | /* Character classes. */ | 610 | /* Character classes. */ |
| 609 | typedef enum { RECC_ERROR = 0, | 611 | typedef enum { RECC_ERROR = 0, |