0

While writing tests for color-identifiers-mode I stumbled upon inability to make Emacs load background and foreground colors from a theme in "batch-mode".

Example:

emacs -batch --eval "(progn (load-theme 'adwaita) (print (face-attribute 'default :foreground)) (print (face-attribute 'default :background)))"

"unspecified-fg"

"unspecified-bg"

I presume that in a batch mode I need to flush font-lock, however doing all of the following after theme is loaded:

(font-lock-flush)
(font-lock-ensure)
(font-lock-fontify-buffer)

has no effect, it's still "unspecified-fg/bg".

So how do I make it load colors?

1 Answer 1

1

Emacs won't initialize the window system when launched by -batch:

When Emacs is started up, it performs the following operations:

If not running in batch mode, it initializes the window system that ...

If appropriate, it creates a graphical frame. As part of creating the graphical frame, it initializes the window system ... This is not done in batch (noninteractive) or daemon mode.

A workaround is to start Emacs normally and then let it make frames invisible or iconified.

4
  • Okay, thank you. I'll ask on ML then to make sure there's no way around. Starting Emacs as usual is something I definitely wouldn't want as part of testing.
    – Hi-Angel
    Commented Feb 13 at 14:38
  • @Hi-Angel: May I ask what ML is?
    – shynur
    Commented Feb 13 at 14:40
  • Sorry, I mean the mailing list
    – Hi-Angel
    Commented Feb 13 at 14:40
  • Asked it here, Eli replied, it seems like there's no way for that to work in batch mode.
    – Hi-Angel
    Commented Feb 15 at 16:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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