Different color themes for each mode in Emacs

How can I ask Emacs to automatically use a different color theme (for example, using the Elisp ColorTheme package) depending on the mode buffers ?

Some color themes work fine when editing code, but not in Dired +, TERM, or shell mode.

thanks

+11
source share
5 answers

It seems that you cannot set separate color themes for different buffers, but you can set it for different frames. Instructions for setting color themes in the frame can be found here http://www.emacswiki.org/emacs/ColorTheme#toc8 .

You can use load-hook to automatically change the color theme when loading a mode, but it will apply the change to all buffers.

You can change the color theme when the mode is loaded using the loading hook. eg.

(add-hook 'dired-mode-hook 'color-theme-emacs-nw) 

Edit: here is a function that opens a shell in a new frame using a different color theme:

 (defun my-shell () (interactive) (let ((color-theme-is-global nil)) (select-frame (make-frame)) (color-theme-gnome) (shell))) 
+12
source

The load-theme-buffer-local (or color-theme-buffer-local.el if you are using pre emacs 24 themes) can set different faces on the buffer. However, your background remains the same.

You can connect it like this:
(add-hook 'js2-mode-hook (lambda nil (load-theme-buffer-local 'tango (current-buffer))))

Packages are available on MELPA ( Mx install-package RET load-theme-buffer-local ), source and readme for github

+7
source

I use zenburn colors and

 (setq font-lock-maximum-decoration (quote ((dired-mode . nil) (t . t)))) 

didn't work for me but

 (setq font-lock-maximum-decoration (quote ((dired-mode) (t . t)))) 

works great with the dired + version released on 2011/01/04.

+4
source

I faced the same problem in the past with unreadable reloaded buffers in the terminal. As a workaround, I made Mx customize-option font-lock-maximum-decoration; you can also set the variable directly in the configuration file, for example. (setq font-lock-maximum-decoration (quote ((dired-mode . nil) (t . t)))) . This uses the default scenery for dired and the maximum for everything else (this was the default setting). See Ch v font-lock-maximum-decoration for more details.

This doesn’t exactly answer the question - I don’t know if color themes can be used in each buffer or in mode, but this can help solve the main problem.

+1
source

You can use per-buffer-theme.el . This is my configuration:

 (require 'per-buffer-theme) (setq per-buffer-theme/use-timer nil) ; Set it to t if the window flickers. (setq per-buffer-theme/default-theme 'notheme) (setq per-buffer-theme/ignored-buffernames-regex (append '("*anaconda-mode*" "*Backtrace*" "*Buffer List*" "*compilation*" "*Compile-Log*" "*Completions*" "*ESS*" "*Flymake log*" "*Help*" "*Ibuffer" "*info*" "*Messages*" "*Warnings*") per-buffer-theme/ignored-buffernames-regex)) (setq per-buffer-theme/themes-alist '(((:theme . dichromacy) (:buffernames nil) (:modes ess-mode inferior-ess-mode python-mode inferior-python-mode)) ((:theme . solarized) (:buffernames nil) (:modes latex-mode)))) (per-buffer-theme/enable) 

For each theme that you want to use, in the per-buffer-theme/themes-alist list, you can specify the modes and buffer names for loading this theme. If there are no rules for a particular combination of buffer name and main mode, per-buffer-theme load per-buffer-theme/default-theme .

+1
source

All Articles