tags/org-modeDavid Bremnerby-nc-sa-2.5
Copyright 2020, David Bremner
https://www.cs.unb.ca/~bremner//tags/org-mode/David Bremnerikiwiki2020-04-09T11:12:20ZTangling multiple fileshttps://www.cs.unb.ca/~bremner//blog/posts/tangle-multi/
<a href="../../whyCC/">by-nc-sa-2.5</a>
Copyright 2020, David Bremner
2020-04-09T11:12:20Z2020-04-08T16:35:00Z
<p>I have lately been using <code>org-mode</code> literate programming to generate
example code and beamer slides from the same source. I hit a wall
trying to re-use functions in multiple files, so I came up with the
following hack. Thanks 'ngz' on #emacs and Charles Berry on the
org-mode list for suggestions and discussion.</p>
<div class="highlight-lisp"><pre class="hl"><span class="hl opt">(</span><span class="hl kwa">defun</span> <span class="hl kwb">db-extract-tangle-includes</span> <span class="hl opt">()</span>
<span class="hl opt">(</span><span class="hl kwa">goto-char</span> <span class="hl opt">(</span><span class="hl kwa">point-min</span><span class="hl opt">))</span>
<span class="hl opt">(</span><span class="hl kwa">let</span> <span class="hl opt">((</span><span class="hl kwa">case-fold-search</span> t<span class="hl opt">)</span>
<span class="hl opt">(</span><span class="hl kwa">retval</span> nil<span class="hl opt">))</span>
<span class="hl opt">(</span><span class="hl kwa">while</span> <span class="hl opt">(</span><span class="hl kwa">re-search-forward</span> <span class="hl sng">"^#[+]TANGLE_INCLUDE:"</span> nil t<span class="hl opt">)</span>
<span class="hl opt">(</span><span class="hl kwa">let</span> <span class="hl opt">((</span><span class="hl kwa">element</span> <span class="hl opt">(</span><span class="hl kwa">org-element-at-point</span><span class="hl opt">)))</span>
<span class="hl opt">(</span><span class="hl kwa">when</span> <span class="hl opt">(</span><span class="hl kwa">eq</span> <span class="hl opt">(</span><span class="hl kwa">org-element-type</span> element<span class="hl opt">) '</span>keyword<span class="hl opt">)</span>
<span class="hl opt">(</span><span class="hl kwa">push</span> <span class="hl opt">(</span><span class="hl kwa">org-element-property</span> <span class="hl kwc">:value</span> element<span class="hl opt">)</span> retval<span class="hl opt">))))</span>
retval<span class="hl opt">))</span>
<span class="hl opt">(</span><span class="hl kwa">defun</span> <span class="hl kwb">db-ob-tangle-hook</span> <span class="hl opt">()</span>
<span class="hl opt">(</span><span class="hl kwa">let</span> <span class="hl opt">((</span><span class="hl kwa">includes</span> <span class="hl opt">(</span><span class="hl kwa">db-extract-tangle-includes</span><span class="hl opt">)))</span>
<span class="hl opt">(</span><span class="hl kwa">mapc</span> <span class="hl opt">#'</span>org-babel-lob-ingest includes<span class="hl opt">)))</span>
<span class="hl opt">(</span><span class="hl kwa">add-hook</span> <span class="hl opt">'</span>org-babel-pre-tangle-hook <span class="hl opt">#'</span>db-ob-tangle-hook t<span class="hl opt">)</span>
</pre></div>
<p>Use involves something like the following in your org-file.</p>
<div class="highlight-text"><pre class="hl">#+SETUPFILE: presentation-settings.org
#+SETUPFILE: tangle-settings.org
#+TANGLE_INCLUDE: lecture21.org
#+TITLE: GC V: Mark & Sweep with free list
</pre></div>
<p>For batch export with make, I do something like
[[!format <span class="error">Error: unsupported page format make</span>]]</p>
Using Org Mode as a time trackerhttps://www.cs.unb.ca/~bremner//blog/posts/org-time-tracker/
<a href="../../whyCC/">by-nc-sa-2.5</a>
Copyright 2020, David Bremner
2009-01-05T10:50:29Z2008-11-10T18:55:00Z
<p>I have been meaning to fix this up for a long time, but so far real
work keeps getting in the way. The idea is that C-C t brings you to
this week's time tracker buffer, and then you use (C-c C-x C-i/C-c C-x
C-o) to start and stop timers.</p>
<p>The only even slightly clever is stopping the timer and saving on
quitting emacs, which I borrowed from the someone on the net.</p>
<ul>
<li><em>Updated</em> dependence on mhc removed.</li>
<li><em>Updated 2009/01/05</em> Fixed week-of-year calculation</li>
</ul>
<p>The main guts of the hack are <a href="https://www.cs.unb.ca/~bremner//blog/files/org-timetracker.el">here</a>.</p>
<p>The result might look like the <a href="https://www.cs.unb.ca/~bremner//blog/files/ott-example.org">this</a>
(works better in emacs org-mode. C-c C-x C-d for a summary)</p>