* 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.
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.
extern bool equal_no_quit (Lisp_Object, Lisp_Object);
extern Lisp_Object nconc2 (Lisp_Object, Lisp_Object);
extern Lisp_Object assq_no_quit (Lisp_Object, Lisp_Object);
+extern Lisp_Object assq_no_signal (Lisp_Object, Lisp_Object);
extern Lisp_Object assoc_no_quit (Lisp_Object, Lisp_Object);
extern void clear_string_char_byte_cache (void);
extern ptrdiff_t string_char_to_byte (Lisp_Object, ptrdiff_t);
}
}
-/* Assq but doesn't signal. */
-static Lisp_Object
-safe_assq (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;
-}
-
/* Given a symbol THING, and a language symbol LANGUAGE, find the
corresponding predicate definition in treesit-things-settings.
Don't check for the type of THING and LANGUAGE.
static Lisp_Object
treesit_traverse_get_predicate (Lisp_Object thing, Lisp_Object language)
{
- Lisp_Object cons = safe_assq (language, Vtreesit_thing_settings);
+ Lisp_Object cons = assq_no_quit (language, Vtreesit_thing_settings);
if (NILP (cons))
return Qnil;
Lisp_Object definitions = XCDR (cons);
- Lisp_Object entry = safe_assq (thing, definitions);
+ Lisp_Object entry = assq_no_quit (thing, definitions);
if (NILP (entry))
return Qnil;
/* ENTRY looks like (THING PRED). */