1844 |
"(shiftf PLACE PLACE... VAL): shift left among PLACEs. |
"(shiftf PLACE PLACE... VAL): shift left among PLACEs. |
1845 |
Example: (shiftf A B C) sets A to B, B to C, and returns the old A. |
Example: (shiftf A B C) sets A to B, B to C, and returns the old A. |
1846 |
Each PLACE may be a symbol, or any generalized variable allowed by `setf'." |
Each PLACE may be a symbol, or any generalized variable allowed by `setf'." |
1847 |
(if (not (memq nil (mapcar 'symbolp (butlast (cons place args))))) |
(cond |
1848 |
(list 'prog1 place |
((null args) place) |
1849 |
(let ((sets nil)) |
((symbolp place) `(prog1 ,place (setq ,place (shiftf ,@args)))) |
1850 |
(while args |
(t |
1851 |
(cl-push (list 'setq place (car args)) sets) |
(let ((method (cl-setf-do-modify place 'unsafe))) |
1852 |
(setq place (cl-pop args))) |
`(let* ,(car method) |
1853 |
`(setq ,(cadar sets) |
(prog1 ,(nth 2 method) |
1854 |
(prog1 ,(caddar sets) |
,(cl-setf-do-store (nth 1 method) `(shiftf ,@args)))))))) |
|
,@(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))) |
|
1855 |
|
|
1856 |
(defmacro rotatef (&rest args) |
(defmacro rotatef (&rest args) |
1857 |
"(rotatef PLACE...): rotate left among PLACEs. |
"(rotatef PLACE...): rotate left among PLACEs. |