Create a new account
Today's inane new elisp macro of mine:
(defmacro ++ (x)
"increment the value of symbol X, returning the new value"
`(setq ,x (1+ ,x))
is a handy shorthand that expands to this:
(setq lines (1+ lines))
; returns new value of the variable
Oh, I didn't think of that! I was only thinking of passing in a symbol constant. But now I see what you mean. [emacswiki.org]
As to the general hardness of Lisp macros: I'm glad it's not just me that thinks that.
Maybe there's just some kind of magic syntax-highlighty thing in (e)lisp mode that will turn on all the happy macro easiness or something.
Emacs is a pathless land.
See also the incf macro from cl.el:
(incf x)(incf (car x))(incf x 23)
It's definitely too hard to write such things from scratch in Lisp. cl.el also has callf and define-modify-macro macros which help somewhat.
Get More Comments