When defining `gv-expander` of `alist-get`, the following binding
specification seems to have a redundant `setq` form.
((set-exp
`(if ,p (setcdr ,p ,v)
,(funcall setter
`(cons (setq ,p (cons ,k ,v))
,getter)))))
Here `set-exp` expands to an s-_expression_ that updates the value
of an alist. `p` is a boolean that equals `(assq KEY ALIST)`
(or any other test function specified in the `alist-get` form).
`k` and `v` are KEY and VALUE respectively.
Evaluate `(macroexpand-all `(setf (alist-get key alist) value))` and
it returns the following:
(let* () ;; /* bindings omitted */
(progn
(if p
(setcdr p v)
(setq alist
(cons (setq p
(cons key v))
alist)))
v))
It seems to me that `(setq p ..)` is unnecessary, i.e. we can simply
use
(setq alist (cons (cons key v) alist)
This commit fixes that.
Signed-off-by: Lucius Hu <
lebensterben@users.noreply.github.com>
---
lisp/emacs-lisp/gv.el | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lisp/emacs-lisp/gv.el b/lisp/emacs-lisp/gv.el
index f08f7ac115..cf6cae4fd8 100644
--- a/lisp/emacs-lisp/gv.el
+++ b/lisp/emacs-lisp/gv.el
@@ -407,7 +407,7 @@ alist-get
(let ((set-exp
`(if ,p (setcdr ,p ,v)
,(funcall setter
- `(cons (setq ,p (cons ,k ,v))
+ `(cons (cons ,k ,v)
,getter)))))
`(progn
,(cond
--
2.32.0