Is it possible to configure emacs so it uses different theme for tramp buffers than for defaults? Say, I use twilight by default, but while editing sth via ssh I'd like to switch to pastels-on-dark...
Changing colors are great at providing a feeling that ”something is different”…
This question in fact covers a few problems:
a) whether there is any natural way to use per-buffer theme (I failed to find one)
b) if not, what is the best way to hook emacs so it switches theme depending on the current buffer (so far I have preliminary solution I am not happy with, see below)
c) and, specifically, how to adapt that to tramp case
Note: I found load-theme-buffer-local. For some reason it does not work for me (once I call it on some buffer, the same theme remains active for every other buffer too).
Here is a partial solution for b) case I found some-time ago. I am not happy with it (it fires only when I open new file and does not react to buffer switch, it fails to revert to default in some cases, and it works only for per-dir-tree case), but maybe it could be improved:
;; in .emacs
(defvar my-local-theme nil
"Name of current theme (intended to be overriden where necessary)")
(defun my-set-local-theme ()
"If variable mkylocal-theme is set, loads this theme."
(interactive)
(when (bound-and-true-p my-local-theme)
(unless(member my-local-theme custom-enabled-themes)
(message "Setting local theme to %s on %s" my-local-theme (current-buffer))
(load-theme my-local-theme t))))
(add-hook 'hack-local-variables-hook 'my-set-local-theme)
;; In .dir-locals.el on top of some source tree
(
(nil
(my-local-theme . twilight-anti-bright)
))
For completeness: I also use the following trick to load themes cleanly, so the code above does not unload themes.
(add-hook 'after-init-hook
(lambda nil
(defadvice load-theme
(before theme-dont-propagate activate)
(mapcar #'disable-theme custom-enabled-themes))))