diff options
author | Yuan Fu <casouri@gmail.com> | 2023-04-16 20:33:51 -0700 |
---|---|---|
committer | Yuan Fu <casouri@gmail.com> | 2023-04-16 20:33:51 -0700 |
commit | d005e685e1df7692085378633348db39a5190374 (patch) | |
tree | c12c2472fe53402ba341b0b518866aad34d6dc42 /src/fns.c | |
parent | 6c81ef4cf985dad908fc473f31c0daf662fd2dad (diff) | |
download | emacs-d005e685e1df7692085378633348db39a5190374.tar.gz |
New helper function assq_no_signal
* src/fns.c (assq_no_signal): New function.
* src/lisp.h (assoc_no_signal): Declare it.
* src/treesit.c (safe_assq): Remove function.
(treesit_traverse_get_predicate): Change safe_assq to assq_no_signal.
Diffstat (limited to 'src/fns.c')
-rw-r--r-- | src/fns.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/fns.c b/src/fns.c index e92ef7e4c81..75acb6f4598 100644 --- a/src/fns.c +++ b/src/fns.c @@ -1966,6 +1966,20 @@ assq_no_quit (Lisp_Object key, Lisp_Object alist) return Qnil; } +/* Assq but doesn't signal. Unlike assq_no_quit, this function still + detect circular lists; like assq_no_quit, this function does not + allow quits and never signals. If anything goes wrong, it returns + Qnil. */ +Lisp_Object +assq_no_signal (Lisp_Object key, Lisp_Object alist) +{ + Lisp_Object tail = alist; + FOR_EACH_TAIL_SAFE (tail) + if (CONSP (XCAR (tail)) && EQ (XCAR (XCAR (tail)), key)) + return XCAR (tail); + return Qnil; +} + DEFUN ("assoc", Fassoc, Sassoc, 2, 3, 0, doc: /* Return non-nil if KEY is equal to the car of an element of ALIST. The value is actually the first element of ALIST whose car equals KEY. |