<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Emacs | Raul Benencia</title>
    <link>https://rbenencia.name/tags/emacs/</link>
    <description>Recent content in Emacs on Raul Benencia</description>
    
    <language>en-us</language>
    <lastBuildDate>Mon, 01 Jun 2026 08:23:41 -0300</lastBuildDate><atom:link href="https://rbenencia.name/tags/emacs/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Org Tempus</title>
      <link>https://rbenencia.name/blog/2026-06-01-org-tempus/</link>
      <pubDate>Mon, 01 Jun 2026 08:23:41 -0300</pubDate>
      <guid>https://rbenencia.name/blog/2026-06-01-org-tempus/</guid>
      <description>&lt;p&gt;Time management is a tricky business. Ideally we should spend our precious time in Earth doing things that we’re interested in for as long as we want. Unfortunately that’s not how the life of a modern human works. We have responsibilities, chores, busy work, etc. We have activities that we enjoy doing, and tasks that we have to get over, and ideally we should make progress in all of them. We’re in a constant state of context switching. Additionally, we need to take regular breaks to ensure our brain is not overly engaged.&lt;/p&gt;
&lt;p&gt;As an Emacser, I’m an avid user of &lt;a href=&#34;https://orgmode.org/&#34;&gt;Org Mode&lt;/a&gt;. I find it essential to keep track of my perennial list of tasks, both personal and at work. Org has a handy &lt;a href=&#34;https://orgmode.org/manual/Clocking-Work-Time.html&#34;&gt;clocking feature&lt;/a&gt; that allows you to track the time you spent on each task. This feature is essential to ensure I don’t overwork, or underwork, in any of my responsibilities. However, it’s a bit of a hassle to clock in and clock out all the time, particularly if you take regular breaks.&lt;/p&gt;
&lt;p&gt;Enter &lt;a href=&#34;https://github.com/rul/org-tempus&#34;&gt;Org Tempus&lt;/a&gt;, an Emacs package I’ve written on top of Org Mode to automate many parts of my workflow. In particular, Org Tempus allows setting up a default task to auto clock-in when activity is detected in the workstation. This default task is how I track administrative work: catching up with emails, messages, and capturing new work items. How “activity” is detected is configurable and extendable: it can be activity coming from Emacs itself, or activity coming from a desktop environment such as GNOME. The package also permits setting intervals for breaks (similar to the Pomodoro technique) and total worked time, and sends notifications when the thresholds are reached.&lt;/p&gt;
&lt;p&gt;Overall, Org Tempus has enabled me to be more intentional with how I spend my computing time. Check the &lt;a href=&#34;https://github.com/rul/org-tempus/blob/main/README.md&#34;&gt;README&lt;/a&gt; for the full list of features. I’ve just released &lt;a href=&#34;https://github.com/rul/org-tempus/releases/tag/0.0.2&#34;&gt;version 0.0.2&lt;/a&gt;.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Emacs server, systemd and XAUTHORITY</title>
      <link>https://rbenencia.name/blog/emacs-daemon-as-a-systemd-service/</link>
      <pubDate>Tue, 30 May 2023 00:00:00 +0000</pubDate>
      <guid>https://rbenencia.name/blog/emacs-daemon-as-a-systemd-service/</guid>
      <description>&lt;p&gt;Running Emacs as a systemd service should be relatively straightforward
if using its Debian package, given that it comes with a systemd
unit.&lt;/p&gt;
&lt;p&gt;Here&amp;rsquo;s a fragment:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;$ cat /usr/lib/systemd/user/emacs.service | head -n7
[Unit]
Description=Emacs text editor
Documentation=info:emacs man:emacs(1) https://gnu.org/software/emacs/

