pages tagged emacs
Don Armstrong
https://www.donarmstrong.com/tags/emacs/
Don Armstrong
ikiwiki
2014-02-16T20:19:51Z
Working with Org-mode: Committing Changes Everywhere
https://www.donarmstrong.com/posts/working_with_org/
2014-02-16T20:19:51Z
2014-02-12T02:00:12Z
<p>I'm a huge fan of <a href="http://orgmode.org/">Org-mode</a>, and I keep all of
my org-mode files in git repositories which are under
<a href="http://myrepos.branchable.com/">myrepos</a> control.</p>
<p>However, because I often make lots of changes to my agenda and notes,
I hate having to manually visit each individual project and make
changes to it.
[And it's also annoying when I forget to commit a specific change and then have to try to get my laptop and desktop back into sync.]</p>
<p>Luckily, myrepos can easily run a command in parallel in all of the
repositories! The following "update_org_files" command will update all
of my org-file containing repositories in parallel:</p>
<div class="highlight-sh"><pre class="hl"><span class="hl slc">#!/bin/bash</span>
ORG_GREP<span class="hl opt">=</span><span class="hl str">'-e .org$ -e .org_archive$ -e .org_done$'</span>
<span class="hl kwa">if</span> <span class="hl opt">[</span> <span class="hl str">"x</span><span class="hl ipl">$1</span><span class="hl str">"</span> <span class="hl opt">==</span> <span class="hl str">"xdoit"</span> <span class="hl opt">];</span> <span class="hl kwa">then</span>
<span class="hl kwa">if</span> git status <span class="hl kwb">--porcelain -z</span> | <span class="hl kwc">grep</span> <span class="hl kwb">-z</span> <span class="hl str">'^ M'</span> | <span class="hl kwc">grep</span> <span class="hl kwb">-zq</span> <span class="hl kwd">$ORG_GREP</span><span class="hl opt">;</span> <span class="hl kwa">then</span>
git status <span class="hl kwb">--porcelain -z</span> | <span class="hl kwc">grep</span> <span class="hl kwb">-z</span> <span class="hl str">'^ M'</span> | <span class="hl kwc">grep</span> <span class="hl kwb">-z</span> <span class="hl kwd">$ORG_GREP</span> | \
<span class="hl kwc">sed</span> <span class="hl kwb">-z</span> <span class="hl str">'s/^ M//g'</span> | \
<span class="hl kwc">xargs</span> <span class="hl kwb">-0</span> git commit <span class="hl kwb">-m</span><span class="hl str">'update org files'</span>
git push<span class="hl opt">;</span>
<span class="hl kwa">fi</span><span class="hl opt">;</span>
<span class="hl kwa">else</span>
emacsclient <span class="hl kwb">-n -e</span> <span class="hl str">'(org-save-all-org-buffers)'</span> <span class="hl opt">>/</span>dev<span class="hl opt">/</span>null <span class="hl num">2</span><span class="hl opt">>&</span><span class="hl num">1</span>
mr <span class="hl kwb">-d</span> ~ <span class="hl kwb">-j5</span> run update_org_files doit<span class="hl opt">;</span>
<span class="hl kwa">fi</span><span class="hl opt">;</span>
</pre></div>
<p>An
<a href="http://git.donarmstrong.com/?p=bin.git;a=blob_plain;f=update_org_files;hb=HEAD">updated version</a>
of this lives in my
<a href="http://git.donarmstrong.com/bin.git">git repository</a></p>
Using Mutt with Org Mode (with refile)
https://www.donarmstrong.com/posts/org_mode_mutt_capture/
2014-01-10T01:45:15Z
2013-10-17T01:12:32Z
<p>I use <a href="http://orgmode.org/">org mode</a> extensively, and had added
<a href="http://upsilon.cc/~zack/">Zack's</a> workflow for
<a href="http://upsilon.cc/~zack/blog/posts/2010/02/integrating_Mutt_with_Org-mode/">integrating mutt with org mode</a>
to my
<a href="http://git.donarmstrong.com/?p=emacs.git;a=blob;f=.emacs;hb=HEAD">~/.emacs</a>
some time ago.</p>
<p>However, I've been annoyed that refiling closes the org-capture frame
before refiling finishes. The following
<a href="http://git.donarmstrong.com/?p=emacs.git;a=commitdiff;h=HEAD">trivial modification</a>
to Zack's code (which I previously modified to work with org-mode >=
0.8) waits to close the frame until you've finished refiling.</p>
<div class="highlight-el"><pre class="hl"><span class="hl opt">(</span><span class="hl kwa">require</span> <span class="hl opt">'</span>org-protocol<span class="hl opt">)</span>
<span class="hl opt">(</span><span class="hl kwa">add-hook</span> <span class="hl opt">'</span>org-capture-mode-hook <span class="hl opt">'</span>delete-other-windows<span class="hl opt">)</span>
<span class="hl opt">(</span><span class="hl kwa">setq</span> my-org-protocol-flag nil<span class="hl opt">)</span>
<span class="hl opt">(</span><span class="hl kwa">defadvice</span> org-capture-finalize <span class="hl opt">(</span><span class="hl kwa">after</span> delete-frame-at-end activate<span class="hl opt">)</span>
<span class="hl str">"Delete frame at remember finalization"</span>
<span class="hl opt">(</span><span class="hl kwa">progn</span> <span class="hl opt">(</span><span class="hl kwa">if</span> my-org-protocol-flag <span class="hl opt">(</span><span class="hl kwa">delete-frame</span><span class="hl opt">))</span>
<span class="hl opt">(</span><span class="hl kwa">setq</span> my-org-protocol-flag nil<span class="hl opt">)))</span>
<span class="hl opt">(</span><span class="hl kwa">defadvice</span> org-capture-refile <span class="hl opt">(</span><span class="hl kwa">around</span> delete-frame-after-refile activate<span class="hl opt">)</span>
<span class="hl str">"Delete frame at remember refile"</span>
<span class="hl opt">(</span><span class="hl kwa">if</span> my-org-protocol-flag
<span class="hl opt">(</span><span class="hl kwa">progn</span>
<span class="hl opt">(</span><span class="hl kwa">setq</span> my-org-protocol-flag nil<span class="hl opt">)</span>
ad-do-it
<span class="hl opt">(</span><span class="hl kwa">delete-frame</span><span class="hl opt">))</span>
ad-do-it<span class="hl opt">)</span>
<span class="hl opt">)</span>
<span class="hl opt">(</span><span class="hl kwa">defadvice</span> org-capture-kill <span class="hl opt">(</span><span class="hl kwa">after</span> delete-frame-at-end activate<span class="hl opt">)</span>
<span class="hl str">"Delete frame at remember abort"</span>
<span class="hl opt">(</span><span class="hl kwa">progn</span> <span class="hl opt">(</span><span class="hl kwa">if</span> my-org-protocol-flag <span class="hl opt">(</span><span class="hl kwa">delete-frame</span><span class="hl opt">))</span>
<span class="hl opt">(</span><span class="hl kwa">setq</span> my-org-protocol-flag nil<span class="hl opt">)))</span>
<span class="hl opt">(</span><span class="hl kwa">defadvice</span> org-protocol-capture <span class="hl opt">(</span><span class="hl kwa">before</span> set-org-protocol-flag activate<span class="hl opt">)</span>
<span class="hl opt">(</span><span class="hl kwa">setq</span> my-org-protocol-flag t<span class="hl opt">))</span>
</pre></div>
<p>Now, the frame automatically disappears after you refile it, keeping
my refile.org clean.</p>