I'd like my *scratch*
buffer to have it's own color theme, different to the one I use elsewhere, so that I know when I'm working there. How can I do this?
-
How about? github.com/vic/color-theme-buffer-local or melpa.org/#/load-theme-buffer-local See also, how to use buffer-local faces: emacs.stackexchange.com/a/7283/2287. And, see also, stackoverflow.com/a/28008006/2112489– lawlistCommented Jan 31, 2019 at 14:50
2 Answers
If you just want to put *scratch*
in its own frame and use special frame parameters for it (e.g. give it its own background color, font, or whatever) then you can do this just by doing these two things:
- Customize
special-display-alist
to have the frame parameters you want. - Customize
special-display-buffer-names
, adding*scratch*
to it.
In a comment you asked for code. No, the right way is to use Customize: M-x customize-option special-display-alist
, choosing what you want, then saving persistently. Likewise, M-x customize-option special-display-buffer-names
.
If the Customize UI is too complex for someone then they shouldn't be asking for code instead. ;-) That's my motto.
But since I'm an easy touch, here's a hint:
(add-to-list 'special-display-buffer-names "*scratch*")
(setq special-display-frame-alist (append '((foreground-color . "Brown")
(background-color . "LightBlue"))
special-display-frame-alist))
-
Help for the two
special-display-
variables indicates that they areobsolete since 24.3; use ‘display-buffer-alist’ instead
. Commented Feb 1, 2019 at 12:04 -
1Yeah, sure, go ahead and use
display-buffer-alist
(overkill) instead, if you're a masochist. ;-) I don't consider them to be obsolete - that deprecation is misguided, IMHO. And thank goodness they are still supported. If they do what you want, I say go for it - simpler is better. If, in some complex corner situation, they don't seem to do what you want, go fordisplay-buffer-alist
if you want. (They're sufficient for me, but what do I know?) Special-display is a simple, useful feature. Its goal is not the same as the much more general (and complex)display-buffer-alist
.– DrewCommented Feb 1, 2019 at 19:02
You could use an external package like https://github.com/vic/color-theme-buffer-local to accomplish this.
(use-package load-theme-buffer-local
:defer 2 ; You may not need this line, but was needed in my setup
:config
(load-theme-buffer-local 'misterioso (get-buffer "*scratch*")))
If you kill the scratch buffer and created a new one, the theme will be lost.