changeset 41695:73a58db610c2

(shiftf): Fix more. Simplify.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Fri, 30 Nov 2001 08:22:46 +0000
parents 835717f56bf2
children 4f66d5b614de
files lisp/emacs-lisp/cl-macs.el
diffstat 1 files changed, 8 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/emacs-lisp/cl-macs.el	Fri Nov 30 01:13:59 2001 +0000
+++ b/lisp/emacs-lisp/cl-macs.el	Fri Nov 30 08:22:46 2001 +0000
@@ -1844,23 +1844,14 @@
   "(shiftf PLACE PLACE... VAL): shift left among PLACEs.
 Example: (shiftf A B C) sets A to B, B to C, and returns the old A.
 Each PLACE may be a symbol, or any generalized variable allowed by `setf'."
-  (if (not (memq nil (mapcar 'symbolp (butlast (cons place args)))))
-      (list 'prog1 place
-	    (let ((sets nil))
-	      (while args
-		(cl-push (list 'setq place (car args)) sets)
-		(setq place (cl-pop args)))
-	      `(setq ,(cadar sets)
-		     (prog1 ,(caddar sets)
-		       ,@(nreverse (cdr sets))))))
-    (let* ((places (reverse (cons place args)))
-	   (form (cl-pop places)))
-      (while places
-	(let ((method (cl-setf-do-modify (cl-pop places) 'unsafe)))
-	  (setq form (list 'let* (car method)
-			   (list 'prog1 (nth 2 method)
-				 (cl-setf-do-store (nth 1 method) form))))))
-      form)))
+  (cond
+   ((null args) place)
+   ((symbolp place) `(prog1 ,place (setq ,place (shiftf ,@args))))
+   (t
+    (let ((method (cl-setf-do-modify place 'unsafe)))
+      `(let* ,(car method)
+	 (prog1 ,(nth 2 method)
+	   ,(cl-setf-do-store (nth 1 method) `(shiftf ,@args))))))))
 
 (defmacro rotatef (&rest args)
   "(rotatef PLACE...): rotate left among PLACEs.