0

I'm trying to turn off all colored text when using gnu emacs as emacs -nw on linux. This answer gives a snippet of code to use for this purpose:

(cl-loop for face in (face-list) do
     (set-face-attribute face nil :foreground nil :background nil))

However, when I put this in my .emacs file, I get this error:

Symbol's function definition is void: cl-loop

How do I fix this?

  • 1
    cl-loop is from cl-macs.el. Have you tried adding (require 'cl-macs) before using cl-loop? – Aquaactress Feb 22 at 18:58
  • 3
    @Aquaactress cl-macs.el is an internal subpackage of the package cl-lib.el. You should always (require 'cl-lib) or (eval-when-compile (require 'cl-lib)) instead. See (cl) Organization. – Basil Feb 22 at 19:04
  • That works. Aquaactress or Basil, maybe that should be an answer so I can accept it. Thanks! – Ben Crowell Feb 22 at 19:05
  • @Aquaactress: I don't see that the manual section you point to says that cl-macs.el is "an internal subpackage" or that "you should always...". What it says is that you can just load cl-lib.el to get the macros (and a bunch of other stuff) autoloaded. If you only need a macro for byte-compilation I see no reason why you would necessarily want to load all that's in cl-lib.el. Of course there's nothing wrong with loading cl-lib.el, and yes, it's generally what people do who want some of its functionality. – Drew Feb 23 at 2:27
  • @Drew I think you meant to reference Basil. I was not the one who referenced that section. – Aquaactress Feb 23 at 20:09
3

The direct solution is to (require 'cl-lib) somewhere, but this is a trivial enough loop that Emacs comes with a macro specifically for it, without needing cl-lib:

(dolist (face (face-list))
  (set-face-attribute face nil :foreground nil :background nil))
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.