Mercurial > emacs
changeset 20649:388cedeebb88
(SYNTAX_TABLE_BYTE_TO_CHAR): New macro.
(struct gl_state_s): New field `object'.
(SETUP_SYNTAX_TABLE_FOR_OBJECT): Set it.
Handle non-current buffer properly. Args renamed to all caps.
(SETUP_SYNTAX_TABLE): Set `object'. Args renamed to all caps.
(UPDATE_SYNTAX_TABLE): Use gl_state.object.
(UPDATE_SYNTAX_TABLE_FORWARD, UPDATE_SYNTAX_TABLE_BACKWARD): Likewise.
(SETUP_SYNTAX_TABLE_FOR_OBJECT): Add gl_state.offset
when using the arg FROM. Use BYTE_TO_CHAR.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Fri, 16 Jan 1998 17:52:16 +0000 |
parents | b644667dcd19 |
children | 427fa7757472 |
files | src/syntax.h |
diffstat | 1 files changed, 53 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/src/syntax.h Fri Jan 16 05:36:23 1998 +0000 +++ b/src/syntax.h Fri Jan 16 17:52:16 1998 +0000 @@ -194,27 +194,50 @@ extern char syntax_code_spec[16]; +/* Convert the byte offset BYTEPOS into a character position, + for the object recorded in gl_state with SETUP_SYNTAX_TABLE_FOR_OBJECT. */ + +#define SYNTAX_TABLE_BYTE_TO_CHAR(bytepos) \ + (STRINGP (gl_state.object) \ + ? string_byte_to_char (gl_state.object, (bytepos)) \ + : BUFFERP (gl_state.object) \ + ? buf_bytepos_to_charpos (XBUFFER (gl_state.object), (bytepos)) \ + : NILP (gl_state.object) \ + ? BYTE_TO_CHAR ((bytepos)) \ + : (bytepos)) + /* Make syntax table state (gl_state) good for POS, assuming it is currently good for a position before POS. */ -#define UPDATE_SYNTAX_TABLE_FORWARD(pos) \ - ((pos) >= gl_state.e_property - gl_state.offset \ - ? (update_syntax_table ((pos) + gl_state.offset, 1, 0, Qnil), 1) : 0) +#define UPDATE_SYNTAX_TABLE_FORWARD(pos) \ + ((pos) >= gl_state.e_property - gl_state.offset \ + ? (update_syntax_table ((pos) + gl_state.offset, 1, 0, \ + gl_state.object), \ + 1) \ + : 0) /* Make syntax table state (gl_state) good for POS, assuming it is currently good for a position after POS. */ -#define UPDATE_SYNTAX_TABLE_BACKWARD(pos) \ - ((pos) <= gl_state.b_property - gl_state.offset \ - ? (update_syntax_table ((pos) + gl_state.offset, -1, 0, Qnil), 1) : 0) +#define UPDATE_SYNTAX_TABLE_BACKWARD(pos) \ + ((pos) <= gl_state.b_property - gl_state.offset \ + ? (update_syntax_table ((pos) + gl_state.offset, -1, 0, \ + gl_state.object), \ + 1) \ + : 0) /* Make syntax table good for POS. */ -#define UPDATE_SYNTAX_TABLE(pos) \ - ((pos) <= gl_state.b_property - gl_state.offset \ - ? (update_syntax_table ((pos) + gl_state.offset, -1, 0, Qnil), 1) \ - : ((pos) >= gl_state.e_property - gl_state.offset \ - ? (update_syntax_table ((pos) + gl_state.offset, 1, 0, Qnil), 1) : 0)) +#define UPDATE_SYNTAX_TABLE(pos) \ + ((pos) <= gl_state.b_property - gl_state.offset \ + ? (update_syntax_table ((pos) + gl_state.offset, -1, 0, \ + gl_state.object), \ + 1) \ + : ((pos) >= gl_state.e_property - gl_state.offset \ + ? (update_syntax_table ((pos) + gl_state.offset, 1, 0, \ + gl_state.object), \ + 1) \ + : 0)) /* This macro should be called with FROM at the start of forward search, or after the last position of the backward search. It @@ -224,14 +247,15 @@ Sign of COUNT gives the direction of the search. */ -#define SETUP_SYNTAX_TABLE(from,count) \ +#define SETUP_SYNTAX_TABLE(FROM, COUNT) \ gl_state.b_property = BEGV - 1; \ gl_state.e_property = ZV + 1; \ + gl_state.object = Qnil; \ gl_state.use_global = 0; \ gl_state.offset = 0; \ gl_state.current_syntax_table = current_buffer->syntax_table; \ if (parse_sexp_lookup_properties) \ - update_syntax_table ((count) > 0 ? (from) : (from) - 1, (count), \ + update_syntax_table ((COUNT) > 0 ? (FROM) : (FROM) - 1, (COUNT), \ 1, Qnil); /* Same as above, but in OBJECT. If OBJECT is nil, use current buffer. @@ -241,16 +265,24 @@ to the UPDATE_SYNTAX_TABLE macros which are relative to BEGV. So if it is a buffer, we set the offset field to BEGV. */ -#define SETUP_SYNTAX_TABLE_FOR_OBJECT(object, from, count) \ +#define SETUP_SYNTAX_TABLE_FOR_OBJECT(OBJECT, FROM, COUNT) \ if (1) \ { \ - if (BUFFERP (object) || NILP (object)) \ + gl_state.object = (OBJECT); \ + if (BUFFERP (gl_state.object)) \ + { \ + struct buffer *buf = XBUFFER (gl_state.object); \ + gl_state.b_property = BUF_BEGV (buf) - 1; \ + gl_state.e_property = BUF_ZV (buf); \ + gl_state.offset = BUF_BEGV (buf) - 1; \ + } \ + else if (NILP (gl_state.object)) \ { \ gl_state.b_property = BEGV - 1; \ gl_state.e_property = ZV; \ gl_state.offset = BEGV - 1; \ } \ - else if (EQ (object, Qt)) \ + else if (EQ (gl_state.object, Qt)) \ { \ gl_state.b_property = - 1; \ gl_state.e_property = 1500000000; \ @@ -259,20 +291,21 @@ else \ { \ gl_state.b_property = -1; \ - gl_state.e_property = 1 + XSTRING (object)->size; \ + gl_state.e_property = 1 + XSTRING (gl_state.object)->size; \ gl_state.offset = 0; \ } \ gl_state.use_global = 0; \ gl_state.current_syntax_table = current_buffer->syntax_table; \ if (parse_sexp_lookup_properties) \ - update_syntax_table ((bytepos_to_charpos (from) \ - + (count > 0 ? 0 : -1)), \ - count, 1, object); \ + update_syntax_table ((BYTE_TO_CHAR ((FROM) + gl_state.offset) \ + + (COUNT > 0 ? 0 : -1)), \ + COUNT, 1, gl_state.object); \ } \ else struct gl_state_s { + Lisp_Object object; /* The object we are scanning. */ int start; /* Where to stop. */ int stop; /* Where to stop. */ int use_global; /* Whether to use global_code