summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuan Fu <casouri@gmail.com>2022-12-24 14:48:50 -0800
committerYuan Fu <casouri@gmail.com>2022-12-24 18:43:03 -0800
commit7f7def2ae62c80fa2fd0c73087b59060b303c230 (patch)
treeeb45038875c4ae51d5e5e98c0c9204efdc92d56e
parentb6a2e1ddf664513d04026f7b9d78e9c65f1a3e2e (diff)
downloademacs-7f7def2ae62c80fa2fd0c73087b59060b303c230.tar.gz
emacs-7f7def2ae62c80fa2fd0c73087b59060b303c230.tar.bz2
emacs-7f7def2ae62c80fa2fd0c73087b59060b303c230.zip
; Add treesit-no-parser error
* lisp/treesit.el (treesit-no-parser): New error. (treesit-buffer-root-node): Use the new error.
-rw-r--r--lisp/treesit.el12
1 files changed, 7 insertions, 5 deletions
diff --git a/lisp/treesit.el b/lisp/treesit.el
index 845e6ab3883..3d9c61b9dc9 100644
--- a/lisp/treesit.el
+++ b/lisp/treesit.el
@@ -141,6 +141,9 @@ parser in `treesit-parser-list', or nil if there is no parser."
;;; Node API supplement
+(define-error 'treesit-no-parser "No available parser for this buffer"
+ 'treesit-error)
+
(defun treesit-node-buffer (node)
"Return the buffer in which NODE belongs."
(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
for LANGUAGE."
(if-let ((parser
- (or (if language
- (treesit-parser-create language)
- (or (car (treesit-parser-list))
- (signal 'treesit-error
- '("Buffer has no parser")))))))
+ (if language
+ (treesit-parser-create language)
+ (or (car (treesit-parser-list))
+ (signal 'treesit-no-parser (list (current-buffer)))))))
(treesit-parser-root-node parser)))
(defun treesit-filter-child (node pred &optional named)