【发布时间】:2016-05-07 03:49:22
【问题描述】:
我定义了这个宏:
(defmacro with-current-directory (directory &rest body)
"Set the working directory temporarily set to DIRECTORY and run BODY.
DIRECTORY is expanded"
`(let ((default-directory
,(file-name-as-directory
(expand-file-name (eval directory)))))
,@body))
我在一些在 emacs 打开时加载的 lisp 函数中使用它。我总是收到这些警告:
Eager macro-expansion failure: (void-variable repo-dir)
Eager macro-expansion failure: (wrong-type-argument stringp nil)
我理解这是因为这些变量在加载时没有定义,并且 emacs 正在尝试评估它们。我的问题是,如何避免收到这些警告。有没有办法定义宏,这样就不会发生?我不知道如何使用变量的值,而不是变量本身的符号。
【问题讨论】: