From 90fcc412e85716ff348c3cc6fdcc06eb08b1f6ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0t=C4=9Bp=C3=A1n=20N=C4=9Bmec?= Date: Sun, 12 Apr 2020 00:27:51 +0200 Subject: [PATCH] Preserve setf semantics in 'substring', 'cons', 'logand' expanders * doc/lispref/variables.texi (Adding Generalized Variables): Fix example. * lisp/emacs-lisp/cl-lib.el (substring) * lisp/emacs-lisp/gv.el (cons, logand): Return the value being assigned, as specified for 'setf'. (bug#35546) --- doc/lispref/variables.texi | 7 +++++-- lisp/emacs-lisp/cl-lib.el | 7 +++++-- lisp/emacs-lisp/gv.el | 18 ++++++++++++------ 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/doc/lispref/variables.texi b/doc/lispref/variables.texi index abcd4bbd0f..94c8c88796 100644 --- a/doc/lispref/variables.texi +++ b/doc/lispref/variables.texi @@ -2585,8 +2585,11 @@ Adding Generalized Variables (macroexp-let2* nil ((start from) (end to)) (funcall do `(substring ,getter ,start ,end) (lambda (v) - (funcall setter `(cl--set-substring - ,getter ,start ,end ,v)))))))) + (macroexp-let2 nil v v + `(progn + ,(funcall setter `(cl--set-substring + ,getter ,start ,end ,v)) + ,v)))))))) @end example @end defmac diff --git a/lisp/emacs-lisp/cl-lib.el b/lisp/emacs-lisp/cl-lib.el index 7a26d9a90f..7a4d3c9c3e 100644 --- a/lisp/emacs-lisp/cl-lib.el +++ b/lisp/emacs-lisp/cl-lib.el @@ -619,8 +619,11 @@ substring (macroexp-let2* nil ((start from) (end to)) (funcall do `(substring ,getter ,start ,end) (lambda (v) - (funcall setter `(cl--set-substring - ,getter ,start ,end ,v)))))))) + (macroexp-let2 nil v v + `(progn + ,(funcall setter `(cl--set-substring + ,getter ,start ,end ,v)) + ,v)))))))) ;;; Miscellaneous. diff --git a/lisp/emacs-lisp/gv.el b/lisp/emacs-lisp/gv.el index 065a968877..aa1516cc5e 100644 --- a/lisp/emacs-lisp/gv.el +++ b/lisp/emacs-lisp/gv.el @@ -517,9 +517,12 @@ gv-delay-error (gv-letplace (dgetter dsetter) d (funcall do `(cons ,agetter ,dgetter) - (lambda (v) `(progn - ,(funcall asetter `(car ,v)) - ,(funcall dsetter `(cdr ,v))))))))) + (lambda (v) + (macroexp-let2 nil v v + `(progn + ,(funcall asetter `(car ,v)) + ,(funcall dsetter `(cdr ,v)) + ,v)))))))) (put 'logand 'gv-expander (lambda (do place &rest masks) @@ -529,9 +532,12 @@ gv-delay-error (funcall do `(logand ,getter ,mask) (lambda (v) - (funcall setter - `(logior (logand ,v ,mask) - (logand ,getter (lognot ,mask)))))))))) + (macroexp-let2 nil v v + `(progn + ,(funcall setter + `(logior (logand ,v ,mask) + (logand ,getter (lognot ,mask)))) + ,v)))))))) ;;; References -- 2.26.0