[Service]
Type=notify
ExecStart=/usr/bin/emacs --fg-daemon
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;However, I&amp;rsquo;ve faced the following problem: when running &lt;code&gt;emacsclient&lt;/code&gt;
from a graphical interface, nothing happened, and it was not clear
what to do next.&lt;/p&gt;
&lt;p&gt;To unravel these kind of problems, we should always start by checking
the logs. An interesting line showed up:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;$ journalctl  --user -u emacs.service
...
May 18 16:51:51 zorzal emacs[1308]: Authorization required, but no authorization protocol specified
...
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;After some digging, I realized this happens because the Emacs server
was started before the &lt;code&gt;XAUTHORITY&lt;/code&gt; variable was set, and &lt;a href=&#34;https://en.wikipedia.org/wiki/X_Window_authorization&#34;&gt;we need
that variable&lt;/a&gt;
to communicate with the display server.&lt;/p&gt;
&lt;p&gt;A quick search didn&amp;rsquo;t show a straightforward or clean
solution. Remediating this problem should be relatively simple: we
just need to instruct systemd to start the Emacs server &lt;em&gt;after&lt;/em&gt; the
graphical session.  systemd &lt;a href=&#34;https://www.freedesktop.org/software/systemd/man/systemd.special.html#graphical-session.target&#34;&gt;comes
preloaded&lt;/a&gt;
with a special &lt;code&gt;target&lt;/code&gt; that can be used for this purpose:
&lt;code&gt;graphical-session.target&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;A &lt;a href=&#34;https://www.freedesktop.org/software/systemd/man/systemd.unit.html#Description&#34;&gt;systemd
drop-in&lt;/a&gt;
file can be used to establish this dependency:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;$ cat ~/.config/systemd/user/emacs.service.d/override.conf
[Unit]
Requires=graphical-session.target
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;To pick-up the override, we must remember to run: &lt;code&gt;systemd --user daemon-reload&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Why isn&amp;rsquo;t this a default in the shipped unit file? I suppose we can&amp;rsquo;t
assume the user will always have a graphical session when launching
an Emacs server, so it wouldn&amp;rsquo;t be safe to make it a default.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Using notmuch-emacs along with other folder-based MUA</title>
      <link>https://rbenencia.name/blog/2015-06-24-notmuch-imap-sync/</link>
      <pubDate>Wed, 24 Jun 2015 00:00:00 +0000</pubDate>
      <guid>https://rbenencia.name/blog/2015-06-24-notmuch-imap-sync/</guid>
      <description>&lt;p&gt;I&amp;rsquo;ve started to leave my &lt;em&gt;mutt&lt;/em&gt; niche in order to start using
