]> code.delx.au - gnu-emacs/blobdiff - src/syntax.c
*** empty log message ***
[gnu-emacs] / src / syntax.c
index 167e20ebed5ee524a07cd9c3867b0499eb321e49..c2711b90ef12bd706ffb172fce53bd5f0ec7f320 100644 (file)
@@ -53,6 +53,12 @@ int multibyte_syntax_as_symbol;
    only very temporarily.  */
 Lisp_Object syntax_temp;
 
+/* Non-zero means an open parenthesis in column 0 is always considered
+   to be the start of a defun.  Zero means an open parenthesis in
+   column 0 has no special meaning.  */
+
+int open_paren_in_column_0_is_defun_start;
+
 /* This is the internal form of the parse state used in parse-partial-sexp.  */
 
 struct lisp_parse_state
@@ -140,14 +146,14 @@ update_syntax_table (charpos, count, init, object)
       while (!NULL_PARENT (i)) 
        {
          if (AM_RIGHT_CHILD (i))
-           i->parent->position = i->position
+           INTERVAL_PARENT (i)->position = i->position
              - LEFT_TOTAL_LENGTH (i) + TOTAL_LENGTH (i) /* right end */
-             - TOTAL_LENGTH (i->parent)
-             + LEFT_TOTAL_LENGTH (i->parent);
+             - TOTAL_LENGTH (INTERVAL_PARENT (i))
+             + LEFT_TOTAL_LENGTH (INTERVAL_PARENT (i));
          else
-           i->parent->position = i->position - LEFT_TOTAL_LENGTH (i)
+           INTERVAL_PARENT (i)->position = i->position - LEFT_TOTAL_LENGTH (i)
              + TOTAL_LENGTH (i);
-         i = i->parent;
+         i = INTERVAL_PARENT (i);
        }
       i = gl_state.forward_i;
       gl_state.b_property = i->position - 1 - gl_state.offset;
@@ -370,11 +376,13 @@ find_defun_start (pos, pos_byte)
   gl_state.use_global = 0;
   while (PT > BEGV)
     {
-      /* Open-paren at start of line means we found our defun-start.  */
+      /* Open-paren at start of line means we may have found our
+        defun-start.  */
       if (SYNTAX (FETCH_CHAR (PT_BYTE)) == Sopen)
        {
          SETUP_SYNTAX_TABLE (PT + 1, -1);      /* Try again... */
-         if (SYNTAX (FETCH_CHAR (PT_BYTE)) == Sopen)
+         if (SYNTAX (FETCH_CHAR (PT_BYTE)) == Sopen
+             && open_paren_in_column_0_is_defun_start)
            break;
          /* Now fallback to the default value.  */
          gl_state.current_syntax_table = current_buffer->syntax_table;
@@ -713,11 +721,12 @@ One argument, a syntax table.")
   (table)
      Lisp_Object table;
 {
+  int idx;
   check_syntax_table (table);
   current_buffer->syntax_table = table;
   /* Indicate that this buffer now has a specified syntax table.  */
-  current_buffer->local_var_flags
-    |= XFASTINT (buffer_local_flags.syntax_table);
+  idx = PER_BUFFER_VAR_IDX (syntax_table);
+  SET_PER_BUFFER_VALUE_P (current_buffer, idx, 1);
   return table;
 }
 \f
@@ -2963,6 +2972,11 @@ relevant only for open/close type.");
     "Non-nil means `scan-sexps' treats all multibyte characters as symbol.");
   multibyte_syntax_as_symbol = 0;
 
+  DEFVAR_BOOL ("open-paren-in-column-0-is-defun-start",
+              &open_paren_in_column_0_is_defun_start,
+    "Non-nil means an open paren in column 0 denotes the start of a defun.");
+  open_paren_in_column_0_is_defun_start = 1;
+
   defsubr (&Ssyntax_table_p);
   defsubr (&Ssyntax_table);
   defsubr (&Sstandard_syntax_table);