[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
emacs-30 3c7687c1dd1 1/2: Allow passing nil to treesit-node-match-p (bug
From: |
Yuan Fu |
Subject: |
emacs-30 3c7687c1dd1 1/2: Allow passing nil to treesit-node-match-p (bug#74612) |
Date: |
Sun, 1 Dec 2024 14:43:40 -0500 (EST) |
branch: emacs-30
commit 3c7687c1dd136fa535e22262f78fdfadbbf73105
Author: Yuan Fu <casouri@gmail.com>
Commit: Yuan Fu <casouri@gmail.com>
Allow passing nil to treesit-node-match-p (bug#74612)
* src/treesit.c (Ftreesit_node_match_p): Return nil if NODE is nil.
---
src/treesit.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/treesit.c b/src/treesit.c
index 4031d80f7c9..cda6d4af2ee 100644
--- a/src/treesit.c
+++ b/src/treesit.c
@@ -4017,7 +4017,8 @@ PREDICATE can be a symbol representing a thing in
`treesit-thing-settings', or a predicate, like regexp matching node
type, etc. See `treesit-thing-settings' for more details.
-Return non-nil if NODE matches PREDICATE, nil otherwise.
+Return non-nil if NODE matches PREDICATE, nil otherwise. If NODE is
+nil, return nil.
Signals `treesit-invalid-predicate' if there's no definition of THING
in `treesit-thing-settings', or if PREDICATE is malformed. If
@@ -4025,6 +4026,8 @@ IGNORE-MISSING is non-nil, don't signal an error for
missing THING
definition, but still signal for malformed PREDICATE. */)
(Lisp_Object node, Lisp_Object predicate, Lisp_Object ignore_missing)
{
+ if (NILP (node)) return Qnil;
+
CHECK_TS_NODE (node);
Lisp_Object parser = XTS_NODE (node)->parser;