I wanted to use assq-delete-all to remove all elements in an alist whose car matched a string.
(setq temp-alist '(("a" . 1) ("b" . 2)))
(defun assq-delete-all-string (key-str alist)
"Delete from ALIST all elements whose car is a string and matches KEY-STR.
Return the modified alist.
Elements of ALIST that are not conses are ignored."
(while (and (consp (car alist))
(string= (car (car alist)) key-str))
(setq alist (cdr alist)))
(let ((tail alist) tail-cdr)
(while (setq tail-cdr (cdr tail))
(if (and (consp (car tail-cdr))
(string= (car (car tail-cdr)) key-str))
(setcdr tail (cdr tail-cdr))
(setq tail tail-cdr))))
alist)
Can the assq-delete-all be updated to use string= when the KEY type is string and eq otherwise (if those two cases cover everything?)
In general I am requesting assq-delete-all to use
- `string=` if KEY is string
- `SOME-OTHER-FN` if KEY is SOME-OTHER-TYPE
- `eq` otherwise