How to Create a Temporary Function in Emacs Lisp

前端 未结 3 1064
北海茫月
北海茫月 2020-12-16 10:56

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

3条回答
  •  青春惊慌失措
    2020-12-16 11:26

    Do (require 'cl) to pull in the Common Lisp package, then use flet instead of let:

    (flet ((do-work (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))))
    

提交回复
热议问题