How to Create a Temporary Function in Emacs Lisp
- by Cristian
I'm making some tedious calls to a bunch of functions, but the parameters will be determined at runtime. I wrote a simple function to keep my code DRY but giving it a name is unnecessary. I don't use this function anywhere else.
I'm trying to do it the way I would in Scheme, but I get a void-function error:
(let ((do-work (lambda (x y z)
(do-x x)
(do-y y)
;; etc
)))
(cond (test-1 (do-work 'a 'b 'c))
(test-2 (do-work 'i 'j 'k))))
I could stick it all into an apply (e.g., (apply (lambda ...) (cond ...))) but that isn't very readable. Is there a better way?