emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 0e01d5a: Preserve setf semantics in 'substring', 'cons', 'logand'


From: t?pn N?mec
Subject: master 0e01d5a: Preserve setf semantics in 'substring', 'cons', 'logand' expanders
Date: Tue, 25 Aug 2020 12:01:34 -0400 (EDT)

branch: master
commit 0e01d5aa723cd50749f9028f0e8ad85a3afe52aa
Author: Štěpán Němec <stepnem@gmail.com>
Commit: Štěpán Němec <stepnem@gmail.com>

    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 abcd4bb..94c8c88 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 7a26d9a..7a4d3c9 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 513bd32..78d86b9 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
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]