我有一个语句想包装成宏。语句是这样的:
(add-hook 'evil-normal-state-entry-hook
(lambda ()
(set-face-attribute 'cursor nil :background moon-normal-state-cursor-color)
))
就是进入normal state的时候光标颜色换成指定的颜色
我写成宏是这样的
(defmacro change-cursor-on-hook| (hook color)
`(add-hook 'hook (lambda ()
(set-face-attribute 'cursor nil :background color)
))
)
然而
(change-cursor-on-hook| evil-insert-state-entry-hook doom-blue)
以后什么都没有发生(语句是有效果的)
Message buffer里把宏打印出来了
((lambda nil (set-face-attribute (quote cursor) nil :background color)) (closure ((color . doom-blue) (hook quote evil-insert-state-entry-hook) t) nil (set-face-attribute (quote cursor) nil :background color)) (closure (t) nil (set-face-attribute (quote cursor) nil :background color)))
如果我把反引号删了,执行宏就会报错“
Debugger entered--Lisp error: (void-function closure)
(closure ((color . doom-blue) (hook quote evil-insert-state-entry-hook) t) nil (set-face-attribute 'cursor nil :background color))
((closure ((color . doom-blue) (hook . evil-insert-state-entry-hook) t) nil (set-face-attribute 'cursor nil :background color)) (function (lambda nil (set-face-attribute 'cursor nil :background color))) (closure ((color . doom-blue) (hook quote evil-insert-state-entry-hook) t) nil (set-face-attribute 'cursor nil :background color)) (closure (t) nil (set-face-attribute 'cursor nil :background color)))
eval(((closure ((color . doom-blue) (hook . evil-insert-state-entry-hook) t) nil (set-face-attribute 'cursor nil :background color)) (function (lambda nil (set-face-attribute 'cursor nil :background color))) (closure ((color . doom-blue) (hook quote evil-insert-state-entry-hook) t) nil (set-face-attribute 'cursor nil :background color)) (closure (t) nil (set-face-attribute 'cursor nil :background color))) t)
我没明白是哪出了问题。谁能指点一下我吗。