# HG changeset patch # User Richard M. Stallman # Date 1053175824 0 # Node ID 5a30d8fb640c9e1acf1eb8ed5c34d606d465e1de # Parent b17fe74b2af3bdd4201d594a6f6ab10c6e82bd04 (find_defun_start): When open_paren_in_column_0_is_defun_start, return beginning of buffer. diff -r b17fe74b2af3 -r 5a30d8fb640c src/syntax.c --- a/src/syntax.c Sat May 17 12:49:12 2003 +0000 +++ b/src/syntax.c Sat May 17 12:50:24 2003 +0000 @@ -337,7 +337,7 @@ It should be the last one before POS, or nearly the last. When open_paren_in_column_0_is_defun_start is nonzero, - the beginning of every line is treated as a defun-start. + only the beginning of the buffer is treated as a defun-start. We record the information about where the scan started and what its result was, so that another call in the same area @@ -353,6 +353,12 @@ { int opoint = PT, opoint_byte = PT_BYTE; + if (!open_paren_in_column_0_is_defun_start) + { + find_start_value_byte = BEGV_BYTE; + return BEGV; + } + /* Use previous finding, if it's valid and applies to this inquiry. */ if (current_buffer == find_start_buffer /* Reuse the defun-start even if POS is a little farther on. @@ -372,24 +378,21 @@ syntax-tables. */ gl_state.current_syntax_table = current_buffer->syntax_table; gl_state.use_global = 0; - if (open_paren_in_column_0_is_defun_start) + while (PT > BEGV) { - while (PT > BEGV) + /* Open-paren at start of line means we may have found our + defun-start. */ + if (SYNTAX (FETCH_CHAR (PT_BYTE)) == Sopen) { - /* Open-paren at start of line means we may have found our - defun-start. */ + SETUP_SYNTAX_TABLE (PT + 1, -1); /* Try again... */ if (SYNTAX (FETCH_CHAR (PT_BYTE)) == Sopen) - { - SETUP_SYNTAX_TABLE (PT + 1, -1); /* Try again... */ - if (SYNTAX (FETCH_CHAR (PT_BYTE)) == Sopen) - break; - /* Now fallback to the default value. */ - gl_state.current_syntax_table = current_buffer->syntax_table; - gl_state.use_global = 0; - } - /* Move to beg of previous line. */ - scan_newline (PT, PT_BYTE, BEGV, BEGV_BYTE, -2, 1); + break; + /* Now fallback to the default value. */ + gl_state.current_syntax_table = current_buffer->syntax_table; + gl_state.use_global = 0; } + /* Move to beg of previous line. */ + scan_newline (PT, PT_BYTE, BEGV, BEGV_BYTE, -2, 1); } /* Record what we found, for the next try. */