我正在尝试使用(cl-loop for ..)
遍历一对列表,但是当代码在启动时执行时(以及使用eval-buffer
),我一直得到“符号的值作为变量为void:mode”,但在用eval-region
进行评估时却没有。
;; clean up the modeline
(require 'diminish)
(defmacro diminish-after-load (file mode)
"After loading FILE, execute `diminish' on MODE."
`(eval-after-load ,file '(diminish ,mode)))
(require 'cl-lib)
(cl-loop for file in '("eldoc" "rainbow-mode" "hideshow" "flyspell"
"undo-tree" "whitespace" "smartparens" "auto-complete")
for mode in '(eldoc-mode rainbow-mode hs-minor-mode
flyspell-mode undo-tree-mode whitespace-mode
smartparens-mode auto-complete-mode)
do (diminish-after-load file mode))
我该如何解决这个问题?
答案 0 :(得分:1)
您的数据结构对于任务来说不是最佳的,即它很麻烦 检查哪个文件对应哪种模式。请改用:
(mapc
(lambda (x)
(diminish-after-load (car x) (cdr x)))
'(("eldoc" . eldoc-mode) ("rainbow-mode" . rainbow-mode)
("hideshow" . hs-minor-mode) ("flyspell" . flyspell-mode)
("undo-tree" . undo-tree-mode) ("whitespace" . whitespace-mode)
("smartparens" . smartparens-mode) ("auto-complete" . auto-complete-mode)))