]> git.eshelyaron.com Git - emacs.git/commitdiff
Preserve setf semantics in 'substring', 'cons', 'logand' expanders
authorŠtěpán Němec <stepnem@gmail.com>
Sat, 11 Apr 2020 22:27:51 +0000 (00:27 +0200)
committerŠtěpán Němec <stepnem@gmail.com>
Tue, 25 Aug 2020 15:59:05 +0000 (17:59 +0200)
* 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
lisp/emacs-lisp/cl-lib.el
lisp/emacs-lisp/gv.el

index abcd4bbd0f786760e9bae1a3102321865c192cd3..94c8c88796f846521b1f85daeba62a7ad5d8d714 100644 (file)
@@ -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
 
index 7a26d9a90fd099d2af43ef5969cc6006d6e7d64d..7a4d3c9c3e31f8c2d47c2789e1e6c5a2a14ab1b6 100644 (file)
@@ -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.
 
index 513bd3288990824deb1118b86d55d9c143bb9362..78d86b9fc311f83c2ed558a775ee9e68e253d197 100644 (file)
@@ -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