<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>emre şahin's digital garden 🍃 - emacs</title>
    <link>https://emresahin.net/tags/emacs/</link>
    <description>Posts in the emacs tag</description>
    <language>en</language>
    <managingEditor>contact@emresahin.net (Emre Şahin)</managingEditor>
    <lastBuildDate>Tue, 29 Sep 2026 14:57:43 +0000</lastBuildDate>
    <atom:link href="https://emresahin.net/tags/emacs/rss.xml" rel="self" type="application/rss+xml"/>
    <item>
      <title>Cat for Writers</title>
      <published>2014-07-06T21:00:00+00:00</published>
      <updated>2014-07-06T21:00:00+00:00</updated>
      <author>Emre Şahin</author>
      <pubDate>Sun, 06 Jul 2014 21:00:00 +0000</pubDate>
      <link>https://emresahin.net/cat-for-writers/</link>
      <guid isPermaLink="true">https://emresahin.net/cat-for-writers/</guid>
      <description>I write every day. Every day, I write. I have a quota of words to fill, and after each sleep session, I sit in front of my keyboard and begin typing. I used to use Emacs for this—the One True Editor. Yet, it has one flaw that disrupted my writing routine: it has too many features. When I encounte...</description>
      <category>Tools</category>
      <category>Writing</category>
      <category>Cat</category>
      <category>Ed</category>
      <category>Emacs</category>
      <category>Org-mode</category>
      <category>Writing</category>
      <category>Bash</category>
      <category>Scripts</category>
      <content:encoded><![CDATA[<p>I write every day. Every day, I write. I have a quota of words to fill, and after each sleep session, I sit in front of my keyboard and begin typing.</p>
<p>I used to use <a href="http://en.wikipedia.org/wiki/GNU_Emacs">Emacs</a> for this—the One True Editor. Yet, it has one flaw that disrupted my writing routine: it has too many features. When I encountered writer’s block or an idea I couldn’t quite articulate, I would start tinkering with the editor instead. Emacs is like a friend, and one should keep friends away from the workplace; otherwise, no work gets done.</p>
<p>For this reason, I began writing with <a href="http://en.wikipedia.org/wiki/Ed_(text_editor)"><code>ed</code></a> some time ago. <code>ed</code> is not my friend; it’s <em>the</em> standard editor. It’s also the grandfather of <a href="http://en.wikipedia.org/wiki/Vi"><code>vi</code></a>, but fathers should not bear the vices of their sons.</p>
<p><strong>Note from 2024:</strong> Ten years after writing this post, I’m editing it with Neovim, the grandson of all these tools.</p>
<p><code>ed</code> was very nice to write with. It doesn’t have many features. It prints a <code>0</code> when it opens, I type <code>i</code> to insert text, and then I write whatever I like. When I put a lonely <code>.</code> on a line, it understands that I’ve finished my words. Then, with <code>w</code>, I save the file to disk and see its length—length in bytes, as every true writer nowadays should know.</p>
<p><code>ed</code> is minimal, and while I occasionally get frustrated by its modal behavior, that’s exactly why I was happy to write with it.</p>
<p>However, I eventually decided that even pressing those few command keys was too much. <code>i</code>, <code>.</code>, and <code>w</code>—one can forget them easily. And it seemed I had a tendency to learn more of its commands, which are passed down to its grandchildren. God save us from the vices of <code>vi</code>.</p>
<p>Then, I decided to concoct a script that uses <code>cat</code>. Everyone knows writers like cats, and I like <code>cat</code> too; it concatenates text into files and is also used to print their content. It’s much simpler than <code>ed</code>—much simpler. It is not an ambiguous dork like <code>ed</code>; it’s a simple animal that writes into files whatever I type into it.</p>
<p>It was easy to check the file size in words after I finished. I wrote a <code>while</code> loop to continue until I reached my daily quota. The script creates a new file, adds an <a href="http://orgmode.org">Org-mode</a> header, and includes the contents of the clipboard just after the title so I can include notes. <code>cat</code> exits with <code>Ctrl-D</code>, and when it finishes, the script checks the word count. If I’m still short of my daily target, it appends a <code>-----</code> separator and opens the file again. <em>You have to finish your words, whether your brain bleeds or your cat dies.</em></p>
<p>The effect? I began using it today, so I’m still not sure about the long-term impact, but there’s certainly nothing to distract me. When I used Emacs, the <code>info</code> pages were highly entertaining—I was just finishing the command-line options of GNU Backgammon when I decided to switch. Modern programs are so customizable that I can’t even finish reading their manuals.</p>
<p>The script is shown below. It asks for a filename; if you don’t provide one, it creates one based on the date. It has some minor changes from the version I use, as I tend to name my files differently and I haven’t tested this specific version thoroughly, but here it is. Copy and paste it into a file named <code>write-with-cat</code>, make it executable with <code>chmod +x write-with-cat</code>, and run it. You’ll need a Unix-like system (even my mom uses Debian, you know).</p>
<p>The second part of the script, which I’ve commented out, copies the written material to a repository and commits it using Mercurial.</p>
<pre><code class="language-bash">#!/bin/bash

WORDSIZE=600

echo "Please set a (tentative) name?"
read response
if [ -z "$response" ] ; then
    dirname=work-`date +%y-%m-%d`-$RANDOM
else
    dirname=work-${response}
fi

tempdirname="/tmp/$dirname"
mkdir $tempdirname
docname="$tempdirname/index.org"

selection=`xsel -ob`
cat &gt; $docname &lt;&lt;EOF
#+TITLE: $response
#+AUTHOR:
#+DATE: `date`

$selection
EOF

clear
cat $docname

while [ `wc -w "$docname" | cut -f 1 -d ' '` -le $WORDSIZE ] ; do
    cat &gt;&gt; $docname
    echo "\n-----" &gt;&gt; "$docname"
    wc -w "$docname"
done
</code></pre>]]></content:encoded>
    </item>
    <item>
      <title>My Emacs Packages</title>
      <published>2014-05-13T14:00:00+00:00</published>
      <updated>2014-05-13T14:00:00+00:00</updated>
      <author>Emre Şahin</author>
      <pubDate>Tue, 13 May 2014 14:00:00 +0000</pubDate>
      <link>https://emresahin.net/my-emacs-packages/</link>
      <guid isPermaLink="true">https://emresahin.net/my-emacs-packages/</guid>
      <description>I’ve been using Emacs for about 7 or 8 years now—maybe a bit less, maybe more. I tried to quit several times for other editors and different workflows, and every time I returned with more enthusiasm. It’s hard to tell for those who use their editors with mouse clicks on pretty icons, but once you...</description>
      <category>Software</category>
      <category>Emacs</category>
      <category>emacs</category>
      <category>org-mode</category>
      <category>software</category>
      <category>python</category>
      <category>latex</category>
      <category>w3m</category>
      <content:encoded><![CDATA[<p>I’ve been using Emacs for about 7 or 8 years now—maybe a bit less,
maybe more. I tried to quit several times for other editors and different
workflows, and every time I returned with more enthusiasm.</p>
<p>It’s hard to tell for those who <em>use</em> their editors with mouse clicks
on pretty icons, but once you catch this virus called <em>doing everything
from the keyboard</em>, it becomes attached to your digital (from <em>digitus</em>,
finger) psyche, making it impossible to leave behind. I even purchased an
Android keyboard for my phablet just to <code>ssh</code> to my home and write with
Emacs. Consider that!</p>
<p>Today I stumbled upon several posts regarding favorite Emacs packages
and wanted to list mine.</p>
<h1 id="org-mode">org-mode</h1>
<p>I’m not writing this in <code>org-mode</code> because I observed that I can
detail, micro-revise, and lose focus while writing because of its
extensive functionality. Instead, I’m using Zsh’s <code>vared</code> to enter lines to
an org-file when I write first drafts. But editing, keeping, following,
creating plots, literate programming—doing everything that can be done
with text—is possible in <code>org-mode</code>.</p>
<p>I have <code>F11</code> bound to <code>org-capture</code> and <code>F12</code> to <code>org-agenda-list</code>.
<code>F9 F9</code> stores links wherever I like, and I can use <code>C-c C-l</code> in org
buffers to paste them.</p>
<h1 id="w3m">w3m</h1>
<p>When I want to search Google but don’t like the idea of running a huge
browser session just to look up an answer on StackOverflow, I use this.</p>
<h1 id="undo-tree">undo-tree</h1>
<p>It shows the versions created by undo/redo of a buffer in a tree format.
Emacs’s default undo may be cumbersome at times, but this package is
terrific.</p>
<h1 id="wc-mode">wc-mode</h1>
<p>To count words in a file. When I forget this package, I use
<code>C-x h M-| wc</code> as a substitute.</p>
<h1 id="auctex">auctex</h1>
<p>Once upon a time, this mode led me to migrate from LyX to LaTeX itself.</p>
<h1 id="ess">ESS</h1>
<p>Emacs Speaks Statistics is an R frontend. I’m not using it daily, but
it’s much better than the R command-line client.</p>
<h1 id="uniquify">Uniquify</h1>
<p>Makes buffer names unique. If you have files with identical names, this
is much better than having names like <code>myfile.txt&lt;1&gt;</code>, <code>myfile.txt&lt;2&gt;</code>,
etc.</p>
<h1 id="recentf-mode">recentf-mode</h1>
<p>A list of recent files.</p>
<h1 id="smex">smex</h1>
<p><code>ido</code> for <code>M-x</code>. Standard <code>M-x</code> selects commands by their prefix; with
<code>smex</code>, you can filter them by any substring. This makes a difference for
those with poor memory.</p>
<h1 id="ahg">ahg</h1>
<p>I use Mercurial more than Git, and <code>ahg-mode</code> seems like a good
alternative to standard <code>vc-</code> commands.</p>
<h1 id="projectile">projectile</h1>
<p>It considers directories under version control as projects and defines
functions like <code>find-file</code>, <code>multi-occur</code>, and <code>recentf</code> for them. It’s a
very simple and non-intrusive way to have project management.</p>
<h1 id="elpy">elpy</h1>
<p>For Python programming, <code>elpy</code> provides completion and much more
functionality.</p>
<h1 id="ack-and-a-half">ack-and-a-half</h1>
<p>An <code>ack</code> mode, a hybrid version of the other two.</p>
<h1 id="xgtags">xgtags</h1>
<p>A GNU Global mode for C++ code tagging.</p>]]></content:encoded>
    </item>
    <item>
      <title>mu4e</title>
      <published>2014-02-18T14:00:00+00:00</published>
      <updated>2014-02-18T14:00:00+00:00</updated>
      <author>Emre Şahin</author>
      <pubDate>Tue, 18 Feb 2014 14:00:00 +0000</pubDate>
      <link>https://emresahin.net/mu4e/</link>
      <guid isPermaLink="true">https://emresahin.net/mu4e/</guid>
      <description>I used mutt for years. I like it. Its customizability and macros make me feel at home, and I was able to automate most of my tasks with it. I began using mutt after Gnus on Emacs. The reason I left Gnus behind is that it was incompatible with offlineimap and slow for IMAP use. I see no point in i...</description>
      <category>Software</category>
      <category>Email</category>
      <category>emacs</category>
      <category>mu4e</category>
      <category>mutt</category>
      <category>offlineimap</category>
      <category>email</category>
      <category>org-mode</category>
      <content:encoded><![CDATA[<p>I used <code>mutt</code> for years. I like it. Its customizability and macros make
me feel at home, and I was able to automate most of my tasks with it.</p>
<p>I began using mutt after Gnus on Emacs. The reason I left Gnus behind
is that it was incompatible with <code>offlineimap</code> and slow for IMAP use. I
see no point in installing a local IMAP server when the tool that should work
with Maildirs does not work. I don’t know the situation with Gnus nowadays,
but I think it was a good decision to use mutt.</p>
<p>However, recently, in Emacs circles, I saw that people are talking about
mu4e as a search-based email client. Almost all my development life is
under Emacs, and I’m using <code>org-mode</code> for non-development more and more.
Using email links with <code>mutt</code> and <code>org</code> requires ugly hacks, and I don’t
like ugly hacks. So I wasn’t able to use links to email messages in
<code>org-mode</code> with <code>mutt</code>. (They weren’t vital as my previous <em>TODO
scheme</em> was based on email and I still keep it for archiving on notes in
the cloud.)</p>
<p>I decided to give <code>mu4e</code> a go. It seems to work with <code>offlineimap</code>
without fuss, and Debian packages are available. And unlike some other
email packages, Emacs support is one of the important parts.</p>
<hr>
<p>I have more than a single email account, and <code>offlineimap</code> reads these to
different mailfolders. Since I wasn’t thinking of combining these email
messages, these were residing in different Maildirs. I used mu4e for
several days on only one of these. As <code>mu</code> updates its index by checking
only the newest messages, (I think) it’s not straightforward to adapt
it to different Maildirs.</p>
<p>Then, <a href="http://varunbpatil.github.io/2013/08/19/eom/">I saw a post that puts all Maildirs into a single
directory</a> and gives this
<em>mail root</em> to <code>mu</code> as the indexing directory. Ah, nice idea. I should
have thought of this.</p>
<p>But I was too lazy to update my offlineimap configuration. First I tried
to put symlinks in a directory and supply this to <code>mu</code>, but it didn’t
work. It doesn’t follow symlinks and as far as I can tell, there is no
option to ask it to do so.</p>
<p>Then I moved my Maildirs to a directory and created symlinks for
<code>offlineimap</code> and <code>mutt</code> in my <code>$HOME</code>. Symlinks are my friend. Pity for
those whose OS doesn’t give an easy way to use them.</p>]]></content:encoded>
    </item>
  </channel>
</rss>
