3
votes

I would like to switch from 'solarized-dark (with my theme by default) to 'solarized-light when typing LATEX or Markdown. I'm using Emacs 24 and solarized from https://github.com/sellout/emacs-color-theme-solarized.

In my custom.el, I wrote the following lines :

(add-to-list 'custom-theme-load-path (make-plugin-path "color-theme-solarized"))
(load-theme 'solarized 1)

(add-hook 'markdown-mode-hook
      (lambda (frame)
        (set-frame-parameter frame 'background-mode 'light))
      )

But it doesn't work properly, i.e. loading a .md file does not make Emacs switch from 'dark to 'light solarized theme.

1
You want to look into buffer-local themes and face-remap-add-relative -- there are at least a few threads that already exist on this subject. - lawlist

1 Answers

2
votes

Try this:

(add-hook 'markdown-mode-hook
  (lambda ()
    (set-frame-parameter (window-frame) 'background-mode 'dark)
    (enable-theme 'solarized)))

The main changes are calling window-frame to get the current frame and then enable-theme to make it active.