ELisp: cl-loop for "The value of a character as a variable is invalid"

I try to iterate over a couple of lists using (cl-loop for ..) , but I continue to get the value "Symbol" as the variable void: mode "when the code starts 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)) 

How to fix it?

+1
source share
1 answer

Your data structures are not optimal for the task, i.e. to check which file matches 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))) 
+1
source

All Articles