&lt;em&gt;notmuch-emacs&lt;/em&gt; MUA. All in all, I can see the see the speed advantage
of using &lt;em&gt;notmuch&lt;/em&gt;, among other little perks. Nevertheless, the
approach of tagging emails instead of organizing them in IMAP folders
makes the use of &lt;em&gt;notmuch&lt;/em&gt; a little non-portable for others folder
based user agents. I wouldn&amp;rsquo;t mind that, but I like receiving my
emails on my mobile phone and as far as I know there is no such thing
as a mobile &lt;em&gt;notmuch&lt;/em&gt; MUA.&lt;/p&gt;
&lt;p&gt;In this blog post I&amp;rsquo;ll share my approach for using a &lt;em&gt;notmuch&lt;/em&gt; based agent,
as &lt;em&gt;notmuch-emacs&lt;/em&gt;, along with other folder based agents, as &lt;em&gt;Thunderbird&lt;/em&gt;
or &lt;em&gt;K-9 Mail&lt;/em&gt;. The first thing to do is to define the layout of our IMAP
folders. In our examples we&amp;rsquo;ll use something like this:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;$ ls -1 ~/Maildir
archive
cur
debian
debian.devel
debian.haskell
debian.haskell.commits
debian.haskell.maintainers
debian.haskell.maintainers.junk
debian.misc
debian.project
new
tmp
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;So, here I have my &lt;strong&gt;inbox&lt;/strong&gt; folder along with an &lt;strong&gt;archive&lt;/strong&gt; maildir and a
hierarchy of folders containing Debian mailing lists. In my folder based
mobile agent, K-9, I won&amp;rsquo;t be bothered with notifications of new mailing
list emails, as the agent is configured to only check for new emails in the
&lt;strong&gt;inbox&lt;/strong&gt; folder. On the other hand, in a default &lt;em&gt;notmuch&lt;/em&gt; setup each time
I run &lt;code&gt;notmuch new&lt;/code&gt; the database will be filled with all the emails in all
the folders and will tag the new ones with &lt;code&gt;inbox&lt;/code&gt;. Now, when I&amp;rsquo;m using
&lt;em&gt;notmuch-emacs&lt;/em&gt;, I like that my &lt;code&gt;inbox&lt;/code&gt; emails be only the ones in my
&lt;strong&gt;inbox&lt;/strong&gt; folder. Besides, I&amp;rsquo;ll also like to add a tag that matches the
name of the folder the email is in. In &lt;em&gt;notmuch&lt;/em&gt; language:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;#!/bin/sh
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;notmuch new
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;notmuch tag +archive -inbox &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;path:archive/**&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;notmuch tag +debian -inbox &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;path:debian/**&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;notmuch tag +debian-devel -inbox &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;path:debian.devel/**&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;notmuch tag +debian-project -inbox &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;path:debian.project/**&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;notmuch tag +debian-haskell -inbox &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;path:debian.haskell/**&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;notmuch tag +debian-haskell-commits -inbox &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;path:debian.haskell.commits/**&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;notmuch tag +debian-haskell-maintainers -inbox &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;path:debian.haskell.maintainers/**&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;notmuch tag +debian-haskell-maintainers-junk -inbox -unread &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;path:debian.haskell.maintainers.junk/**&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;notmuch tag +debian-misc -inbox &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;path:debian.misc/**&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;With this method we can use a folder based approach with &lt;em&gt;notmuch&lt;/em&gt;
tags. Let&amp;rsquo;s move to another topic. In the &lt;em&gt;notmuch&lt;/em&gt; world, archiving an
email means removing the &lt;code&gt;inbox&lt;/code&gt; tag. If we only do this, all the archived
emails will still be in our &lt;strong&gt;inbox&lt;/strong&gt; folder, so what we&amp;rsquo;ll like to do is
to move &lt;em&gt;to&lt;/em&gt; the &lt;strong&gt;archive&lt;/strong&gt; folder all the emails &lt;em&gt;from&lt;/em&gt; the &lt;strong&gt;inbox&lt;/strong&gt;
folder that don&amp;rsquo;t have the &lt;code&gt;inbox&lt;/code&gt; tag. In other words:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;function&lt;/span&gt; archive&lt;span style=&#34;color:#f92672&#34;&gt;()&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;[&lt;/span&gt; $# -ne &lt;span style=&#34;color:#ae81ff&#34;&gt;2&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;]&lt;/span&gt;; &lt;span style=&#34;color:#66d9ef&#34;&gt;then&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;       echo &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Incorrent parameters. Send INBOX and ARCHIVE&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;       &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;fi&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;for&lt;/span&gt; e in &lt;span style=&#34;color:#66d9ef&#34;&gt;$(&lt;/span&gt;notmuch search --output&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;files &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;path:&lt;/span&gt;$1&lt;span style=&#34;color:#e6db74&#34;&gt;/**&amp;#34;&lt;/span&gt; and not tag:inbox&lt;span style=&#34;color:#66d9ef&#34;&gt;)&lt;/span&gt;; &lt;span style=&#34;color:#66d9ef&#34;&gt;do&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        mv $e $2
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;done&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;0&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;archive cur &lt;span style=&#34;color:#e6db74&#34;&gt;${&lt;/span&gt;MAILDIR&lt;span style=&#34;color:#e6db74&#34;&gt;}&lt;/span&gt;/archive/cur
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Finally, one little detail is left: &lt;em&gt;spam&lt;/em&gt;. In a folder based agent, we&amp;rsquo;ll
usually have a &lt;strong&gt;spam&lt;/strong&gt; folder. In the &lt;em&gt;notmuch&lt;/em&gt; world, when we tag an
email with &lt;code&gt;spam&lt;/code&gt;, a decent client won&amp;rsquo;t show it in the results of
&lt;em&gt;notmuch&lt;/em&gt; searches, but it will remain in the folder it was found. So, what
we have to do is to move all the &lt;code&gt;spam&lt;/code&gt; tagged email to our &lt;strong&gt;spam&lt;/strong&gt;
folder.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;for&lt;/span&gt; e in &lt;span style=&#34;color:#66d9ef&#34;&gt;$(&lt;/span&gt;notmuch search --output&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;files tag:spam and not &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;path:spam/**&amp;#34;&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;)&lt;/span&gt;; &lt;span style=&#34;color:#66d9ef&#34;&gt;do&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    mv $e $MAILDIR/spam/cur
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;done&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;So, if we cron this little script we&amp;rsquo;ll be able to use a &lt;em&gt;notmuch&lt;/em&gt; based
MUA along with an IMAP folder based one. Enjoy!&lt;/p&gt;</description>
    </item>
    
  </channel>
</rss>
