mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-07 23:10:28 -08:00
Make syntax.c call syntax-propertize on demand
* lisp/emacs-lisp/syntax.el (syntax--jit-propertize): New function. (parse-sexp-propertize-function): Use it. (syntax-propertize): Disable parse-sexp-propertize-function. * src/syntax.c (parse_sexp_propertize, update_syntax_table_forward): New functions. (syms_of_syntax): New vars `parse-sexp-propertize-done' and `parse-sexp-propertize-function'. * src/syntax.h (struct gl_state_s): Add `e_property_truncated' field. (UPDATE_SYNTAX_TABLE_FORWARD): Use update_syntax_table_forward. (SETUP_BUFFER_SYNTAX_TABLE): Set e_property_truncated. * lisp/progmodes/elisp-mode.el (elisp-byte-code-syntax-propertize): Don't assume `point' is set.
This commit is contained in:
parent
74baea086d
commit
ab21f61a55
5 changed files with 104 additions and 25 deletions
|
|
@ -297,7 +297,10 @@ The return value is a function suitable for `syntax-propertize-function'."
|
|||
(set (make-local-variable 'parse-sexp-lookup-properties) t)
|
||||
(save-excursion
|
||||
(with-silent-modifications
|
||||
(make-local-variable 'parse-sexp-propertize-done) ;Just in case!
|
||||
(let* ((start (max syntax-propertize--done (point-min)))
|
||||
;; Avoid recursion!
|
||||
(parse-sexp-propertize-done most-positive-fixnum)
|
||||
(end (max pos
|
||||
(min (point-max)
|
||||
(+ start syntax-propertize-chunk-size))))
|
||||
|
|
@ -324,6 +327,18 @@ The return value is a function suitable for `syntax-propertize-function'."
|
|||
'(syntax-table nil syntax-multiline nil))
|
||||
(funcall syntax-propertize-function start end))))))
|
||||
|
||||
;;; Link syntax-propertize with the new parse-sexp-propertize.
|
||||
|
||||
(setq-default parse-sexp-propertize-function #'syntax--jit-propertize)
|
||||
(defun syntax--jit-propertize (charpos)
|
||||
(if (not syntax-propertize-function)
|
||||
(setq parse-sexp-propertize-done (1+ (point-max)))
|
||||
(syntax-propertize charpos)
|
||||
(setq parse-sexp-propertize-done
|
||||
(if (= (point-max) syntax-propertize--done)
|
||||
(1+ (point-max))
|
||||
syntax-propertize--done))))
|
||||
|
||||
;;; Incrementally compute and memoize parser state.
|
||||
|
||||
(defsubst syntax-ppss-depth (ppss)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue