From: Stefan Monnier Date: Fri, 18 Sep 2015 00:33:55 +0000 (-0400) Subject: * lisp/font-lock.el (font-lock-beginning-of-syntax-function): Remove X-Git-Tag: emacs-25.0.90~1224^2~85 X-Git-Url: https://code.delx.au/gnu-emacs/commitdiff_plain/644c6b414f39222890246d7fe155a369b1983246 * lisp/font-lock.el (font-lock-beginning-of-syntax-function): Remove (font-lock-fontify-block): Don't let-bind it. (font-lock-compile-keywords): Don't use it. (font-lock-set-defaults): Don't set it. Allow the variable alist to start one slot earlier, instead. * lisp/emacs-lisp/syntax.el (font-lock-beginning-of-syntax-function): Don't declare. (syntax-ppss): Don't use it either. * lisp/font-core.el (font-lock-defaults): Remove SYNTAX-BEGIN from docstring. * doc/emacs/display.texi (Font Lock): Don't mention font-lock-beginning-of-syntax-function. * doc/lispref/modes.texi (Font Lock Basics): Update description of font-lock-defaults. (Syntactic Font Lock): Remove font-lock-beginning-of-syntax-function. * lisp/loadhist.el (unload-feature-special-hooks): Remove font-lock-beginning-of-syntax-function. * lisp/obsolete/lazy-lock.el (lazy-lock-fontify-region): * lisp/emacs-lisp/lisp.el (beginning-of-defun-raw): Don't let-bind font-lock-beginning-of-syntax-function. --- diff --git a/doc/emacs/display.texi b/doc/emacs/display.texi index 7b90e19991..7aef52d99d 100644 --- a/doc/emacs/display.texi +++ b/doc/emacs/display.texi @@ -854,7 +854,6 @@ and the default level otherwise, use the value '((c-mode . 1) (c++-mode . 1))) @end example -@vindex font-lock-beginning-of-syntax-function @cindex incorrect fontification @cindex parenthesis in column zero and fontification @cindex brace in column zero and fontification @@ -867,19 +866,6 @@ 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. -@cindex slow display during scrolling - The variable @code{font-lock-beginning-of-syntax-function}, which is -always buffer-local, specifies how Font Lock mode can find a position -guaranteed to be outside any comment or string. In modes which use -the leftmost column parenthesis convention, the default value of the -variable is @code{beginning-of-defun}---that tells Font Lock mode to -use the convention. If you set this variable to @code{nil}, Font Lock -no longer relies on the convention. This avoids incorrect results, -but the price is that, in some cases, fontification for a changed text -must rescan buffer text from the beginning of the buffer. This can -considerably slow down redisplay while scrolling, particularly if you -are close to the end of a large buffer. - @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/lispref/modes.texi b/doc/lispref/modes.texi index 8d7e29f9ee..a1747707d1 100644 --- a/doc/lispref/modes.texi +++ b/doc/lispref/modes.texi @@ -2527,7 +2527,7 @@ If non-@code{nil}, the value should look like this: @example (@var{keywords} [@var{keywords-only} [@var{case-fold} - [@var{syntax-alist} [@var{syntax-begin} @var{other-vars}@dots{}]]]]) + [@var{syntax-alist} @var{other-vars}@dots{}]]]) @end example The first element, @var{keywords}, indirectly specifies the value of @@ -2559,11 +2559,6 @@ fontification; the resulting syntax table is stored in @code{nil}, syntactic fontification uses the syntax table returned by the @code{syntax-table} function. @xref{Syntax Table Functions}. -The fifth element, @var{syntax-begin}, specifies the value of -@code{font-lock-beginning-of-syntax-function}. We recommend setting -this variable to @code{nil} and using @code{syntax-begin-function} -instead. - All the remaining elements (if any) are collectively called @var{other-vars}. Each of these elements should have the form @code{(@var{variable} . @var{value})}---which means, make @@ -3124,26 +3119,6 @@ is @code{nil}, syntactic fontification uses the buffer's syntax table Table Functions}). @end defvar -@defvar font-lock-beginning-of-syntax-function -If this variable is non-@code{nil}, it should be a function to move -point back to a position that is syntactically at top level and -outside of strings or comments. The value is normally set through an -@var{other-vars} element in @code{font-lock-defaults}. If it is -@code{nil}, Font Lock uses @code{syntax-begin-function} to move back -outside of any comment, string, or sexp (@pxref{Position Parse}). - -This variable is semi-obsolete; we usually recommend setting -@code{syntax-begin-function} instead. One of its uses is to tune the -behavior of syntactic fontification, e.g., to ensure that different -kinds of strings or comments are highlighted differently. - -The specified function is called with no arguments. It should leave -point at the beginning of any enclosing syntactic block. Typical values -are @code{beginning-of-line} (used when the start of the line is known -to be outside a syntactic block), or @code{beginning-of-defun} for -programming modes, or @code{backward-paragraph} for textual modes. -@end defvar - @defvar font-lock-syntactic-face-function If this variable is non-@code{nil}, it should be a function to determine which face to use for a given syntactic element (a string or a comment). diff --git a/etc/NEWS b/etc/NEWS index 49ce9b7eb0..b5c52e311e 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -856,6 +856,9 @@ a typographically-correct documents. * Incompatible Lisp Changes in Emacs 25.1 +** Removed font-lock-beginning-of-syntax-function and the SYNTAX-BEGIN +slot in font-lock-defaults. + +++ ** `package-initialize' now sets `package-enable-at-startup' to nil if called during startup. Users who call this function in their init diff --git a/lisp/emacs-lisp/lisp.el b/lisp/emacs-lisp/lisp.el index 7b7b48c66d..ca977db4b1 100644 --- a/lisp/emacs-lisp/lisp.el +++ b/lisp/emacs-lisp/lisp.el @@ -364,8 +364,7 @@ is called as a function to find the defun's beginning." (arg-+ve (> arg 0))) (save-restriction (widen) - (let ((ppss (let (syntax-begin-function - font-lock-beginning-of-syntax-function) + (let ((ppss (let (syntax-begin-function) (syntax-ppss))) ;; position of least enclosing paren, or nil. encl-pos) diff --git a/lisp/emacs-lisp/syntax.el b/lisp/emacs-lisp/syntax.el index 5101925494..fee62149b3 100644 --- a/lisp/emacs-lisp/syntax.el +++ b/lisp/emacs-lisp/syntax.el @@ -43,8 +43,6 @@ (eval-when-compile (require 'cl-lib)) -(defvar font-lock-beginning-of-syntax-function) - ;;; Applying syntax-table properties where needed. (defvar syntax-propertize-function nil @@ -503,11 +501,6 @@ running the hook." ;; - The function might be slow. ;; - If this function almost always finds a safe nearby spot, ;; the cache won't be populated, so consulting it is cheap. - (when (and (not syntax-begin-function) - (boundp 'font-lock-beginning-of-syntax-function) - font-lock-beginning-of-syntax-function) - (set (make-local-variable 'syntax-begin-function) - font-lock-beginning-of-syntax-function)) (when (and syntax-begin-function (progn (goto-char pos) (funcall syntax-begin-function) diff --git a/lisp/font-core.el b/lisp/font-core.el index 6d8588bfa3..2253204d9f 100644 --- a/lisp/font-core.el +++ b/lisp/font-core.el @@ -30,7 +30,7 @@ "Defaults for Font Lock mode specified by the major mode. Defaults should be of the form: - (KEYWORDS [KEYWORDS-ONLY [CASE-FOLD [SYNTAX-ALIST [SYNTAX-BEGIN ...]]]]) + (KEYWORDS [KEYWORDS-ONLY [CASE-FOLD [SYNTAX-ALIST ...]]]) KEYWORDS may be a symbol (a variable or function whose value is the keywords to use for fontification) or a list of symbols (specifying different levels @@ -45,20 +45,9 @@ If SYNTAX-ALIST is non-nil, it should be a list of cons pairs of the form \(CHAR-OR-STRING . STRING) used to set the local Font Lock syntax table, for keyword and syntactic fontification (see `modify-syntax-entry'). -If SYNTAX-BEGIN is non-nil, it should be a function with no args used to move -backwards outside any enclosing syntactic block, for syntactic fontification. -Typical values are `beginning-of-line' (i.e., the start of the line is known to -be outside a syntactic block), or `beginning-of-defun' for programming modes or -`backward-paragraph' for textual modes (i.e., the mode-dependent function is -known to move outside a syntactic block). If nil, the beginning of the buffer -is used as a position outside of a syntactic block, in the worst case. - -\(See also Info node `(elisp)Font Lock Basics'.) - These item elements are used by Font Lock mode to set the variables `font-lock-keywords', `font-lock-keywords-only', -`font-lock-keywords-case-fold-search', `font-lock-syntax-table' and -`font-lock-beginning-of-syntax-function', respectively. +`font-lock-keywords-case-fold-search', `font-lock-syntax-table'. Further item elements are alists of the form (VARIABLE . VALUE) and are in no particular order. Each VARIABLE is made buffer-local before set to VALUE. diff --git a/lisp/font-lock.el b/lisp/font-lock.el index cec95bf259..d93cf7184c 100644 --- a/lisp/font-lock.el +++ b/lisp/font-lock.el @@ -556,21 +556,6 @@ This is normally set via `font-lock-defaults'.") If this is nil, the major mode's syntax table is used. This is normally set via `font-lock-defaults'.") -(defvar font-lock-beginning-of-syntax-function nil - "Non-nil means use this function to move back outside all constructs. -When called with no args it should move point backward to a place which -is not in a string or comment and not within any bracket-pairs (or else, -a place such that any bracket-pairs outside it can be ignored for Emacs -syntax analysis and fontification). - -If this is nil, Font Lock uses `syntax-begin-function' to move back -outside of any comment, string, or sexp. This variable is semi-obsolete; -we recommend setting `syntax-begin-function' instead. - -This is normally set via `font-lock-defaults'.") -(make-obsolete-variable 'font-lock-beginning-of-syntax-function - 'syntax-begin-function "23.3" 'set) - (defvar font-lock-mark-block-function nil "Non-nil means use this function to mark a block of text. When called with no args it should leave point at the beginning of any @@ -1347,7 +1332,7 @@ no ARG is given and `font-lock-mark-block-function' is nil. If `font-lock-mark-block-function' non-nil and no ARG is given, it is used to delimit the region to fontify." (interactive "P") - (let ((inhibit-point-motion-hooks t) font-lock-beginning-of-syntax-function + (let ((inhibit-point-motion-hooks t) deactivate-mark) ;; Make sure we have the right `font-lock-keywords' etc. (if (not font-lock-mode) (font-lock-set-defaults)) @@ -1765,9 +1750,7 @@ If SYNTACTIC-KEYWORDS is non-nil, it means these keywords are used for (cons t (cons keywords (mapcar #'font-lock-compile-keyword keywords)))) (if (and (not syntactic-keywords) - (let ((beg-function - (or font-lock-beginning-of-syntax-function - syntax-begin-function))) + (let ((beg-function syntax-begin-function)) (or (eq beg-function 'beginning-of-defun) (get beg-function 'font-lock-syntax-paren-check))) (not beginning-of-defun-function)) @@ -1890,17 +1873,14 @@ Sets various variables using `font-lock-defaults' and (list (car selem)) (mapcar 'identity (car selem)))) (modify-syntax-entry char syntax font-lock-syntax-table))))) - ;; Syntax function for syntactic fontification? - (if (nth 4 defaults) - (set (make-local-variable 'font-lock-beginning-of-syntax-function) - (nth 4 defaults)) - (kill-local-variable 'font-lock-beginning-of-syntax-function)) + ;; (nth 4 defaults) used to hold `font-lock-beginning-of-syntax-function', + ;; but that was removed in 25.1, so if it's a cons cell, we assume that + ;; it's part of the variable alist. ;; Variable alist? - (dolist (x (nthcdr 5 defaults)) + (dolist (x (nthcdr (if (consp (nth 4 defaults)) 4 5) defaults)) (set (make-local-variable (car x)) (cdr x))) ;; Set up `font-lock-keywords' last because its value might depend - ;; on other settings (e.g. font-lock-compile-keywords uses - ;; font-lock-beginning-of-syntax-function). + ;; on other settings. (set (make-local-variable 'font-lock-keywords) (font-lock-eval-keywords keywords)) ;; Local fontification? diff --git a/lisp/jit-lock.el b/lisp/jit-lock.el index 8c798d5c4d..4e8fa7b15c 100644 --- a/lisp/jit-lock.el +++ b/lisp/jit-lock.el @@ -382,14 +382,6 @@ Defaults to the whole buffer. END can be out of bounds." (save-excursion (unless start (setq start (point-min))) (setq end (if end (min end (point-max)) (point-max))) - ;; This did bind `font-lock-beginning-of-syntax-function' to - ;; nil at some point, for an unknown reason. Don't do this; it - ;; can make highlighting slow due to expensive calls to - ;; `parse-partial-sexp' in function - ;; `font-lock-fontify-syntactically-region'. Example: paging - ;; from the end of a buffer to its start, can do repeated - ;; `parse-partial-sexp' starting from `point-min', which can - ;; take a long time in a large buffer. (let ((orig-start start) next) (save-match-data ;; Fontify chunks beginning at START. The end of a diff --git a/lisp/loadhist.el b/lisp/loadhist.el index 52fd04736f..4ea1bcb9f5 100644 --- a/lisp/loadhist.el +++ b/lisp/loadhist.el @@ -123,7 +123,6 @@ from a file." delete-frame-functions disabled-command-function fill-nobreak-predicate find-directory-functions find-file-not-found-functions - font-lock-beginning-of-syntax-function font-lock-fontify-buffer-function font-lock-fontify-region-function font-lock-mark-block-function diff --git a/lisp/obsolete/lazy-lock.el b/lisp/obsolete/lazy-lock.el index 79afd80813..d05a7d86db 100644 --- a/lisp/obsolete/lazy-lock.el +++ b/lisp/obsolete/lazy-lock.el @@ -892,8 +892,7 @@ verbosity is controlled via the variable `lazy-lock-stealth-verbose'." (save-excursion (save-match-data (save-buffer-state - ;; Ensure syntactic fontification is always correct. - (font-lock-beginning-of-syntax-function next) + (next) ;; Find successive unfontified regions between BEG and END. (condition-case data (do-while beg