I would like to be able to specify a theme or set of custom faces that are specific to a file that will be opened in org-mode
. Is there any way I can do that? I already have https://github.com/vic/color-theme-buffer-local but that doesn't provide a way to automatically apply it when a specific file opens.
An ideal solution would not involve hardcoding in my init.el, but would involve setting a variable or calling elisp in the loaded file (or a referenced setupfile).
For an example of why this would be useful, some files are very flat, and are more readable with one set of styles, and other files are deeply nested, and benefit from another set of styles.
The original poster has cited a particular library called
color-theme-buffer-local
( https://github.com/vic/color-theme-buffer-local ), which the original poster wants to apply to a file opened in the major-mode known asorg-mode
-- only if a certain variable ist
.The following example uses the code cited in the instructions for
color-theme-buffer-local
by calling the line of code:(load-theme-buffer-local 'misterioso (current-buffer))
The variablemy-favorite-variable
will control when the previous line of code is called when opening anorg-mode
buffer -- i.e., whennon-nil
it applies, whennil
it does not apply.EDIT (November 16, 2014): The following is a revised answer based upon the desire of the original poster to use file-local variables:
https://www.gnu.org/software/emacs/manual/html_node/emacs/Specifying-File-Variables.html#Specifying-File-Variables
http://www.gnu.org/software/emacs/manual/html_node/elisp/File-Local-Variables.html#File-Local-Variables
The behavior described by the original poster in the comment underneath this answer is due to the fact that the regular
org-mode-hook
is run before the file-local variables are taken into consideration. Therefore, the variablemy-favorite-variable
was stillnil
when theorg-mode-hook
ran its course (using the initial answer). The following revised answer uses thehack-local-variables-hook
, which runs after the file-local variables are taken into consideration.