Mercurial > emacs
comparison src/syntax.c @ 107366:14ff9accfbd3
Cleanup setup of gl_state in various parts of the code.
* syntax.h (SETUP_BUFFER_SYNTAX_TABLE): New macro.
(SETUP_SYNTAX_TABLE, SETUP_SYNTAX_TABLE_FOR_OBJECT):
* syntax.c (find_defun_start, Fchar_syntax, Fmatching_paren, skip_chars):
* regex.c (regex_compile): Use it.
(re_compile_pattern): Don't set gl_state.current_syntax_table since
it's now set in regex_compile when/if we need it.
| author | Stefan Monnier <monnier@iro.umontreal.ca> |
|---|---|
| date | Wed, 10 Mar 2010 09:45:21 -0500 |
| parents | 230cb6c59526 |
| children | ea6ba19c6edd |
comparison
equal
deleted
inserted
replaced
| 107365:cdbf4c64ae3c | 107366:14ff9accfbd3 |
|---|---|
| 383 scan_newline (pos, pos_byte, BEGV, BEGV_BYTE, -1, 1); | 383 scan_newline (pos, pos_byte, BEGV, BEGV_BYTE, -1, 1); |
| 384 | 384 |
| 385 /* We optimize syntax-table lookup for rare updates. Thus we accept | 385 /* We optimize syntax-table lookup for rare updates. Thus we accept |
| 386 only those `^\s(' which are good in global _and_ text-property | 386 only those `^\s(' which are good in global _and_ text-property |
| 387 syntax-tables. */ | 387 syntax-tables. */ |
| 388 gl_state.current_syntax_table = current_buffer->syntax_table; | 388 SETUP_BUFFER_SYNTAX_TABLE (); |
| 389 gl_state.use_global = 0; | |
| 390 while (PT > BEGV) | 389 while (PT > BEGV) |
| 391 { | 390 { |
| 392 int c; | 391 int c; |
| 393 | 392 |
| 394 /* Open-paren at start of line means we may have found our | 393 /* Open-paren at start of line means we may have found our |
| 399 SETUP_SYNTAX_TABLE (PT + 1, -1); /* Try again... */ | 398 SETUP_SYNTAX_TABLE (PT + 1, -1); /* Try again... */ |
| 400 c = FETCH_CHAR_AS_MULTIBYTE (PT_BYTE); | 399 c = FETCH_CHAR_AS_MULTIBYTE (PT_BYTE); |
| 401 if (SYNTAX (c) == Sopen) | 400 if (SYNTAX (c) == Sopen) |
| 402 break; | 401 break; |
| 403 /* Now fallback to the default value. */ | 402 /* Now fallback to the default value. */ |
| 404 gl_state.current_syntax_table = current_buffer->syntax_table; | 403 SETUP_BUFFER_SYNTAX_TABLE (); |
| 405 gl_state.use_global = 0; | |
| 406 } | 404 } |
| 407 /* Move to beg of previous line. */ | 405 /* Move to beg of previous line. */ |
| 408 scan_newline (PT, PT_BYTE, BEGV, BEGV_BYTE, -2, 1); | 406 scan_newline (PT, PT_BYTE, BEGV, BEGV_BYTE, -2, 1); |
| 409 } | 407 } |
| 410 | 408 |
| 858 are listed in the documentation of `modify-syntax-entry'. */) | 856 are listed in the documentation of `modify-syntax-entry'. */) |
| 859 (character) | 857 (character) |
| 860 Lisp_Object character; | 858 Lisp_Object character; |
| 861 { | 859 { |
| 862 int char_int; | 860 int char_int; |
| 863 gl_state.current_syntax_table = current_buffer->syntax_table; | |
| 864 | |
| 865 gl_state.use_global = 0; | |
| 866 CHECK_NUMBER (character); | 861 CHECK_NUMBER (character); |
| 867 char_int = XINT (character); | 862 char_int = XINT (character); |
| 863 SETUP_BUFFER_SYNTAX_TABLE (); | |
| 868 return make_number (syntax_code_spec[(int) SYNTAX (char_int)]); | 864 return make_number (syntax_code_spec[(int) SYNTAX (char_int)]); |
| 869 } | 865 } |
| 870 | 866 |
| 871 DEFUN ("matching-paren", Fmatching_paren, Smatching_paren, 1, 1, 0, | 867 DEFUN ("matching-paren", Fmatching_paren, Smatching_paren, 1, 1, 0, |
| 872 doc: /* Return the matching parenthesis of CHARACTER, or nil if none. */) | 868 doc: /* Return the matching parenthesis of CHARACTER, or nil if none. */) |
| 873 (character) | 869 (character) |
| 874 Lisp_Object character; | 870 Lisp_Object character; |
| 875 { | 871 { |
| 876 int char_int, code; | 872 int char_int, code; |
| 877 gl_state.current_syntax_table = current_buffer->syntax_table; | |
| 878 gl_state.use_global = 0; | |
| 879 CHECK_NUMBER (character); | 873 CHECK_NUMBER (character); |
| 880 char_int = XINT (character); | 874 char_int = XINT (character); |
| 875 SETUP_BUFFER_SYNTAX_TABLE (); | |
| 881 code = SYNTAX (char_int); | 876 code = SYNTAX (char_int); |
| 882 if (code == Sopen || code == Sclose) | 877 if (code == Sopen || code == Sclose) |
| 883 return SYNTAX_MATCH (char_int); | 878 return SYNTAX_MATCH (char_int); |
| 884 return Qnil; | 879 return Qnil; |
| 885 } | 880 } |
| 1750 /* This code may look up syntax tables using macros that rely on the | 1745 /* This code may look up syntax tables using macros that rely on the |
| 1751 gl_state object. To make sure this object is not out of date, | 1746 gl_state object. To make sure this object is not out of date, |
| 1752 let's initialize it manually. | 1747 let's initialize it manually. |
| 1753 We ignore syntax-table text-properties for now, since that's | 1748 We ignore syntax-table text-properties for now, since that's |
| 1754 what we've done in the past. */ | 1749 what we've done in the past. */ |
| 1755 SETUP_SYNTAX_TABLE (BEGV, 0); | 1750 SETUP_BUFFER_SYNTAX_TABLE (); |
| 1756 if (forwardp) | 1751 if (forwardp) |
| 1757 { | 1752 { |
| 1758 if (multibyte) | 1753 if (multibyte) |
| 1759 while (1) | 1754 while (1) |
| 1760 { | 1755 { |
