1

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?

Tobias
  • 32,569
  • 1
  • 34
  • 75
  • 1
    `cl-loop` is from `cl-macs.el`. Have you tried adding `(require 'cl-macs)` before using `cl-loop`? – Aquaactress Feb 22 '20 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`](https://www.gnu.org/software/emacs/manual/html_node/cl/Organization.html). – Basil Feb 22 '20 at 19:04
  • That works. Aquaactress or Basil, maybe that should be an answer so I can accept it. Thanks! –  Feb 22 '20 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 '20 at 02:27
  • @Drew I think you meant to reference Basil. I was not the one who referenced that section. – Aquaactress Feb 23 '20 at 20:09
  • @Aquaactress: Yes, sorry. – Drew Feb 23 '20 at 22:16
  • @Basil: Sorry, I meant to reply to you, not Aquaactress. – Drew Feb 23 '20 at 22:16

1 Answers1

2

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))
Stefan
  • 26,154
  • 3
  • 46
  • 84