From: Yuan Fu Date: Sat, 24 Dec 2022 22:48:50 +0000 (-0800) Subject: ; Add treesit-no-parser error X-Git-Tag: emacs-29.0.90~1013 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=7f7def2ae62c80fa2fd0c73087b59060b303c230;p=emacs.git ; Add treesit-no-parser error * lisp/treesit.el (treesit-no-parser): New error. (treesit-buffer-root-node): Use the new error. --- 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)