From: Štěpán Němec Date: Sat, 11 Apr 2020 22:27:51 +0000 (+0200) Subject: Preserve setf semantics in 'substring', 'cons', 'logand' expanders X-Git-Tag: emacs-28.0.90~6407 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=0e01d5aa723cd50749f9028f0e8ad85a3afe52aa;p=emacs.git 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) --- diff --git a/doc/lispref/variables.texi b/doc/lispref/variables.texi index abcd4bbd0f7..94c8c88796f 100644 --- a/doc/lispref/variables.texi +++ b/doc/lispref/variables.texi @@ -2585,8 +2585,11 @@ implemented this way: (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 7a26d9a90fd..7a4d3c9c3e3 100644 --- a/lisp/emacs-lisp/cl-lib.el +++ b/lisp/emacs-lisp/cl-lib.el @@ -619,8 +619,11 @@ If ALIST is non-nil, the new pairs are prepended to it." (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 513bd328899..78d86b9fc31 100644 --- a/lisp/emacs-lisp/gv.el +++ b/lisp/emacs-lisp/gv.el @@ -527,9 +527,12 @@ This macro only makes sense when used in a place." (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) @@ -539,9 +542,12 @@ This macro only makes sense when used in a place." (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