Don't flush the syntax-ppss cache unless necessary.

master
Fanael Linithien 12 years ago
parent f91b36bad7
commit 4bac5ce118
  1. 28
      rainbow-delimiters.el

@ -255,17 +255,23 @@ Used by font-lock for dynamic highlighting."
(when rainbow-delimiters-mode (when rainbow-delimiters-mode
(font-lock-add-keywords nil rainbow-delimiters--font-lock-keywords 'append) (font-lock-add-keywords nil rainbow-delimiters--font-lock-keywords 'append)
(set (make-local-variable 'jit-lock-contextually) t) (set (make-local-variable 'jit-lock-contextually) t)
;; `syntax-begin-function' may break the assumption we rely on that (let ((flush-needed nil))
;; `syntax-ppss' is exactly equivalent to `parse-partial-sexp' from (when syntax-begin-function
;; `point-min'. Just don't use it, the performance hit should be negligible. ;; `syntax-begin-function' may break the assumption we rely on that
(set (make-local-variable 'syntax-begin-function) nil) ;; `syntax-ppss' is exactly equivalent to `parse-partial-sexp' from
;; Obsolete equivalent of `syntax-begin-function'. ;; `point-min'. Just don't use it, the performance hit should be
(when (boundp 'font-lock-beginning-of-syntax-function) ;; negligible.
(with-no-warnings (setq flush-needed t)
(set (make-local-variable 'font-lock-beginning-of-syntax-function) nil))) (set (make-local-variable 'syntax-begin-function) nil))
;; We modified `syntax-begin-function', so flush the cache to avoid getting ;; Obsolete equivalent of `syntax-begin-function'.
;; cached values that used the old value. (when (bound-and-true-p font-lock-beginning-of-syntax-function)
(syntax-ppss-flush-cache 0)) (setq flush-needed t)
(with-no-warnings
(set (make-local-variable 'font-lock-beginning-of-syntax-function) nil)))
(when flush-needed
;; We modified `syntax-begin-function', so flush the cache to avoid
;; getting cached values that used the old value.
(syntax-ppss-flush-cache 0))))
(when font-lock-mode (when font-lock-mode
(if (fboundp 'font-lock-flush) (if (fboundp 'font-lock-flush)
(font-lock-flush) (font-lock-flush)

Loading…
Cancel
Save