aboutsummaryrefslogtreecommitdiffstats
path: root/src/syntax.c
diff options
context:
space:
mode:
authorKenichi Handa2000-02-23 00:10:34 +0000
committerKenichi Handa2000-02-23 00:10:34 +0000
commitbd25db0802f127d32b50f37e207faa3893287234 (patch)
treeadcf2fcb6bd447340d865e61dbb29a3da071344b /src/syntax.c
parentb021ef186f6062705a29ae8e3840ad32db451811 (diff)
downloademacs-bd25db0802f127d32b50f37e207faa3893287234.tar.gz
emacs-bd25db0802f127d32b50f37e207faa3893287234.zip
(multibyte_syntax_as_symbol): New variable.
(syms_of_syntax): Declare it as a Lisp variable. (SYNTAX_WITH_MULTIBYTE_CHECK): New macro. (scan_lists): If both sexpflag and multibyte_syntax_as_symbol are nonzero, treat all multibyte characters as symbol. (init_syntax_once): Give syntax `word' to all mutlbiyte characters.
Diffstat (limited to 'src/syntax.c')
-rw-r--r--src/syntax.c41
1 files changed, 32 insertions, 9 deletions
diff --git a/src/syntax.c b/src/syntax.c
index c7e60ce1894..167e20ebed5 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -45,6 +45,9 @@ Lisp_Object Qsyntax_table_p, Qsyntax_table, Qscan_error;
45int words_include_escapes; 45int words_include_escapes;
46int parse_sexp_lookup_properties; 46int parse_sexp_lookup_properties;
47 47
48/* Nonzero means `scan-sexps' treat all multibyte characters as symbol. */
49int multibyte_syntax_as_symbol;
50
48/* Used as a temporary in SYNTAX_ENTRY and other macros in syntax.h, 51/* Used as a temporary in SYNTAX_ENTRY and other macros in syntax.h,
49 if not compiled with GCC. No need to mark it, since it is used 52 if not compiled with GCC. No need to mark it, since it is used
50 only very temporarily. */ 53 only very temporarily. */
@@ -1942,6 +1945,13 @@ between them, return t; otherwise return nil.")
1942 return Qt; 1945 return Qt;
1943} 1946}
1944 1947
1948/* Return syntax code of character C if C is a single byte character
1949 or `multibyte_symbol_p' is zero. Otherwise, retrun Ssymbol. */
1950
1951#define SYNTAX_WITH_MULTIBYTE_CHECK(c) \
1952 ((SINGLE_BYTE_CHAR_P (c) || !multibyte_symbol_p) \
1953 ? SYNTAX (c) : Ssymbol)
1954
1945static Lisp_Object 1955static Lisp_Object
1946scan_lists (from, count, depth, sexpflag) 1956scan_lists (from, count, depth, sexpflag)
1947 register int from; 1957 register int from;
@@ -1963,6 +1973,7 @@ scan_lists (from, count, depth, sexpflag)
1963 int from_byte; 1973 int from_byte;
1964 int out_bytepos, out_charpos; 1974 int out_bytepos, out_charpos;
1965 int temp, dummy; 1975 int temp, dummy;
1976 int multibyte_symbol_p = sexpflag && multibyte_syntax_as_symbol;
1966 1977
1967 if (depth > 0) min_depth = 0; 1978 if (depth > 0) min_depth = 0;
1968 1979
@@ -1982,7 +1993,7 @@ scan_lists (from, count, depth, sexpflag)
1982 int comstart_first, prefix; 1993 int comstart_first, prefix;
1983 UPDATE_SYNTAX_TABLE_FORWARD (from); 1994 UPDATE_SYNTAX_TABLE_FORWARD (from);
1984 c = FETCH_CHAR (from_byte); 1995 c = FETCH_CHAR (from_byte);
1985 code = SYNTAX (c); 1996 code = SYNTAX_WITH_MULTIBYTE_CHECK (c);
1986 comstart_first = SYNTAX_COMSTART_FIRST (c); 1997 comstart_first = SYNTAX_COMSTART_FIRST (c);
1987 comnested = SYNTAX_COMMENT_NESTED (c); 1998 comnested = SYNTAX_COMMENT_NESTED (c);
1988 prefix = SYNTAX_PREFIX (c); 1999 prefix = SYNTAX_PREFIX (c);
@@ -2026,7 +2037,8 @@ scan_lists (from, count, depth, sexpflag)
2026 UPDATE_SYNTAX_TABLE_FORWARD (from); 2037 UPDATE_SYNTAX_TABLE_FORWARD (from);
2027 2038
2028 /* Some compilers can't handle this inside the switch. */ 2039 /* Some compilers can't handle this inside the switch. */
2029 temp = SYNTAX (FETCH_CHAR (from_byte)); 2040 c = FETCH_CHAR (from_byte);
2041 temp = SYNTAX_WITH_MULTIBYTE_CHECK (c);
2030 switch (temp) 2042 switch (temp)
2031 { 2043 {
2032 case Scharquote: 2044 case Scharquote:
@@ -2101,13 +2113,14 @@ scan_lists (from, count, depth, sexpflag)
2101 { 2113 {
2102 if (from >= stop) goto lose; 2114 if (from >= stop) goto lose;
2103 UPDATE_SYNTAX_TABLE_FORWARD (from); 2115 UPDATE_SYNTAX_TABLE_FORWARD (from);
2116 c = FETCH_CHAR (from_byte);
2104 if (code == Sstring 2117 if (code == Sstring
2105 ? (FETCH_CHAR (from_byte) == stringterm) 2118 ? c == stringterm
2106 : SYNTAX (FETCH_CHAR (from_byte)) == Sstring_fence) 2119 : SYNTAX_WITH_MULTIBYTE_CHECK (c) == Sstring_fence)
2107 break; 2120 break;
2108 2121
2109 /* Some compilers can't handle this inside the switch. */ 2122 /* Some compilers can't handle this inside the switch. */
2110 temp = SYNTAX (FETCH_CHAR (from_byte)); 2123 temp = SYNTAX_WITH_MULTIBYTE_CHECK (c);
2111 switch (temp) 2124 switch (temp)
2112 { 2125 {
2113 case Scharquote: 2126 case Scharquote:
@@ -2140,7 +2153,7 @@ scan_lists (from, count, depth, sexpflag)
2140 DEC_BOTH (from, from_byte); 2153 DEC_BOTH (from, from_byte);
2141 UPDATE_SYNTAX_TABLE_BACKWARD (from); 2154 UPDATE_SYNTAX_TABLE_BACKWARD (from);
2142 c = FETCH_CHAR (from_byte); 2155 c = FETCH_CHAR (from_byte);
2143 code = SYNTAX (c); 2156 code = SYNTAX_WITH_MULTIBYTE_CHECK (c);
2144 if (depth == min_depth) 2157 if (depth == min_depth)
2145 last_good = from; 2158 last_good = from;
2146 comstyle = 0; 2159 comstyle = 0;
@@ -2188,7 +2201,7 @@ scan_lists (from, count, depth, sexpflag)
2188 temp_pos--; 2201 temp_pos--;
2189 UPDATE_SYNTAX_TABLE_BACKWARD (from - 1); 2202 UPDATE_SYNTAX_TABLE_BACKWARD (from - 1);
2190 c1 = FETCH_CHAR (temp_pos); 2203 c1 = FETCH_CHAR (temp_pos);
2191 temp_code = SYNTAX (c1); 2204 temp_code = SYNTAX_WITH_MULTIBYTE_CHECK (c1);
2192 /* Don't allow comment-end to be quoted. */ 2205 /* Don't allow comment-end to be quoted. */
2193 if (temp_code == Sendcomment) 2206 if (temp_code == Sendcomment)
2194 goto done2; 2207 goto done2;
@@ -2200,7 +2213,7 @@ scan_lists (from, count, depth, sexpflag)
2200 UPDATE_SYNTAX_TABLE_BACKWARD (from - 1); 2213 UPDATE_SYNTAX_TABLE_BACKWARD (from - 1);
2201 } 2214 }
2202 c1 = FETCH_CHAR (temp_pos); 2215 c1 = FETCH_CHAR (temp_pos);
2203 temp_code = SYNTAX (c1); 2216 temp_code = SYNTAX_WITH_MULTIBYTE_CHECK (c1);
2204 if (! (quoted || temp_code == Sword 2217 if (! (quoted || temp_code == Sword
2205 || temp_code == Ssymbol 2218 || temp_code == Ssymbol
2206 || temp_code == Squote)) 2219 || temp_code == Squote))
@@ -2260,7 +2273,8 @@ scan_lists (from, count, depth, sexpflag)
2260 if (from == stop) goto lose; 2273 if (from == stop) goto lose;
2261 UPDATE_SYNTAX_TABLE_BACKWARD (from); 2274 UPDATE_SYNTAX_TABLE_BACKWARD (from);
2262 if (!char_quoted (from, from_byte) 2275 if (!char_quoted (from, from_byte)
2263 && SYNTAX (FETCH_CHAR (from_byte)) == code) 2276 && (c = FETCH_CHAR (from_byte),
2277 SYNTAX_WITH_MULTIBYTE_CHECK (c) == code))
2264 break; 2278 break;
2265 } 2279 }
2266 if (code == Sstring_fence && !depth && sexpflag) goto done2; 2280 if (code == Sstring_fence && !depth && sexpflag) goto done2;
@@ -2909,6 +2923,11 @@ init_syntax_once ()
2909 c = ".,;:?!#@~^'`"[i]; 2923 c = ".,;:?!#@~^'`"[i];
2910 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, c, temp); 2924 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, c, temp);
2911 } 2925 }
2926
2927 /* All multibyte characters have syntax `word' by default. */
2928 temp = XVECTOR (Vsyntax_code_object)->contents[(int) Sword];
2929 for (i = CHAR_TABLE_SINGLE_BYTE_SLOTS; i < CHAR_TABLE_ORDINARY_SLOTS; i++)
2930 XCHAR_TABLE (Vstandard_syntax_table)->contents[i] = temp;
2912} 2931}
2913 2932
2914void 2933void
@@ -2940,6 +2959,10 @@ relevant only for open/close type.");
2940 DEFVAR_BOOL ("words-include-escapes", &words_include_escapes, 2959 DEFVAR_BOOL ("words-include-escapes", &words_include_escapes,
2941 "Non-nil means `forward-word', etc., should treat escape chars part of words."); 2960 "Non-nil means `forward-word', etc., should treat escape chars part of words.");
2942 2961
2962 DEFVAR_BOOL ("multibyte-syntax-as-symbol", &multibyte_syntax_as_symbol,
2963 "Non-nil means `scan-sexps' treats all multibyte characters as symbol.");
2964 multibyte_syntax_as_symbol = 0;
2965
2943 defsubr (&Ssyntax_table_p); 2966 defsubr (&Ssyntax_table_p);
2944 defsubr (&Ssyntax_table); 2967 defsubr (&Ssyntax_table);
2945 defsubr (&Sstandard_syntax_table); 2968 defsubr (&Sstandard_syntax_table);