On today's episode, we again find ourselves admiring the cl package
and focus on a very little-known feature of Emacs, psetq. Short for
“parallel-setq”, it takes the same syntax as setq, but saves all
values before assigning.
For instance, if one needs to swap the variables old and new,
assuming you've required cl-lib, you can simply do the following.
And, of course, it has also been generalized to psetf for assigning
generalized places.
Update <2014-09-09 Tue>
Truth be told, psetq is more useful when your demands are more
sophisticated. When all you need is to swap two variables (or places),
the nice and quick solution is cl-rotatef.
Swaping Variables with cl-lib
07 Sep 2014, by Artur Malabarba.Common-Lisp in Emacs post series
On today's episode, we again find ourselves admiring the
cl
package and focus on a very little-known feature of Emacs,psetq
. Short for “parallel-setq”, it takes the same syntax assetq
, but saves all values before assigning.For instance, if one needs to swap the variables
old
andnew
, assuming you've requiredcl-lib
, you can simply do the following.And, of course, it has also been generalized to
psetf
for assigning generalized places.Update <2014-09-09 Tue>
Truth be told,
psetq
is more useful when your demands are more sophisticated. When all you need is to swap two variables (or places), the nice and quick solution iscl-rotatef
.Tags: lisp, emacs,
Launcher Keymap for Standalone Features »
« Quick update on narrow-or-widen-dwim
Related Posts
Eval-result-overlays in Emacs-lisp in lisp
Define context-aware keys in Emacs in lisp
Using prettify-symbols in Clojure and Elisp without breaking indentation in lisp
Content © 2019, All rights reserved. Icons under CC3.0.