summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r--lisp/emacs-lisp/syntax.el15
1 files changed, 15 insertions, 0 deletions
diff --git a/lisp/emacs-lisp/syntax.el b/lisp/emacs-lisp/syntax.el
index 05dd7d57503..6c9cba3e563 100644
--- a/lisp/emacs-lisp/syntax.el
+++ b/lisp/emacs-lisp/syntax.el
@@ -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)