ELisp:“符号变量的值为void”的cl-loop [英] ELisp: cl-loop for "Symbol's value as variable is void"
本文介绍了ELisp:“符号变量的值为void”的cl-loop的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图使用(cl-loop for ..)
循环使用一个列表,但是我不断得到Symbol的值为void:mode当代码在启动时执行(并且使用 eval-buffer
),但在使用 eval-region
进行评估时不执行。
I'm trying to loop over a pair of lists using (cl-loop for ..)
but I keep getting "Symbol's value as variable is void: mode" when the code executes at startup (and with eval-buffer
), but not when evaluating it with 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))
如何解决这个问题?
推荐答案
结构对于任务来说不是最佳的,也就是说,它是一个麻烦的
来检查哪个文件对应于哪种模式。使用此代替:
Your data structures aren't optimal for the task, i.e. it's a bother to check which file corresponds to which mode. Use this instead:
(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)))
这篇关于ELisp:“符号变量的值为void”的cl-loop的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文