mirror of
https://github.com/correl/correl.github.io.git
synced 2024-12-29 11:09:24 +00:00
Using a different theme when publishing org files
This commit is contained in:
parent
2e38a6b369
commit
48b4f74524
2 changed files with 60 additions and 0 deletions
32
_posts/2016-02-23-org-publish-with-theme.html
Normal file
32
_posts/2016-02-23-org-publish-with-theme.html
Normal file
|
@ -0,0 +1,32 @@
|
|||
---
|
||||
title: "Use a different theme when publishing Org files"
|
||||
author: "Correl Roush"
|
||||
tags: emacs org-mode themes
|
||||
---
|
||||
<p>
|
||||
I've been using <a href="https://github.com/cpaulik/emacs-material-theme">material-theme</a> lately, and I sometimes switch around,
|
||||
but I've found that <a href="https://github.com/bbatsov/solarized-emacs">solarized</a> 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:
|
||||
</p>
|
||||
|
||||
<div class="org-src-container">
|
||||
|
||||
<pre class="src src-emacs-lisp"><span style="color: #2aa198;">(</span><span style="color: #859900; font-weight: bold;">defun</span> <span style="color: #268bd2;">my/with-theme</span> <span style="color: #b58900;">(</span><span style="color: #c0afa7;">theme</span> <span style="color: #a7aac0;">fn</span> <span style="color: #b58900;">&rest</span> <span style="color: #a6bb99;">args</span><span style="color: #b58900;">)</span>
|
||||
<span style="color: #b58900;">(</span><span style="color: #859900; font-weight: bold;">let</span> <span style="color: #268bd2;">(</span><span style="color: #6c71c4;">(</span><span style="color: #a7aac0;">current-themes</span> <span style="color: #b6a0e0;">custom-enabled-themes</span><span style="color: #6c71c4;">)</span><span style="color: #268bd2;">)</span>
|
||||
<span style="color: #268bd2;">(</span><span style="color: #9999bb;">mapcar</span> #'<span style="color: #a6bb99;">disable-theme</span> <span style="color: #b6a0e0;">custom-enabled-themes</span><span style="color: #268bd2;">)</span>
|
||||
<span style="color: #268bd2;">(</span><span style="color: #c0afa7;">load-theme</span> <span style="color: #c0afa7;">theme</span> <span style="color: #a0d6e0;">t</span><span style="color: #268bd2;">)</span>
|
||||
<span style="color: #268bd2;">(</span><span style="color: #859900; font-weight: bold;">let</span> <span style="color: #6c71c4;">(</span><span style="color: #859900;">(</span><span style="color: #a0d6e0;">result</span> <span style="color: #b58900;">(</span><span style="color: #b3c0a7;">apply</span> <span style="color: #a7aac0;">fn</span> <span style="color: #a6bb99;">args</span><span style="color: #b58900;">)</span><span style="color: #859900;">)</span><span style="color: #6c71c4;">)</span>
|
||||
<span style="color: #6c71c4;">(</span><span style="color: #9999bb;">mapcar</span> #'<span style="color: #a6bb99;">disable-theme</span> <span style="color: #b6a0e0;">custom-enabled-themes</span><span style="color: #6c71c4;">)</span>
|
||||
<span style="color: #6c71c4;">(</span><span style="color: #9999bb;">mapcar</span> <span style="color: #859900;">(</span><span style="color: #859900; font-weight: bold;">lambda</span> <span style="color: #b58900;">(</span><span style="color: #c0afa7;">theme</span><span style="color: #b58900;">)</span> <span style="color: #b58900;">(</span><span style="color: #c0afa7;">load-theme</span> <span style="color: #c0afa7;">theme</span> <span style="color: #a0d6e0;">t</span><span style="color: #b58900;">)</span><span style="color: #859900;">)</span> <span style="color: #a7aac0;">current-themes</span><span style="color: #6c71c4;">)</span>
|
||||
<span style="color: #a0d6e0;">result</span><span style="color: #268bd2;">)</span><span style="color: #b58900;">)</span><span style="color: #2aa198;">)</span>
|
||||
|
||||
<span style="color: #2aa198;">(</span><span style="color: #e0d0a0;">advice-add</span> #'<span style="color: #c0afa7;">org-export-to-file</span> <span style="color: #839496; font-weight: bold;">:around</span> <span style="color: #b58900;">(</span><span style="color: #b6a0e0;">apply-partially</span> #'<span style="color: #bba699;">my/with-theme</span> '<span style="color: #99bbb4;">solarized-dark</span><span style="color: #b58900;">)</span><span style="color: #2aa198;">)</span>
|
||||
<span style="color: #2aa198;">(</span><span style="color: #e0d0a0;">advice-add</span> #'<span style="color: #9999bb;">org-export-to-buffer</span> <span style="color: #839496; font-weight: bold;">:around</span> <span style="color: #b58900;">(</span><span style="color: #b6a0e0;">apply-partially</span> #'<span style="color: #bba699;">my/with-theme</span> '<span style="color: #99bbb4;">solarized-dark</span><span style="color: #b58900;">)</span><span style="color: #2aa198;">)</span>
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
Voilà, no more bizarrely formatted code block exports from whatever
|
||||
theme I might have loaded at the time :)
|
||||
</p>
|
28
_posts/2016-02-23-org-publish-with-theme.org
Normal file
28
_posts/2016-02-23-org-publish-with-theme.org
Normal file
|
@ -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 :)
|
Loading…
Reference in a new issue