mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-06 06:20:55 -08:00
; Add treesit-no-parser error
* lisp/treesit.el (treesit-no-parser): New error. (treesit-buffer-root-node): Use the new error.
This commit is contained in:
parent
b6a2e1ddf6
commit
7f7def2ae6
1 changed files with 7 additions and 5 deletions
|
|
@ -141,6 +141,9 @@ parser in `treesit-parser-list', or nil if there is no parser."
|
||||||
|
|
||||||
;;; Node API supplement
|
;;; Node API supplement
|
||||||
|
|
||||||
|
(define-error 'treesit-no-parser "No available parser for this buffer"
|
||||||
|
'treesit-error)
|
||||||
|
|
||||||
(defun treesit-node-buffer (node)
|
(defun treesit-node-buffer (node)
|
||||||
"Return the buffer in which NODE belongs."
|
"Return the buffer in which NODE belongs."
|
||||||
(treesit-parser-buffer
|
(treesit-parser-buffer
|
||||||
|
|
@ -248,11 +251,10 @@ Use the first parser in `treesit-parser-list'.
|
||||||
If optional argument LANGUAGE is non-nil, use the first parser
|
If optional argument LANGUAGE is non-nil, use the first parser
|
||||||
for LANGUAGE."
|
for LANGUAGE."
|
||||||
(if-let ((parser
|
(if-let ((parser
|
||||||
(or (if language
|
(if language
|
||||||
(treesit-parser-create language)
|
(treesit-parser-create language)
|
||||||
(or (car (treesit-parser-list))
|
(or (car (treesit-parser-list))
|
||||||
(signal 'treesit-error
|
(signal 'treesit-no-parser (list (current-buffer)))))))
|
||||||
'("Buffer has no parser")))))))
|
|
||||||
(treesit-parser-root-node parser)))
|
(treesit-parser-root-node parser)))
|
||||||
|
|
||||||
(defun treesit-filter-child (node pred &optional named)
|
(defun treesit-filter-child (node pred &optional named)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue