From: Eshel Yaron Date: Tue, 20 Aug 2024 13:37:52 +0000 (+0200) Subject: Drop left margin convention and associated cruft X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=005ae98741321b0eb675ad686b202ae6ea0a6d02;p=emacs.git Drop left margin convention and associated cruft --- diff --git a/doc/emacs/display.texi b/doc/emacs/display.texi index 96078213134..58becc51d7a 100644 --- a/doc/emacs/display.texi +++ b/doc/emacs/display.texi @@ -1102,18 +1102,6 @@ otherwise, use the value '((c-mode . 1) (c++-mode . 1))) @end example -@cindex incorrect fontification -@cindex parenthesis in column zero and fontification -@cindex brace in column zero and fontification - Comment and string fontification (or ``syntactic'' fontification) -relies on analysis of the syntactic structure of the buffer text. For -the sake of speed, some modes, including Lisp mode, rely on a special -convention: an open-parenthesis or open-brace in the leftmost column -always defines the beginning of a defun, and is thus always outside -any string or comment. Therefore, you should avoid placing an -open-parenthesis or open-brace in the leftmost column, if it is inside -a string or comment. @xref{Left Margin Paren}, for details. - @findex font-lock-add-keywords Font Lock highlighting patterns already exist for most modes, but you may want to fontify additional patterns. You can use the function diff --git a/doc/emacs/emacs.texi b/doc/emacs/emacs.texi index fe1f91bb34c..a566472f3cd 100644 --- a/doc/emacs/emacs.texi +++ b/doc/emacs/emacs.texi @@ -698,8 +698,6 @@ Editing Programs Top-Level Definitions, or Defuns -* Left Margin Paren:: An open-paren or similar opening delimiter - starts a defun if it is at the left margin. * Moving by Defuns:: Commands to move over or mark a major definition. * Imenu:: Making buffer indexes as menus. * Which Function:: Which Function mode shows which function you are in. diff --git a/doc/emacs/programs.texi b/doc/emacs/programs.texi index 3b863eefd72..e98f55267c8 100644 --- a/doc/emacs/programs.texi +++ b/doc/emacs/programs.texi @@ -161,36 +161,12 @@ a function, is called a @dfn{defun}. The name comes from Lisp, but in Emacs we use it for all languages. @menu -* Left Margin Paren:: An open-paren or similar opening delimiter - starts a defun if it is at the left margin. * Moving by Defuns:: Commands to move over or mark a major definition. * Moving by Sentences:: Commands to move over certain code units. * Imenu:: Making buffer indexes as menus. * Which Function:: Which Function mode shows which function you are in. @end menu -@node Left Margin Paren -@subsection Left Margin Convention - -@cindex open-parenthesis in leftmost column -@cindex ( in leftmost column - Many programming-language modes have traditionally assumed that any -opening parenthesis or brace found at the left margin is the start of -a top-level definition, or defun. So, by default, commands which seek -the beginning of a defun accept such a delimiter as signifying that -position. - -@vindex open-paren-in-column-0-is-defun-start - If you want to override this convention, you can do so by setting -the user option @code{open-paren-in-column-0-is-defun-start} to -@code{nil}. If this option is set to @code{t} (the default), commands -seeking the start of a defun will stop at opening parentheses or -braces at column zero which aren't in a comment or string. When it is -@code{nil}, defuns are found by searching for parens or braces at the -outermost level. Since low-level Emacs routines no longer depend on -this convention, you usually won't need to change -@code{open-paren-in-column-0-is-defun-start} from its default. - @node Moving by Defuns @subsection Moving by Defuns @cindex defuns @@ -505,14 +481,6 @@ within the group, or under the text after the parenthesis. If you manually give one of these lines a nonstandard indentation (e.g., for aesthetic purposes), the lines below will follow it. - The indentation commands for most programming language modes assume -that an open-parenthesis, open-brace or other opening delimiter at the -left margin is the start of a function. If the code you are editing -violates this assumption---even if the delimiters occur in strings or -comments---you must set @code{open-paren-in-column-0-is-defun-start} -to @code{nil} for indentation to work properly. @xref{Left Margin -Paren}. - @node Multi-line Indent @subsection Indenting Several Lines diff --git a/doc/lispref/positions.texi b/doc/lispref/positions.texi index 4feda608d80..7ea469f2dce 100644 --- a/doc/lispref/positions.texi +++ b/doc/lispref/positions.texi @@ -812,16 +812,6 @@ on a line that starts with a match for this regular expression, followed by a character with open-parenthesis syntax. @end defopt -@cindex \( in strings -@defopt open-paren-in-column-0-is-defun-start -If this variable's value is non-@code{nil}, an open parenthesis in -column 0 is considered to be the start of a defun. If it is -@code{nil}, an open parenthesis in column 0 has no special meaning. -The default is @code{t}. If a string literal happens to have a -parenthesis in column 0, escape it with a backslash to avoid a false -positive. -@end defopt - @defvar beginning-of-defun-function If non-@code{nil}, this variable holds a function for finding the beginning of a defun. The function @code{beginning-of-defun} diff --git a/doc/misc/cc-mode.texi b/doc/misc/cc-mode.texi index c0819b232a4..37a67c0ace3 100644 --- a/doc/misc/cc-mode.texi +++ b/doc/misc/cc-mode.texi @@ -7619,29 +7619,6 @@ modify @code{c-offsets-alist} directly: (setq c-offsets-alist '((substatement-open . 0))) @end example -@item -@cindex open paren in column zero -@emph{I have an open paren character at column zero inside a comment or -multiline string literal, and it causes the fontification and/or -indentation to go haywire. What gives?} - -It's due to the ad-hoc rule in (X)Emacs that such open parens always -start defuns (which translates to functions, classes, namespaces or any -other top-level block constructs in the @ccmode{} languages). -@ifset XEMACS -@xref{Defuns,,, xemacs, XEmacs User's Manual}, for details. -@end ifset -@ifclear XEMACS -@xref{Left Margin Paren,,, emacs, GNU Emacs Manual}, for details -(@xref{Defuns,,, emacs, GNU Emacs Manual}, in the Emacs 20 manual). -@end ifclear - -This heuristic is built into the core syntax analysis routines in -(X)Emacs, so it's not really a @ccmode{} issue. However, in Emacs -21.1 it became possible to turn it off@footnote{Using the variable -@code{open-paren-in-column-0-is-defun-start}.} and @ccmode{} does so -there since it's got its own system to keep track of blocks. - @end itemize diff --git a/lisp/cus-start.el b/lisp/cus-start.el index fadb5b9c683..0736248d0d6 100644 --- a/lisp/cus-start.el +++ b/lisp/cus-start.el @@ -582,8 +582,6 @@ Leaving \"Default\" unchecked is equivalent with specifying a default of ;; syntax.c (parse-sexp-ignore-comments editing-basics boolean) (words-include-escapes editing-basics boolean) - (open-paren-in-column-0-is-defun-start editing-basics boolean - "21.1") ;; term.c (visible-cursor cursor boolean "22.1") ;; terminal.c @@ -954,9 +952,6 @@ since it could result in memory overflow and make Emacs crash." ((eq prop :tag) (put symbol 'custom-tag propval)))))))) -(custom-add-to-group 'font-lock 'open-paren-in-column-0-is-defun-start - 'custom-variable) - ;; Record cus-start as loaded if we have set up all the info that we can. ;; Don't record it as loaded if we have only set up the standard values ;; and safe/risky properties. diff --git a/lisp/emacs-lisp/checkdoc.el b/lisp/emacs-lisp/checkdoc.el index addf933affd..949ca6b74ad 100644 --- a/lisp/emacs-lisp/checkdoc.el +++ b/lisp/emacs-lisp/checkdoc.el @@ -334,14 +334,6 @@ This should be set in an Emacs Lisp file's local variables." :version "28.1") ;;;###autoload(put 'checkdoc-symbol-words 'safe-local-variable #'list-of-strings-p) -(defcustom checkdoc-column-zero-backslash-before-paren t - "Non-nil means to warn if there is no \"\\\" before \"(\" in column zero. -This backslash is no longer needed on Emacs 27.1 or later. - -See Info node `(elisp) Documentation Tips' for background." - :type 'boolean - :version "28.1") - ;; This is how you can use checkdoc to make mass fixes on the Emacs ;; source tree: ;; @@ -1498,21 +1490,6 @@ buffer, otherwise stop after the first error." `("Remove indentation" ((,(current-buffer) (,(match-beginning 1) ,(match-end 1) "")))))))) - ;; * Check for '(' in column 0. - (when checkdoc-column-zero-backslash-before-paren - (save-excursion - (when (re-search-forward "^(" e t) - (if (checkdoc-autofix-ask-replace (match-beginning 0) - (match-end 0) - (format-message "Escape this `('?") - "\\(") - nil - (checkdoc-create-error - "Open parenthesis in column 0 should be escaped" - (match-beginning 0) (match-end 0) - `("Escape parenthesis in column 0" - ((,(current-buffer) - (,(match-beginning 0) ,(match-beginning 0) "\\"))))))))) ;; * Do not start or end a documentation string with whitespace. (let (start end) (if (or (if (looking-at "\"\\([ \t\n]+\\)") diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index 601cc7bf712..bd088a93591 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el @@ -278,7 +278,7 @@ to a package-local -loaddefs.el file.") (defmacro let-when-compile (bindings &rest body) "Like `let*', but allow for compile time optimization. -Use BINDINGS as in regular `let*', but in BODY each usage should +Use BINDINGS as in regular `let*', but in \BODY each usage should be wrapped in `eval-when-compile'. This will generate compile-time constants from BINDINGS." (declare (indent 1) (debug let)) @@ -297,11 +297,8 @@ This will generate compile-time constants from BINDINGS." (let* ((beg0 (match-beginning 0)) (end0 (match-end 0)) (ppss (save-excursion (syntax-ppss beg0)))) - (and (nth 3 ppss) ;Inside a string. - (not (nth 5 ppss)) ;The \ is not itself \-escaped. - ;; Don't highlight the \( introduced because of - ;; `open-paren-in-column-0-is-defun-start'. - (not (eq ?\n (char-before beg0))) + (and (nth 3 ppss) ;Inside a string. + (not (nth 5 ppss)) ;The \ is not itself \-escaped. (equal (ignore-errors (car (read-from-string (format "\"%s\"" diff --git a/lisp/emacs-lisp/lisp.el b/lisp/emacs-lisp/lisp.el index e65eec508d9..af092733e18 100644 --- a/lisp/emacs-lisp/lisp.el +++ b/lisp/emacs-lisp/lisp.el @@ -359,13 +359,9 @@ to the ARGth following beginning of defun. If search is successful, return t; point ends up at the beginning of the line where the search succeeded. Otherwise, return nil. -When `open-paren-in-column-0-is-defun-start' is non-nil, a defun -is assumed to start where there is a char with open-parenthesis -syntax at the beginning of a line. If `defun-prompt-regexp' is -non-nil, then a string which matches that regexp may also precede -the open-parenthesis. If `defun-prompt-regexp' and -`open-paren-in-column-0-is-defun-start' are both nil, this -function instead finds an open-paren at the outermost level. +If `defun-prompt-regexp' is non-nil, then a string which matches that +regexp may also precede the open-parenthesis. Otherwise, this function +instead finds an open-paren at the outermost level. If the variable `beginning-of-defun-function' is non-nil, its value is called as a function, with argument ARG, to find the @@ -414,16 +410,14 @@ of a defun, nil if it failed to find one." (dotimes (_ (- arg)) (funcall end-of-defun-function)))))) - ((or defun-prompt-regexp open-paren-in-column-0-is-defun-start) + (defun-prompt-regexp (and (< arg 0) (not (eobp)) (forward-char 1)) (and (let (found) (while (and (setq found (re-search-backward (if defun-prompt-regexp - (concat (if open-paren-in-column-0-is-defun-start - "^\\s(\\|" "") - "\\(?:" defun-prompt-regexp "\\)\\s(") + (concat "\\(?:" defun-prompt-regexp "\\)\\s(") "^\\s(") nil 'move arg)) (save-match-data @@ -432,9 +426,9 @@ of a defun, nil if it failed to find one." (progn (goto-char (1- (match-end 0))) t))) - ;; If open-paren-in-column-0-is-defun-start and defun-prompt-regexp - ;; are both nil, column 0 has no significance - so scan forward - ;; from BOB to see how nested point is, then carry on from there. + ;; If defun-prompt-regexp is nil, column 0 has no significance - so + ;; scan forward from BOB to see how nested point is, then carry on + ;; from there. ;; ;; It is generally not a good idea to land up here, because the ;; call to scan-lists below can be extremely slow. This is because diff --git a/lisp/emacs-lisp/scope.el b/lisp/emacs-lisp/scope.el index c48c9da2933..bccfdbc43fe 100644 --- a/lisp/emacs-lisp/scope.el +++ b/lisp/emacs-lisp/scope.el @@ -54,8 +54,10 @@ Optional argument LOCAL is a local context to extend." (let* ((beg (scope-sym-pos sym)) (bare (bare-symbol sym)) (len (length (symbol-name bare)))) - (unless (or (booleanp bare) (keywordp bare) (null beg)) - (funcall scope-callback 'variable beg len (scope-local-get bare local))))) + (when (and beg (not (booleanp bare))) + (if (keywordp bare) + (funcall scope-callback 'constant beg len nil) + (funcall scope-callback 'variable beg len (scope-local-get bare local)))))) (defun scope-let-1 (local0 local bindings body) (if bindings @@ -524,6 +526,10 @@ a (possibly empty) list of safe macros.") nil)) (scope-n local forms)) ((special-form-p bare) + (when (symbol-with-pos-p f) + (funcall scope-callback 'special-form + (symbol-with-pos-pos f) (length (symbol-name bare)) + nil)) (cond ((eq bare 'let) (scope-let local (car forms) (cdr forms))) @@ -543,6 +549,10 @@ a (possibly empty) list of safe macros.") progn prog1)) (scope-n local forms)))) ((macrop bare) + (when (symbol-with-pos-p f) + (funcall scope-callback 'macro + (symbol-with-pos-pos f) (length (symbol-name bare)) + nil)) (cond ((eq (get bare 'edebug-form-spec) t) (scope-n local forms)) ((eq bare 'lambda) (scope-lambda local (car forms) (cdr forms))) @@ -563,8 +573,6 @@ a (possibly empty) list of safe macros.") ((memq bare '(declare-function)) (scope-declare-function local (car forms) (cadr forms) (caddr forms) (cadddr forms))) - ((memq bare '(let-when-compile)) - (scope-let* local (car forms) (cdr forms))) ((memq bare '(setq-local setq-default)) (scope-setq local forms)) ((memq bare '(cl-block)) @@ -573,6 +581,8 @@ a (possibly empty) list of safe macros.") (scope-return-from local (car forms) (cadr forms))) ((memq bare '(rx)) ; `rx' is unsafe, never expand! (scope-rx local forms)) + ((memq bare '(let-when-compile)) ; `let-when-compile' too! + (scope-let* local (car forms) (cdr forms))) ((memq bare '(cl-eval-when)) ; Likewise! (scope-rx local (cdr forms))) ((scope-safe-macro-p bare) diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index f9524526ce2..1ec3d55d865 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -1274,9 +1274,6 @@ like \"/sys\" or \"/C:\".") ;; buffer local variable, which is computed depending on remote host properties ;; when `tramp-chunksize' is zero or nil. (defcustom tramp-chunksize (when (memq system-type '(hpux)) 500) -;; Parentheses in docstring starting at beginning of line are escaped. -;; Fontification is messed up when -;; `open-paren-in-column-0-is-defun-start' set to t. "If non-nil, chunksize for sending input to local process. It is necessary only on systems which have a buggy `process-send-string' implementation. The necessity, whether this variable must be set, can be diff --git a/lisp/progmodes/cc-defs.el b/lisp/progmodes/cc-defs.el index e45ab76ec07..9cf6748f007 100644 --- a/lisp/progmodes/cc-defs.el +++ b/lisp/progmodes/cc-defs.el @@ -2177,8 +2177,6 @@ non-nil, a caret is prepended to invert the set." ;; Figure out what features this Emacs has -(cc-bytecomp-defvar open-paren-in-column-0-is-defun-start) - (defconst c-emacs-features (let (list) @@ -2280,29 +2278,25 @@ non-nil, a caret is prepended to invert the set." (= (skip-chars-forward "[:alpha:]") 3)) (setq list (cons 'posix-char-classes list))) - ;; See if `open-paren-in-column-0-is-defun-start' exists and - ;; isn't buggy (Emacs >= 21.4). - (when (boundp 'open-paren-in-column-0-is-defun-start) - (let ((open-paren-in-column-0-is-defun-start nil) - (parse-sexp-ignore-comments t)) - (delete-region (point-min) (point-max)) - (set-syntax-table (make-syntax-table)) - (modify-syntax-entry ?\' "\"") - (cond - ;; XEmacs. Afaik this is currently an Emacs-only - ;; feature, but it's good to be prepared. - ((memq '8-bit list) - (modify-syntax-entry ?/ ". 1456") - (modify-syntax-entry ?* ". 23")) - ;; Emacs - ((memq '1-bit list) - (modify-syntax-entry ?/ ". 124b") - (modify-syntax-entry ?* ". 23"))) - (modify-syntax-entry ?\n "> b") - (insert "/* '\n () */") - (backward-sexp) - (if (bobp) - (setq list (cons 'col-0-paren list))))) + (let ((parse-sexp-ignore-comments t)) + (delete-region (point-min) (point-max)) + (set-syntax-table (make-syntax-table)) + (modify-syntax-entry ?\' "\"") + (cond + ;; XEmacs. Afaik this is currently an Emacs-only + ;; feature, but it's good to be prepared. + ((memq '8-bit list) + (modify-syntax-entry ?/ ". 1456") + (modify-syntax-entry ?* ". 23")) + ;; Emacs + ((memq '1-bit list) + (modify-syntax-entry ?/ ". 124b") + (modify-syntax-entry ?* ". 23"))) + (modify-syntax-entry ?\n "> b") + (insert "/* '\n () */") + (backward-sexp) + (if (bobp) + (setq list (cons 'col-0-paren list)))) (set-buffer-modified-p nil)) (kill-buffer buf))) diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index 4c319a78e01..1ffca7365ea 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el @@ -3721,8 +3721,7 @@ initializing CC Mode. Currently (2020-06) these are `js-mode' and ;; instead? This heuristic no longer works well in C++, where ;; declarations inside namespace brace blocks are frequently placed at ;; column zero. (2015-11-10): Remove the condition on C++ Mode. - (when (and (or (not (memq 'col-0-paren c-emacs-features)) - open-paren-in-column-0-is-defun-start) + (when (and (not (memq 'col-0-paren c-emacs-features)) ;; (not (c-major-mode-is 'c++-mode)) (> how-far c-state-cache-too-far)) (setq BOD-pos (c-get-fallback-scan-pos here)) ; somewhat EXPENSIVE!!! diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el index 5f11622733f..93bfad1df39 100644 --- a/lisp/progmodes/cc-mode.el +++ b/lisp/progmodes/cc-mode.el @@ -697,16 +697,6 @@ that requires a literal mode spec at compile time." (cons `(,tprop . t) text-property-default-nonsticky)))) '(syntax-table c-fl-syn-tab category c-type))) - ;; In Emacs 21 and later it's possible to turn off the ad-hoc - ;; heuristic that open parens in column 0 are defun starters. Since - ;; we have c-state-cache, that heuristic isn't useful and only causes - ;; trouble, so turn it off. -;; 2006/12/17: This facility is somewhat confused, and doesn't really seem -;; helpful. Comment it out for now. -;; (when (memq 'col-0-paren c-emacs-features) -;; (make-local-variable 'open-paren-in-column-0-is-defun-start) -;; (setq open-paren-in-column-0-is-defun-start nil)) - (c-clear-found-types) ;; now set the mode style based on default-style diff --git a/lisp/progmodes/cperl-mode.el b/lisp/progmodes/cperl-mode.el index 0b9b4aa1491..6f4726b25f3 100644 --- a/lisp/progmodes/cperl-mode.el +++ b/lisp/progmodes/cperl-mode.el @@ -1890,9 +1890,6 @@ or as help on variables `cperl-tips', `cperl-problems', (if (cperl-val 'cperl-electric-keywords) (abbrev-mode 1)) (set-syntax-table cperl-mode-syntax-table) - ;; Workaround for Bug#30393, needed for Emacs 26. - (when (< emacs-major-version 27) - (setq-local open-paren-in-column-0-is-defun-start nil)) ;; Until Emacs is multi-threaded, we do not actually need it local: (make-local-variable 'cperl-font-locking) (setq-local outline-regexp cperl-outline-regexp) diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el index 4322d210152..6678b727a8e 100644 --- a/lisp/progmodes/elisp-mode.el +++ b/lisp/progmodes/elisp-mode.el @@ -1525,7 +1525,6 @@ Semicolons start comments. "Elisp-Byte-Code" "Major mode for *.elc files." ;; TODO: Add way to disassemble byte-code under point. - (setq-local open-paren-in-column-0-is-defun-start nil) (setq-local syntax-propertize-function #'elisp-byte-code-syntax-propertize)) diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index 75c8111035c..a338c19763f 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -3751,7 +3751,6 @@ Currently there are `js-mode' and `js-ts-mode'." (setq-local indent-line-function #'js-indent-line) (setq-local beginning-of-defun-function #'js-beginning-of-defun) (setq-local end-of-defun-function #'js-end-of-defun) - (setq-local open-paren-in-column-0-is-defun-start nil) (setq-local font-lock-defaults (list js--font-lock-keywords nil nil nil nil '(font-lock-syntactic-face-function diff --git a/lisp/subr.el b/lisp/subr.el index b8753835467..a367f6ef817 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -2013,6 +2013,12 @@ be a list of the form returned by `event-start' and `event-end'." (make-obsolete-variable 'load-dangerous-libraries "no longer used." "27.1") +(defvar comment-use-syntax-ppss nil "Unused obsolete variable.") +(make-obsolete-variable 'comment-use-syntax-ppss nil "31.1") + +(defvar open-paren-in-column-0-is-defun-start nil "Unused obsolete variable.") +(make-obsolete-variable 'open-paren-in-column-0-is-defun-start nil "31.1") + (define-obsolete-function-alias 'compare-window-configurations #'window-configuration-equal-p "29.1") diff --git a/src/syntax.c b/src/syntax.c index a4ad61328e6..738af91f97f 100644 --- a/src/syntax.c +++ b/src/syntax.c @@ -555,9 +555,6 @@ dec_bytepos (ptrdiff_t bytepos) /* Return a defun-start position before POS and not too far before. It should be the last one before POS, or nearly the last. - When open_paren_in_column_0_is_defun_start is nonzero, - 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 can return the same value very quickly. @@ -582,64 +579,23 @@ find_defun_start (ptrdiff_t pos, ptrdiff_t pos_byte) && MODIFF == find_start_modiff) return find_start_value; - if (!NILP (Vcomment_use_syntax_ppss)) - { - modiff_count modiffs = CHARS_MODIFF; - Lisp_Object ppss = call1 (Qsyntax_ppss, make_fixnum (pos)); - if (modiffs != CHARS_MODIFF) - error ("syntax-ppss modified the buffer!"); - TEMP_SET_PT_BOTH (opoint, opoint_byte); - Lisp_Object boc = Fnth (make_fixnum (8), ppss); - if (FIXNUMP (boc)) - { - find_start_value = XFIXNUM (boc); - find_start_value_byte = CHAR_TO_BYTE (find_start_value); - } - else - { - find_start_value = pos; - find_start_value_byte = pos_byte; - } - goto found; - } - if (!open_paren_in_column_0_is_defun_start) + modiff_count modiffs = CHARS_MODIFF; + Lisp_Object ppss = call1 (Qsyntax_ppss, make_fixnum (pos)); + if (modiffs != CHARS_MODIFF) + error ("syntax-ppss modified the buffer!"); + TEMP_SET_PT_BOTH (opoint, opoint_byte); + Lisp_Object boc = Fnth (make_fixnum (8), ppss); + if (FIXNUMP (boc)) { - find_start_value = BEGV; - find_start_value_byte = BEGV_BYTE; - goto found; + find_start_value = XFIXNUM (boc); + find_start_value_byte = CHAR_TO_BYTE (find_start_value); } - - /* Back up to start of line. */ - scan_newline (pos, pos_byte, BEGV, BEGV_BYTE, -1, 1); - - /* We optimize syntax-table lookup for rare updates. Thus we accept - only those `^\s(' which are good in global _and_ text-property - syntax-tables. */ - SETUP_BUFFER_SYNTAX_TABLE (); - while (PT > BEGV) + else { - /* Open-paren at start of line means we may have found our - defun-start. */ - int c = FETCH_CHAR_AS_MULTIBYTE (PT_BYTE); - if (SYNTAX (c) == Sopen) - { - SETUP_SYNTAX_TABLE (PT + 1, -1); /* Try again... */ - c = FETCH_CHAR_AS_MULTIBYTE (PT_BYTE); - if (SYNTAX (c) == Sopen) - break; - /* Now fallback to the default value. */ - SETUP_BUFFER_SYNTAX_TABLE (); - } - /* Move to beg of previous line. */ - scan_newline (PT, PT_BYTE, BEGV, BEGV_BYTE, -2, 1); + find_start_value = pos; + find_start_value_byte = pos_byte; } - /* Record what we found, for the next try. */ - find_start_value = PT; - find_start_value_byte = PT_BYTE; - TEMP_SET_PT_BOTH (opoint, opoint_byte); - - found: find_start_buffer = current_buffer; find_start_modiff = MODIFF; find_start_begv = BEGV; @@ -722,7 +678,6 @@ back_comment (ptrdiff_t from, ptrdiff_t from_byte, ptrdiff_t stop, { rarely_quit (++quit_count); - ptrdiff_t temp_byte; int prev_syntax; bool com2start, com2end, comstart; @@ -868,20 +823,6 @@ back_comment (ptrdiff_t from, ptrdiff_t from_byte, ptrdiff_t stop, comment_lossage = 1; break; - case Sopen: - /* Assume a defun-start point is outside of strings. */ - if (open_paren_in_column_0_is_defun_start - && NILP (Vcomment_use_syntax_ppss) - && (from == stop - || (temp_byte = dec_bytepos (from_byte), - FETCH_CHAR (temp_byte) == '\n'))) - { - defun_start = from; - defun_start_byte = from_byte; - from = stop; /* Break out of the loop. */ - } - break; - default: break; } @@ -3725,10 +3666,6 @@ syms_of_syntax (void) { DEFSYM (Qsyntax_table_p, "syntax-table-p"); DEFSYM (Qsyntax_ppss, "syntax-ppss"); - DEFVAR_LISP ("comment-use-syntax-ppss", - Vcomment_use_syntax_ppss, - doc: /* Non-nil means `forward-comment' can use `syntax-ppss' internally. */); - Vcomment_use_syntax_ppss = Qt; staticpro (&Vsyntax_code_object); @@ -3766,12 +3703,6 @@ See the info node `(elisp)Syntax Properties' for a description of the doc: /* 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, - doc: /* Non-nil means an open paren in column 0 denotes the start of a defun. */); - open_paren_in_column_0_is_defun_start = 1; - - DEFVAR_LISP ("find-word-boundary-function-table", Vfind_word_boundary_function_table, doc: /*