diff options
| author | Richard M. Stallman | 2003-05-17 12:50:31 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2003-05-17 12:50:31 +0000 |
| commit | 1fd1cc2fc21249b2ef0d776b73333995cbe1e960 (patch) | |
| tree | f51d45b2150e05b36b70efcd5e6126d4aeee500f /src/syntax.c | |
| parent | 07c9ebd607bbf27658b752974cc5869276aec8f8 (diff) | |
| download | emacs-1fd1cc2fc21249b2ef0d776b73333995cbe1e960.tar.gz emacs-1fd1cc2fc21249b2ef0d776b73333995cbe1e960.zip | |
(find_defun_start): When open_paren_in_column_0_is_defun_start,
return beginning of buffer.
Diffstat (limited to 'src/syntax.c')
| -rw-r--r-- | src/syntax.c | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/src/syntax.c b/src/syntax.c index d25c4394c6e..706706a53a1 100644 --- a/src/syntax.c +++ b/src/syntax.c | |||
| @@ -337,7 +337,7 @@ dec_bytepos (bytepos) | |||
| 337 | It should be the last one before POS, or nearly the last. | 337 | It should be the last one before POS, or nearly the last. |
| 338 | 338 | ||
| 339 | When open_paren_in_column_0_is_defun_start is nonzero, | 339 | When open_paren_in_column_0_is_defun_start is nonzero, |
| 340 | the beginning of every line is treated as a defun-start. | 340 | only the beginning of the buffer is treated as a defun-start. |
| 341 | 341 | ||
| 342 | We record the information about where the scan started | 342 | We record the information about where the scan started |
| 343 | and what its result was, so that another call in the same area | 343 | and what its result was, so that another call in the same area |
| @@ -353,6 +353,12 @@ find_defun_start (pos, pos_byte) | |||
| 353 | { | 353 | { |
| 354 | int opoint = PT, opoint_byte = PT_BYTE; | 354 | int opoint = PT, opoint_byte = PT_BYTE; |
| 355 | 355 | ||
| 356 | if (!open_paren_in_column_0_is_defun_start) | ||
| 357 | { | ||
| 358 | find_start_value_byte = BEGV_BYTE; | ||
| 359 | return BEGV; | ||
| 360 | } | ||
| 361 | |||
| 356 | /* Use previous finding, if it's valid and applies to this inquiry. */ | 362 | /* Use previous finding, if it's valid and applies to this inquiry. */ |
| 357 | if (current_buffer == find_start_buffer | 363 | if (current_buffer == find_start_buffer |
| 358 | /* Reuse the defun-start even if POS is a little farther on. | 364 | /* Reuse the defun-start even if POS is a little farther on. |
| @@ -372,24 +378,21 @@ find_defun_start (pos, pos_byte) | |||
| 372 | syntax-tables. */ | 378 | syntax-tables. */ |
| 373 | gl_state.current_syntax_table = current_buffer->syntax_table; | 379 | gl_state.current_syntax_table = current_buffer->syntax_table; |
| 374 | gl_state.use_global = 0; | 380 | gl_state.use_global = 0; |
| 375 | if (open_paren_in_column_0_is_defun_start) | 381 | while (PT > BEGV) |
| 376 | { | 382 | { |
| 377 | while (PT > BEGV) | 383 | /* Open-paren at start of line means we may have found our |
| 384 | defun-start. */ | ||
| 385 | if (SYNTAX (FETCH_CHAR (PT_BYTE)) == Sopen) | ||
| 378 | { | 386 | { |
| 379 | /* Open-paren at start of line means we may have found our | 387 | SETUP_SYNTAX_TABLE (PT + 1, -1); /* Try again... */ |
| 380 | defun-start. */ | ||
| 381 | if (SYNTAX (FETCH_CHAR (PT_BYTE)) == Sopen) | 388 | if (SYNTAX (FETCH_CHAR (PT_BYTE)) == Sopen) |
| 382 | { | 389 | break; |
| 383 | SETUP_SYNTAX_TABLE (PT + 1, -1); /* Try again... */ | 390 | /* Now fallback to the default value. */ |
| 384 | if (SYNTAX (FETCH_CHAR (PT_BYTE)) == Sopen) | 391 | gl_state.current_syntax_table = current_buffer->syntax_table; |
| 385 | break; | 392 | gl_state.use_global = 0; |
| 386 | /* Now fallback to the default value. */ | ||
| 387 | gl_state.current_syntax_table = current_buffer->syntax_table; | ||
| 388 | gl_state.use_global = 0; | ||
| 389 | } | ||
| 390 | /* Move to beg of previous line. */ | ||
| 391 | scan_newline (PT, PT_BYTE, BEGV, BEGV_BYTE, -2, 1); | ||
| 392 | } | 393 | } |
| 394 | /* Move to beg of previous line. */ | ||
| 395 | scan_newline (PT, PT_BYTE, BEGV, BEGV_BYTE, -2, 1); | ||
| 393 | } | 396 | } |
| 394 | 397 | ||
| 395 | /* Record what we found, for the next try. */ | 398 | /* Record what we found, for the next try. */ |