Commit 644c6b41 authored by Stefan Monnier's avatar Stefan Monnier

* 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.
parent 284c470e
......@@ -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
......
......@@ -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).
......
......@@ -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
......
......@@ -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)
......
......@@ -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)
......
......@@ -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.
......
......@@ -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?
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment