diff --git a/_posts/2016-02-23-org-publish-with-theme.html b/_posts/2016-02-23-org-publish-with-theme.html new file mode 100644 index 0000000..38687df --- /dev/null +++ b/_posts/2016-02-23-org-publish-with-theme.html @@ -0,0 +1,32 @@ +--- +title: "Use a different theme when publishing Org files" +author: "Correl Roush" +tags: emacs org-mode themes +--- +
+I've been using material-theme lately, and I sometimes switch around, +but I've found that solarized produces the best exported code block +results. To avoid having to remember to switch themes when exporting, +I wrote a quick wrapper for org-export to do it for me: +
+ +(defun my/with-theme (theme fn &rest args) + (let ((current-themes custom-enabled-themes)) + (mapcar #'disable-theme custom-enabled-themes) + (load-theme theme t) + (let ((result (apply fn args))) + (mapcar #'disable-theme custom-enabled-themes) + (mapcar (lambda (theme) (load-theme theme t)) current-themes) + result))) + +(advice-add #'org-export-to-file :around (apply-partially #'my/with-theme 'solarized-dark)) +(advice-add #'org-export-to-buffer :around (apply-partially #'my/with-theme 'solarized-dark)) ++
+VoilĂ , no more bizarrely formatted code block exports from whatever +theme I might have loaded at the time :) +
diff --git a/_posts/2016-02-23-org-publish-with-theme.org b/_posts/2016-02-23-org-publish-with-theme.org new file mode 100644 index 0000000..243cebc --- /dev/null +++ b/_posts/2016-02-23-org-publish-with-theme.org @@ -0,0 +1,28 @@ +#+TITLE: Use a different theme when publishing Org files +#+AUTHOR: Correl Roush +#+STARTUP: indent inlineimages showall hideblocks +#+OPTIONS: toc:nil num:nil +#+PROPERTY: header-args :exports both :results silent +#+KEYWORDS: emacs org-mode themes + +I've been using [[https://github.com/cpaulik/emacs-material-theme][material-theme]] lately, and I sometimes switch around, +but I've found that [[https://github.com/bbatsov/solarized-emacs][solarized]] produces the best exported code block +results. To avoid having to remember to switch themes when exporting, +I wrote a quick wrapper for org-export to do it for me: + +#+BEGIN_SRC emacs-lisp :exports code + (defun my/with-theme (theme fn &rest args) + (let ((current-themes custom-enabled-themes)) + (mapcar #'disable-theme custom-enabled-themes) + (load-theme theme t) + (let ((result (apply fn args))) + (mapcar #'disable-theme custom-enabled-themes) + (mapcar (lambda (theme) (load-theme theme t)) current-themes) + result))) + + (advice-add #'org-export-to-file :around (apply-partially #'my/with-theme 'solarized-dark)) + (advice-add #'org-export-to-buffer :around (apply-partially #'my/with-theme 'solarized-dark)) +#+END_SRC + +VoilĂ , no more bizarrely formatted code block exports from whatever +theme I might have loaded at the time :)