diff options
| author | Stefan Monnier | 2001-10-12 01:37:54 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2001-10-12 01:37:54 +0000 |
| commit | bb0de0842091e634d493c984fbd553cbad407c7f (patch) | |
| tree | 272be61916fbe667571ce47a7014db109803b12e /src | |
| parent | 4948e1f227daae7d3541a6f1d9cd4d3dd4b4487b (diff) | |
| download | emacs-bb0de0842091e634d493c984fbd553cbad407c7f.tar.gz emacs-bb0de0842091e634d493c984fbd553cbad407c7f.zip | |
(update_syntax_table): Simplify.
(Fforward_comment): Don't skip quoted chars when going backward.
Diffstat (limited to 'src')
| -rw-r--r-- | src/syntax.c | 133 |
1 files changed, 59 insertions, 74 deletions
diff --git a/src/syntax.c b/src/syntax.c index 28ec964f877..6a17e659979 100644 --- a/src/syntax.c +++ b/src/syntax.c | |||
| @@ -134,17 +134,17 @@ update_syntax_table (charpos, count, init, object) | |||
| 134 | 134 | ||
| 135 | if (init) | 135 | if (init) |
| 136 | { | 136 | { |
| 137 | gl_state.old_prop = Qnil; | ||
| 137 | gl_state.start = gl_state.b_property; | 138 | gl_state.start = gl_state.b_property; |
| 138 | gl_state.stop = gl_state.e_property; | 139 | gl_state.stop = gl_state.e_property; |
| 139 | gl_state.forward_i = interval_of (charpos, object); | 140 | i = interval_of (charpos, object); |
| 140 | i = gl_state.backward_i = gl_state.forward_i; | 141 | gl_state.backward_i = gl_state.forward_i = i; |
| 141 | gl_state.left_ok = gl_state.right_ok = 1; | ||
| 142 | invalidate = 0; | 142 | invalidate = 0; |
| 143 | if (NULL_INTERVAL_P (i)) | 143 | if (NULL_INTERVAL_P (i)) |
| 144 | return; | 144 | return; |
| 145 | /* interval_of updates only ->position of the return value, so | 145 | /* interval_of updates only ->position of the return value, so |
| 146 | update the parents manually to speed up update_interval. */ | 146 | update the parents manually to speed up update_interval. */ |
| 147 | while (!NULL_PARENT (i)) | 147 | while (!NULL_PARENT (i)) |
| 148 | { | 148 | { |
| 149 | if (AM_RIGHT_CHILD (i)) | 149 | if (AM_RIGHT_CHILD (i)) |
| 150 | INTERVAL_PARENT (i)->position = i->position | 150 | INTERVAL_PARENT (i)->position = i->position |
| @@ -157,7 +157,7 @@ update_syntax_table (charpos, count, init, object) | |||
| 157 | i = INTERVAL_PARENT (i); | 157 | i = INTERVAL_PARENT (i); |
| 158 | } | 158 | } |
| 159 | i = gl_state.forward_i; | 159 | i = gl_state.forward_i; |
| 160 | gl_state.b_property = i->position - 1 - gl_state.offset; | 160 | gl_state.b_property = i->position - gl_state.offset; |
| 161 | gl_state.e_property = INTERVAL_LAST_POS (i) - gl_state.offset; | 161 | gl_state.e_property = INTERVAL_LAST_POS (i) - gl_state.offset; |
| 162 | goto update; | 162 | goto update; |
| 163 | } | 163 | } |
| @@ -173,10 +173,9 @@ update_syntax_table (charpos, count, init, object) | |||
| 173 | error ("Error in syntax_table logic for intervals <-"); | 173 | error ("Error in syntax_table logic for intervals <-"); |
| 174 | /* Update the interval. */ | 174 | /* Update the interval. */ |
| 175 | i = update_interval (i, charpos); | 175 | i = update_interval (i, charpos); |
| 176 | if (!gl_state.left_ok || oldi->position != INTERVAL_LAST_POS (i)) | 176 | if (INTERVAL_LAST_POS (i) != gl_state.b_property) |
| 177 | { | 177 | { |
| 178 | invalidate = 0; | 178 | invalidate = 0; |
| 179 | gl_state.right_ok = 1; /* Invalidate the other end. */ | ||
| 180 | gl_state.forward_i = i; | 179 | gl_state.forward_i = i; |
| 181 | gl_state.e_property = INTERVAL_LAST_POS (i) - gl_state.offset; | 180 | gl_state.e_property = INTERVAL_LAST_POS (i) - gl_state.offset; |
| 182 | } | 181 | } |
| @@ -187,19 +186,13 @@ update_syntax_table (charpos, count, init, object) | |||
| 187 | error ("Error in syntax_table logic for intervals ->"); | 186 | error ("Error in syntax_table logic for intervals ->"); |
| 188 | /* Update the interval. */ | 187 | /* Update the interval. */ |
| 189 | i = update_interval (i, charpos); | 188 | i = update_interval (i, charpos); |
| 190 | if (!gl_state.right_ok || i->position != INTERVAL_LAST_POS (oldi)) | 189 | if (i->position != gl_state.e_property) |
| 191 | { | 190 | { |
| 192 | invalidate = 0; | 191 | invalidate = 0; |
| 193 | gl_state.left_ok = 1; /* Invalidate the other end. */ | ||
| 194 | gl_state.backward_i = i; | 192 | gl_state.backward_i = i; |
| 195 | gl_state.b_property = i->position - 1 - gl_state.offset; | 193 | gl_state.b_property = i->position - gl_state.offset; |
| 196 | } | 194 | } |
| 197 | } | 195 | } |
| 198 | else if (count > 0 ? gl_state.right_ok : gl_state.left_ok) | ||
| 199 | { | ||
| 200 | /* We do not need to recalculate tmp_table. */ | ||
| 201 | tmp_table = gl_state.old_prop; | ||
| 202 | } | ||
| 203 | 196 | ||
| 204 | update: | 197 | update: |
| 205 | tmp_table = textget (i->plist, Qsyntax_table); | 198 | tmp_table = textget (i->plist, Qsyntax_table); |
| @@ -213,32 +206,33 @@ update_syntax_table (charpos, count, init, object) | |||
| 213 | if (count > 0) | 206 | if (count > 0) |
| 214 | { | 207 | { |
| 215 | gl_state.backward_i = i; | 208 | gl_state.backward_i = i; |
| 216 | gl_state.left_ok = 1; /* Invalidate the other end. */ | 209 | gl_state.b_property = i->position - gl_state.offset; |
| 217 | gl_state.b_property = i->position - 1 - gl_state.offset; | 210 | } |
| 218 | } | 211 | else |
| 219 | else | ||
| 220 | { | 212 | { |
| 221 | gl_state.forward_i = i; | 213 | gl_state.forward_i = i; |
| 222 | gl_state.right_ok = 1; /* Invalidate the other end. */ | ||
| 223 | gl_state.e_property = INTERVAL_LAST_POS (i) - gl_state.offset; | 214 | gl_state.e_property = INTERVAL_LAST_POS (i) - gl_state.offset; |
| 224 | } | 215 | } |
| 225 | } | 216 | } |
| 226 | 217 | ||
| 227 | gl_state.current_syntax_table = tmp_table; | 218 | if (!EQ (tmp_table, gl_state.old_prop)) |
| 228 | gl_state.old_prop = tmp_table; | ||
| 229 | if (EQ (Fsyntax_table_p (tmp_table), Qt)) | ||
| 230 | { | ||
| 231 | gl_state.use_global = 0; | ||
| 232 | } | ||
| 233 | else if (CONSP (tmp_table)) | ||
| 234 | { | 219 | { |
| 235 | gl_state.use_global = 1; | 220 | gl_state.current_syntax_table = tmp_table; |
| 236 | gl_state.global_code = tmp_table; | 221 | gl_state.old_prop = tmp_table; |
| 237 | } | 222 | if (EQ (Fsyntax_table_p (tmp_table), Qt)) |
| 238 | else | 223 | { |
| 239 | { | 224 | gl_state.use_global = 0; |
| 240 | gl_state.use_global = 0; | 225 | } |
| 241 | gl_state.current_syntax_table = current_buffer->syntax_table; | 226 | else if (CONSP (tmp_table)) |
| 227 | { | ||
| 228 | gl_state.use_global = 1; | ||
| 229 | gl_state.global_code = tmp_table; | ||
| 230 | } | ||
| 231 | else | ||
| 232 | { | ||
| 233 | gl_state.use_global = 0; | ||
| 234 | gl_state.current_syntax_table = current_buffer->syntax_table; | ||
| 235 | } | ||
| 242 | } | 236 | } |
| 243 | 237 | ||
| 244 | while (!NULL_INTERVAL_P (i)) | 238 | while (!NULL_INTERVAL_P (i)) |
| @@ -246,42 +240,39 @@ update_syntax_table (charpos, count, init, object) | |||
| 246 | if (cnt && !EQ (tmp_table, textget (i->plist, Qsyntax_table))) | 240 | if (cnt && !EQ (tmp_table, textget (i->plist, Qsyntax_table))) |
| 247 | { | 241 | { |
| 248 | if (count > 0) | 242 | if (count > 0) |
| 249 | gl_state.right_ok = 0; | 243 | { |
| 250 | else | 244 | gl_state.e_property = i->position - gl_state.offset; |
| 251 | gl_state.left_ok = 0; | 245 | gl_state.forward_i = i; |
| 252 | break; | 246 | } |
| 247 | else | ||
| 248 | { | ||
| 249 | gl_state.b_property = i->position + LENGTH (i) - gl_state.offset; | ||
| 250 | gl_state.backward_i = i; | ||
| 251 | } | ||
| 252 | return; | ||
| 253 | } | 253 | } |
| 254 | else if (cnt == INTERVALS_AT_ONCE) | 254 | else if (cnt == INTERVALS_AT_ONCE) |
| 255 | { | 255 | { |
| 256 | if (count > 0) | 256 | if (count > 0) |
| 257 | gl_state.right_ok = 1; | 257 | { |
| 258 | else | 258 | gl_state.e_property = i->position + LENGTH (i) - gl_state.offset; |
| 259 | gl_state.left_ok = 1; | 259 | gl_state.forward_i = i; |
| 260 | break; | 260 | } |
| 261 | else | ||
| 262 | { | ||
| 263 | gl_state.b_property = i->position - gl_state.offset; | ||
| 264 | gl_state.backward_i = i; | ||
| 265 | } | ||
| 266 | return; | ||
| 261 | } | 267 | } |
| 262 | cnt++; | 268 | cnt++; |
| 263 | i = count > 0 ? next_interval (i) : previous_interval (i); | 269 | i = count > 0 ? next_interval (i) : previous_interval (i); |
| 264 | } | 270 | } |
| 265 | if (NULL_INTERVAL_P (i)) | 271 | eassert (NULL_INTERVAL_P (i)); /* This property goes to the end. */ |
| 266 | { /* This property goes to the end. */ | 272 | if (count > 0) |
| 267 | if (count > 0) | 273 | gl_state.e_property = gl_state.stop; |
| 268 | gl_state.e_property = gl_state.stop; | 274 | else |
| 269 | else | 275 | gl_state.b_property = gl_state.start; |
| 270 | gl_state.b_property = gl_state.start; | ||
| 271 | } | ||
| 272 | else | ||
| 273 | { | ||
| 274 | if (count > 0) | ||
| 275 | { | ||
| 276 | gl_state.e_property = i->position - gl_state.offset; | ||
| 277 | gl_state.forward_i = i; | ||
| 278 | } | ||
| 279 | else | ||
| 280 | { | ||
| 281 | gl_state.b_property = i->position + LENGTH (i) - 1 - gl_state.offset; | ||
| 282 | gl_state.backward_i = i; | ||
| 283 | } | ||
| 284 | } | ||
| 285 | } | 276 | } |
| 286 | 277 | ||
| 287 | /* Returns TRUE if char at CHARPOS is quoted. | 278 | /* Returns TRUE if char at CHARPOS is quoted. |
| @@ -1929,11 +1920,6 @@ between them, return t; otherwise return nil.") | |||
| 1929 | DEC_BOTH (from, from_byte); | 1920 | DEC_BOTH (from, from_byte); |
| 1930 | /* char_quoted does UPDATE_SYNTAX_TABLE_BACKWARD (from). */ | 1921 | /* char_quoted does UPDATE_SYNTAX_TABLE_BACKWARD (from). */ |
| 1931 | quoted = char_quoted (from, from_byte); | 1922 | quoted = char_quoted (from, from_byte); |
| 1932 | if (quoted) | ||
| 1933 | { | ||
| 1934 | DEC_BOTH (from, from_byte); | ||
| 1935 | goto leave; | ||
| 1936 | } | ||
| 1937 | c = FETCH_CHAR (from_byte); | 1923 | c = FETCH_CHAR (from_byte); |
| 1938 | code = SYNTAX (c); | 1924 | code = SYNTAX (c); |
| 1939 | comstyle = 0; | 1925 | comstyle = 0; |
| @@ -2010,7 +1996,7 @@ between them, return t; otherwise return nil.") | |||
| 2010 | break; | 1996 | break; |
| 2011 | } | 1997 | } |
| 2012 | } | 1998 | } |
| 2013 | else if (code != Swhitespace) | 1999 | else if (code != Swhitespace || quoted) |
| 2014 | { | 2000 | { |
| 2015 | leave: | 2001 | leave: |
| 2016 | immediate_quit = 0; | 2002 | immediate_quit = 0; |
| @@ -3031,11 +3017,10 @@ syms_of_syntax () | |||
| 3031 | "Non-nil means `forward-sexp', etc., should treat comments as whitespace."); | 3017 | "Non-nil means `forward-sexp', etc., should treat comments as whitespace."); |
| 3032 | 3018 | ||
| 3033 | DEFVAR_BOOL ("parse-sexp-lookup-properties", &parse_sexp_lookup_properties, | 3019 | DEFVAR_BOOL ("parse-sexp-lookup-properties", &parse_sexp_lookup_properties, |
| 3034 | "Non-nil means `forward-sexp', etc., grant `syntax-table' property.\n\ | 3020 | "Non-nil means `forward-sexp', etc., obey `syntax-table' property.\n\ |
| 3035 | The value of this property should be either a syntax table, or a cons\n\ | 3021 | Otherwise, that text property is simply ignored.\n\ |
| 3036 | of the form (SYNTAXCODE . MATCHCHAR), SYNTAXCODE being the numeric\n\ | 3022 | See the info node `(elisp)Syntax Properties' for a description of the\n\ |
| 3037 | syntax code, MATCHCHAR being nil or the character to match (which is\n\ | 3023 | `syntax-table' property."); |
| 3038 | relevant only for open/close type."); | ||
| 3039 | 3024 | ||
| 3040 | words_include_escapes = 0; | 3025 | words_include_escapes = 0; |
| 3041 | DEFVAR_BOOL ("words-include-escapes", &words_include_escapes, | 3026 | DEFVAR_BOOL ("words-include-escapes", &words_include_escapes, |