diff options
| author | Kenichi Handa | 2002-08-01 12:33:55 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2002-08-01 12:33:55 +0000 |
| commit | 869bb2372a8b46eb10f9d8b3b956386146773c9e (patch) | |
| tree | da4522dceb004a04fb9ba199a569fcd46dacbb41 /src | |
| parent | 6ab1fb6a7819c4efe8f3e43f3fa7fcd1423b3aab (diff) | |
| download | emacs-869bb2372a8b46eb10f9d8b3b956386146773c9e.tar.gz emacs-869bb2372a8b46eb10f9d8b3b956386146773c9e.zip | |
(Vnext_word_boundary_function_table): New variable.
(syms_of_syntax): Declare it as a Lisp variable.
(scan_words): Call functions in Vnext_word_boundary_function_table
if any.
Diffstat (limited to 'src')
| -rw-r--r-- | src/syntax.c | 95 |
1 files changed, 70 insertions, 25 deletions
diff --git a/src/syntax.c b/src/syntax.c index ef9e9defcfc..ba86b91fc03 100644 --- a/src/syntax.c +++ b/src/syntax.c | |||
| @@ -1162,6 +1162,8 @@ DEFUN ("internal-describe-syntax-value", Finternal_describe_syntax_value, | |||
| 1162 | 1162 | ||
| 1163 | int parse_sexp_ignore_comments; | 1163 | int parse_sexp_ignore_comments; |
| 1164 | 1164 | ||
| 1165 | Lisp_Object Vnext_word_boundary_function_table; | ||
| 1166 | |||
| 1165 | /* Return the position across COUNT words from FROM. | 1167 | /* Return the position across COUNT words from FROM. |
| 1166 | If that many words cannot be found before the end of the buffer, return 0. | 1168 | If that many words cannot be found before the end of the buffer, return 0. |
| 1167 | COUNT negative means scan backward and stop at word beginning. */ | 1169 | COUNT negative means scan backward and stop at word beginning. */ |
| @@ -1183,6 +1185,8 @@ scan_words (from, count) | |||
| 1183 | 1185 | ||
| 1184 | while (count > 0) | 1186 | while (count > 0) |
| 1185 | { | 1187 | { |
| 1188 | Lisp_Object func; | ||
| 1189 | |||
| 1186 | while (1) | 1190 | while (1) |
| 1187 | { | 1191 | { |
| 1188 | if (from == end) | 1192 | if (from == end) |
| @@ -1202,23 +1206,36 @@ scan_words (from, count) | |||
| 1202 | } | 1206 | } |
| 1203 | /* Now CH0 is a character which begins a word and FROM is the | 1207 | /* Now CH0 is a character which begins a word and FROM is the |
| 1204 | position of the next character. */ | 1208 | position of the next character. */ |
| 1205 | while (1) | 1209 | func = CHAR_TABLE_REF (Vnext_word_boundary_function_table, ch0); |
| 1210 | if (! NILP (Ffboundp (func))) | ||
| 1206 | { | 1211 | { |
| 1207 | if (from == end) break; | 1212 | Lisp_Object pos; |
| 1208 | UPDATE_SYNTAX_TABLE_FORWARD (from); | 1213 | |
| 1209 | ch1 = FETCH_CHAR (from_byte); | 1214 | pos = call2 (func, make_number (from - 1), make_number (end)); |
| 1210 | code = SYNTAX (ch1); | 1215 | from = XINT (pos); |
| 1211 | if (!(words_include_escapes | 1216 | from_byte = CHAR_TO_BYTE (from); |
| 1212 | && (code == Sescape || code == Scharquote))) | ||
| 1213 | if (code != Sword || WORD_BOUNDARY_P (ch0, ch1)) | ||
| 1214 | break; | ||
| 1215 | INC_BOTH (from, from_byte); | ||
| 1216 | ch0 = ch1; | ||
| 1217 | } | 1217 | } |
| 1218 | else | ||
| 1219 | while (1) | ||
| 1220 | { | ||
| 1221 | if (from == end) break; | ||
| 1222 | UPDATE_SYNTAX_TABLE_FORWARD (from); | ||
| 1223 | ch1 = FETCH_CHAR (from_byte); | ||
| 1224 | code = SYNTAX (ch1); | ||
| 1225 | if (code != Sword | ||
| 1226 | && (! words_include_escapes | ||
| 1227 | || (code != Sescape && code != Scharquote))) | ||
| 1228 | break; | ||
| 1229 | INC_BOTH (from, from_byte); | ||
| 1230 | ch0 = ch1; | ||
| 1231 | } | ||
| 1232 | |||
| 1218 | count--; | 1233 | count--; |
| 1219 | } | 1234 | } |
| 1220 | while (count < 0) | 1235 | while (count < 0) |
| 1221 | { | 1236 | { |
| 1237 | Lisp_Object func; | ||
| 1238 | |||
| 1222 | while (1) | 1239 | while (1) |
| 1223 | { | 1240 | { |
| 1224 | if (from == beg) | 1241 | if (from == beg) |
| @@ -1238,23 +1255,33 @@ scan_words (from, count) | |||
| 1238 | } | 1255 | } |
| 1239 | /* Now CH1 is a character which ends a word and FROM is the | 1256 | /* Now CH1 is a character which ends a word and FROM is the |
| 1240 | position of it. */ | 1257 | position of it. */ |
| 1241 | while (1) | 1258 | func = CHAR_TABLE_REF (Vnext_word_boundary_function_table, ch1); |
| 1259 | if (! NILP (Ffboundp (func))) | ||
| 1242 | { | 1260 | { |
| 1243 | int temp_byte; | 1261 | Lisp_Object pos; |
| 1244 | 1262 | ||
| 1245 | if (from == beg) | 1263 | pos = call2 (func, make_number (from), make_number (beg)); |
| 1246 | break; | 1264 | from = XINT (pos); |
| 1247 | temp_byte = dec_bytepos (from_byte); | 1265 | from_byte = CHAR_TO_BYTE (from); |
| 1248 | UPDATE_SYNTAX_TABLE_BACKWARD (from); | ||
| 1249 | ch0 = FETCH_CHAR (temp_byte); | ||
| 1250 | code = SYNTAX (ch0); | ||
| 1251 | if (!(words_include_escapes | ||
| 1252 | && (code == Sescape || code == Scharquote))) | ||
| 1253 | if (code != Sword || WORD_BOUNDARY_P (ch0, ch1)) | ||
| 1254 | break; | ||
| 1255 | DEC_BOTH (from, from_byte); | ||
| 1256 | ch1 = ch0; | ||
| 1257 | } | 1266 | } |
| 1267 | else | ||
| 1268 | while (1) | ||
| 1269 | { | ||
| 1270 | int temp_byte; | ||
| 1271 | |||
| 1272 | if (from == beg) | ||
| 1273 | break; | ||
| 1274 | temp_byte = dec_bytepos (from_byte); | ||
| 1275 | UPDATE_SYNTAX_TABLE_BACKWARD (from); | ||
| 1276 | ch0 = FETCH_CHAR (temp_byte); | ||
| 1277 | code = SYNTAX (ch0); | ||
| 1278 | if (code != Sword | ||
| 1279 | && (! words_include_escapes | ||
| 1280 | || (code != Sescape && code != Scharquote))) | ||
| 1281 | break; | ||
| 1282 | DEC_BOTH (from, from_byte); | ||
| 1283 | ch1 = ch0; | ||
| 1284 | } | ||
| 1258 | count++; | 1285 | count++; |
| 1259 | } | 1286 | } |
| 1260 | 1287 | ||
| @@ -2984,6 +3011,24 @@ See the info node `(elisp)Syntax Properties' for a description of the | |||
| 2984 | doc: /* Non-nil means an open paren in column 0 denotes the start of a defun. */); | 3011 | doc: /* Non-nil means an open paren in column 0 denotes the start of a defun. */); |
| 2985 | open_paren_in_column_0_is_defun_start = 1; | 3012 | open_paren_in_column_0_is_defun_start = 1; |
| 2986 | 3013 | ||
| 3014 | DEFVAR_LISP ("next-word-boundary-function-table", | ||
| 3015 | &Vnext_word_boundary_function_table, | ||
| 3016 | doc: /* | ||
| 3017 | Char table of functions to search for the next word boundary. | ||
| 3018 | Each function is called with two arguments; POS and LIMIT. | ||
| 3019 | POS and LIMIT are character positions in the current buffer. | ||
| 3020 | |||
| 3021 | If POS is less than LIMIT, POS is at the first character of a word, | ||
| 3022 | and the return value of a function is a position after the last | ||
| 3023 | character of that word. | ||
| 3024 | |||
| 3025 | If POS is not less than LIMIT, POS is at the last character of a word, | ||
| 3026 | and the return value of a function is a position at the first | ||
| 3027 | character of that word. | ||
| 3028 | |||
| 3029 | In both cases, LIMIT bounds the search. */); | ||
| 3030 | Vnext_word_boundary_function_table = Fmake_char_table (Qnil, Qnil); | ||
| 3031 | |||
| 2987 | defsubr (&Ssyntax_table_p); | 3032 | defsubr (&Ssyntax_table_p); |
| 2988 | defsubr (&Ssyntax_table); | 3033 | defsubr (&Ssyntax_table); |
| 2989 | defsubr (&Sstandard_syntax_table); | 3034 | defsubr (&Sstandard_syntax_table); |