mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-04-07 06:41:00 -07:00
Support setopt-local in treesit--font-lock-level-setter (bug#80731)
* lisp/treesit.el (treesit--font-lock-level-setter): Add buffer-local behavior as invoked by 'setopt-local'.
This commit is contained in:
parent
5fdeb3c881
commit
86efaec00e
1 changed files with 22 additions and 12 deletions
|
|
@ -1423,21 +1423,31 @@ LANGUAGE is the language of QUERY.")
|
|||
(setf (nth 1 new-setting) t)
|
||||
new-setting))
|
||||
|
||||
(defun treesit--font-lock-level-setter (sym val)
|
||||
(defun treesit--font-lock-level-setter (sym val &optional buffer-local)
|
||||
"Custom setter for `treesit-font-lock-level'.
|
||||
Set the default value of SYM to VAL, recompute fontification
|
||||
features and refontify for every buffer where tree-sitter-based
|
||||
fontification is enabled."
|
||||
(set-default sym val)
|
||||
(when (treesit-available-p)
|
||||
(dolist (buffer (buffer-list))
|
||||
(with-current-buffer buffer
|
||||
;; FIXME: This doesn't re-run major mode hooks, meaning any
|
||||
;; customization done in major mode hooks (e.g., with
|
||||
;; `treesit-font-lock-recompute-features') is lost.
|
||||
(when treesit-font-lock-settings
|
||||
(treesit-font-lock-recompute-features)
|
||||
(font-lock-flush))))))
|
||||
fontification is enabled.
|
||||
|
||||
If optional BUFFER-LOCAL is non-nil, only affect the current buffer. Set
|
||||
SYM buffer locally and refontify."
|
||||
;; FIXME: This doesn't re-run major mode hooks, meaning any
|
||||
;; customization done in major mode hooks (e.g., with
|
||||
;; `treesit-font-lock-recompute-features') may be overridden.
|
||||
(cond (buffer-local
|
||||
(set-local sym val)
|
||||
(when (and (treesit-available-p)
|
||||
treesit-font-lock-settings)
|
||||
(treesit-font-lock-recompute-features)
|
||||
(font-lock-flush)))
|
||||
(t
|
||||
(set-default sym val)
|
||||
(when (treesit-available-p)
|
||||
(dolist (buffer (buffer-list))
|
||||
(with-current-buffer buffer
|
||||
(when treesit-font-lock-settings
|
||||
(treesit-font-lock-recompute-features)
|
||||
(font-lock-flush))))))))
|
||||
|
||||
(defcustom treesit-font-lock-level 3
|
||||
"Decoration level to be used by tree-sitter fontifications.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue