<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Emacs on manuel uberti</title>
    <link>https://manueluberti.eu/tags/emacs/</link>
    <description>Recent content in Emacs on manuel uberti</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-us</language>
    <managingEditor>manuel.uberti@inventati.org (Manuel Uberti)</managingEditor>
    <webMaster>manuel.uberti@inventati.org (Manuel Uberti)</webMaster>
    <lastBuildDate>Sun, 21 Sep 2025 00:00:00 +0000</lastBuildDate>
    <atom:link href="https://manueluberti.eu/tags/emacs/feed.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Insert date at point</title>
      <link>https://manueluberti.eu/posts/2025-09-21-date-at-point/</link>
      <pubDate>Sun, 21 Sep 2025 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2025-09-21-date-at-point/</guid>
      <description>&lt;p&gt;I don&amp;rsquo;t know why I haven&amp;rsquo;t shared this little helper before, but here it is.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defun mu-date-at-point (date)
  &amp;quot;Insert current DATE at point via `completing-read&#39;.&amp;quot;
  (interactive
   (let* ((formats &#39;(&amp;quot;%Y%m%d&amp;quot; &amp;quot;%F&amp;quot; &amp;quot;%Y%m%d%H%M&amp;quot; &amp;quot;%Y-%m-%dT%T&amp;quot;))
          (vals (mapcar #&#39;format-time-string formats))
          (opts
           (lambda (string pred action)
             (if (eq action &#39;metadata)
                 &#39;(metadata (display-sort-function . identity))
               (complete-with-action action vals string pred)))))
     (list (completing-read &amp;quot;Insert date: &amp;quot; opts nil t))))
  (insert date))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;What &lt;code&gt;mu-date-at-point&lt;/code&gt; does is formatting the current date in four different ways with &lt;code&gt;format-time-string&lt;/code&gt;  and then offering them as options to &lt;code&gt;completing-read&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The interesting part is how &lt;code&gt;opts&lt;/code&gt; is built. It&amp;rsquo;s a nice trick to ensure its content is always sorted according to the order in &lt;code&gt;formats&lt;/code&gt;. Without leveraging &lt;code&gt;completion-metadata&lt;/code&gt; the completion system would take care of sorting the items for me.&lt;/p&gt;
&lt;p&gt;For the record, I learned how to tweak &lt;code&gt;completion-metadata&lt;/code&gt; on &lt;a href=&#34;https://emacs.stackexchange.com/a/41808&#34;&gt;Emacs StackExchange&lt;/a&gt;. I suggest reading &lt;code&gt;C-h f completing-read&lt;/code&gt; and &lt;code&gt;C-h f completion-metadata&lt;/code&gt; to know more.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Delete duplicate words</title>
      <link>https://manueluberti.eu/posts/2024-06-15-duplicate-words/</link>
      <pubDate>Sat, 15 Jun 2024 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2024-06-15-duplicate-words/</guid>
      <description>&lt;p&gt;I make a lot of mistakes when I write prose, because I usually write down
everything that comes to mind and then edit sentences and paragraphs over and
over again until I get what I want. This is a recipe for all sort of errors, of
course.&lt;/p&gt;
&lt;p&gt;Although I have been a happy user of Flyspell and &lt;code&gt;proselint&lt;/code&gt;, in order not to
get distracted by warnings and errors nowadays I like to avoid automatic
spell-checkers or linters and rely on &lt;code&gt;ispell-buffer&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;There is however a specific category of errors for which &lt;code&gt;ispell-buffer&lt;/code&gt; cannot
help: duplicate words. When quickly rephrasing a sentence or adjusting a
paragraph it could happen that I do not pay enough attention to the words I
remove and so I keep typing with no care whatsoever.&lt;/p&gt;
&lt;p&gt;Much in the spirit of my occasional use of &lt;code&gt;ispell-buffer&lt;/code&gt;, I want a command
that scans the buffer, finds consecutive occurrences of the same word, and
removes all but one of them. Emacs already has a built-in solution for this:
&lt;code&gt;C-M-%&lt;/code&gt; (&lt;code&gt;query-replace-regexp&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;Nevertheless, laziness prevails. Why typing the necessary regular expression
every time when a simple command can do it for me?&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defun mu-delete-duplicate-words ()
  &amp;quot;Delete duplicate words via `query-replace-regexp&#39;.&amp;quot;
  (interactive nil text-mode)
  (save-excursion
    (goto-char (point-min))
    (query-replace-regexp &amp;quot;\\(\\b\\w+\\b\\)\\W+\\1\\b&amp;quot; &amp;quot;\\1&amp;quot;)))
&lt;/code&gt;&lt;/pre&gt;
</description>
    </item>
    <item>
      <title>Thesis frontispiece with LaTeX</title>
      <link>https://manueluberti.eu/posts/2024-04-10-thesis-latex/</link>
      <pubDate>Wed, 10 Apr 2024 15:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2024-04-10-thesis-latex/</guid>
      <description>&lt;p&gt;Usually when I start writing a new document I am not immediately interested
about the output layout. This may sound unorthodox to one accustomed to the
&lt;a href=&#34;https://en.wikipedia.org/wiki/WYSIWYG&#34;&gt;WYSIWYG&lt;/a&gt; likes of Microsoft Word, but
since I mainly write in Markdown and LaTeX, I like to focus on what I want to
say first and think about typesetting the text later. The look of the output
matters, though, so eventually I have to deal with it.&lt;/p&gt;
&lt;p&gt;For example, while working on my BA thesis with LaTeX I was faced with the
problem of the frontispiece. Ca&amp;rsquo; Foscari university provides &lt;a href=&#34;https://unive.it/pag/8751/&#34;&gt;a
template&lt;/a&gt; that students can slap in front of their
documents, but the choice is limited to a couple of popular file formats: DOC
and ODT.&lt;/p&gt;
&lt;p&gt;The quick and dirty solution could have been along these lines:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;edit the ODT template;&lt;/li&gt;
&lt;li&gt;export it to a PDF file;&lt;/li&gt;
&lt;li&gt;add it to the front of my final document.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;However, I decided to stick with AUCTeX and accept the challenge. The following
is a working example based on my thesis that can be saved to a
&lt;code&gt;frontispiece.tex&lt;/code&gt; file:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-tex&#34;&gt;\documentclass[12pt]{book}
\usepackage{geometry}
\usepackage{graphicx}
\usepackage{xcolor}

\begin{document}

\begin{titlepage}

\newgeometry{top=1cm,bottom=1cm,right=1cm,left=1cm}
\fontfamily{lmss}\selectfont
\includegraphics[width=0.15\textwidth]{cafoscari-logo}\par\vspace{1cm}

\begin{center}
\LARGE{Corso di Laurea triennale in \colorbox{gray!10}{indirizzo}\par}
\vspace{1cm}
\LARGE{Tesi di Laurea\par}
\vspace{1.5cm}
{\huge\bfseries \colorbox{gray!10}{titolo}\par}
\LARGE{\colorbox{gray!10}{sottotitolo}\par}
\end{center}
\vspace{2cm}
\vfill
\textbf{Relatore}\\
\colorbox{gray!10}{nome e cognome}\\[0.5cm]
\textbf{Laureando}\\
\colorbox{gray!10}{nome e cognome}\\
\colorbox{gray!10}{numero matricola}\\[0.5cm]
\textbf{Anno Accademico}\\
\colorbox{gray!10}{0000/0001}
\vfill

\end{titlepage}

\end{document}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The only missing bit is the Ca&amp;rsquo; Foscari university logo, referenced above as
&lt;code&gt;{cafoscari-logo}&lt;/code&gt; as per the name of the image file I used, which is
&lt;code&gt;cafoscari-logo.png&lt;/code&gt;. Here it is:&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;&lt;figure&gt;
  &lt;img src=&#34;https://manueluberti.eu/images/cafoscari-logo.png&#34; alt=&#34;&#34;&gt;
  &lt;figcaption class=&#34;center&#34;&gt;
    &lt;small&gt;&lt;em&gt;&lt;/em&gt;&lt;/small&gt;    
  &lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/p&gt;
&lt;p&gt;Now, getting a PDF is simply a matter of placing the &lt;code&gt;.tex&lt;/code&gt; and the &lt;code&gt;.png&lt;/code&gt; files
in the same directory and run something like &lt;code&gt;pdflatex frontispiece.tex&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;On the other hand, I have AUCTeX and PDF Tools on my side. From the comfort of
Emacs I can then set &lt;code&gt;TeX-view-program-selection&lt;/code&gt; to &lt;code&gt;&#39;((output-pdf &amp;quot;PDF Tools&amp;quot;))&lt;/code&gt; and then press &lt;code&gt;C-c C a&lt;/code&gt; to create and display the desired
PDF output.&lt;/p&gt;
&lt;p&gt;One last remark for any Ca&amp;rsquo; Foscari student reading this. To the best of my
knowledge supervisors in the Philosophy department usually ask for drafts in DOC
format. Although this may not be true for other departments, unless LaTeX is a
requirement make sure your supervisor and assistant supervisor, if any, accept
PDFs when you want their valuable opinion on your draft.&lt;/p&gt;
&lt;div class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;
&lt;hr&gt;
&lt;ol&gt;
&lt;li id=&#34;fn:1&#34;&gt;
&lt;p&gt;The logo comes from the ODT template, which is publicly available on the
university website. I just extracted it to a PNG file using LibreOffice
Writer.&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    <item>
      <title>My 2023</title>
      <link>https://manueluberti.eu/posts/2023-12-22-my-2023/</link>
      <pubDate>Fri, 22 Dec 2023 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2023-12-22-my-2023/</guid>
      <description>&lt;p&gt;Another year, another recap. 2023 has been a strange bunch of months for
different reasons. Last year I complained about not finding enough motivation
with my studies and the book clubs I had joined. 2023, on the other hand, has
been definitely better in these regards. I will return to my studies later when
I will deal with my favourite books, but in terms of book clubs I am now a
member of the &lt;a href=&#34;https://proustsociety.org/&#34;&gt;Proust Society of Greenwich&lt;/a&gt; and I
have found myself deeply involved in monthly discussions on my favourite author.
A rewarding experience to say the least, something I would like to expand on
soon.&lt;/p&gt;
&lt;p&gt;Anyway, let&amp;rsquo;s proceed.&lt;/p&gt;
&lt;h3 class=&#34;heading&#34; id=&#34;emacs&#34;&gt;Emacs&lt;/h3&gt;
&lt;p&gt;I have to say 2023 has seen few experiments with the one and only text editor. I
have moved around completion solutions just to rely on the standard, built-in
one eventually, because it has been much improved in &lt;a href=&#34;https://manueluberti.eu/posts/2023-01-12-completions/&#34;&gt;Emacs 29&lt;/a&gt; and therefore in the development version I use as
well. The one thing I was missing is a predictable behaviour for the window
containing the &lt;code&gt;*Completions*&lt;/code&gt; buffer. Basically, I want this window to always
pop up at the bottom.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(add-to-list
 &#39;display-buffer-alist
 &#39;(&amp;quot;\\*Completions*\\*&amp;quot;
   (display-buffer-reuse-mode-window display-buffer-at-bottom)))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Furthermore, I have been relying a lot on &lt;code&gt;project-compile&lt;/code&gt; to run unit and
integration tests and execute &lt;code&gt;shadow-cljs&lt;/code&gt; when needed. Speaking of Cloure, I
have played around a bit with &lt;a href=&#34;https://manueluberti.eu/posts/2023-08-26-clojure-tree-sitter/&#34;&gt;clojure-ts-mode&lt;/a&gt; with nothing to be sad about, although I
have yet to find corner cases which regular &lt;code&gt;clojure-mode&lt;/code&gt; seriously struggles
with.&lt;/p&gt;
&lt;h3 class=&#34;heading&#34; id=&#34;learning-french&#34;&gt;Learning French&lt;/h3&gt;
&lt;p&gt;Early this year I briefly mentioned &lt;a href=&#34;https://manueluberti.eu/posts/2023-02-19-why-proust/&#34;&gt;my intention to learn French&lt;/a&gt; in order to read the entirety of Proust&amp;rsquo;s oeuvre. I
started with the popular Duolingo, but after a while I was tired of random
phrases without context. I cannot learn a language like this. At most this is
good for practising and revising.&lt;/p&gt;
&lt;p&gt;Therefore I went with the good old way: a proper course with a professional
language teacher. I looked for one on Preply until I found the teacher with the
right qualifications. Everything has been great so far, my basic knowledge of
French has already improved a lot.&lt;/p&gt;
&lt;p&gt;Along with the lessons I have been following the same approach I had used in the
past to learn English: language exposure. I watched my first French film without
English subtitles (Roman Polanski&amp;rsquo;s &lt;em&gt;J&amp;rsquo;accuse&lt;/em&gt;), I read my first French book
with a dictionary on the side and no translation to help me (Neige Sinno&amp;rsquo;s
&lt;em&gt;Triste tigre&lt;/em&gt;), I have been reaching for French news (Franceinfo and France
24), and I have been keeping a grammar book next to me for some extra practice.&lt;/p&gt;
&lt;p&gt;All of this would not make much sense if I had not set a goal for myself, which
is a DELF B2 certification. It will take time, but I will get there.&lt;/p&gt;
&lt;h3 class=&#34;heading&#34; id=&#34;books&#34;&gt;Books&lt;/h3&gt;
&lt;p&gt;First, the usual selection from this year&amp;rsquo;s readings:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;I piaceri e i giorni&lt;/em&gt; (Marcel Proust)&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Jean Santeuil&lt;/em&gt; (Marcel Proust)&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Saggi&lt;/em&gt; (Marcel Proust)&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Vita di Marcel Proust&lt;/em&gt; (Jean Yves-Tadié)&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Giovanni&amp;rsquo;s Room&lt;/em&gt; (James Baldwin)&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Teoria del romanzo&lt;/em&gt; (Guido Mazzoni)&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Le vite del romanzo&lt;/em&gt; (Thomas Pavel)&lt;/li&gt;
&lt;li&gt;&lt;em&gt;The Idiot&lt;/em&gt; (Elif Batuman)&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Sulla poesia moderna&lt;/em&gt; (Guido Mazzoni)&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Either/Or&lt;/em&gt; (Elif Batuman)&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Bel Ami&lt;/em&gt; (Guy De Maupassant)&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Blonde&lt;/em&gt; (Joyce Carol Oates)&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Fontamara&lt;/em&gt; (Ignazio Silone)&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Senza intellettuali&lt;/em&gt; (Giorgio Caravale)&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Triste tigre&lt;/em&gt; (Neige Sinno)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;There is no need to explain again why Proust is there. Nonetheless,
here are some additional notes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;literary theory is a wonderful thing;&lt;/li&gt;
&lt;li&gt;I consider &lt;a href=&#34;https://manueluberti.eu/posts/2023-07-23-batuman-ferrari/&#34;&gt;Elif Batuman&lt;/a&gt; one of the
most interesting writers out there. Her newsletter is a nice way to entertain
me while I eagerly wait for her next book;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://manueluberti.eu/posts/2023-09-17-marilyn-avatar/&#34;&gt;Blonde&lt;/a&gt; hit me on so many levels
that I have struggled to find something interesting to write about it. I
honestly believe it is one of the greatest books I have ever put my eyes on;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Triste tigre&lt;/em&gt; started as an exercise because I wanted to read something in
French and it has ended up being an emotional tour de force. A &lt;em&gt;Lolita&lt;/em&gt; from
the other side if you will.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;There is another author that has played an important role in the last months,
but I have not put him on the list because I have only studied bits and pieces
of his writings so far. Still, since it has already been moving me in so many
ways,&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt; he deserves a mention: Antonio Gramsci. Thanks to a course on
political philosophy I have finally had the chance to study Gramsci more closely
and work on my rather sparse knowledge of him. The more I dig the more he is
leaving a mark on me as great as Spinoza&amp;rsquo;s.&lt;/p&gt;
&lt;h3 class=&#34;heading&#34; id=&#34;music&#34;&gt;Music&lt;/h3&gt;
&lt;p&gt;The new records from RVG and Angie McMahon came out right when I needed them
this year. RVG showed up with their best album so far, fiercely personal and
less obvious about its roots than the two before, while McMahon healed her
wounds with an open letter from her heart to the world, as close to a real-life
hug as possible.&lt;/p&gt;
&lt;p&gt;I should also put Róisín Murphy here. Even though her controversial statements
ruined her party, I still believe her latest effort is fantastic. And let&amp;rsquo;s not
forget about Paul St. Hilaire, who came back after many years with all the dub
vibes one could ask for.&lt;/p&gt;
&lt;p&gt;As for Italy, I am glad the people behind the music festival I mentioned last
year are back with a new place for great live music. Thanks to them I found out
about Trust The Mask and their lovely &lt;em&gt;Idiom&lt;/em&gt;. It was impossible to stay still
at the concert, a sign of undeniable quality. I have also the utmost respect for
the intrepid Daniela Pes, whose &lt;em&gt;Spira&lt;/em&gt; sounds like nothing else around me, and
only good words for Marta Del Grandi and The Thugs.&lt;/p&gt;
&lt;p&gt;However, boygenius&amp;rsquo; &lt;em&gt;the record&lt;/em&gt; and, to a lesser extent, the follow-up EP &lt;em&gt;the
rest&lt;/em&gt; are what 2023 has been mostly all about in terms of music. The vinyl did
not come cheap, but &lt;em&gt;the record&lt;/em&gt; has been pretty much my go-to album until
McMahon stole its thunder. It does not matter, anyway, because boygenius are a
storm and they still have plenty a thunder to share.&lt;/p&gt;
&lt;p&gt;As for older music, I have fallen madly in love with Ada Oda, who are clearly
here to remind me new wave is as relevant for me today as it was back in my
youth, and I have found something worth of attention in Andrew WK&amp;rsquo;s most recent
and less appreciated albums. They cannot match the wild rides of his first two
works but at least they do find him at peace with himself somehow.&lt;/p&gt;
&lt;h3 class=&#34;heading&#34; id=&#34;cinema&#34;&gt;Cinema&lt;/h3&gt;
&lt;p&gt;Just as it has been a great year for studying and reading, cinema has found its
way to my heart again. The following is a mixed selection of titles from 2023
and from 2022, because I had so much to catch up with.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;Knock at the Cabin&lt;/em&gt; (M. Night Shyamalan)&lt;/li&gt;
&lt;li&gt;&lt;em&gt;La Nuit du 12&lt;/em&gt; (Dominik Moll)&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Novembre&lt;/em&gt; (Cédric Jimenez)&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Coma&lt;/em&gt; (Bertrand Bonello)&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Pacifiction&lt;/em&gt; (Albert Serra)&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Blonde&lt;/em&gt; (Andrew Dominik)&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Avatar: The Way of Water&lt;/em&gt; (James Cameron)&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Malum&lt;/em&gt; (Anthony DiBlasi)&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Sick of Myself&lt;/em&gt; (Kristoffer Borgli)&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Bodies Bodies Bodies&lt;/em&gt; (Halina Reijn)&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Anatomy of a Fall&lt;/em&gt; (Justine Triet)&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Bottoms&lt;/em&gt; (Emma Seligman)&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Ferrari&lt;/em&gt; (Michael Mann)&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Priscilla&lt;/em&gt; (Sofia Coppola)&lt;/li&gt;
&lt;li&gt;&lt;em&gt;May December&lt;/em&gt; (Todd Haynes)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;As I did with books, some extra notes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;French cinema is still able to say things like nobody else;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://manueluberti.eu/posts/2023-09-17-marilyn-avatar/&#34;&gt;Blonde&lt;/a&gt; is absolutely fantastic and
I wonder if my appreciation for it could explain why I feel so distant from
most contemporary film critics;&lt;/li&gt;
&lt;li&gt;James Cameron is once again reinventing cinema;&lt;/li&gt;
&lt;li&gt;I am so happy that horror films still talk to me;&lt;/li&gt;
&lt;li&gt;I did not need &lt;em&gt;Ferrari&lt;/em&gt; to love Michael Mann, but I am glad he wanted to make
sure my feelings have not changed.&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;
&lt;hr&gt;
&lt;ol&gt;
&lt;li id=&#34;fn:1&#34;&gt;
&lt;p&gt;So much so that the critical editions of his &lt;em&gt;Notebooks&lt;/em&gt; and &lt;em&gt;Letters&lt;/em&gt; are
already next to me.&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    <item>
      <title>Using Ugrep with Embark</title>
      <link>https://manueluberti.eu/posts/2023-10-01-embark-ugrep/</link>
      <pubDate>Sun, 01 Oct 2023 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2023-10-01-embark-ugrep/</guid>
      <description>&lt;p&gt;When I wrote about &lt;a href=&#34;https://manueluberti.eu/posts/2023-09-16-consult-ugrep/&#34;&gt;using Ugrep with Consult&lt;/a&gt; I hinted at the chance of having my custom command available in Embark as
well.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Building on top of Consult is great. Much like &lt;code&gt;consult-git-grep&lt;/code&gt; and
&lt;code&gt;consult-ripgrep&lt;/code&gt;, the integration with Embark is around the corner.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;As &lt;a href=&#34;https://github.com/oantolin/embark/issues/663#issuecomment-1722966589&#34;&gt;Omar Antolín
Camarena&lt;/a&gt;
explained to me, though, it is not immediately obvious how to combine
&lt;code&gt;mu-consult-ugrep&lt;/code&gt; with Embark.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Consult async search commands are tricky to use as Embark actions, which is
why there is an entire, nontrivial embark-consult package to set up the
integration.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;However, he kindly suggested &lt;a href=&#34;https://github.com/oantolin/embark/issues/663#issuecomment-1722967814&#34;&gt;the
solution&lt;/a&gt;
to my problem as well. I just had to add it to my setup:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(with-eval-after-load &#39;embark-consult
  (setf (alist-get &#39;mu-consult-ugrep embark-target-injection-hooks)
        &#39;(embark-consult--prep-async embark--allow-edit))

  (setf (alist-get &#39;mu-consult-ugrep embark-pre-action-hooks)
        &#39;(embark--unmark-target))

  (setf (alist-get &#39;mu-consult-ugrep embark-around-action-hooks)
        &#39;(embark-consult--projectless embark--cd))

  (keymap-set embark-consult-search-map &amp;quot;u&amp;quot; #&#39;mu-consult-ugrep))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The above code lets me call &lt;code&gt;mu-consult-ugrep&lt;/code&gt; on the candidate at point with
&lt;code&gt;C-. C u&lt;/code&gt;, where &lt;code&gt;C-.&lt;/code&gt; corresponds to &lt;code&gt;embark-act&lt;/code&gt; while &lt;code&gt;C&lt;/code&gt;
gives me access to &lt;code&gt;embark-consult-search-map&lt;/code&gt;. This approach complements my
regular usage of &lt;code&gt;mu-consult-ugrep&lt;/code&gt; via &lt;code&gt;M-s u&lt;/code&gt;, which I generally use
when what I am looking for is &lt;em&gt;not&lt;/em&gt; the thing at point.&lt;/p&gt;
&lt;p&gt;Note that &lt;code&gt;C-. C u&lt;/code&gt; can be just as easily replaced by &lt;code&gt;M-s u M-n M-n&lt;/code&gt;
to leverage Emacs&amp;rsquo; future history&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt; or even by &lt;a href=&#34;https://manueluberti.eu/posts/2022-09-01-consult-xref/&#34;&gt;a basic wrapper&lt;/a&gt; around &lt;code&gt;mu-consult-ugrep&lt;/code&gt; that would grab the
thing at point. This is Emacs, of course, so the user is in charge of their
preferences.&lt;/p&gt;
&lt;div class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;
&lt;hr&gt;
&lt;ol&gt;
&lt;li id=&#34;fn:1&#34;&gt;
&lt;p&gt;Type &lt;code&gt;C-h i g&lt;/code&gt; &lt;code&gt;(emacs) Minibuffer History&lt;/code&gt; &lt;code&gt;RET&lt;/code&gt; to
know more.&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    <item>
      <title>Using Ugrep with Consult</title>
      <link>https://manueluberti.eu/posts/2023-09-16-consult-ugrep/</link>
      <pubDate>Sat, 16 Sep 2023 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2023-09-16-consult-ugrep/</guid>
      <description>&lt;p&gt;I have &lt;a href=&#34;https://manueluberti.eu/posts/2022-09-01-consult-xref/&#34;&gt;already discussed&lt;/a&gt; how one can
leverage &lt;code&gt;ugrep&lt;/code&gt; and &lt;code&gt;consult-xref&lt;/code&gt; to make a &lt;code&gt;completing-read&lt;/code&gt; variant of
&lt;code&gt;project-find-regexp&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;However, today I would like to go a bit further and show how easily Consult can
be extended to include a command that behaves like &lt;code&gt;consult-grep&lt;/code&gt;,
&lt;code&gt;consult-git-grep&lt;/code&gt;, and &lt;code&gt;consult-ripgrep&lt;/code&gt;, but with &lt;code&gt;ugrep&lt;/code&gt; as its engine. True,
something along these lines &lt;a href=&#34;https://github.com/minad/consult/issues/604&#34;&gt;has been
around&lt;/a&gt; for a while. And yet I have
no need for an external package when Consult has everything in place in order to
devise a custom command.&lt;/p&gt;
&lt;p&gt;By inspecting the code behind &lt;code&gt;consult-git-grep&lt;/code&gt; and &lt;code&gt;consult-ripgrep&lt;/code&gt; the
pattern is pretty clear:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;a &lt;code&gt;defcustom&lt;/code&gt; with the command (e.g., &lt;code&gt;git grep&lt;/code&gt;) and its arguments&lt;/li&gt;
&lt;li&gt;a builder function to create the actual command to be invoked (e.g.,
&lt;code&gt;consult--git-grep-make-builder&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;a wrapper around &lt;code&gt;consult--grep&lt;/code&gt; (e.g., &lt;code&gt;consult-git-grep&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Therefore, the solution is simple:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defvar mu-consult-ugrep-args (string-join &#39;(&amp;quot;ugrep&amp;quot;
                                             &amp;quot;--color=never&amp;quot;
                                             &amp;quot;--exclude-dir=.git/&amp;quot;
                                             &amp;quot;--hidden&amp;quot;
                                             &amp;quot;--ignore-binary&amp;quot;
                                             &amp;quot;--ignore-case&amp;quot;
                                             &amp;quot;--line-buffered&amp;quot;
                                             &amp;quot;--line-number&amp;quot;
                                             &amp;quot;--null&amp;quot;
                                             &amp;quot;--recursive&amp;quot;)
                                           &amp;quot; &amp;quot;))

(defun mu-consult-ugrep-make-builder (paths)
  &amp;quot;Create ugrep command line builder given PATHS.&amp;quot;
  (let ((cmd (consult--build-args mu-consult-ugrep-args)))
    (lambda (input)
      (pcase-let* ((`(,arg . ,opts) (consult--command-split input))
                   (`(,re . ,hl)
                    (funcall consult--regexp-compiler arg &#39;extended t)))
        (when re
          (cons (append cmd
                        (cdr (mapcan (lambda (x) (list &amp;quot;--and&amp;quot; &amp;quot;-e&amp;quot; x)) re))
                        opts paths)
                hl))))))

(defun mu-consult-ugrep (&amp;amp;optional dir initial)
  &amp;quot;Search with `ugrep&#39; for files in DIR with INITIAL input.&amp;quot;
  (interactive &amp;quot;P&amp;quot;)
  (require &#39;consult)
  (consult--grep &amp;quot;Ugrep&amp;quot; #&#39;mu-consult-ugrep-make-builder dir initial))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Since I am always using the same &lt;code&gt;ugrep&lt;/code&gt; options, my builder function is a bit
simpler than &lt;code&gt;consult--git-grep-make-builder&lt;/code&gt; or
&lt;code&gt;consult--ripgrep-make-builder&lt;/code&gt;. Other than that, it&amp;rsquo;s only a matter of
understanding the right options for &lt;code&gt;ugrep&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Building on top of Consult is great. Much like &lt;code&gt;consult-git-grep&lt;/code&gt; and
&lt;code&gt;consult-ripgrep&lt;/code&gt;, the integration with Embark is around the corner. And now
that the power of the minibuffer is available during my searches I have no use
for &lt;a href=&#34;https://manueluberti.eu/posts/2022-08-07-emacs-ugrep/&#34;&gt;mu-recursive-grep&lt;/a&gt; any more.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Clojure and Tree-sitter</title>
      <link>https://manueluberti.eu/posts/2023-08-26-clojure-tree-sitter/</link>
      <pubDate>Sat, 26 Aug 2023 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2023-08-26-clojure-tree-sitter/</guid>
      <description>&lt;p&gt;By now Emacs users are well aware of
&lt;a href=&#34;https://tree-sitter.github.io/tree-sitter/&#34;&gt;Tree-sitter&lt;/a&gt; and the built-in
integration that comes with &lt;a href=&#34;https://www.masteringemacs.org/article/how-to-get-started-tree-sitter&#34;&gt;Emacs
29&lt;/a&gt;. I am
a bit late to the party because only recently I have started to look into
&lt;code&gt;treesit-language-source-alist&lt;/code&gt; and &lt;code&gt;treesit-install-language-grammar&lt;/code&gt;, but
right now I am more interested in how Clojure programming can benefit from
Tree-sitter.&lt;/p&gt;
&lt;p&gt;Danny Freeman is the maintainer of
&lt;a href=&#34;https://github.com/clojure-emacs/clojure-ts-mode&#34;&gt;clojure-ts-mode&lt;/a&gt;, and after I
kindly &lt;a href=&#34;https://github.com/clojure-emacs/clojure-ts-mode/issues/8#issuecomment-1675729535&#34;&gt;nudged
him&lt;/a&gt;
he made it available on NonGNU ELPA. This means that the package is only a &lt;code&gt;M-x package-install&lt;/code&gt; away.&lt;/p&gt;
&lt;p&gt;Once installed Emacs has to know how to prefer &lt;code&gt;clojure-ts-mode&lt;/code&gt; to good old
&lt;code&gt;clojure-mode&lt;/code&gt;. This is where &lt;code&gt;majore-mode-remap-alist&lt;/code&gt; comes into play.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(push &#39;(clojure-mode . clojure-ts-mode) major-mode-remap-alist)
(push &#39;(clojurec-mode . clojurec-ts-mode) major-mode-remap-alist)
(push &#39;(clojurescript-mode . clojurescript-ts-mode) major-mode-remap-alist)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Since I always use CIDER let&amp;rsquo;s leverage &lt;code&gt;clojure-ts-mode-hook&lt;/code&gt; to enable it.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(add-hook &#39;clojure-ts-mode-hook #&#39;cider-mode)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is enough to activate &lt;code&gt;clojure-ts-mode&lt;/code&gt;, but upon entering a project I
noticed the lack of a couple of useful key bindings.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(with-eval-after-load &#39;clojure-ts-mode
  (keymap-set clojure-ts-mode-map &amp;quot;C-c C-r&amp;quot; &#39;clojure-refactor-map)
  (keymap-set clojure-ts-mode-map &amp;quot;C-c C-x&amp;quot; &#39;cider-start-map))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note that &lt;code&gt;clojure-ts-mode&lt;/code&gt; is still under development. For instance, Danny is
working on allowing users to pick their preferred &lt;a href=&#34;https://github.com/clojure-emacs/clojure-ts-mode/issues/9&#34;&gt;indentation
style&lt;/a&gt;. As Daw-Ran
Liou suggested, for now I can use &lt;code&gt;clojure-mode-variables&lt;/code&gt; to make
&lt;code&gt;clojure-ts-mode&lt;/code&gt; follow my preferred &lt;a href=&#34;https://github.com/clojure-emacs/clojure-ts-mode/issues/9#issuecomment-1547271293&#34;&gt;formatting settings&lt;/a&gt;.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(add-hook &#39;clojure-ts-mode-hook #&#39;clojure-mode-variables)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I have been using &lt;code&gt;clojure-ts-mode&lt;/code&gt; daily in the last two weeks and the
experience has been great. They say Tree-sitter is a game changer. I say thank
you, Danny Freeman.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Tweaking Consult completion</title>
      <link>https://manueluberti.eu/posts/2023-06-17-consult-completion/</link>
      <pubDate>Sat, 17 Jun 2023 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2023-06-17-consult-completion/</guid>
      <description>&lt;p&gt;After &lt;a href=&#34;https://manueluberti.eu/posts/2023-04-16-vertico-current/&#34;&gt;having adapted&lt;/a&gt;
&lt;code&gt;vertico--format-candidate&lt;/code&gt; to behave like I want in my Marginalia-less setup, I
noticed I still had undesired documentation during completion.&lt;/p&gt;
&lt;p&gt;Now, Daniel Mendler created the beautiful Corfu to improve completion at point
in Emacs. However, he did not forget about old school users such as myself and
provided &lt;code&gt;consult-completion-in-region&lt;/code&gt; for the minibuffer lovers out there.&lt;/p&gt;
&lt;p&gt;My only &amp;ldquo;problem&amp;rdquo;&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt; with &lt;code&gt;consult-completion-in-region&lt;/code&gt; is that by default
candidates are offered with some related documentation next to them, much like
what one would see with &lt;code&gt;M-x&lt;/code&gt; were one to use Marginalia. It is
possible to leverage &lt;code&gt;consult-customize&lt;/code&gt; to change a subset of
&lt;code&gt;consult-completion-in-region&lt;/code&gt; details,&lt;sup id=&#34;fnref:2&#34;&gt;&lt;a href=&#34;#fn:2&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;2&lt;/a&gt;&lt;/sup&gt; but to remove the extra information
something else is needed.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(define-advice consult-completion-in-region
    (:around (&amp;amp;rest args) mu-completion-no-extra-properties)
  &amp;quot;Remove extra properties from completion candidates.&amp;quot;
  (cl-letf (((default-value &#39;completion-extra-properties) nil))
    (apply args)))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;A hack, yes, but also another way to prove the level of freedom Emacs empowers
the user with.&lt;/p&gt;
&lt;p&gt;Note that my small modifications to &lt;code&gt;vertico--format-candidate&lt;/code&gt; and
&lt;code&gt;consult-completion-in-region&lt;/code&gt; are not intended to highlight any Vertico or
Consult shortcomings. These are great packages that improve the standard Emacs
experience, thus they should be tried as they come out of the box for a while.
The fact that I can easily adjust them to my preferences just make them shine
even more.&lt;/p&gt;
&lt;div class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;
&lt;hr&gt;
&lt;ol&gt;
&lt;li id=&#34;fn:1&#34;&gt;
&lt;p&gt;The quotes should be enough to suggest that this is not a real problem,
but let me spell it out to avoid confusion.&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&#34;fn:2&#34;&gt;
&lt;p&gt;Try &lt;code&gt;C-h f consult-completion-in-region RET&lt;/code&gt; to know more.&amp;#160;&lt;a href=&#34;#fnref:2&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    <item>
      <title>Tweaking Vertico candidates</title>
      <link>https://manueluberti.eu/posts/2023-04-16-vertico-current/</link>
      <pubDate>Sun, 16 Apr 2023 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2023-04-16-vertico-current/</guid>
      <description>&lt;p&gt;One of the Emacs packages I do not seem to get used to is
&lt;a href=&#34;https://github.com/minad/marginalia&#34;&gt;Marginalia&lt;/a&gt;. There is nothing wrong with
it and since Daniel Mendler is involved the ELisp underneath is great. However,
to me it&amp;rsquo;s just too much information where I rarely want it. When I need that
sort of documentation it&amp;rsquo;s always a quick key binding away.&lt;/p&gt;
&lt;p&gt;Given the author it should not come as a surprise that Marginalia works rather
smoothly with &lt;a href=&#34;https://github.com/minad&#34;&gt;Vertico&lt;/a&gt;. In fact, it works so well
that I only see a &amp;ldquo;problem&amp;rdquo; when I use it &lt;em&gt;without&lt;/em&gt; Marginalia. Months ago I
reported &lt;a href=&#34;https://github.com/minad/vertico/issues/269&#34;&gt;this minor glitch&lt;/a&gt; to
Daniel, but to cut a long story short, at the end of the current selected item
&lt;code&gt;vertico--format-candidate&lt;/code&gt; adds a newline escape sequence to which the
&lt;code&gt;vertico-current&lt;/code&gt; face is applied as well.&lt;/p&gt;
&lt;p&gt;I know, it&amp;rsquo;s a minor thing that should not stop me from using Vertico. Still, it
can be fixed quite easily. I suggested an advice in the aforementioned report,
but since &lt;code&gt;vertico--format-candidate&lt;/code&gt; is implemented as a &lt;code&gt;cl-defgeneric&lt;/code&gt; I can
do better:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(with-eval-after-load &#39;vertico
  (set-face-attribute &#39;vertico-current nil :extend nil)
  
  (cl-defmethod vertico--format-candidate (cnd pref suf idx _start)
    &amp;quot;Format CND given PREF, SUF, and IDX.&amp;quot;
    (setq cnd (vertico--display-string (concat pref cnd suf &amp;quot;\n&amp;quot;)))
    (when (= idx vertico--index)
      (add-face-text-property 0 (1- (length cnd)) &#39;vertico-current &#39;append cnd))
    cnd))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Beside ensuring that &lt;code&gt;vertico-current&lt;/code&gt; does not extend beyond the selected
candidate, I use the lovely named &lt;code&gt;1-&lt;/code&gt; function to avoid applying this face to
&lt;code&gt;\n&lt;/code&gt; as well.&lt;/p&gt;
&lt;p&gt;Note that something like &lt;code&gt;fido-vertical-mode&lt;/code&gt; does not need a hack like this.
Yet I simply cannot resist tinkering with my favourite packages.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>CIDER and Clojure LSP</title>
      <link>https://manueluberti.eu/posts/2023-03-25-clojure-lsp/</link>
      <pubDate>Sat, 25 Mar 2023 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2023-03-25-clojure-lsp/</guid>
      <description>&lt;p&gt;When I wrote about &lt;a href=&#34;https://manueluberti.eu/posts/2022-10-27-cljformat/&#34;&gt;formatting Clojure buffers&lt;/a&gt; I also mentioned that &lt;a href=&#34;https://clojure-lsp.io/&#34;&gt;Clojure LSP&lt;/a&gt; can take care
of this among other things. Since my working days are pretty much Clojure days,
it&amp;rsquo;s time to check out how LSP can help me in this regard and whether the
experience is worth an extra tool.&lt;/p&gt;
&lt;p&gt;Installing Clojure LSP is trivial so I will leave you on your own with that.
After the installation the first thing I tried is the obvious &lt;code&gt;M-x&lt;/code&gt;
&lt;code&gt;eglot&lt;/code&gt; in a Clojure buffer, but all I got was a connection timeout error as a
reply. Weird, I thought, this has never happened with LaTeX. However, the
solution was simple: I just needed to increase the default value of
&lt;code&gt;eglot-connect-timeout&lt;/code&gt; to &lt;code&gt;60&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Emacs can leverage many goodies from Clojure LSP thanks to Eglot, but some of
them out of the box interfere with CIDER. For instance, the integration with
ElDoc is better left in the capable hands of Eglot in order to avoid duplicates
when displaying documentation.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(setq-default cider-eldoc-display-for-symbol-at-point nil)

(defun mu-cider-disable-eldoc ()
  &amp;quot;Let LSP handle ElDoc instead of CIDER.&amp;quot;
  (remove-hook &#39;eldoc-documentation-functions #&#39;cider-eldoc t))

(add-hook &#39;cider-mode-hook #&#39;mu-cider-disable-eldoc)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In a similar fashion I put Clojure LSP in charge of completions. This approach
is useful when in a Clojure buffer all I need is some poking around to
understand the code in front of me. There is no need to jack-in with CIDER to do
just that.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defun mu-cider-disable-completion ()
  &amp;quot;Let LSP handle completion instead of CIDER.&amp;quot;
  (remove-hook &#39;completion-at-point-functions #&#39;cider-complete-at-point t))

(add-hook &#39;cider-mode-hook #&#39;mu-cider-disable-completion)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I am sure CIDER can, and probably will, embrace Clojure LSP some day, but one
cannot blame its developers for these nuisances. On the contrary, we should be
grateful for the ease of customization at our disposal, which is one more reason
to appreciate CIDER, if you ask me.&lt;/p&gt;
&lt;p&gt;Anyway, now I can get rid of &lt;code&gt;mu-cljfmt-format-buffer&lt;/code&gt; and rely on &lt;code&gt;M- eglot-format-buffer&lt;/code&gt; for my Clojure formatting needs. A happy ending
indeed, because removing code from my &lt;code&gt;init.el&lt;/code&gt; is always a pleasure.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Jump to minibuffer from completions</title>
      <link>https://manueluberti.eu/posts/2023-02-25-switch-to-minibuffer/</link>
      <pubDate>Sat, 25 Feb 2023 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2023-02-25-switch-to-minibuffer/</guid>
      <description>&lt;p&gt;More than a month after &lt;a href=&#34;https://manueluberti.eu/posts/2023-01-12-completions/&#34;&gt;my commitment&lt;/a&gt; to
the default built-in completion system I can say that everything has been going
smoothly. I adjusted my muscle memory to hit &lt;code&gt;TAB&lt;/code&gt; in the minibuffer
whenever I need to pop up the &lt;code&gt;*Completions*&lt;/code&gt; window, which to my surprise has
not been happening as much as I was expecting. The only thing that I added to
the original setup is the following:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(keymap-set completion-list-mode-map &amp;quot;M-e&amp;quot; #&#39;switch-to-minibuffer)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is easier to reach than &lt;code&gt;M-g M-c&lt;/code&gt; when I want to move from the
completion window to the minibuffer. Admittedly, it&amp;rsquo;s not something that I do
often, but it can be useful if I need to edit what I have just typed.&lt;/p&gt;
&lt;p&gt;If you are wondering why I chose &lt;code&gt;M-e&lt;/code&gt; for this, the answer is simple.
I like &lt;code&gt;isearch-edit-string&lt;/code&gt; and use it regularly, plus the &lt;code&gt;e&lt;/code&gt; in
&lt;code&gt;M-e&lt;/code&gt; reminds me of the verb &amp;ldquo;edit&amp;rdquo;, which is what this key binding
allows me to do.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Better built-in completions</title>
      <link>https://manueluberti.eu/posts/2023-01-12-completions/</link>
      <pubDate>Thu, 12 Jan 2023 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2023-01-12-completions/</guid>
      <description>&lt;p&gt;Despite me doing my best to track Emacs development and build the latest
&lt;code&gt;master&lt;/code&gt; regularly, I forgot to check out the improvements on the default
&lt;code&gt;*Completions*&lt;/code&gt; buffer that are going to be available on the next official
release of our favourite text editor. Thankfully, &lt;a href=&#34;https://robbmann.io/posts/emacs-29-completions/&#34;&gt;Robert
Enzmann&lt;/a&gt; did it for me.&lt;/p&gt;
&lt;p&gt;Much like Robert, I&amp;rsquo;ve been living with Vertico, Consult, Corfu and Orderless
for a while now, and you won&amp;rsquo;t be hearing any complaint from me on that side.
These packages are simply fantastic. Still, by now a regular reader knows I
enjoy the vanilla Emacs experience, and if there is a chance to stick with it I
am not the one who is going to miss it.&lt;/p&gt;
&lt;p&gt;Robert did a great job already at explaining what&amp;rsquo;s new when it comes to
built-in completions and what settings you can tweak to take advantage of the
new developments. He is sporting pretty animations too, so go check his writing
for further details. I&amp;rsquo;ll just mention that, beside setting
&lt;code&gt;completions-header-format&lt;/code&gt; to &lt;code&gt;nil&lt;/code&gt;, I set &lt;code&gt;completion-show-help&lt;/code&gt; to &lt;code&gt;nil&lt;/code&gt; to
keep the &lt;code&gt;*Completions*&lt;/code&gt; buffer as clean as possible.&lt;/p&gt;
&lt;p&gt;A setup like this is a radical change for me. From my IDO days, I have always
relied on a completion approach rather different than what is available on the
very first Emacs run. Basically one that provides more than a bare prompt. As
expected, it took me a while to adapt and learn to change my old habits. Take
&lt;code&gt;M-x&lt;/code&gt;, for instance. With Helm or Icomplete candidates appear before I
hit other keys, and since I usually sort them by usage, I can navigate to the
most recent one without typing its name at all. To overcome the confusion, I
tried to think at the prompt as a shell one. Like I do in a shell, I type some
letters and then reach for &lt;code&gt;TAB&lt;/code&gt; to complete the rest. It&amp;rsquo;s not that I
wasn&amp;rsquo;t doing something like this before. Think of file paths, for example.
However, most of the times the initial list took me away from the prompt
entirely because what I was after was a &lt;code&gt;C-n&lt;/code&gt; away.&lt;/p&gt;
&lt;p&gt;Moreover, every Vertico and friends user knows that they stay close to Emacs
internals and work like building blocks, nicely complementing each other in
order to extend step by step core functionalities. This means that nothing is
stopping me to keep Consult and Orderless around or having Corfu ready to pop up
completion candidates at point without having to move my eyes to the bottom of
the screen. For anyone yet not convinced, this is another sound proof of how
carefully the likes of Daniel Mendler and Omar Antolín Camarena designed their
packages.&lt;/p&gt;
&lt;p&gt;To get back at Robert&amp;rsquo;s article, I&amp;rsquo;ll ask myself the same question he did to
himself and I&amp;rsquo;ll reply with a similar, enigmatic answer: will I see the
&lt;code&gt;*Completions*&lt;/code&gt; buffer more often from now on? Yes, probably yes.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>LaTeX footnotes and Tempel</title>
      <link>https://manueluberti.eu/posts/2023-01-02-latex-footnotes/</link>
      <pubDate>Mon, 02 Jan 2023 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2023-01-02-latex-footnotes/</guid>
      <description>&lt;p&gt;For those who remember, the combination of AUCTeX and Eglot &lt;a href=&#34;https://manueluberti.eu/posts/2022-03-12-eglot-digestif/&#34;&gt;makes me happy&lt;/a&gt;. And those with even better memory surely
recall me mentioning BibLaTeX for my footnotes. The thing with footnotes,
though, is that having beautiful, automatic completion for my bibliography is
only half of the story. The other half is leveraging yet another great package
from the unstoppable Daniel Mendler: &lt;a href=&#34;https://github.com/minad/tempel&#34;&gt;Tempel&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;As usual with Daniel, the README is full of details, so there is little for me
to add. Following the documentation, I have &lt;code&gt;M-+&lt;/code&gt; bound to
&lt;code&gt;tempel-complete&lt;/code&gt; and then I have few templates for things like &lt;code&gt;clojure-mode&lt;/code&gt;,
&lt;code&gt;emacs-lisp-mode&lt;/code&gt;, and &lt;code&gt;haskell-mode&lt;/code&gt; in an aptly named &lt;code&gt;templates&lt;/code&gt; file. I also
have the following for &lt;code&gt;latex-mode&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-lisp&#34;&gt;(footnote &amp;quot;\\footnote{&amp;quot; p &amp;quot;.}&amp;quot;)
(texcite &amp;quot;\\textcite{&amp;quot; p &amp;quot;}&amp;quot;)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It may look like trivial stuff, I know, but this is all it takes to insert a
footnote:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Hit &lt;code&gt;M-+&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Pick &lt;code&gt;footnote&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;If no bibliographical entry is needed, type the desired text&lt;/li&gt;
&lt;li&gt;Otherwise, hit &lt;code&gt;M-+&lt;/code&gt; again&lt;/li&gt;
&lt;li&gt;Pick &lt;code&gt;textcite&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Let Corfu powered by Digestif offer the required bibliographical entry&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Trust me, it&amp;rsquo;s a quick manoeuvre once you get used to it. It&amp;rsquo;s also a bit
cumbersome, if you ask me. Daniel must know me better than I know myself because
Tempel already provides a simpler option, namely the &lt;code&gt;tempel-key&lt;/code&gt; macro.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(with-eval-after-load &#39;tex
  (tempel-key &amp;quot;C-c t f&amp;quot; footnote TeX-mode-map)
  (tempel-key &amp;quot;C-c t t&amp;quot; texcite TeX-mode-map))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now with few key strokes and AUCTeX doing the rest of the heavy lifting I can
safely focus on the content of my document without worrying about the footnotes.&lt;/p&gt;
&lt;p&gt;Note that &lt;code&gt;tempel-key&lt;/code&gt; sort of fixes a small issue with &lt;code&gt;tempel-complete&lt;/code&gt;. When
I hit &lt;code&gt;M-+&lt;/code&gt; right after the last letter of a word, I get a message
saying &lt;code&gt;tempel--interactive: tempel-complete: No completions&lt;/code&gt;. To avoid this
unpleasant behaviour either I add an extra whitespace character to be removed
after the footnote is ready, or I use &lt;code&gt;tempel-key&lt;/code&gt;. The better alternative is
obvious.&lt;/p&gt;
&lt;p&gt;A final warning: the most recent version of Digestif introduced a problem with
&lt;code&gt;completion-at-point&lt;/code&gt; and Xref, which &lt;a href=&#34;https://github.com/astoff/digestif/issues/55&#34;&gt;I
reported&lt;/a&gt; on the bug tracker. For
now it&amp;rsquo;s possible to work around the issue by using commit &lt;code&gt;f1b4202&lt;/code&gt; as &lt;a href=&#34;https://github.com/astoff/digestif/issues/55#issuecomment-1368907844&#34;&gt;I
wrote&lt;/a&gt;
over there.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>My 2022</title>
      <link>https://manueluberti.eu/posts/2022-12-22-my-2022/</link>
      <pubDate>Thu, 22 Dec 2022 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2022-12-22-my-2022/</guid>
      <description>&lt;p&gt;This year I am going to approach my usual recap in a different way. Instead of
separating best-of lists I will look back at 2022 in a single writing to keep it
simple.&lt;/p&gt;
&lt;p&gt;2022 will not be remembered as a particularly stimulating time. For instance, I
have struggled to keep my enthusiasm alive when it comes to university. This is
not solely because of the whole mess with &lt;a href=&#34;https://manueluberti.eu/posts/2022-07-05-remote-uni/&#34;&gt;dual lessons&lt;/a&gt;, but it encompasses the quality of the courses and
what I have been learning as well. Maybe I will return on this at some point in
the future, but for now let me just add that once again I can&amp;rsquo;t wait to get it
over with. Almost the same reasoning can explain why I left the two book clubs I
had joined in 2021. I was not pleased by the reading choices nor by the
discussions around them, and more often than not it felt like I was putting
obstacles between me and the books I want to read. But let&amp;rsquo;s set aside the
negativity for a while and see what really mattered this year.&lt;/p&gt;
&lt;h3 class=&#34;heading&#34; id=&#34;emacs&#34;&gt;Emacs&lt;/h3&gt;
&lt;p&gt;I usually document my Emacs adventures on this website so I&amp;rsquo;ll be brief. For the
ever-present and more reliable software in my computing life this has been the
first year fully away from Magit and MELPA. The built-in VC system has been a
trustworthy companion, and the combination of GNU ELPA and NonGNU ELPA has
provided the few external packages I need. Speaking of packages, Eglot deserves
a mention. It&amp;rsquo;s true that I don&amp;rsquo;t use it for work, but whenever I deal with
academic writings (LaTeX) or hobby projects (Haskell) Eglot has made me
appreciate some of the goodies that LSP has to offer. Another package worth
being included here is
&lt;a href=&#34;https://git.sr.ht/%7Eniklaseklund/detached.el&#34;&gt;detached.el&lt;/a&gt;, which I&amp;rsquo;ve been
using to run commands like &lt;code&gt;bundle&lt;/code&gt;, &lt;code&gt;yarn&lt;/code&gt;, and &lt;code&gt;shadow-cljs&lt;/code&gt; from &lt;code&gt;shell-mode&lt;/code&gt;
without losing control of the buffer. So neat.&lt;/p&gt;
&lt;h3 class=&#34;heading&#34; id=&#34;sourcehut&#34;&gt;SourceHut&lt;/h3&gt;
&lt;p&gt;Early this year I moved my projects from GitHub to &lt;a href=&#34;https://manueluberti.eu/posts/2022-04-08-sourcehut/&#34;&gt;SourceHut&lt;/a&gt;. This was such an important step for me because for
my repositories I don&amp;rsquo;t want to worry about actions, notifications, unnecessary
JavaScript, and giant corporations stalking my code. SourceHut firmly avoids all
of that and provides the user with a small set of great tools. GitHub helped me
to get out of my cave and learn how to share and collaborate with others,
something not to be underestimated. However, SourceHut cares. The least I could
do was joining them to support this wonderful act of caring.&lt;/p&gt;
&lt;h3 class=&#34;heading&#34; id=&#34;divestos&#34;&gt;DivestOS&lt;/h3&gt;
&lt;p&gt;After almost six years, in May I decided to leave the default Fairphone OS
behind and look for &lt;a href=&#34;https://manueluberti.eu/posts/2022-05-15-divestos/&#34;&gt;something different&lt;/a&gt;.
The experience with DivestOS has been so fantastic I had to make a donation to
this awesome project. My phone battery now lasts longer than ever before and the
user interface is generally more responsive, but the true value of this OS is
that I have a Google-free Fairphone 2 that works as expected. For a person who
has basic needs when it comes to their smartphone and wishes for better privacy,
DivestOS is the perfect solution.&lt;/p&gt;
&lt;h3 class=&#34;heading&#34; id=&#34;books&#34;&gt;Books&lt;/h3&gt;
&lt;p&gt;From the book lover perspective 2022 has been intense, and I am not referring to
the total number of pages I read. What I mean is the profound quality of the
works I&amp;rsquo;ve been through and the hours spent thinking both while reading and
after the turn of the last page. Even in &lt;a href=&#34;https://manueluberti.eu/posts/2022-04-13-il-cavallo-rosso/&#34;&gt;the one case&lt;/a&gt; where I got angry at the author it was still
worth it. Here are the most rewarding readings of the past months:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;Anna Karenina&lt;/em&gt; (Leo Tolstoy)&lt;/li&gt;
&lt;li&gt;&lt;em&gt;In the Eye of the Wild&lt;/em&gt; (Nastassja Martin)&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Cecilia e le streghe&lt;/em&gt; (Laura Conti)&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Malvina, or the Heart&amp;rsquo;s Intuition&lt;/em&gt; (Maria Wirtemberska)&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Le Père Goriot&lt;/em&gt; (Honoré de Balzac)&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Beloved&lt;/em&gt; (Toni Morrison)&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Spinoza&amp;rsquo;s Religion: A New Reading of the Ethics&lt;/em&gt; (Clare Carlisle)&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://manueluberti.eu/posts/2022-08-19-horcynus-orca/&#34;&gt;Horcynus Orca&lt;/a&gt; (Stefano D&amp;rsquo;Arrigo)&lt;/li&gt;
&lt;li&gt;&lt;em&gt;The Handmaid&amp;rsquo;s Tale&lt;/em&gt; (Margaret Atwood)&lt;/li&gt;
&lt;li&gt;&lt;em&gt;The Pale King&lt;/em&gt; (David Foster Wallace)&lt;/li&gt;
&lt;li&gt;&lt;em&gt;In Search of Lost Time&lt;/em&gt; (Marcel Proust)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Most of these are classics so you don&amp;rsquo;t really need my words to pick them up.
Still, it&amp;rsquo;s safe to say that for one reason or another they all are experiences
to treasure, worth the time and the effort that they require. If you are
wondering where philosophy fits in my 2022 readings, I can say Kant, Hegel, and
Deleuze are the authors I have spent a great deal of days on, but there has been
room for Spinoza, Heidegger, Wittgenstein, and Adorno too.&lt;/p&gt;
&lt;h3 class=&#34;heading&#34; id=&#34;music&#34;&gt;Music&lt;/h3&gt;
&lt;p&gt;As an avid music listener and record collector, I feel a bit ashamed in this
regard. The only records I bought this year are &lt;a href=&#34;https://manueluberti.eu/posts/2022-08-14-big-time/&#34;&gt;Big Time&lt;/a&gt; by Angel Olsen and &lt;em&gt;II&lt;/em&gt; by Liberato, but Olsen&amp;rsquo;s
costed me a small fortune, so there goes my banal excuse for not sticking more
with music in 2022.&lt;/p&gt;
&lt;p&gt;Anyway, some of my best experiences had more to do with concerts. I went to a
little festival last summer, called Upside Fest, created by the same people
behind the loveliest place for beer and live music around here that sadly did
not survive the pandemic. The festival was all about independent music,
workshops, and being friendly to each other, which is the sort of spirit the
organizers always put in everything they do. It took place in the small park of
what long ago was the castle of the town, a cozy and quiet environment which
invites everyone to massive chill out sessions. It&amp;rsquo;s impossible to come out
bored or unhappy when these people are involved.&lt;/p&gt;
&lt;p&gt;On the opposite side of the intimacy spectrum, I finally attend a Liberato&amp;rsquo;s
live performance. The show has been postponed multiple times due to COVID-19,
but eventually they did it and it was glorious. I am not too fond of big
concerts and huge crowds these days, but Liberato is some of the best music
Italy has at the moment so I could not miss it. He pretty much remixed all of
his tracks, interpolating covers and extending them with new beats for the
entire set. We danced (well, jumped around mostly) and yelled Neapolitan words
for two hours. Fun times indeed.&lt;/p&gt;
&lt;h3 class=&#34;heading&#34; id=&#34;cinema&#34;&gt;Cinema&lt;/h3&gt;
&lt;p&gt;I know this is going to sound horrible coming from a self-proclaimed cinephile,
but all things considered I have not been able to feel moved, involved,
passionate with a film not already part of my Blu-ray and DVD collection. I can
mention &lt;em&gt;Elvis&lt;/em&gt; and &lt;em&gt;Kimi&lt;/em&gt; as pleasant and interesting movies, but titles such
as &lt;em&gt;Deep Water&lt;/em&gt;, &lt;em&gt;Armageddon Time&lt;/em&gt;, and &lt;em&gt;Crimes of the Future&lt;/em&gt; were just below
my expectations. The only exception to this bleakness is &lt;em&gt;The Fabelmans&lt;/em&gt;, which
although formulaic, predictable, and not up there with the best from Steven
Spielberg, shows love for the art and it understands where the heart fits among
the images. It reminded me of Zhang Yimou&amp;rsquo;s &lt;em&gt;One Second&lt;/em&gt;, hence storytelling for
the sake of telling.&lt;/p&gt;
&lt;p&gt;It looks like I have been approaching films with a precise idea of what I wanted
from them, which is obviously not the right thing to do. Cinema owes me nothing
and it&amp;rsquo;s up to me to be open and apply my mind accordingly. I see myself getting
tired quickly with recent films, throwing around comparisons and unable to
accept what is in front of me. I have not been keeping up with new releases, at
least not as much as I used to, so I don&amp;rsquo;t have the proper tools to understand
where cinema is going and why. I hope this is just some sort of vacation from
one of my deepest and oldest loves in order to regain the mindset to be at peace
with it again.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Automatically format Clojure buffers</title>
      <link>https://manueluberti.eu/posts/2022-10-27-cljformat/</link>
      <pubDate>Thu, 27 Oct 2022 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2022-10-27-cljformat/</guid>
      <description>&lt;p&gt;Contrary to my experience with free or open source projects, when it comes to
the proprietary software I have been developing for work since late 2004, code
formatting has never been matter of discussion. There was a team, back in my
days in the UK, that enforced some strict rules via Ant, but until today that
was the sole exception.&lt;/p&gt;
&lt;p&gt;Luckily the people I am coding with nowadays are more open to this kind of
problem. Yes, I used the word &lt;em&gt;problem&lt;/em&gt;. As I explained to a co-worker when I
raised the question of formatting tools, I read code as I read a book. I cannot
imagine sitting through different books each written according to the authors&#39;
own ideas of stylistic conventions. It&amp;rsquo;s about having the text, whether words or
code,&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt; accessible to anyone by making the assumption that the first step to
understanding is ease of legibility.&lt;/p&gt;
&lt;p&gt;The team agreed on using &lt;a href=&#34;https://github.com/weavejester/cljfmt&#34;&gt;cljfmt&lt;/a&gt; for
this task. Most of the developers here use Clojure LSP and, from what I
understand, the integration with &lt;code&gt;cljfmt&lt;/code&gt; is already there for them. I, on the
other hand, went with a more manual approach. I first built the &lt;code&gt;cljfmt&lt;/code&gt; binary
with GraalVM thanks to Rune Juhl Jacobsen&amp;rsquo;s useful
&lt;a href=&#34;https://github.com/runejuhl/cljfmt-graalvm&#34;&gt;cljfmt-graalvm&lt;/a&gt;. Rune offers a
snippet for &lt;code&gt;use-package&lt;/code&gt; and Projectile users, but I leveraged &lt;code&gt;project.el&lt;/code&gt; and
a CIDER hook instead.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defvar mu-cljfmt-edn &amp;quot;cljfmt.edn&amp;quot;
  &amp;quot;The name of `cljfmt&#39; configuration file.&amp;quot;)
  
(defun mu-cljfmt-format-buffer ()
  &amp;quot;Format current buffer with `cljfmt&#39;.&amp;quot;
  (when (derived-mode-p &#39;clojure-mode)
    (let* ((pr (project-root (project-current)))
           (cfg-dir (locate-dominating-file pr mu-cljfmt-edn))
           (cfg-edn (expand-file-name mu-cljfmt-edn cfg-dir))
           (cmd (if (file-exists-p cfg-edn)
                    (format &amp;quot;cljfmt -c %s %s&amp;quot; cfg-edn buffer-file-name)
                  (format &amp;quot;cljfmt %s&amp;quot; buffer-file-name))))
      (shell-command-to-string cmd))
    (revert-buffer t t)))

(defun mu-cider-format-buffer ()
  &amp;quot;Automatically format current buffer after saving.&amp;quot;
  (add-hook &#39;after-save-hook #&#39;mu-cljfmt-format-buffer nil t))

(add-hook &#39;cider-mode-hook #&#39;mu-cider-format-buffer)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Some things worth considering:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;the location and the name of the &lt;code&gt;cljfmt.edn&lt;/code&gt; file matter, so check your
projects if you follow my approach. For instance, the snippet provided by Rune
uses &lt;code&gt;.cljfmt.edn&lt;/code&gt;. With &lt;code&gt;mu-cljfmt-edn&lt;/code&gt; I can customize it per-project via
directory variables, if needed.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;clojurec-mode&lt;/code&gt; and &lt;code&gt;clojurescript-mode&lt;/code&gt; are both derived from &lt;code&gt;clojure-mode&lt;/code&gt;.
This explains the use of &lt;code&gt;derived-mode-p&lt;/code&gt;;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;in buffers handled by &lt;code&gt;clojure-mode&lt;/code&gt; I always have CIDER enabled, even if not
necessarily jacked-in. For a more general approach, &lt;code&gt;clojure-mode-hook&lt;/code&gt; should
be preferred;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;CIDER provides an
&lt;a href=&#34;https://docs.cider.mx/cider/usage/misc_features.html#formatting-code-with-cljfmt&#34;&gt;integration&lt;/a&gt;
with &lt;code&gt;cljfmt&lt;/code&gt;. Depending on your needs that may be already enough.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;With a tool tweaked to format code
&lt;a href=&#34;https://github.com/bbatsov/clojure-style-guide&#34;&gt;idiomatically&lt;/a&gt; for us, now it&amp;rsquo;s
time to argue about names. Wait, let me refresh my &lt;em&gt;hadoukens&lt;/em&gt; first.&lt;/p&gt;
&lt;div class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;
&lt;hr&gt;
&lt;ol&gt;
&lt;li id=&#34;fn:1&#34;&gt;
&lt;p&gt;By the way, looking at code as text is the subject of &lt;a href=&#34;https://pwlconf.org/2022/zach-tellman/&#34;&gt;Sense and
Structure: Towards a Textual Analysis of
Software&lt;/a&gt;, a recent talk by Zach
Tellman.&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    <item>
      <title>Jump to the last change in the buffer</title>
      <link>https://manueluberti.eu/posts/2022-10-16-back-last-edit/</link>
      <pubDate>Sun, 16 Oct 2022 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2022-10-16-back-last-edit/</guid>
      <description>&lt;p&gt;Ages ago I did the minimally required amount of work to get Chris Done&amp;rsquo;s
&lt;a href=&#34;https://github.com/chrisdone/emacs-config/blob/master/packages/goto-last-point/goto-last-point.el&#34;&gt;goto-last-point&lt;/a&gt;
to MELPA. Recently the maintenance of that package has been taken over by
&lt;a href=&#34;https://github.com/melpa/melpa/pull/8164&#34;&gt;someone else&lt;/a&gt; as part of me moving
away from GitHub and caring only about projects I want to actively maintain.&lt;/p&gt;
&lt;p&gt;The thing with &lt;code&gt;goto-last-point&lt;/code&gt; is that it&amp;rsquo;s too much code for me. I simply
want to jump back to the last change in the buffer when I need. A savvy Emacs
user knows that commands such as &lt;code&gt;isearch-forward&lt;/code&gt; (&lt;code&gt;C-s&lt;/code&gt;) or
&lt;code&gt;beginning-of-buffer&lt;/code&gt; (&lt;code&gt;M-&amp;lt;&lt;/code&gt;) push mark at the previous position,
making it easy to go back to that position with a quick &lt;code&gt;C-u C-SPC&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;However, suppose for a moment that for some inexplicable reason you reached over
to the scroll wheel to move around your buffer. &lt;code&gt;C-u C-SPC&lt;/code&gt; cannot help
you now.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defun mu-back-to-last-edit ()
  &amp;quot;Jump back to the last change in the current buffer.&amp;quot;
  (interactive)
  (ignore-errors
    (let ((inhibit-message t))
      (undo-only)
      (undo-redo))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Bind &lt;code&gt;mu-back-to-last-edit&lt;/code&gt; to a key binding of your choice and no matter the
weird dances your point is put through, you can safely reach for the last edit
without thinking too much about it.&lt;/p&gt;
&lt;p&gt;Note that I am using &lt;code&gt;ignore-errors&lt;/code&gt; and &lt;code&gt;inhibit-message&lt;/code&gt; just because both
&lt;code&gt;undo-only&lt;/code&gt; and &lt;code&gt;undo-redo&lt;/code&gt; display useful messages that, in this specific case
only, I don&amp;rsquo;t need. You could avoid them if you don&amp;rsquo;t mind some noise in the
echo area.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Update on Eglot and jdtls</title>
      <link>https://manueluberti.eu/posts/2022-09-27-jdtls-data/</link>
      <pubDate>Tue, 27 Sep 2022 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2022-09-27-jdtls-data/</guid>
      <description>&lt;p&gt;This is just a quick update on the status of Eclipse JDT Language Server support
in Eglot.&lt;/p&gt;
&lt;p&gt;Since my Python skills are close to none, &lt;a href=&#34;https://github.com/eclipse/eclipse.jdt.ls/pull/2207#issuecomment-1258544400&#34;&gt;Roland
Grunberg&lt;/a&gt;
kindly stepped forward to &lt;a href=&#34;https://github.com/eclipse/eclipse.jdt.ls/commit/b93370662a8e4e552dc2af162eb9510b276e0203&#34;&gt;make
sure&lt;/a&gt;
that &lt;code&gt;jdtls&lt;/code&gt; can take care of setting up everything in order to &lt;a href=&#34;https://manueluberti.eu/posts/2022-08-18-eglot-jdtls-data/&#34;&gt;avoid ugly
workarounds in Emacs&lt;/a&gt; and, I guess,
other text editors and IDEs as well.&lt;/p&gt;
&lt;p&gt;The fix will be available on the
&lt;a href=&#34;https://github.com/eclipse/eclipse.jdt.ls/milestone/106?closed=1&#34;&gt;next&lt;/a&gt; Eclipse
JDT milestone. However, nothing stops you from grabbing the &lt;a href=&#34;https://download.eclipse.org/jdtls/snapshots/?d&#34;&gt;latest snapshot
build&lt;/a&gt; and &lt;code&gt;M-x&lt;/code&gt;
&lt;code&gt;eglot&lt;/code&gt; away in your Java projects.&lt;/p&gt;
&lt;p&gt;Even though I am not working with Java these days, it&amp;rsquo;s good to know that I
&lt;em&gt;could&lt;/em&gt; do it in Emacs with the nice features LSP offers.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Working with diff-mode</title>
      <link>https://manueluberti.eu/posts/2022-09-24-diff-mode/</link>
      <pubDate>Sat, 24 Sep 2022 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2022-09-24-diff-mode/</guid>
      <description>&lt;p&gt;One Emacs package that has been with me for a very long time is
&lt;a href=&#34;https://github.com/dgutov/diff-hl&#34;&gt;diff-hl&lt;/a&gt;, and the reason is not its
on-the-fly coloured fringe markers, but the fact that colours stay there when I
visit the same buffer later. This is useful since more often than not I end my
work day with something still in progress, so the next morning it&amp;rsquo;s easier to
use &lt;code&gt;diff-hl-next-hunk&lt;/code&gt; and &lt;code&gt;diff-hl-previous-hunk&lt;/code&gt; to move around my unfinished
edits.&lt;/p&gt;
&lt;p&gt;However, I have put &lt;code&gt;diff-hl&lt;/code&gt; aside because there have been some welcome
improvements lately on the built-in &lt;code&gt;diff-mode&lt;/code&gt;, especially the possibility to
edit its buffer contents and commit &lt;a href=&#34;https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=4803fba487d41f0817feab48b5095ef4b4940ff6&#34;&gt;straight from it&lt;/a&gt;. I now find myself using
&lt;code&gt;C-x v D&lt;/code&gt; (&lt;code&gt;vc-root-diff&lt;/code&gt;) many times a day, and by using
&lt;code&gt;diff-mode&lt;/code&gt; more, I have started to appreciate one simple thing that was already
available to me but have always ignored, that is the navigation among hunks with
&lt;code&gt;diff-hunk-next&lt;/code&gt; (&lt;code&gt;n&lt;/code&gt;) and &lt;code&gt;diff-hunk-prev&lt;/code&gt; (&lt;code&gt;p&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;The pattern, already become muscle memory, is the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;C-x p p&lt;/code&gt; to enter the project I am working on&lt;/li&gt;
&lt;li&gt;Visit the file I am interested in&lt;/li&gt;
&lt;li&gt;Hit &lt;code&gt;C-x v =&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Move with either &lt;code&gt;n&lt;/code&gt; or &lt;code&gt;p&lt;/code&gt; to the desired hunk&lt;/li&gt;
&lt;li&gt;Hit &lt;code&gt;RET&lt;/code&gt; to jump to the hunk&lt;/li&gt;
&lt;li&gt;Hit &lt;code&gt;C-x 1&lt;/code&gt; to hide the &lt;code&gt;diff-mode&lt;/code&gt; buffer&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Easy and quick. I guess one could even speed up the process by using
something like &lt;code&gt;recentf-mode&lt;/code&gt;, for instance, but I&amp;rsquo;ll leave that to you wild
ELisp explorers.&lt;/p&gt;
&lt;p&gt;By the way, after months with VC instead of Magit,&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt; the combination of
&lt;code&gt;vc-dir&lt;/code&gt;, &lt;code&gt;vc-git&lt;/code&gt;, &lt;code&gt;diff-mode&lt;/code&gt;, and &lt;code&gt;shell-command&lt;/code&gt; has resulted in one of the
most dreaded command any serious Emacs user can think of, one that I cannot even
type out of fear of mystical forces coming after me. Let&amp;rsquo;s just say it involves
&lt;code&gt;package-delete&lt;/code&gt; and&amp;hellip; Dear GNU, they&amp;rsquo;re already here.&lt;/p&gt;
&lt;div class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;
&lt;hr&gt;
&lt;ol&gt;
&lt;li id=&#34;fn:1&#34;&gt;
&lt;p&gt;My actual focus on VC roughly started last year, see: &lt;a href=&#34;https://manueluberti.eu/posts/2021-12-05-vc-rebasing/&#34;&gt;Rebasing with
VC&lt;/a&gt;.&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    <item>
      <title>Automatically highlight regular expressions</title>
      <link>https://manueluberti.eu/posts/2022-09-06-tk-font-lock/</link>
      <pubDate>Tue, 06 Sep 2022 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2022-09-06-tk-font-lock/</guid>
      <description>&lt;p&gt;While reading the nice &lt;a href=&#34;https://jakebox.github.io/blog/posts/highlight_buffer_text/&#34;&gt;Straightforward Emacs: Automatically Highlight Buffer
Text&lt;/a&gt;, I kept
wondering whether I could get a similar solution with Emacs built-in facilities.
The article explains how to highlight &amp;ldquo;TK&amp;rdquo; and variations of it (e.g.,
&amp;ldquo;TKTKTKTK&amp;rdquo;) using the helpful
&lt;a href=&#34;https://codeberg.org/ideasman42/emacs-hl-prog-extra&#34;&gt;hl-prog-extra&lt;/a&gt;. The author
says they had to rely on an external package &amp;ldquo;after some searching and trial and
error&amp;rdquo;, but it is in fact possible to avoid &lt;code&gt;hl-prog-extra&lt;/code&gt; for the simple
problem they are trying to solve. The trick is using &lt;code&gt;font-lock-add-keywords&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;First of all, I am going to use a custom face instead of the
&lt;code&gt;font-lock-warning-face&lt;/code&gt; one used in the original article, because I like to
think of &amp;ldquo;TK&amp;rdquo; as a comment instead of a warning.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defface mu-tk-face &#39;((t :inherit font-lock-comment-face :bold t))
  &amp;quot;Face used to highlight \&amp;quot;TK\&amp;quot; markers.&amp;quot;)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then I am going to create a small function to hook into the mode where I want to
use &amp;ldquo;TK&amp;rdquo; markers.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defvar mu-tk-regexp &amp;quot;\\(TK\\)+&amp;quot;
  &amp;quot;Regexp to identify \&amp;quot;TK\&amp;quot; markers.&amp;quot;)

(defun mu-markdown-mode-setup ()
  &amp;quot;Configure `markdown-mode&#39;.&amp;quot;
  (font-lock-add-keywords nil `((,mu-tk-regexp 0 &#39;mu-tk-face))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The rest is trivial:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(add-hook &#39;markdown-mode-hook #&#39;mu-markdown-mode-setup)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This should be enough already, but since I use &lt;code&gt;flyspell-mode&lt;/code&gt; in my Markdown
documents it has to ignore &amp;ldquo;TK&amp;rdquo; so as to avoid having the &lt;code&gt;flyspell-incorrect&lt;/code&gt;
face interfering with my own &lt;code&gt;mu-tk-face&lt;/code&gt;. In order to accomplish this, I need a
function that ignores these markers so I can use it as the value of
&lt;code&gt;flyspell-generic-check-word-predicate&lt;/code&gt;.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defun mu-flyspell-skip-tk ()
  &amp;quot;Ignore \&amp;quot;TK\&amp;quot; markers when spell-checking.&amp;quot;
  (not (string-match-p mu-tk-regexp (thing-at-point &#39;word t))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Finally it&amp;rsquo;s enough to add the following to &lt;code&gt;mu-markdown-mode-setup&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(setq-local flyspell-generic-check-word-predicate #&#39;mu-flyspell-skip-tk)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now I can use &amp;ldquo;TK&amp;rdquo; markers as intended.&lt;/p&gt;
&lt;p&gt;&lt;figure&gt;
  &lt;img src=&#34;https://manueluberti.eu/images/tk.png&#34; alt=&#34;&#34;&gt;
  &lt;figcaption class=&#34;center&#34;&gt;
    &lt;small&gt;&lt;em&gt;&lt;/em&gt;&lt;/small&gt;    
  &lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/p&gt;
&lt;p&gt;Hopefully it should be obvious that I am &lt;em&gt;not&lt;/em&gt; advising against using
&lt;code&gt;hl-prog-extra&lt;/code&gt; for your highlighting needs. My code is a small solution to a
tiny itch, while the scope of &lt;code&gt;hl-prog-extra&lt;/code&gt; is much larger. The intent of this
writing is just showing that for certain tasks Emacs comes already prepared.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Ugrep and consult-xref</title>
      <link>https://manueluberti.eu/posts/2022-09-01-consult-xref/</link>
      <pubDate>Thu, 01 Sep 2022 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2022-09-01-consult-xref/</guid>
      <description>&lt;p&gt;This is going to be a small correction to my &lt;a href=&#34;https://manueluberti.eu/posts/2022-08-31-project-find-regexp/&#34;&gt;previous post&lt;/a&gt; about Ugrep and project navigation.&lt;/p&gt;
&lt;p&gt;If you remember, I was using &lt;code&gt;xref-show-definitions-completing-read&lt;/code&gt; to make
&lt;code&gt;project-find-regexp&lt;/code&gt; offer its results in the minibuffer. The problem with that
command is that the results are grouped by file, which is good, but within the
groups they do not appear to be sorted by line number, which is not so good.&lt;/p&gt;
&lt;p&gt;However, since I am already using &lt;a href=&#34;https://github.com/minad/consult&#34;&gt;consult&lt;/a&gt;
the solution is right behind the corner.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defun mu-project-find-regexp ()
  &amp;quot;Use `project-find-regexp&#39; with completion.&amp;quot;
  (interactive)
  (defvar xref-show-xrefs-function)
  (let ((xref-show-xrefs-function #&#39;consult-xref))
    (if-let ((tap (thing-at-point &#39;symbol)))
        (project-find-regexp tap)
      (call-interactively #&#39;project-find-regexp))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The documentation of &lt;code&gt;consult-xref&lt;/code&gt; itself is pretty clear.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Show xrefs with preview in the minibuffer.&lt;/p&gt;
&lt;p&gt;This function can be used for ‘xref-show-xrefs-function&#39;.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Now the only thing left is saying &amp;ldquo;Thank you, Daniel Mendler!&amp;rdquo; one more time for
all his beautiful work.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Search thing at point with Ugrep</title>
      <link>https://manueluberti.eu/posts/2022-08-31-project-find-regexp/</link>
      <pubDate>Wed, 31 Aug 2022 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2022-08-31-project-find-regexp/</guid>
      <description>&lt;p&gt;When I described &lt;a href=&#34;https://manueluberti.eu/posts/2022-08-07-emacs-ugrep/&#34;&gt;how I use Ugrep in
Emacs&lt;/a&gt; I forgot to mention
something. It&amp;rsquo;s true that I rely on &lt;code&gt;project-find-regexp&lt;/code&gt; (&lt;code&gt;C-x p g&lt;/code&gt;)
for searches, but there is a specific use-case where this command is not as
handy as it usually is: project-wide navigation.&lt;/p&gt;
&lt;p&gt;To be more precise, in my daily workflows it can happen that all I need to do is
jump to a different file where the thing at point is used. The power of
&lt;code&gt;project-find-regexp&lt;/code&gt; is too much here, because I don&amp;rsquo;t need the &lt;code&gt;*xref*&lt;/code&gt; buffer
with all the results and the ability to replace them. I just want a quick a way
to hit &lt;code&gt;RET&lt;/code&gt; on the candidate I am looking for and move to the desired
file.&lt;/p&gt;
&lt;p&gt;With &lt;code&gt;xref-search-program&lt;/code&gt; set to &lt;code&gt;&#39;ugrep&lt;/code&gt;&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt; the solution is trivial.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defun mu-project-find-regexp ()
  &amp;quot;Use `project-find-regexp&#39; with completion.&amp;quot;
  (interactive)
  (defvar xref-show-xrefs-function)
  (let ((xref-show-xrefs-function #&#39;xref-show-definitions-completing-read))
    (if-let ((tap (thing-at-point &#39;symbol)))
        (project-find-regexp tap)
      (call-interactively #&#39;project-find-regexp))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The trick is temporarily setting &lt;code&gt;xref-show-xrefs-function&lt;/code&gt; to
&lt;code&gt;xref-show-definitions-completing-read&lt;/code&gt;, which according to its documentation
does exactly what I am looking for.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Let the user choose the target definition with completion.&lt;/p&gt;
&lt;p&gt;When there is more than one definition, let the user choose
between them by typing in the minibuffer with completion.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;I then bind &lt;code&gt;mu-project-find-regexp&lt;/code&gt; to &lt;code&gt;M-?&lt;/code&gt; and all is set.
Needless to say, the heavy work is still done by &lt;code&gt;project-find-regexp&lt;/code&gt;. Such an
awesome tool.&lt;/p&gt;
&lt;p&gt;Note that I am overriding the default &lt;code&gt;M-?&lt;/code&gt; on purpose, because the
original &lt;code&gt;xref-find-references&lt;/code&gt; does not take things like &lt;code&gt;.gitignore&lt;/code&gt; into
account, something absolutely necessary in large projects where I want to avoid
having useless candidates spam the ever precious minibuffer.&lt;/p&gt;
&lt;p&gt;Finally, be aware that a better version of &lt;code&gt;mu-project-find-regexp&lt;/code&gt; can be found
&lt;a href=&#34;https://manueluberti.eu/posts/2022-09-01-consult-xref/&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;div class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;
&lt;hr&gt;
&lt;ol&gt;
&lt;li id=&#34;fn:1&#34;&gt;
&lt;p&gt;Once again, refer to &lt;a href=&#34;https://github.com/Genivia/ugrep#using-ugrep-within-emacs&#34;&gt;Using ugrep with
Emacs&lt;/a&gt; for the
configuration details.&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    <item>
      <title>Fix jdtls configuration for Eglot</title>
      <link>https://manueluberti.eu/posts/2022-08-18-eglot-jdtls-data/</link>
      <pubDate>Thu, 18 Aug 2022 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2022-08-18-eglot-jdtls-data/</guid>
      <description>&lt;p&gt;When thanks to its developers I added support for &lt;code&gt;jdtls&lt;/code&gt; in
&lt;a href=&#34;https://manueluberti.eu/posts/2022-03-16-eglot-jdtls/&#34;&gt;Eglot&lt;/a&gt;, I did it by
removing a lot of boilerplate in the package devised to accommodate the complex
setup needed for Eclipse JDT to start the language server. This made the
&lt;code&gt;java-mode&lt;/code&gt; entry in &lt;code&gt;eglot-server-programs&lt;/code&gt; simpler and it also moved the
responsibility of providing the correct defaults to the &lt;code&gt;jdtls&lt;/code&gt; script itself.&lt;/p&gt;
&lt;p&gt;However, recent versions of &lt;code&gt;jdtls&lt;/code&gt; seem to still require extra configuration,
in particular with regards to the &lt;code&gt;-data&lt;/code&gt; argument that before my change was
tweaked &lt;a href=&#34;https://github.com/joaotavora/eglot/issues/1008&#34;&gt;within Eglot&lt;/a&gt;.
Understandably, Eglot&amp;rsquo;s maintainer cannot spend all his time hunting down random
quirks for every LSP server &lt;a href=&#34;https://github.com/joaotavora/eglot/issues/1008#issuecomment-1214462761&#34;&gt;out
there&lt;/a&gt;.
Therefore, it&amp;rsquo;s up to the users to update their configuration at least until
&lt;code&gt;jdtls&lt;/code&gt; takes care of &lt;a href=&#34;https://github.com/eclipse/eclipse.jdt.ls/issues/2191&#34;&gt;this
problem&lt;/a&gt; once and for
all.&lt;/p&gt;
&lt;p&gt;The small hack I added to my &lt;code&gt;init.el&lt;/code&gt; is the following:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(with-eval-after-load &#39;eglot
  (let ((cache (expand-file-name (md5 (project-root (project-current t)))
                                 (locate-user-emacs-file &amp;quot;jdtls-cache&amp;quot;))))
    (add-to-list &#39;eglot-server-programs `(java-mode &amp;quot;jdtls&amp;quot; &amp;quot;-data&amp;quot; ,cache))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The above snippet works fine with the latest &lt;code&gt;jdtls&lt;/code&gt; (as of 2022-08-11 14:25)
and OpenJDK 18.0.2-ea. I updated the relevant Eglot
&lt;a href=&#34;https://github.com/joaotavora/eglot/discussions/868&#34;&gt;discussion&lt;/a&gt; as well, so
refer to it if you need more details.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Ugrep in Emacs</title>
      <link>https://manueluberti.eu/posts/2022-08-07-emacs-ugrep/</link>
      <pubDate>Sun, 07 Aug 2022 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2022-08-07-emacs-ugrep/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;https://manueluberti.eu/posts/2021-09-10-rgrep-and-vc-git-grep/&#34;&gt;Almost a year ago&lt;/a&gt; I wrote
about my handy &lt;code&gt;mu-recursive-grep&lt;/code&gt;, an easy way to combine &lt;code&gt;rgrep&lt;/code&gt; and
&lt;code&gt;vc-git-grep&lt;/code&gt;. But after &lt;a href=&#34;https://leahneukirchen.org/blog/archive/2022/03/note-taking-in-emacs-with-howm.html&#34;&gt;Leah
Neukirchen&lt;/a&gt;
mentioned &lt;code&gt;ugrep&lt;/code&gt; recently, I could not resist checking whether it was a good
fit for my daily Emacs usage. A couple of benchmark&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt; impressed me enough to
add support for it directly via &lt;code&gt;xref-search-program-alist&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The details to configure everything you need are over at &lt;a href=&#34;https://github.com/Genivia/ugrep#using-ugrep-within-emacs&#34;&gt;Using ugrep within
Emacs&lt;/a&gt; on the project
README. Once set, you can just hit &lt;code&gt;C-x p g&lt;/code&gt; (&lt;code&gt;project-find-regexp&lt;/code&gt;)
in your project and let &lt;code&gt;ugrep&lt;/code&gt; do his magic.&lt;/p&gt;
&lt;p&gt;Moreover, as the README mentions, it&amp;rsquo;s possible to leverage &lt;code&gt;grep-template&lt;/code&gt; to
have commands like &lt;code&gt;lgrep&lt;/code&gt; rely on &lt;code&gt;ugrep&lt;/code&gt;.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(setq-default grep-template (string-join &#39;(&amp;quot;ugrep&amp;quot;
                                           &amp;quot;--color=always&amp;quot;
                                           &amp;quot;--ignore-binary&amp;quot;
                                           &amp;quot;--ignore-case&amp;quot;
                                           &amp;quot;--include=&amp;lt;F&amp;gt;&amp;quot;
                                           &amp;quot;--line-number&amp;quot;
                                           &amp;quot;--null&amp;quot;
                                           &amp;quot;--recursive&amp;quot;
                                           &amp;quot;--regexp=&amp;lt;R&amp;gt;&amp;quot;)
                                         &amp;quot; &amp;quot;))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Thus, &lt;code&gt;mu-recursive-grep&lt;/code&gt; becomes a bit simpler:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defun mu-recursive-grep (search-term search-path)
  &amp;quot;Recursively search for SEARCH-TERM in SEARCH-PATH.&amp;quot;
  (interactive
   (progn
     (unless grep-command
       (grep-compute-defaults))
     (let ((search-term (grep-read-regexp))
           (search-path (expand-file-name
                         (read-directory-name
                          &amp;quot;Directory: &amp;quot; nil default-directory t))))
       (list search-term search-path))))
  (lgrep search-term &amp;quot;*&amp;quot; search-path))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As mentioned in &lt;a href=&#34;https://manueluberti.eu/posts/2021-09-10-rgrep-and-vc-git-grep/&#34;&gt;Grep&amp;rsquo;s good rep&lt;/a&gt;, for project-wide searches &lt;code&gt;C-x p g&lt;/code&gt; is my go-to key binding.
However, there are situations when I want to limit the search to specific paths,
and that&amp;rsquo;s where I prefer using &lt;code&gt;mu-recursive-grep&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;A closing remark: before blindly leaving &lt;code&gt;grep&lt;/code&gt;, &lt;code&gt;ripgrep&lt;/code&gt;, or even
&lt;code&gt;vc-git-grep&lt;/code&gt; behind, I suggest to benchmark the performance of each tool and
see what actually suits you best. You may find that whatever you are using at
the moment is already the best choice.&lt;/p&gt;
&lt;div class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;
&lt;hr&gt;
&lt;ol&gt;
&lt;li id=&#34;fn:1&#34;&gt;
&lt;p&gt;See &lt;a href=&#34;https://debbugs.gnu.org/cgi/bugreport.cgi?bug=54608#14&#34;&gt;54608#14&lt;/a&gt; and
&lt;a href=&#34;https://debbugs.gnu.org/cgi/bugreport.cgi?bug=54608#20&#34;&gt;54608#20&lt;/a&gt;.&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    <item>
      <title>Restart Emacs</title>
      <link>https://manueluberti.eu/posts/2022-04-18-restart-emacs/</link>
      <pubDate>Mon, 18 Apr 2022 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2022-04-18-restart-emacs/</guid>
      <description>&lt;p&gt;Tracking Emacs development is always nice, because I get to explore new things
as soon as they are made available. Yesterday Lars Ingebrigtsen introduced a new
command:
&lt;a href=&#34;https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=5be9a9cacfaae1959c4b95c45c146044a181ad20&#34;&gt;restart-emacs&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Let&amp;rsquo;s &lt;code&gt;C-h f restart-emacs RET&lt;/code&gt; to check what we are dealing with:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Kill the current Emacs process and start a new one. This goes through the same
shutdown procedure as ‘save-buffers-kill-emacs&amp;rsquo;, but instead of killing Emacs
and exiting, it re-executes Emacs (using the same command line arguments as the
running Emacs).&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;It sounds useful, doesn&amp;rsquo;t it? So I quickly devised a new command to let me
decide whether I want to quit Emacs or re-launch it:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defun mu-quit-or-restart (&amp;amp;optional restart)
  &amp;quot;Quit Emacs or restart it with RESTART.&amp;quot;
  (interactive &amp;quot;P&amp;quot;)
  (if restart
      (restart-emacs)
    (save-buffers-kill-terminal t)))
(keymap-global-set &amp;quot;C-x C-c&amp;quot; #&#39;mu-quit-or-restart)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This little command should be obvious: &lt;code&gt;C-x C-c&lt;/code&gt; does the usually
killing, whereas &lt;code&gt;C-u C-x C-c&lt;/code&gt; re-executes Emacs. This will come in
handy when I upgrade packages, because I tend to restart Emacs after that and
being able to do it quickly is a great thing indeed.&lt;/p&gt;
&lt;p&gt;Note that &lt;code&gt;keymap-global-set&lt;/code&gt; may not be available if you are not following the
Emacs master branch. Rely on &lt;code&gt;global-set-key&lt;/code&gt; in that case.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Eglot and Eclipse JDT for Java</title>
      <link>https://manueluberti.eu/posts/2022-03-16-eglot-jdtls/</link>
      <pubDate>Wed, 16 Mar 2022 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2022-03-16-eglot-jdtls/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;https://manueluberti.eu/posts/2022-03-12-eglot-digestif/&#34;&gt;Last time&lt;/a&gt; I mentioned that I helped
making it possible for Eglot to use &lt;code&gt;jdtls&lt;/code&gt;, the Python helper script packaged
with Eclipse JDT to start the language server with sane defaults. The only
problem I had during my work on this is that &lt;code&gt;jdtls&lt;/code&gt; requires Python 3.9 or
later, why my Ubuntu 20.04 machine comes with the 3.8.10 version. Since changing
the default Python on Ubuntu can bring pain,&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt; I decided to have Emacs work
with Python 3.9 only for my Java projects.&lt;/p&gt;
&lt;p&gt;First, I installed the required Python packages:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-shell&#34;&gt;$ sudo apt install python3.9 python3-9-venv
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then, in my Java project root directory I ran:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-shell&#34;&gt;$ python3.9 -m venv env
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Finally, I had to tell Emacs how to interact with this new Python environment.
In the root directory of my project I added a &lt;code&gt;.dir-locals.el&lt;/code&gt; file with the
following content:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;((nil . ((buffer-env-command . &amp;quot;&amp;gt;&amp;amp;2 . \&amp;quot;$0\&amp;quot; &amp;amp;&amp;amp; env -0&amp;quot;)
         (buffer-env-script-name . &amp;quot;env/bin/activate&amp;quot;)
         (python-shell-virtualenv-root . &amp;quot;./env&amp;quot;))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I am using Augusto Stoffel&amp;rsquo;s &lt;a href=&#34;https://github.com/astoff/buffer-env&#34;&gt;buffer-env&lt;/a&gt;
to pick up the &lt;code&gt;activate&lt;/code&gt; script and run it automatically for me. Checking the
Python version with &lt;code&gt;M-! /usr/bin/env python3 -V RET&lt;/code&gt; told me I
was doing the right thing. Keep in mind that you don&amp;rsquo;t have to set
&lt;code&gt;buffer-env-command&lt;/code&gt; like I do. Here I am setting it back to its default value
because I changed it in my &lt;code&gt;init.el&lt;/code&gt; to specifically deal with &lt;code&gt;direnv&lt;/code&gt;. Anyway,
with everything in place Eglot correctly interfaced with &lt;code&gt;jdtls&lt;/code&gt; for a smooth
Java developing experience.&lt;/p&gt;
&lt;p&gt;A note to myself: I will probably need to revisit this setup as soon as I move
to the new Ubuntu LTS which, I guess, will provide a more recent Python by
default.&lt;/p&gt;
&lt;div class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;
&lt;hr&gt;
&lt;ol&gt;
&lt;li id=&#34;fn:1&#34;&gt;
&lt;p&gt;Trust me on this.&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    <item>
      <title>Eglot and digestif for LaTeX</title>
      <link>https://manueluberti.eu/posts/2022-03-12-eglot-digestif/</link>
      <pubDate>Sat, 12 Mar 2022 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2022-03-12-eglot-digestif/</guid>
      <description>&lt;p&gt;I don&amp;rsquo;t think I have enough words to express my admiration for
&lt;a href=&#34;https://github.com/joaotavora/eglot&#34;&gt;Eglot&lt;/a&gt;. The more I use it, the more I
appreciate its minimalist approach that just does the right thing and then gets
out of my way. With the help of its maintainer João Távora and the friendly
Felicián Németh, I have done &lt;a href=&#34;https://github.com/joaotavora/eglot/discussions/868&#34;&gt;my
part&lt;/a&gt; to help keeping it up
to speed with Eclipse JDT latest developments. I had to give back something,
didn&amp;rsquo;t I?&lt;/p&gt;
&lt;p&gt;Why stop at Java, though? Since I have come to enjoy the niceties of LSP, I
decided to push it a little further and step outside my comfortable software
developer zone to check how Eglot can improve on my experience with LaTeX.
Albeit a bit early in my student&amp;rsquo;s career, I have followed a kind professor&amp;rsquo;s
prompt to pursue some ideas of mine and have started working on my thesis. Mind
you, I have been a happy &lt;a href=&#34;https://www.gnu.org/software/auctex/&#34;&gt;AUCTeX&lt;/a&gt; user for
quite a long time and I do not intend to leave it behind. How can Eglot fit in,
then?&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;The &amp;ldquo;don&amp;rsquo;t be silly, trust Emacs!&amp;rdquo; answer comes from Augusto Stoffel in the form
of &lt;a href=&#34;https://github.com/astoff/digestif&#34;&gt;digestif&lt;/a&gt;. If you are familiar with a
language server, you know what &lt;code&gt;digestif&lt;/code&gt; does. I like to think of it as AUCTeX
missing piece, because it offers completion, documentation, and navigation
commands that really make a difference when writing a non-trivial LaTeX
document. Furthermore, Augusto has recently added &lt;a href=&#34;https://github.com/astoff/digestif/issues/42#issuecomment-1065396699&#34;&gt;specific
integration&lt;/a&gt;
for BibLaTeX, which turns inserting citation and footnotes into a nice and easy
task and it also means that I can safely disable RefTeX now.&lt;/p&gt;
&lt;p&gt;Installing &lt;code&gt;digestif&lt;/code&gt; is just as painless as well: put the &lt;a href=&#34;https://raw.githubusercontent.com/astoff/digestif/master/scripts/digestif&#34;&gt;self-installing
script&lt;/a&gt;
in your &lt;code&gt;$PATH&lt;/code&gt;, make it executable, and run it once. Or you can use &lt;code&gt;luarocks install digestif&lt;/code&gt; if you have &lt;code&gt;luarocks&lt;/code&gt; on your machine. Back in Emacs, Eglot
will take care of everything else. Try &lt;code&gt;M-x&lt;/code&gt; &lt;code&gt;eglot&lt;/code&gt; in your LaTeX
buffers if you don&amp;rsquo;t believe me.&lt;/p&gt;
&lt;p&gt;When I first heard of LSP I wasn&amp;rsquo;t sure of what to do with it. Well, to a
certain degree I still am. For instance, I am not using
&lt;a href=&#34;https://clojure-lsp.io/&#34;&gt;clojure-lsp&lt;/a&gt; even though I spend eight hours a day
with Clojure. However, when it comes to LaTeX I don&amp;rsquo;t think I am going to
abandon Eglot and &lt;code&gt;digestif&lt;/code&gt; any time soon. Whether or not you use AUCTeX, with
&lt;code&gt;digestif&lt;/code&gt; the experience is simply more comfortable and, thus, better.&lt;/p&gt;
&lt;div class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;
&lt;hr&gt;
&lt;ol&gt;
&lt;li id=&#34;fn:1&#34;&gt;
&lt;p&gt;Most Emacs users would suggest Org instead of plain LaTeX here, but I
just enjoy writing LaTeX in the old fashioned way.&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    <item>
      <title>Ignore project buffers</title>
      <link>https://manueluberti.eu/posts/2022-02-27-project-ignore-buffers/</link>
      <pubDate>Sun, 27 Feb 2022 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2022-02-27-project-ignore-buffers/</guid>
      <description>&lt;p&gt;As you may already know, I take buffer switching
&lt;a href=&#34;https://manueluberti.eu/posts/2021-08-14-switch-buffer/&#34;&gt;seriously&lt;/a&gt;. Jokes aside,
one of the key bindings I use the most is &lt;code&gt;C-x p b&lt;/code&gt;, which is bound to
&lt;code&gt;project-switch-to-buffer&lt;/code&gt; by default. As the above linked article explains, it
takes little time to find myself with many open buffers, some of which may not
be immediately relevant to the context of my actual work.&lt;/p&gt;
&lt;p&gt;Instead of tweaking &lt;code&gt;switch-to-buffer&lt;/code&gt;, though, I decided to make it possible
for &lt;code&gt;project-switch-to-buffer&lt;/code&gt; to act according to certain conditions. With the
help of &lt;a href=&#34;https://github.com/dgutov&#34;&gt;Dmitry Gutov&lt;/a&gt;, I have recently added
&lt;code&gt;project-ignore-buffer-conditions&lt;/code&gt; on Emacs master. Now, for instance, I can do
the following:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defvar-local mu-ignored-buffers
    &#39;(&amp;quot;\\` &amp;quot; &amp;quot;^\\*Async&amp;quot; &amp;quot;^\\*Completions&amp;quot; &amp;quot;^\\*Flymake&amp;quot; &amp;quot;^\\*Help&amp;quot;
      &amp;quot;^\\*Messages&amp;quot; &amp;quot;^\\*eldoc&amp;quot; &amp;quot;^\\*envrc&amp;quot; &amp;quot;\\*tramp&amp;quot; &amp;quot;^\\*xref&amp;quot;)
  &amp;quot;A list of predicates for buffers to ignore.&amp;quot;)
  
(defun mu-project-ignore-buffer-p (buffer)
  &amp;quot;Check if BUFFER is a member of `mu-ignored-buffers&#39;.&amp;quot;
  (seq-contains-p mu-ignored-buffers (buffer-name buffer) #&#39;string-match-p)) 
  
(setq-default project-ignore-buffer-conditions &#39;(mu-project-ignore-buffer-p
                                                 (derived-mode . comint-mode))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note that I changed &lt;code&gt;project--read-project-buffer&lt;/code&gt; to take the new &lt;code&gt;defcustom&lt;/code&gt;
into account, so &lt;code&gt;project-display-buffer&lt;/code&gt; and
&lt;code&gt;project-display-buffer-other-frame&lt;/code&gt; are also affected.&lt;/p&gt;
&lt;p&gt;Futhermore, to understand what kind of conditions you can use, check
&lt;code&gt;project-kill-buffer-conditions&lt;/code&gt; which is what I based
&lt;code&gt;project-ignore-buffer-conditions&lt;/code&gt; on following Dmitry&amp;rsquo;s tip.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Handling wildcards in paths</title>
      <link>https://manueluberti.eu/posts/2022-01-20-wildcards/</link>
      <pubDate>Thu, 20 Jan 2022 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2022-01-20-wildcards/</guid>
      <description>&lt;p&gt;My recent experiments with
&lt;a href=&#34;https://manueluberti.eu/posts/2021-11-21-eglot-and-vc/&#34;&gt;Eglot&lt;/a&gt; and Java led me to
figure out how to speed up the connection to Eclipse JDT Language Server.
Basically I wanted a simpler version of &lt;code&gt;eglot--eclipse-jdt-contact&lt;/code&gt; to avoid
any prompt and just do the right thing for me.&lt;/p&gt;
&lt;p&gt;Looking at Eglot&amp;rsquo;s bug tracker, there is an issue with some tips:
&lt;a href=&#34;https://github.com/joaotavora/eglot/issues/424#issuecomment-598415067&#34;&gt;#424&lt;/a&gt;. I
followed the instructions and added the relevant code to my &lt;code&gt;init.el&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(with-eval-after-load &#39;eglot
  (defconst mu-jdt-launcher
    (concat &amp;quot;/home/manuel/jdt/plugins&amp;quot;
            &amp;quot;/org.eclipse.equinox.launcher_1.6.400.v20210924-0641.jar&amp;quot;))

  (defun mu-eglot-jdt-contact (_interactive)
    &amp;quot;See `eglot--eclipse-jdt-contact&#39;.&amp;quot;
    (let ((cp (or (getenv &amp;quot;CLASSPATH&amp;quot;) path-separator)))
      (setenv &amp;quot;CLASSPATH&amp;quot; (concat cp path-separator mu-jdt-launcher))
      (unwind-protect (eglot--eclipse-jdt-contact nil)
        (setenv &amp;quot;CLASSPATH&amp;quot; cp))))
  (setcdr (assq &#39;java-mode eglot-server-programs) #&#39;mu-eglot-jdt-contact))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;However, I do not like the hard-coded path to the JDT jar file, mainly because I
have to manually update it every time I install a new version of the language
server. Fortunately, Emacs has what I need right under the hood:
&lt;code&gt;file-expand-wildcards&lt;/code&gt;.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defconst mu-jdt-launcher
  (let ((path &amp;quot;~/jdt/plugins/org.eclipse.equinox.launcher_*&amp;quot;))
    (car (file-expand-wildcards path &#39;full))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you check the documentation of &lt;code&gt;file-expand-wildcards&lt;/code&gt; you will notice that
it returns a list of file names matching the given pattern. In this case, there
is only one element in that list, so &lt;code&gt;car&lt;/code&gt; can safely grab it. Again, the
documentation will also explain the meaning of that &lt;code&gt;&#39;full&lt;/code&gt; argument, but I am
sure it is pretty clear already.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Completing shell commands</title>
      <link>https://manueluberti.eu/posts/2021-12-10-shell-command/</link>
      <pubDate>Fri, 10 Dec 2021 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2021-12-10-shell-command/</guid>
      <description>&lt;p&gt;The more I move to VC,&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt; the more I end up relying on &lt;code&gt;M-!&lt;/code&gt;
(&lt;code&gt;shell-command&lt;/code&gt;). Admittedly, this is a tool I&amp;rsquo;ve hardly ever used before, but
since VC lacks many features covered by Magit, sometimes I need to interact with
the power of Git straight from the command line.&lt;/p&gt;
&lt;p&gt;One of the best things about Magit is that I don&amp;rsquo;t have to remember the many Git
options to use it every day. Through transient menus, Magit makes Git a matter
of few key strokes. On the other hand, from time to time I find myself on remote
machines where Magit is not available, so it does not hurt to have a better
understanding of the basic Git operations at my disposal.&lt;/p&gt;
&lt;p&gt;However, typing them all out every single time is not the kind of pleasant
activity a lazy Emacs user enjoys. Juri Linkov shared this little trick on
&lt;a href=&#34;https://lists.gnu.org/archive/html/emacs-devel/2021-12/msg00802.html&#34;&gt;emacs-devel&lt;/a&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defun mu-minibuffer-complete-history ()
  &amp;quot;Complete minibuffer history.&amp;quot;
  (interactive)
  (completion-in-region (minibuffer--completion-prompt-end) (point-max)
                        (symbol-value minibuffer-history-variable)
                        nil))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Juri also suggested to bind it to &lt;code&gt;C-TAB&lt;/code&gt; in &lt;code&gt;minibuffer-local-map&lt;/code&gt;
which, coincidentally, is the same key binding I have to manually complete with
Company outside of the minibuffer.&lt;/p&gt;
&lt;p&gt;What Juri&amp;rsquo;s code does is popping up a &lt;code&gt;*Completions*&lt;/code&gt; buffer with the history of
the commands used in the minibuffer. I only use it with &lt;code&gt;shell-command&lt;/code&gt;, but try
it with &lt;code&gt;C-x C-f&lt;/code&gt; for fun.&lt;/p&gt;
&lt;p&gt;I leave it as a small exercise for the reader to understand how to switch from
the minibuffer to the &lt;code&gt;*Completions*&lt;/code&gt; buffer and vice versa. Tip: &lt;code&gt;C-h m&lt;/code&gt; is your friend.&lt;/p&gt;
&lt;div class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;
&lt;hr&gt;
&lt;ol&gt;
&lt;li id=&#34;fn:1&#34;&gt;
&lt;p&gt;See &lt;a href=&#34;https://manueluberti.eu/posts/2021-11-27-vc/&#34;&gt;A job for VC&lt;/a&gt; and
&lt;a href=&#34;https://manueluberti.eu/posts/2021-12-05-vc-rebasing/&#34;&gt;Rebasing with VC&lt;/a&gt;.&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    <item>
      <title>Rebasing with VC</title>
      <link>https://manueluberti.eu/posts/2021-12-05-vc-rebasing/</link>
      <pubDate>Sun, 05 Dec 2021 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2021-12-05-vc-rebasing/</guid>
      <description>&lt;p&gt;Two weeks without Magit&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt; have forced me to rethink how I use Git in my
projects. I have already written about &lt;a href=&#34;https://manueluberti.eu/posts/2021-11-27-vc/&#34;&gt;some commands&lt;/a&gt; I have been using, but beside basic things, how does Emacs hold up in a
more complex situation?&lt;/p&gt;
&lt;p&gt;Let&amp;rsquo;s talk about interactive rebasing. If you are familiar with Magit,&lt;sup id=&#34;fnref:2&#34;&gt;&lt;a href=&#34;#fn:2&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;2&lt;/a&gt;&lt;/sup&gt; you
know how simple it gets. This is what I usually do from &lt;code&gt;magit-status&lt;/code&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;l&lt;/code&gt; for &lt;code&gt;magit-log&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;l&lt;/code&gt; for &lt;code&gt;current&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;n&lt;/code&gt; as many times as needed to move to the commit I want to start
rebasing with&lt;/li&gt;
&lt;li&gt;&lt;code&gt;r&lt;/code&gt; for &lt;code&gt;magit-rebase&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;i&lt;/code&gt; for &lt;code&gt;interactive&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;s&lt;/code&gt; on the commits I want to squash&lt;/li&gt;
&lt;li&gt;&lt;code&gt;C-c C-c&lt;/code&gt; to confirm&lt;/li&gt;
&lt;li&gt;write the commit message I want&lt;/li&gt;
&lt;li&gt;&lt;code&gt;C-c C-c&lt;/code&gt; to confirm&lt;/li&gt;
&lt;li&gt;&lt;code&gt;P&lt;/code&gt; and &lt;code&gt;-f&lt;/code&gt; to push with &lt;code&gt;--force-with-lease&lt;/code&gt; enabled&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;It&amp;rsquo;s quicker to do it than to write it all down, especially now that it has
become muscle memory. No wonder I was still relying on Magit to interactively
rebase on my first days with VC.&lt;/p&gt;
&lt;p&gt;Since I did not find a similar solution in &lt;code&gt;vc-git&lt;/code&gt;, I asked on
&lt;a href=&#34;https://lists.gnu.org/archive/html/emacs-devel/2021-12/msg00238.html&#34;&gt;emacs-devel&lt;/a&gt;
how the core developers approach this workflow. I got different, interesting
replies that can be roughly summed up with:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;bare command line&lt;/li&gt;
&lt;li&gt;&lt;code&gt;helm-ls-git&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;custom code&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Not wanting to be scared away from a non-Magit option, this is what I have
eventually ended up doing:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;in &lt;code&gt;shell-mode&lt;/code&gt;, I run &lt;code&gt;git rebase -i &amp;lt;branch&amp;gt;~&amp;lt;commits&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;in the buffer that opens up I type &lt;code&gt;s&lt;/code&gt; on the commits I want to squash&lt;/li&gt;
&lt;li&gt;&lt;code&gt;C-x C-s&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;C-x k RET&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;in the buffer with the commit message I edit the text as I wish&lt;/li&gt;
&lt;li&gt;&lt;code&gt;C-x C-s&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;C-x k RET&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;either I run &lt;code&gt;git push --force-with-lease&lt;/code&gt; from &lt;code&gt;shell-mode&lt;/code&gt;, or &lt;code&gt;C-u P&lt;/code&gt; from &lt;code&gt;C-x p v&lt;/code&gt; to push with &lt;code&gt;--force-with-lease&lt;/code&gt; added
manually&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Note that this approach requires that in &lt;code&gt;~/.config/git/config&lt;/code&gt; I have &lt;code&gt;editor&lt;/code&gt;
set to &lt;code&gt;emacsclient&lt;/code&gt; and either I have &lt;code&gt;server-start&lt;/code&gt; somewhere in my &lt;code&gt;init.el&lt;/code&gt;
or I do &lt;code&gt;M-x&lt;/code&gt; &lt;code&gt;server-start&lt;/code&gt; before starting the actual rebasing.&lt;/p&gt;
&lt;p&gt;It looks like that even without Magit I can do everything from Emacs, which
makes for a good alternative in my opinion. Nonetheless, it does not take a PhD
to notice that Magit makes the whole rebasing easier to sort out. Hence, you
will not hear me scream &amp;ldquo;&lt;em&gt;drop it already and party hard, fellas!&lt;/em&gt;&amp;rdquo;. Sorry.&lt;/p&gt;
&lt;div class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;
&lt;hr&gt;
&lt;ol&gt;
&lt;li id=&#34;fn:1&#34;&gt;
&lt;p&gt;Not entirely true, but keep reading.&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&#34;fn:2&#34;&gt;
&lt;p&gt;Who isn&amp;rsquo;t in this day and age?&amp;#160;&lt;a href=&#34;#fnref:2&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    <item>
      <title>Stashing with VC</title>
      <link>https://manueluberti.eu/posts/2021-11-29-vc-stashing/</link>
      <pubDate>Mon, 29 Nov 2021 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2021-11-29-vc-stashing/</guid>
      <description>&lt;p&gt;Following my &lt;a href=&#34;https://manueluberti.eu/posts/2021-11-27-vc/&#34;&gt;previous article&lt;/a&gt; on
VC, I felt like proposing a key binding for &lt;code&gt;vc-git-stash&lt;/code&gt; to the Emacs
developers was something that could turn out to be useful for other VC users.&lt;/p&gt;
&lt;p&gt;As it is usually recommended to do in these cases,&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt; I filed my request using
&lt;code&gt;M-x&lt;/code&gt; &lt;code&gt;report-emacs-bug&lt;/code&gt;:
&lt;a href=&#34;https://debbugs.gnu.org/cgi/bugreport.cgi?bug=52158&#34;&gt;#52158&lt;/a&gt;. You can see that
I specifically mentioned &lt;code&gt;mu-vc-git-stash&lt;/code&gt;, the thin wrapper I coded to have VC
stashing commands easily reachable, in order to back my proposal with the custom
code I used to scratch a tiny itch.&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://lars.ingebrigtsen.no/&#34;&gt;Lars Ingebrigtsen&lt;/a&gt;, one of the Emacs
co-maintainers, replied to me quickly&lt;sup id=&#34;fnref:2&#34;&gt;&lt;a href=&#34;#fn:2&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;2&lt;/a&gt;&lt;/sup&gt; suggesting that I can use &lt;code&gt;C&lt;/code&gt;
if I put my cursor on the &lt;code&gt;Stash:&lt;/code&gt; line of the &lt;code&gt;vc-dir&lt;/code&gt; buffer. That led me to
discover that if I move the cursor onto a line pointing to a stash I can press
&lt;code&gt;P&lt;/code&gt; to pop it with &lt;code&gt;vc-git-stash-pop-at-point&lt;/code&gt;. The outcome should be
obvious: I can get rid of &lt;code&gt;mu-vc-git-stash&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Why wasn&amp;rsquo;t I using these key bindings before? As I wrote on the bug tracker,
&lt;code&gt;C-h m&lt;/code&gt; in &lt;code&gt;vc-dir&lt;/code&gt; buffers does not document them and I did not find
them explained in the &lt;code&gt;28.1.10.2 VC Directory Commands&lt;/code&gt; section of the manual
either. If the documentation is not added, I may get in touch with the Emacs
maintainers to see if I can contribute it myself. Unless of course the
documentation is already there and it&amp;rsquo;s just my reading and searching skills
failing me.&lt;/p&gt;
&lt;div class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;
&lt;hr&gt;
&lt;ol&gt;
&lt;li id=&#34;fn:1&#34;&gt;
&lt;p&gt;I was once advised to use this approach on &lt;code&gt;emacs-devel&lt;/code&gt;.&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&#34;fn:2&#34;&gt;
&lt;p&gt;This is something Emacs core developers do all the time and I don&amp;rsquo;t think
it&amp;rsquo;s appreciated enough. They always reply to my questions, even the ones
that on second thoughts I consider silly.&amp;#160;&lt;a href=&#34;#fnref:2&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    <item>
      <title>A job for VC</title>
      <link>https://manueluberti.eu/posts/2021-11-27-vc/</link>
      <pubDate>Sat, 27 Nov 2021 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2021-11-27-vc/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;https://manueluberti.eu/posts/2021-11-21-eglot-and-vc/&#34;&gt;Some days ago&lt;/a&gt; I briefly wrote about my
willingness to give Emacs built-in VC system a try for real. For real means that
it&amp;rsquo;s easy to praise the beauties of &lt;code&gt;vc-git&lt;/code&gt; when working on personal projects
such as this blog, but is VC actually worth it on bigger projects where
different people commit and push regularly, rebasing is a habit, and merge
conflicts are unavoidable necessities?&lt;/p&gt;
&lt;p&gt;A warning first. This article is not intended as a VC tutorial. It aims to be an
example of how &lt;em&gt;I&lt;/em&gt; use it or, to phrase it better, how I &lt;em&gt;started&lt;/em&gt; to use it. As
&lt;a href=&#34;https://www.masteringemacs.org/&#34;&gt;Mickey Petersen&lt;/a&gt; suggests in the &amp;ldquo;Exploring
Emacs&amp;rdquo; section of his great &lt;em&gt;Mastering Emacs&lt;/em&gt; book, if you want to know more
about VC there is plenty of information right within our favourite text editor.
Furthermore, Protesilaos Stavrou has a couple of nice videos on VC you might
want to check out: &lt;a href=&#34;https://www.youtube.com/watch?v=SQ3Beqn2CEc&#34;&gt;Introduction to
VC&lt;/a&gt; and &lt;a href=&#34;https://www.youtube.com/watch?v=0YlYX_UjH5Q&#34;&gt;Workflow with VC for
Git&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Now, let&amp;rsquo;s break down a common workflow of mine:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A new ticket is assigned to me&lt;/li&gt;
&lt;li&gt;I create a new branch for this ticket, starting from the &lt;code&gt;master&lt;/code&gt; one&lt;/li&gt;
&lt;li&gt;I code my thing&lt;/li&gt;
&lt;li&gt;I commit and push my code&lt;/li&gt;
&lt;li&gt;I file a new merge request ready to be reviewed&lt;/li&gt;
&lt;li&gt;The review may require changes to my code&lt;/li&gt;
&lt;li&gt;I may need to rebase my changes onto &lt;code&gt;master&lt;/code&gt; because other developers have
merged their branches before me&lt;/li&gt;
&lt;li&gt;Merge conflicts may arise and need to be fixed&lt;/li&gt;
&lt;li&gt;I push my updated code ready to be reviewed again&lt;/li&gt;
&lt;li&gt;If everything&amp;rsquo;s fine I merge my changes, otherwise back to my
edit/rebase/merge process until it&amp;rsquo;s properly done&lt;/li&gt;
&lt;li&gt;Meanwhile, it may happen that I need to stash my changes and quickly fix a
higher priority bug&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This more or less happens on a daily basis, so the interaction with Git (the
only VCS I have used in the last ten years) must be smooth. On the other hand,
Git-wise the above workflow is not that complicated. For instance, I rarely
use features such as cherry-picking or bisecting.&lt;/p&gt;
&lt;p&gt;On the surface, the main difference between Magit and VC is &lt;code&gt;transient&lt;/code&gt;. Magit
transient menus make all the operations I described above&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt; a breeze. From
checking out a branch to interactive rebasing, Magit requires few key strokes to
accommodate my needs. The blatant truth is that Magit wraps everything I want
from Git and much more in a user interface that just works.&lt;/p&gt;
&lt;p&gt;VC, however, is not tightly coupled to Git, so it does not cover all of its many
options. And yet I was able to manage my work projects with VC alternatives to
Magit commands.&lt;/p&gt;
&lt;p&gt;VC has its own &lt;code&gt;vc-git-stash&lt;/code&gt;, &lt;code&gt;vc-git-stash-pop&lt;/code&gt;, and &lt;code&gt;vc-git-stash-delete&lt;/code&gt;
commands, but instead of calling them via &lt;code&gt;M-x&lt;/code&gt; I devised
&lt;code&gt;mu-vc-git-stash&lt;/code&gt; and bound it to &lt;code&gt;z&lt;/code&gt; in &lt;code&gt;vc-dir-mode-map&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defun mu-vc-git-stash (pop-or-delete)
  &amp;quot;Create, pop, or delete Git stashes.
With no POP-OR-DELETE call `vc-git-stash&#39;. With one prefix
argument call `vc-git-stash-pop&#39;. With two prefix arguments call
`vc-git-stash-delete&#39;.&amp;quot;
  (interactive &amp;quot;P&amp;quot; vc-dir-mode)
  (cond ((= (prefix-numeric-value pop-or-delete) 4)
         (call-interactively #&#39;vc-git-stash-pop))
        ((= (prefix-numeric-value pop-or-delete) 16)
         (call-interactively #&#39;vc-git-stash-delete))
        (t (call-interactively #&#39;vc-git-stash))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As you can see, &lt;code&gt;C-u z&lt;/code&gt; issues &lt;code&gt;vc-git-stash-pop&lt;/code&gt; while &lt;code&gt;C-u C-u z&lt;/code&gt; runs &lt;code&gt;vc-git-stash-delete&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;One thing that Magit really shines at for me is interactive rebasing (&lt;code&gt;r i&lt;/code&gt;). I haven&amp;rsquo;t had the opportunity so far to check how I can handle this
with VC. I guess a combination of &lt;code&gt;shell-command&lt;/code&gt; and something I have yet to
discover would do, probably.&lt;/p&gt;
&lt;p&gt;Anyway, I&amp;rsquo;ll keep using VC in the next days and report back if I manage to adapt
more of my Git workflows to it. I suspect Magit will outshine the humbler Emacs
built-in eventually, but who knows. Reading on the &lt;code&gt;emacs-devel&lt;/code&gt; mailing list
that some wild Emacs developers prefer VC to Magit seems to confirm that the
world is still full of surprises.&lt;/p&gt;
&lt;div class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;
&lt;hr&gt;
&lt;ol&gt;
&lt;li id=&#34;fn:1&#34;&gt;
&lt;p&gt;Well, only the ones related to Git of course.&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    <item>
      <title>On Eglot and VC</title>
      <link>https://manueluberti.eu/posts/2021-11-21-eglot-and-vc/</link>
      <pubDate>Sun, 21 Nov 2021 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2021-11-21-eglot-and-vc/</guid>
      <description>&lt;p&gt;I have been pretty busy since my last update here, but that does not mean I
haven&amp;rsquo;t had the time to explore a couple of things for my everyday Emacs usage.&lt;/p&gt;
&lt;p&gt;Lately I had to deal with some Java and some JavaScript. No fancy libraries on
top of them, no languages built upon them, just plain, old Java and JavaScript.
I took that as a chance to familiarize myself with
&lt;a href=&#34;https://microsoft.github.io/language-server-protocol/&#34;&gt;LSP&lt;/a&gt; and especially with
&lt;a href=&#34;https://github.com/joaotavora/eglot&#34;&gt;Eglot&lt;/a&gt;, one of the two (to my knowledge)
packages that add LSP support to Emacs. Why Eglot and not
&lt;a href=&#34;https://github.com/emacs-lsp/lsp-mode&#34;&gt;lsp-mode&lt;/a&gt;? Easy: I like how Eglot
leverages &lt;code&gt;project.el&lt;/code&gt; and Flymake, tools I heavily rely on, and I also like how
quickly it enabled me to type Java and JavaScript code. I mean, it&amp;rsquo;s just a
matter of &lt;code&gt;M-x&lt;/code&gt; &lt;code&gt;eglot&lt;/code&gt;. It does not get any easier than that, if
you ask me.&lt;/p&gt;
&lt;p&gt;Eglot works well with Company, Xref, and ElDoc, so coding in Java finally makes
sense in Emacs. Granted, I haven&amp;rsquo;t used it on a big project and I am sure the
likes of IntelliJ IDEA and Eclipse do wonders, but none of them has the editing
capabilities or the openness to infinite customization that Emacs offers.&lt;/p&gt;
&lt;p&gt;Another tool that entered my day-to-day computing is the built-in
version-control system, or VC for short. My love for
&lt;a href=&#34;https://manueluberti.eu/posts/2017-11-09-magit/&#34;&gt;Magit&lt;/a&gt; is well-known, but on my
way to a vanilla Emacs appreciation I thought I could give VC a try. It turns
out most of the things I need to do with my Git-versioned projects can be done
from &lt;code&gt;vc-dir&lt;/code&gt;. This means that instead of &lt;code&gt;C-x g&lt;/code&gt; for &lt;code&gt;magit-status&lt;/code&gt; I
have been using &lt;code&gt;C-x p v&lt;/code&gt; for &lt;code&gt;project-vc-dir&lt;/code&gt;. When it&amp;rsquo;s time to get
my hands dirty with some advanced Git-fu, Magit is always next to me.&lt;/p&gt;
&lt;p&gt;One thing should be obvious here: Magit is more powerful and feature rich than
the built-in VC, so I do not intend to drop Magit as quickly I dropped
Projectile and Flycheck. Why don&amp;rsquo;t I just use Magit, then, you ask. For the same
reason I tried Eglot instead of installing Eclipse, I&amp;rsquo;d reply. Curiosity will
not kill any cat in my house.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Grep’s good rep</title>
      <link>https://manueluberti.eu/posts/2021-09-10-rgrep-and-vc-git-grep/</link>
      <pubDate>Fri, 10 Sep 2021 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2021-09-10-rgrep-and-vc-git-grep/</guid>
      <description>&lt;p&gt;Look around this blog and you will find nice words about
&lt;a href=&#34;https://github.com/BurntSushi/ripgrep&#34;&gt;ripgrep&lt;/a&gt;. I especially enjoy how I can
plug it into Emacs, like the time when I devised my own &lt;a href=&#34;https://manueluberti.eu/posts/2020-02-22-ripgrepping-with-helm/&#34;&gt;Helm
commands&lt;/a&gt; for it.&lt;/p&gt;
&lt;p&gt;However, roughly &lt;a href=&#34;https://manueluberti.eu/posts/2020-09-18-project/&#34;&gt;a year ago&lt;/a&gt; I
started my journey to a more vanilla Emacs experience. During this time I have
been slowly moving away from the niceties of &lt;code&gt;ripgrep&lt;/code&gt; in order to stick to a
couple of built-in tools: &lt;code&gt;rgrep&lt;/code&gt; and &lt;code&gt;vc-git-grep&lt;/code&gt;. Now, technically speaking,
both this commands rely on external tools, &lt;code&gt;grep&lt;/code&gt; and &lt;code&gt;git grep&lt;/code&gt;. Why should I
use these instead of &lt;code&gt;ripgrep&lt;/code&gt;? Personal preferences, of course: &lt;code&gt;grep&lt;/code&gt; is
readily available on Ubuntu and &lt;code&gt;git&lt;/code&gt; is the first tool I install when upgrading
to a new LTS from Canonical.&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;Furthermore, I rarely need the power of &lt;code&gt;ripgrep&lt;/code&gt;. Your experience may be
different on this, but the size of my projects does not scare neither &lt;code&gt;grep&lt;/code&gt; nor
&lt;code&gt;git grep&lt;/code&gt;. For instance, I regularly use &lt;code&gt;vc-git-grep&lt;/code&gt; on Emacs sources, which
amounts to something like 2,755,361 lines of code,&lt;sup id=&#34;fnref:2&#34;&gt;&lt;a href=&#34;#fn:2&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;2&lt;/a&gt;&lt;/sup&gt; and the performances are
just fine for me.&lt;/p&gt;
&lt;p&gt;The only thing I usually do not need from these commands is the prompt for the
file types to look into.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defun mu-recursive-grep (search-term search-path)
  &amp;quot;Recursively search for SEARCH-TERM in SEARCH-PATH.&amp;quot;
  (interactive
   (progn
     (unless grep-command
       (grep-compute-defaults))
     (let ((search-term (grep-read-regexp))
           (search-path (expand-file-name
                         (read-directory-name
                          &amp;quot;Directory: &amp;quot; nil default-directory t))))
       (list search-term search-path))))
  (if (vc-root-dir)
      (vc-git-grep search-term &amp;quot;*&amp;quot; search-path)
    (rgrep search-term &amp;quot;*&amp;quot; search-path)))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I combined the two commands to make it simpler. When I am in a Git-versioned
project (i.e., &lt;code&gt;vc-root-dir&lt;/code&gt; is not &lt;code&gt;nil&lt;/code&gt;) &lt;code&gt;mu-recursive-grep&lt;/code&gt; runs
&lt;code&gt;vc-git-grep&lt;/code&gt;; otherwise, it&amp;rsquo;s time for &lt;code&gt;rgrep&lt;/code&gt; to shine. As trivial as it might
look, the fact that the last two lines of &lt;code&gt;mu-recursive-grep&lt;/code&gt; look similar is
what made it easier for me to devise a common wrapper. Emacs &lt;code&gt;describe&lt;/code&gt; system
is always invaluable for discoveries such as this.&lt;/p&gt;
&lt;p&gt;One last thing. When in a project, if I want to find where the thing at point is
used I do not need &lt;code&gt;mu-recursive-grep&lt;/code&gt;. For this task &lt;code&gt;project-find-regexp&lt;/code&gt;
(&lt;code&gt;C-x p g&lt;/code&gt;) is enough,&lt;sup id=&#34;fnref:3&#34;&gt;&lt;a href=&#34;#fn:3&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;3&lt;/a&gt;&lt;/sup&gt; but &lt;code&gt;mu-recursive-grep&lt;/code&gt; is still helpful
when I want to narrow the search down to a specific path.&lt;/p&gt;
&lt;div class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;
&lt;hr&gt;
&lt;ol&gt;
&lt;li id=&#34;fn:1&#34;&gt;
&lt;p&gt;I use Ansible Playbooks to set up the new system.&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&#34;fn:2&#34;&gt;
&lt;p&gt;That&amp;rsquo;s what &lt;code&gt;scc&lt;/code&gt; tells me today, anyway.&amp;#160;&lt;a href=&#34;#fnref:2&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&#34;fn:3&#34;&gt;
&lt;p&gt;&lt;code&gt;C-h v xref-search-program&lt;/code&gt; shows that &lt;code&gt;ripgrep&lt;/code&gt; can be used
instead of the default &lt;code&gt;grep&lt;/code&gt;. Hence you can keep ripgrepping if that&amp;rsquo;s what
you prefer.&amp;#160;&lt;a href=&#34;#fnref:3&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    <item>
      <title>Package report</title>
      <link>https://manueluberti.eu/posts/2021-09-01-package-report/</link>
      <pubDate>Wed, 01 Sep 2021 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2021-09-01-package-report/</guid>
      <description>&lt;p&gt;I don&amp;rsquo;t know about you, but I like to monitor my Emacs configuration to see if
it is growing out of control due to my penchant for experimenting with ELisp and
new packages. This led me to a simple question: why not have a command that can
produce a summary of the installed packages? Specifically, I want to know the
total number of packages installed and I&amp;rsquo;d like to list the packages for every
archive set up in &lt;code&gt;package-archives&lt;/code&gt;.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defun mu-package-report ()
  &amp;quot;Report total package counts grouped by archive.&amp;quot;
  (interactive)
  (package-refresh-contents)
  (mu--display-package-report
   (let* ((arch-pkgs (mu--archive-packages))
          (counts (seq-sort-by #&#39;cdr #&#39;&amp;gt; (mu--archive-counts arch-pkgs)))
          (by-arch (seq-group-by #&#39;car arch-pkgs)))
     (concat
      (format &amp;quot;Total packages: %s\n\n&amp;quot; (apply #&#39;+ (mapcar #&#39;cdr counts)))
      (mapconcat
       (lambda (archive)
         (concat &amp;quot;• &amp;quot;
                 (format &amp;quot;%s (%s)&amp;quot; (car archive) (cdr archive))
                 &amp;quot;: &amp;quot;
                 (mapconcat (lambda (ap-pair) (cdr ap-pair))
                            (alist-get (car archive) by-arch)
                            &amp;quot;, &amp;quot;)))
       counts
       &amp;quot;\n\n&amp;quot;)))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now, let&amp;rsquo;s unpack it.&lt;/p&gt;
&lt;p&gt;I want my report buffer to be displayed in a new window, so this is what
&lt;code&gt;mu--display-package-report&lt;/code&gt; does:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defun mu--display-package-report (output)
  &amp;quot;Display OUTPUT in a popup buffer.&amp;quot;
  (let ((buffer-name &amp;quot;*package-report*&amp;quot;))
    (with-help-window buffer-name
      (with-current-buffer buffer-name
        (visual-line-mode 1)
        (erase-buffer)
        (insert output)
        (goto-char (point-min))))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Next, I want to know from which archive (e.g., GNU ELPA) a package is coming to
my system:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defun mu--archive-packages ()
  &amp;quot;Return a list of (archive . package) cons cells.&amp;quot;
  (seq-reduce
   (lambda (res package)
     (let ((archive (package-desc-archive
                     (cadr (assq package package-archive-contents))))
           (pkg (symbol-name package)))
       (push (cons archive pkg) res)))
   (mapcar #&#39;car package-alist)
   nil))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is nice because now I can also have the number of packages for every archive.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defun mu--archive-counts (arch-pkgs)
  &amp;quot;Return a list of cons cells from alist ARCH-PKGS.
The cars are package archives, the cdrs are the number of
packages installed from each archive.&amp;quot;
  (seq-reduce
   (lambda (counts key)
     (cons (cons key (+ 1 (or (cdr (assoc key counts)) 0)))
           (assoc-delete-all key counts)))
   (mapcar #&#39;car arch-pkgs)
   nil))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The rest of the code in &lt;code&gt;mu-package-report&lt;/code&gt; deals with formatting the output.
For example, I am using &lt;code&gt;seq-sort-by&lt;/code&gt; to have the archive with the highest
number of packages on top. As for the &lt;code&gt;mapconcat&lt;/code&gt; producing the actual bullet
points, the Emacs community came to the rescue on &lt;a href=&#34;https://emacs.stackexchange.com/questions/65088/format-alist-into-bullet-points&#34;&gt;Emacs Stack
Exchange&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Finally, this is how &lt;code&gt;M-x&lt;/code&gt; &lt;code&gt;mu-package-report&lt;/code&gt; &lt;code&gt;RET&lt;/code&gt; looks
like:&lt;/p&gt;
&lt;p&gt;&lt;figure&gt;
  &lt;img src=&#34;https://manueluberti.eu/images/package-report.png&#34; alt=&#34;&#34;&gt;
  &lt;figcaption class=&#34;center&#34;&gt;
    &lt;small&gt;&lt;em&gt;&lt;/em&gt;&lt;/small&gt;    
  &lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Switching buffers (Take 3)</title>
      <link>https://manueluberti.eu/posts/2021-08-14-switch-buffer/</link>
      <pubDate>Sat, 14 Aug 2021 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2021-08-14-switch-buffer/</guid>
      <description>&lt;p&gt;The more I remove code from my &lt;code&gt;init.el&lt;/code&gt; to rely on Emacs defaults, the more I
am getting used to it. This means I stopped using the likes of &lt;a href=&#34;https://manueluberti.eu/posts/2019-02-05-nswbuff/&#34;&gt;nswbuff&lt;/a&gt; and &lt;a href=&#34;https://manueluberti.eu/posts/2019-03-16-switch-buffers/&#34;&gt;counsel-projectile&lt;/a&gt;, but it doesn&amp;rsquo;t mean there isn&amp;rsquo;t room for small
tweaks.&lt;/p&gt;
&lt;p&gt;The basic &lt;code&gt;switch-to-buffer&lt;/code&gt; (&lt;code&gt;C-x b&lt;/code&gt;) does exactly what it says: it
lets you switch to a buffer of your choice. Now, if you play around in Emacs for
a while you end up with many open buffers such as &lt;code&gt;*Messages*&lt;/code&gt;, &lt;code&gt;*Flymake log*&lt;/code&gt;,
&lt;code&gt;*Help*&lt;/code&gt;, &lt;code&gt;*Ibuffer*&lt;/code&gt;, etc. Usually when I want to switch to a buffer I start
typing and &lt;code&gt;fido-mode&lt;/code&gt; gets me there, but the output of vanilla
&lt;code&gt;switch-to-buffer&lt;/code&gt; is still a bit cluttered with buffers I never jump to.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defvar mu-ignored-buffers
  &#39;(&amp;quot;\\` &amp;quot; &amp;quot;^\\*Async&amp;quot; &amp;quot;^\\*Compile-Log&amp;quot; &amp;quot;^\\*Completions&amp;quot; &amp;quot;^\\*Flymake&amp;quot;
    &amp;quot;^\\*Messages&amp;quot; &amp;quot;^\\*eldoc&amp;quot; &amp;quot;^\\*envrc&amp;quot; &amp;quot;\\*tramp&amp;quot; &amp;quot;^\\*xref&amp;quot;)
  &amp;quot;A list of predicates for buffers to ignore.&amp;quot;)
  
(defun mu-switch-to-buffer (buffer-or-name)
  &amp;quot;Switch to BUFFER-OR-NAME but ignore specific buffers.&amp;quot;
  (interactive
   (list (read-buffer &amp;quot;Switch to: &amp;quot;
                      (other-buffer (current-buffer))
                      (confirm-nonexistent-file-or-buffer)
                      (lambda (buf)
                        (not
                         (seq-contains-p
                          mu-ignored-buffers (car buf) #&#39;string-match-p))))))
  (switch-to-buffer buffer-or-name))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The key point in &lt;code&gt;mu-switch-to-buffer&lt;/code&gt; is the fourth argument passed to
&lt;code&gt;read-buffer&lt;/code&gt;.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Optional arg PREDICATE, if non-nil, is a function limiting the buffers that
can be considered. It will be called with each potential candidate, in the form
of either a string or a cons cell whose `car&amp;rsquo; is a string, and should return
non-nil to accept the candidate for completion, nil otherwise.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Note that I am using &lt;code&gt;mu-ignored-buffers&lt;/code&gt; only in &lt;code&gt;mu-switch-to-buffer&lt;/code&gt;. Ibuffer
still shows the ignored buffers to me. If I&amp;rsquo;ll ever get particularly angry at
those buffers, I could hide them in Ibuffer as well by adding them to
&lt;code&gt;ibuffer-never-show-predicates&lt;/code&gt;. These days, though, teenage angst is far behind
myself.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Trust me, I complete</title>
      <link>https://manueluberti.eu/posts/2021-08-06-fido/</link>
      <pubDate>Fri, 06 Aug 2021 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2021-08-06-fido/</guid>
      <description>&lt;p&gt;Not too long ago I wrote about my pleasant experience with
&lt;a href=&#34;https://manueluberti.eu/posts/2021-06-24-icomplete-vertical/&#34;&gt;icomplete-vertical-mode&lt;/a&gt;, a recent
addition on Emacs master which gives a vertical spin to the good old Icomplete.
But now Emacs also comes with &lt;code&gt;fido-mode&lt;/code&gt;, which enhances &lt;code&gt;icomplete-mode&lt;/code&gt; with
&lt;code&gt;ido-mode&lt;/code&gt; powers.&lt;/p&gt;
&lt;p&gt;The question is: can I combine &lt;code&gt;fido-mode&lt;/code&gt; and &lt;code&gt;icomplete-vertical-mode&lt;/code&gt; to have
the best of both worlds? Yep, it turns out I can and it is simple and easy.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(fido-vertical-mode 1)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And this is basically it. The only other thing I did was setting
&lt;code&gt;icomplete-matches-format&lt;/code&gt; to &lt;code&gt;nil&lt;/code&gt; because I don&amp;rsquo;t have a particular need for
the match count at the prompt.&lt;/p&gt;
&lt;p&gt;Whether or not one uses &lt;code&gt;fido-vertical-mode&lt;/code&gt;, &lt;code&gt;fido-mode&lt;/code&gt; enables nice features
such as &lt;code&gt;icomplete-fido-delete-char&lt;/code&gt; (&lt;code&gt;C-d&lt;/code&gt;), which deletes the current
character or calls &lt;code&gt;dired&lt;/code&gt; on the current directory, and &lt;code&gt;icomplete-fido-kill&lt;/code&gt;
(&lt;code&gt;C-k&lt;/code&gt;), which kills the current line or, for instance, if we are
completing files asks if we want to delete the selected one. Check
&lt;code&gt;icomplete-fido-mode-map&lt;/code&gt; for more details on the available key bindings.&lt;/p&gt;
&lt;p&gt;Inspecting &lt;code&gt;icomplete--fido-mode-setup&lt;/code&gt; reveals that &lt;code&gt;fido-mode&lt;/code&gt; also uses the
&lt;code&gt;flex&lt;/code&gt; completion style,&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt; but nothing forces us to stick with it or try
something like Orderless instead. As always with Emacs, the power is in our
hands.&lt;/p&gt;
&lt;p&gt;One more thing. The &lt;em&gt;&amp;ldquo;Trust me&amp;rdquo;&lt;/em&gt; in the title aims to be a pun on the word
&lt;em&gt;&amp;ldquo;fido&amp;rdquo;&lt;/em&gt;. In Italian &lt;em&gt;&amp;ldquo;fido&amp;rdquo;&lt;/em&gt; is the form for &amp;ldquo;I&amp;rdquo; of &lt;em&gt;&amp;ldquo;fidare&amp;rdquo;&lt;/em&gt; which means &lt;em&gt;&amp;ldquo;to
trust&amp;rdquo;&lt;/em&gt;: &lt;em&gt;&amp;ldquo;Mi fido di te&amp;rdquo;&lt;/em&gt; becomes &lt;em&gt;&amp;ldquo;I trust you&amp;rdquo;&lt;/em&gt; in English. &lt;em&gt;&amp;ldquo;Fido&amp;rdquo;&lt;/em&gt; is also
a &lt;a href=&#34;https://en.wikipedia.org/wiki/Fido_(dog)&#34;&gt;famous dog&lt;/a&gt; in Italy that came to
public attention because of his strong loyalty. Thus using &lt;code&gt;fido-mode&lt;/code&gt; implies
that my love for dogs is sincere and trustworthy.&lt;/p&gt;
&lt;div class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;
&lt;hr&gt;
&lt;ol&gt;
&lt;li id=&#34;fn:1&#34;&gt;
&lt;p&gt;&lt;code&gt;C-h o completion-styles-alist RET&lt;/code&gt; to know more about it.
Specifically, search for &lt;code&gt;flex&lt;/code&gt; in the &lt;code&gt;Value:&lt;/code&gt; section of the
documentation.&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    <item>
      <title>A dictionary in Emacs</title>
      <link>https://manueluberti.eu/posts/2021-07-31-dictionary/</link>
      <pubDate>Sat, 31 Jul 2021 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2021-07-31-dictionary/</guid>
      <description>&lt;p&gt;I explained my need for an English dictionary when I wrote about my own
[helm-wordnut]({% post_url 2020-06-13-helm-wordnut %}). To sum it up: my English is good but it&amp;rsquo;s not David Foster
Wallace good, so a dictionary is mandatory.&lt;/p&gt;
&lt;p&gt;Last October Torsten Hilbrich added &lt;a href=&#34;https://github.com/myrkr/dictionary-el&#34;&gt;dictionary-el&lt;/a&gt; to Emacs master so, in my
quest for a Vanilla Emacs appreciation, I decided to give it a try. According to
the first line of &lt;code&gt;dictionary.el&lt;/code&gt; this library is a client for &lt;a href=&#34;https://datatracker.ietf.org/doc/html/rfc2229&#34;&gt;RFC 2229&lt;/a&gt; dictionary
servers, which as the RFC says, rely on the DICT protocol:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The DICT protocol is designed to provide access to multiple databases. Word
definitions can be requested, the word index can be searched (using an easily
extended set of algorithms), information about the server can be provided (e.g.,
which index search strategies are supported, or which databases are available),
and information about a database can be provided (e.g., copyright, citation, or
distribution information). Further, the DICT protocol has hooks that can be used
to restrict access to some or all of the databases.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;This is very useful because it means that one can collect different definitions
from various dictionary and possibly compare synonyms.&lt;/p&gt;
&lt;p&gt;This is how I set up &lt;code&gt;dictionary.el&lt;/code&gt; in my &lt;code&gt;init.el&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(global-set-key (kbd &amp;quot;C-c d&amp;quot;) #&#39;dictionary-search)
(setq dictionary-server &amp;quot;dict.org&amp;quot;)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;dictionary-search&lt;/code&gt; cleverly picks up the word at point which means that when I
hit &lt;code&gt;C-c d RET&lt;/code&gt; on a word I don&amp;rsquo;t know I get a &lt;code&gt;*Dictionary*&lt;/code&gt; buffer with entries
coming from:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The Collaborative International Dictionary of English&lt;/li&gt;
&lt;li&gt;WordNet&lt;/li&gt;
&lt;li&gt;Moby Thesaurus II&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;There is much more in &lt;code&gt;dictionary.el&lt;/code&gt;, though. I counted 17 &lt;code&gt;defcustom&lt;/code&gt;s for
starters, so go on and tweak it like any Emacs hacker would do. As for me, the
couple of ELisp lines above are adequate.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Reuse Dired buffers</title>
      <link>https://manueluberti.eu/posts/2021-07-14-dired/</link>
      <pubDate>Wed, 14 Jul 2021 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2021-07-14-dired/</guid>
      <description>&lt;p&gt;This is going to be a real quick one, mainly a “thank you!” to Lars
Ingebrigtsen. Lars has recently added a new option on the Emacs master branch:
&lt;code&gt;dired-kill-when-opening-new-dired-buffer&lt;/code&gt;. I will let the documentation speak for
itself:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;dired-kill-when-opening-new-dired-buffer is a variable defined in ‘dired.el&#39;.&lt;/p&gt;
&lt;p&gt;Its value is t&lt;br&gt;
Original value was nil&lt;/p&gt;
&lt;p&gt;You can customize this variable.
This variable was introduced, or its default value was changed, in
version 28.1 of Emacs.
Probably introduced at or before Emacs version 28.1.&lt;/p&gt;
&lt;p&gt;If non-nil, kill the current buffer when selecting a new directory.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Setting this new option to &lt;code&gt;t&lt;/code&gt; means that pressing &lt;code&gt;RET&lt;/code&gt; or &lt;code&gt;^&lt;/code&gt; in a Dired
buffer will reuse the existing buffer. This is something I required a while ago
(&lt;a href=&#34;https://debbugs.gnu.org/cgi/bugreport.cgi?bug=20598&#34;&gt;#20598&lt;/a&gt;) and that up
until today I had been hacking up poorly in my &lt;code&gt;.init.el&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;I know the Emacs developers have more urgent bugs to work on, but this is such a
nice improvement I am pretty sure you can see me happily smiling right now.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>I complete. You?</title>
      <link>https://manueluberti.eu/posts/2021-06-24-icomplete-vertical/</link>
      <pubDate>Thu, 24 Jun 2021 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2021-06-24-icomplete-vertical/</guid>
      <description>&lt;p&gt;Tracking the Emacs development by building its master branch may not be a smooth
experience for everyone, but for the average enthusiast is the perfect way to
see their favourite tool evolve, trying experimental things, and reporting back
to the core developers to help them. Sure, one has to deal with occasional build
failures, but with Git at one&amp;rsquo;s service it&amp;rsquo;s always easy to reset to a working
commit and find happiness again.&lt;/p&gt;
&lt;p&gt;Recently a shiny new mode has been implemented on master:
&lt;code&gt;icomplete-vertical-mode&lt;/code&gt;. Now, if you had the chance to read this blog in the
past you know that when it comes to candidate completion I am a gangsta jumping
back and forth among packages with excessive self-satisfaction. But you should
also already know that I like to use as many Emacs built-ins as possible. Hence,
I could not wait to give &lt;code&gt;icomplete-vertical-mode&lt;/code&gt; a try.&lt;/p&gt;
&lt;p&gt;Turning it on is trivial:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(icomplete-mode 1)
(add-hook &#39;icomplete-mode-hook #&#39;icomplete-vertical-mode)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Since other completion systems have spoiled me, I prefer scrolling over the
rotating behaviour of the standard &lt;code&gt;icomplete&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(setq icomplete-scroll t)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Furthermore, I always want to see the candidate list:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(setq icomplete-show-matches-on-no-input t)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is pretty much it. I use &lt;code&gt;icomplete-fido-backward-updir&lt;/code&gt; to move up one
directory and I have &lt;code&gt;exit-minibuffer&lt;/code&gt; bound to &lt;code&gt;C-j&lt;/code&gt; for convenience.&lt;/p&gt;
&lt;p&gt;I have been using &lt;code&gt;icomplete-vertical-mode&lt;/code&gt; daily for a while now and everything
has been working as expected. For the record, this mode works seamlessly with
your favourite &lt;code&gt;completion-styles&lt;/code&gt; settings, so moving from, say, Vertico to
&lt;code&gt;icomplete-vertical-mode&lt;/code&gt; is simple and easy.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Would Alfred Hitchcock use Emacs?</title>
      <link>https://manueluberti.eu/posts/2021-04-12-vertico/</link>
      <pubDate>Mon, 12 Apr 2021 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2021-04-12-vertico/</guid>
      <description>&lt;p&gt;First you have to excuse the awful title, but a cinephile cannot resist the
temptation of an easy reference when the Emacs package he is going to write
about is called &lt;a href=&#34;https://github.com/minad/vertico&#34;&gt;Vertico&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Daniel Mendler has become such a prolific contributor to our Emacs world. His
work with Omar Antolín Camarena and Clemens Radermacher (to name a few!) has
been showing me how much can be done with little improvements on Emacs default
completion system. Actually, “little” is a bit unfair to them because they have
been putting a lot of effort in their packages and contributions. What “little”
stands for instead is the amount of code I had to add to my &lt;code&gt;init.el&lt;/code&gt; to get a
superb completion UI. I combine Vertico with
&lt;a href=&#34;https://github.com/oantolin/orderless&#34;&gt;Orderless&lt;/a&gt; and I didn&amp;rsquo;t have to do much
beside this after the installation via &lt;code&gt;package.el&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(require &#39;orderless)
(setq completion-styles &#39;(orderless))

(require &#39;vertico)
(vertico-mode 1)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Well, to be fair I did something more, like binding &lt;code&gt;vertico-exit-input&lt;/code&gt; to
&lt;code&gt;C-j&lt;/code&gt; and setting &lt;code&gt;orderless-matching-styles&lt;/code&gt; to &lt;code&gt;orderless-regexp&lt;/code&gt;,
plus I am using Daniel&amp;rsquo;s &lt;a href=&#34;https://github.com/minad/consult&#34;&gt;consult&lt;/a&gt; to extend
Vertico capabilities, but I guess you see where I am going by now. The
combination of small packages makes for a modular system that I can interact
with more easily. For instance, Daniel can go berserk and forget about the
lovely 500 lines of code limit he set himself to with Vertico. Why should
I trust this criminal mind, then? I can switch to
&lt;a href=&#34;https://github.com/raxod502/selectrum&#34;&gt;Selectrum&lt;/a&gt; and keep using Consult and
Orderless with it.&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;The beauty of Vertico is that it is not about reinventing Emacs completion once
again. By sticking to Emacs built-in commands and completion facilities, Vertico
succeeds in staying close to the source without losing the chance to improve on
it. On the one hand, moving to Vertico means it is up to the user to configure
extra niceties. That is what packages like Consult, Orderless,
&lt;a href=&#34;https://github.com/oantolin/embark&#34;&gt;Embark&lt;/a&gt;, and
&lt;a href=&#34;https://github.com/minad/marginalia&#34;&gt;Marginalia&lt;/a&gt; aim for, but again, the user
is in charge of the right setup for their needs, while a solution such as Helm
offers a lot of functionalities out of the box. On the other hand, tools such as
Helm, Ivy, and Selectrum are more complex than Vertico and may bring in code you
do not necessarily need, which is something even Emacs itself doesn&amp;rsquo;t shy away
from.&lt;sup id=&#34;fnref:2&#34;&gt;&lt;a href=&#34;#fn:2&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;2&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;I find it amazing that a seemingly simple and yet so central feature in my
everyday Emacs such as the completion system has pushed people to create all
these amazing packages. It seems to me that Helm has helped pave the way for a
more powerful experience when it comes to completion and that by studying Emacs
internals carefully one can achieve similar benefits with a different approach.
As humble end-users of all this we really are a lucky bunch.&lt;/p&gt;
&lt;div class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;
&lt;hr&gt;
&lt;ol&gt;
&lt;li id=&#34;fn:1&#34;&gt;
&lt;p&gt;The irony should be obvious.&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&#34;fn:2&#34;&gt;
&lt;p&gt;I don&amp;rsquo;t really need games in my text editor.&amp;#160;&lt;a href=&#34;#fnref:2&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    <item>
      <title>Back to the roots</title>
      <link>https://manueluberti.eu/posts/2021-04-08-no-use-package/</link>
      <pubDate>Thu, 08 Apr 2021 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2021-04-08-no-use-package/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;https://manueluberti.eu/posts/2021-03-08-package/&#34;&gt;Last time&lt;/a&gt; I left &lt;code&gt;straight&lt;/code&gt; for the built-in
&lt;code&gt;package.el&lt;/code&gt;, a choice I have not had the pleasure to regret so far. Now I am
going to reason about a more ambitious change in my Emacs configuration: I am
not using &lt;a href=&#34;https://github.com/jwiegley/use-package&#34;&gt;use-package&lt;/a&gt; any more.&lt;/p&gt;
&lt;p&gt;Before answering your concerned &lt;em&gt;why!?&lt;/em&gt; let me just say that if you are happy
with &lt;code&gt;use-package&lt;/code&gt; you should stay with it. By wrapping all the settings for a
built-in feature or an external package with &lt;code&gt;use-package&lt;/code&gt; you can easily notice
what you are doing wrong when tweaking something, while having control over the
installation and the loading of your favourite library as well. Despite some
unhappiness around the web,&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt; &lt;code&gt;use-package&lt;/code&gt; is just a great tool that any
serious Emacs hacker should consider when digging deep into their &lt;code&gt;.emacs.d&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;As for my choice to move away from it, it all started as an experiment. I wanted
to see if I could have the same amount of control and readability over my
&lt;code&gt;init.el&lt;/code&gt; without an extra package. You see, most of the recent changes to my
setup involved trying to rely on Emacs own facilities to answer my needs, and
I am glad to say vanilla Emacs has been really a surprise in this regard. My
liaisons with &lt;a href=&#34;https://manueluberti.eu/posts/2020-09-18-project/&#34;&gt;project.el&lt;/a&gt; and
&lt;a href=&#34;https://manueluberti.eu/posts/2020-09-23-flymake/&#34;&gt;Flymake&lt;/a&gt; are nice examples of
this.&lt;/p&gt;
&lt;p&gt;Removing &lt;code&gt;use-package&lt;/code&gt; has meant rethinking the way I install packages,
especially if I want my setup to be ready to go any time I upgrade to a newer
version of Ubuntu. My solution was adding the packages I use to
&lt;code&gt;package-selected-packages&lt;/code&gt; and have a check on startup to make sure they are
installed. This works very well combined with &lt;code&gt;package-autoremove&lt;/code&gt;: if a package
is not listed under &lt;code&gt;package-selected-packages&lt;/code&gt;, Emacs takes care of the mess.&lt;/p&gt;
&lt;p&gt;All the &lt;code&gt;use-package&lt;/code&gt; blocks have been replaced with a combination of
&lt;code&gt;with-eval-after-load&lt;/code&gt;, &lt;code&gt;define-key&lt;/code&gt;, and &lt;code&gt;add-hook&lt;/code&gt;, which was not as
complicated as it might sound, and more often than not was similar to what I had
in my days before the &lt;code&gt;use-package&lt;/code&gt; takeover. True, I lost the nice readability
of &lt;code&gt;use-package&lt;/code&gt; with this massive edit. For example, its keywords have the
benefit of grouping settings together and clearly indicate when a new group
starts, but on the other hand now there is less macro-magic masking
package-related operations. As a result I have a more detailed insight of what
is really going on with my Emacs Lisp. For instance, I have gained a better
knowledge of what &lt;code&gt;run-with-idle-timer&lt;/code&gt; actually does.&lt;/p&gt;
&lt;p&gt;Again, it is a matter of personal preferences. By now the beauty of
&lt;code&gt;use-package&lt;/code&gt; is well-known in the Emacs world and all the praises are
well-deserved. Let me stress it again: &lt;code&gt;use-package&lt;/code&gt; makes your configuration
simpler to manage and easier to read. Those were the main reasons I switched to
it years ago, anyway.&lt;/p&gt;
&lt;p&gt;However, if you know what you are doing you can achieve a clean and pleasant
&lt;code&gt;init.el&lt;/code&gt; with what Emacs already offers. Does it take more effort? Yes, it
probably does. Is it really worth it? It&amp;rsquo;s up to you, mate. Am I just showing
off? No, come on, don&amp;rsquo;t be rude.&lt;/p&gt;
&lt;div class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;
&lt;hr&gt;
&lt;ol&gt;
&lt;li id=&#34;fn:1&#34;&gt;
&lt;p&gt;See for instance &lt;a href=&#34;https://github.com/conao3/leaf.el#description&#34;&gt;here&lt;/a&gt; or
&lt;a href=&#34;https://two-wrongs.com/migrating-away-from-use-package&#34;&gt;here&lt;/a&gt;.&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    <item>
      <title>Quick starting is a bendy road</title>
      <link>https://manueluberti.eu/posts/2021-03-08-package/</link>
      <pubDate>Mon, 08 Mar 2021 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2021-03-08-package/</guid>
      <description>&lt;p&gt;After more than a year with &lt;a href=&#34;https://manueluberti.eu/posts/2019-10-04-straight/&#34;&gt;straight&lt;/a&gt; as my
package manager, recently I have decided to sit down and look closely at how
I handle my Emacs packages.&lt;/p&gt;
&lt;p&gt;For all the interesting design choices and splendid documentation &lt;code&gt;straight&lt;/code&gt;
offers, I have never used neither its version freezing capabilities nor the
chances to edit the source code of a package to try possible fixes before
sending patches upstream. Two reasons, mainly:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;I update my packages on a daily basis, accepting the risk of breakages in
order to signal them to the maintainers and offer some help;&lt;/li&gt;
&lt;li&gt;when I want to send a patch, I have the source code of the package I am
working on outside of my Emacs configuration to avoid leaving something messy
around.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;These are not issues with &lt;code&gt;straight&lt;/code&gt;, of course. It all depends on what one needs
from their package manager.&lt;/p&gt;
&lt;p&gt;One of the major benefits that &lt;code&gt;straight&lt;/code&gt; brought to my setup is a boost in
startup speed. However, why don&amp;rsquo;t give &lt;code&gt;package-quickstart&lt;/code&gt; a try? Setting
&lt;code&gt;package-quickstart&lt;/code&gt; to &lt;code&gt;t&lt;/code&gt; instructs &lt;code&gt;package.el&lt;/code&gt; to pre-compute an autoload
file so that the activation of packages can be done much faster, resulting in a
&lt;a href=&#34;https://git.savannah.gnu.org/cgit/emacs.git/commit/etc/NEWS?id=6dfdf0c9e8e4aca77b148db8d009c862389c64d3&#34;&gt;faster
startup&lt;/a&gt;.
And indeed it does, resulting in more or less the same 0.4 seconds that I was
getting with &lt;code&gt;straight&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;One thing to be aware of is that, as the documention of &lt;code&gt;package-quickstart&lt;/code&gt;
suggests, “the use of ‘package-quickstart-refresh&amp;rsquo; every time the activation
need to be changed, such as when ‘package-load-list&amp;rsquo; is modified” is required.
Hence, I added an &lt;code&gt;:after-while&lt;/code&gt; advice to &lt;code&gt;package-menu-execute&lt;/code&gt; (bound to
&lt;code&gt;x&lt;/code&gt; in &lt;code&gt;Package Menu&lt;/code&gt;) to make sure &lt;code&gt;package-quickstart-refresh&lt;/code&gt; is run
after every upgrade.&lt;/p&gt;
&lt;p&gt;Again, mine is not an argument against &lt;code&gt;straight&lt;/code&gt;. It&amp;rsquo;s still a great package
manager and a fantastic alternative to the built-in &lt;code&gt;package.el&lt;/code&gt;. However, these
days my Emacs interactions do not need the fine-grained control &lt;code&gt;straight&lt;/code&gt;
provides.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Embarking in a new affair with completions</title>
      <link>https://manueluberti.eu/posts/2020-12-25-embark/</link>
      <pubDate>Fri, 25 Dec 2020 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2020-12-25-embark/</guid>
      <description>&lt;p&gt;What a year this 2020. Beside the pandemic changing our lives in unpredictable
ways, from the perspective of my Emacs usage much was going on in my &lt;code&gt;init.el&lt;/code&gt;
until I felt that &lt;a href=&#34;https://manueluberti.eu/posts/2020-09-08-end-of-era/&#34;&gt;a temporary break was
necessary&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Most of my tinkering concerned the minibuffer and its completion mechanisms.
I finished last year and started this one with Helm, but I am about to close
2020 with the built-in minibuffer completion and
&lt;a href=&#34;https://github.com/oantolin/embark&#34;&gt;Embark&lt;/a&gt; providing candidates. A solution
that &lt;a href=&#34;https://protesilaos.com/dotemacs/&#34;&gt;Protesilaos Stavrou&lt;/a&gt; explored and which
has been really suiting me.&lt;/p&gt;
&lt;p&gt;Before detailing how I adapted his approach to my preferences, though, let me
give you a bit of rationale. First, Helm rocks and it rocks hard. Its power is
evident after a couple of hours with it. I briefly used Icomplete tweaked to
display its results vertically, but I didn&amp;rsquo;t find it responsive enough to stick
with it. Then I found out about Selectrum, which fixed the responsiveness but
eventually was not adding a significant difference compared to Helm. True,
Selectrum has a simpler codebase, but were I only to look at my daily
interactions with Emacs, only the user interface can tell Helm and Selectrum
apart.&lt;/p&gt;
&lt;p&gt;Protesilaos took a different path. He wants to understand the code in front of
him, so the less changes the better. In this regard Helm, Selectrum, and even
Icomplete add a layer of indirection between him and the minibuffer. He is right
in this. The minibuffer is more capable than the plethora of completion
frameworks may suggest, and one can leverage its strength without forcing it to
behave in a totally new way. Protesilaos&amp;rsquo; reasoning got me thinking. Once again,
am I looking for a solution from the outside before having really understood
what lies underneath my beloved text editor?&lt;/p&gt;
&lt;p&gt;Following Protesilaos&amp;rsquo; steps, I set up the minibuffer to rely only on
&lt;a href=&#34;https://github.com/oantolin/orderless&#34;&gt;orderless&lt;/a&gt; and Embark, with
&lt;a href=&#34;https://github.com/minad/consult&#34;&gt;Consult&lt;/a&gt; chiming in for a some of operations
like better history in &lt;code&gt;shell-mode&lt;/code&gt; and an improved &lt;code&gt;apropos&lt;/code&gt;. What I added to
Protesilaos&amp;rsquo; code is the only thing that I felt was missing: a command to search
for the symbol at point in my project, with the results displayed in an
&lt;code&gt;embark-live-occur&lt;/code&gt; window in order to quickly jump to a specific entry. Over at
the Consult&amp;rsquo;s GitHub there are talks about a &lt;code&gt;consult-rg&lt;/code&gt; utility which would
serves this purpose, and there has been suggestions of using
&lt;code&gt;project-find-regexp&lt;/code&gt; as well.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defun mu-project-find-refs ()
  &amp;quot;Use `project-find-regexp&#39; to search for thing at point.&amp;quot;
  (interactive)
  (if-let (tap (thing-at-point &#39;symbol))
      (project-find-regexp tap)
    (message &amp;quot;Nothing at point to search for&amp;quot;)))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Easy enough to understand. However, if you, like me, set up Embark like
Protesilaos does you&amp;rsquo;ll notice that this command doesn&amp;rsquo;t show any candidate
unless you type something at the &lt;code&gt;Jump to definition&lt;/code&gt; prompt. The candidates are
there already, though, so I have to avoid waiting for an input and display the
candidate list immediately.&lt;/p&gt;
&lt;p&gt;The solution is straightforward: just remove &lt;code&gt;embark-live-occur-after-input&lt;/code&gt;
from &lt;code&gt;minibuffer-setup-hook&lt;/code&gt; and use &lt;code&gt;embark-live-occur-after-delay&lt;/code&gt; instead.
I added a &lt;code&gt;:before&lt;/code&gt; advice on &lt;code&gt;mu-project-find-refs&lt;/code&gt; for this. The beauty of
this advice is that it works elsewhere as well. For instance, I have been using
it for &lt;code&gt;consult-flymake&lt;/code&gt; and &lt;code&gt;flyspell-correct-at-point&lt;/code&gt; too.&lt;/p&gt;
&lt;p&gt;Note that this advice requires a little change to the original
&lt;code&gt;minibuffer-setup-hook&lt;/code&gt; I have lifted from Protesilaos. Instead of adding
&lt;code&gt;embark-live-occur-after-input&lt;/code&gt; to it I am using this to ensure only
&lt;code&gt;embark-live-occur-after-input&lt;/code&gt; is present.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defun mu-embark-live-occur-after-input ()
  &amp;quot;Ensure only `embark-live-occur-after-input&#39; is active.&amp;quot;
  (remove-hook &#39;minibuffer-setup-hook #&#39;embark-live-occur-after-delay)
  (add-hook &#39;minibuffer-setup-hook #&#39;embark-live-occur-after-input))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Without a dedicated completion framework the minibuffer may feel rather basic at
first, but do not let it deceive you with its frugality. Like &lt;code&gt;project.el&lt;/code&gt;, all
it needs is love.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Restricting Flymake to my projects</title>
      <link>https://manueluberti.eu/posts/2020-11-21-flymake-projects/</link>
      <pubDate>Sat, 21 Nov 2020 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2020-11-21-flymake-projects/</guid>
      <description>&lt;p&gt;My recent move &lt;a href=&#34;https://manueluberti.eu/posts/2020-09-23-flymake/&#34;&gt;from Flycheck to
Flymake&lt;/a&gt; has proven to be a
solid choice because the Emacs built-in syntax checker has yet to let me down.
And since by now I am sure my love for &lt;code&gt;project.el&lt;/code&gt; is absolutely obvious, could
I miss the opportunity to make these two underappreciated gems shine together?&lt;/p&gt;
&lt;p&gt;Honestly, though, the credit here goes all to Protesilaos Stavrou. &lt;a href=&#34;https://protesilaos.com/dotemacs/#h:b8bfcc05-c0d3-4093-b3fe-f06187d22c6a&#34;&gt;His Flymake
setup&lt;/a&gt;
made me aware of a neat way to limit the use of Flymake to the places I actually
need it.&lt;/p&gt;
&lt;p&gt;All I had to do was adapt it to my preferences:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defun mu-flymake-mode-activate ()
  &amp;quot;Activate `flymake-mode&#39; only in my projects.&amp;quot;
  (project--ensure-read-project-list)
  (let ((known-projects (project-known-project-roots))
        (pr (or (locate-dominating-file &amp;quot;.&amp;quot; &amp;quot;.git&amp;quot;)
                default-directory)))
    (if (and (eq buffer-read-only nil)
             (member pr known-projects))
        (flymake-mode 1)
      (flymake-mode -1))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I then hooked this little function to &lt;code&gt;prog-mode-hook&lt;/code&gt; and &lt;code&gt;text-mode-hook&lt;/code&gt; and
everything was good to go.&lt;/p&gt;
&lt;p&gt;Note that &lt;code&gt;project.el&lt;/code&gt; must be required before running &lt;code&gt;mu-flymake-mode-activate&lt;/code&gt;,
otherwise Emacs will complain about &lt;code&gt;project--ensure-read-project-list&lt;/code&gt; not being
available.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Extending project.el</title>
      <link>https://manueluberti.eu/posts/2020-11-14-extending-project/</link>
      <pubDate>Sat, 14 Nov 2020 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2020-11-14-extending-project/</guid>
      <description>&lt;p&gt;In my &lt;a href=&#34;https://manueluberti.eu/posts/2020-09-18-project/&#34;&gt;first appreciation&lt;/a&gt; of
&lt;code&gt;project.el&lt;/code&gt; I wrote about a patch for &lt;code&gt;project--files-in-directory&lt;/code&gt;. It&amp;rsquo;s a
working solution, I won&amp;rsquo;t deny that, but patching code always feels hacky.
It&amp;rsquo;s like a dirty workaround you cannot avoid to look at every time you visit
your Emacs configuration.&lt;/p&gt;
&lt;p&gt;By inspecting the code of &lt;code&gt;project.el&lt;/code&gt; I noticed that &lt;code&gt;project-files&lt;/code&gt; is a
generic function. In Emacs Lisp parlance, a &lt;a href=&#34;https://www.gnu.org/software/emacs/manual/html_node/elisp/Generic-Functions.html&#34;&gt;generic
function&lt;/a&gt;
specifies an abstract operation with the actual implementation provided by
methods. This simply means that I can devise my own implementation of
&lt;code&gt;project-files&lt;/code&gt;.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(cl-defmethod project-root ((project (head local)))
  (cdr project))

(defun mu--project-files-in-directory (dir)
  &amp;quot;Use `fd&#39; to list files in DIR.&amp;quot;
  (let* ((default-directory dir)
         (localdir (file-local-name (expand-file-name dir)))
         (command (format &amp;quot;fd -t f -0 . %s&amp;quot; localdir)))
    (project--remote-file-names
     (sort (split-string (shell-command-to-string command) &amp;quot;\0&amp;quot; t)
           #&#39;string&amp;lt;))))

(cl-defmethod project-files ((project (head local)) &amp;amp;optional dirs)
  &amp;quot;Override `project-files&#39; to use `fd&#39; in local projects.&amp;quot;
  (mapcan #&#39;mu--project-files-in-directory
          (or dirs (list (project-root project)))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;project.el&lt;/code&gt; has to be made aware of my &lt;code&gt;local&lt;/code&gt; type now.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defun mu-project-try-local (dir)
  &amp;quot;Determine if DIR is a non-Git project.
DIR must include a .project file to be considered a project.&amp;quot;
  (let ((root (locate-dominating-file dir &amp;quot;.project&amp;quot;)))
    (and root (cons &#39;local root))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;mu-project-try-local&lt;/code&gt; just needs to be added to &lt;code&gt;project-find-functions&lt;/code&gt; to
make sure my non-Git projects become known and remembered across sessions when
I hit &lt;code&gt;C-x p p&lt;/code&gt;. This is way more elegant than the previous patch.&lt;/p&gt;
&lt;p&gt;Since I also never use Git submodules, I can push my extensions a little further.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defun mu--backend (dir)
  &amp;quot;Check if DIR is under Git, otherwise return nil.&amp;quot;
  (when (locate-dominating-file dir &amp;quot;.git&amp;quot;)
    &#39;Git))

(defun mu-project-try-vc (dir)
  &amp;quot;Determine if DIR is a project.
This is a thin variant of `project-try-vc&#39;:
- It takes only Git into consideration
- It does not check for submodules&amp;quot;
  (let* ((backend (mu--backend dir))
         (root
          (when (eq backend &#39;Git)
            (or (vc-file-getprop dir &#39;project-git-root)
                (let ((root (vc-call-backend backend &#39;root dir)))
                  (vc-file-setprop dir &#39;project-git-root root))))))
    (and root (cons &#39;vc root))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;mu-project-try-vc&lt;/code&gt; now replaces &lt;code&gt;project-try-vc&lt;/code&gt; in &lt;code&gt;project-find-functions&lt;/code&gt;.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Emacs and Emanuele Severino</title>
      <link>https://manueluberti.eu/posts/2020-10-24-emacs-severino/</link>
      <pubDate>Sat, 24 Oct 2020 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2020-10-24-emacs-severino/</guid>
      <description>&lt;p&gt;The recently available &lt;a href=&#34;https://emacssurvey.org/&#34;&gt;Emacs User Survey&lt;/a&gt; made me think, once again, about the
status of the technological world around me. The survey was painstakingly
discussed on the &lt;a href=&#34;https://lists.gnu.org/mailman/listinfo/emacs-devel&#34;&gt;emacs-devel&lt;/a&gt; mailing list, and generated some interesting
reactions among people outside the core developing team as well. More
interesting for the perspective of this writing are the reactions to the
discussions on &lt;code&gt;emacs-devel&lt;/code&gt;, because they reveal how great the distance between
me and some members of the Emacs community has been getting.&lt;/p&gt;
&lt;p&gt;You see, I am a failed Free Software supporter. I stopped campaigning in its
favour as soon as my wife&amp;rsquo;s school closed. There I had set up everything with
Free and Open Source software, and watching the teachers effectively do their
job with technological solutions they were not accustomed to made me happy. They
did not really care about the reasons behind my choices, but they respected my
contribution and were willing to overcome the first weeks of adaptation as long
as I could guarantee a comfortable working environment. When all of this ended
and I went back to software development, Free and Open Source software became
only a private concern. While still set on Linux,&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt; I left Debian for Ubuntu
because I didn&amp;rsquo;t want to spend time tinkering with my operative system to get
the best out of my Dell XPS. My distro-hopping days had come to an end. I just
wanted a system that would let me code, write, and browse the Web. I chose the
easy way.&lt;/p&gt;
&lt;p&gt;However, I have never stopped paying attention to the world around me and
behaving consciously. For instance, I hate wasting technology. The
3-and-a-half-year old Dell XPS where I am writing now replaced my 8-year old
Dell Inspiron, and my 7-year old HP server is still rock-solid and here to stay.
I have a 4-year old Fairphone, my first and only smartphone, that I intend to
keep for as long as possible. Beside gadgets, I&amp;rsquo;ve been on a vegan diet for
almost seven years and I consider it one of the best and most important choices
I&amp;rsquo;ve ever made regarding the ethics of what I eat. Come to think of it, as bad
as the Coronavirus crisis is turning out to be, it “fixed” the problem of
getting to the office every day, cutting my car usage down to once a week for
groceries&lt;sup id=&#34;fnref:2&#34;&gt;&lt;a href=&#34;#fn:2&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;2&lt;/a&gt;&lt;/sup&gt; and thus decreasing my impact on the environment.&lt;/p&gt;
&lt;p&gt;This is why mixing technocraticism with pragmatism bothers me. The words
“pragmatic” and “pragmatism” have been kind of a constant in the IT world I live
in since “The Pragmatic Programmer” passed on my shelves. As every word in every
language, “pragmatic” and “pragmatism” are complex words and their actual
meaning is not trivially describable. Immanuel Kant distinguishes between
“practical” and “pragmatic”, but without asking him we can quickly see what the
dictionary tells us. According to the Oxford Learner&amp;rsquo;s Dictionary, “pragmatic”
means “solving problems in a practical and sensible way rather than by having
fixed ideas or theories”. Treccani, however, is closer to how “pragmatic” is
known nowadays: “what is being characterised by the prevailing of practical
interests over theoretical ones and ideal &lt;em&gt;values&lt;/em&gt;”. I won&amp;rsquo;t digress on the
multiple meanings of “ideal” to keep it simple and because “values” is actually
the key word for me here.&lt;/p&gt;
&lt;p&gt;“Pragmatic” and “pragmatism”, in common parlance, imply a separation between
theoretical thoughts and practical action, but it is actually impossible to draw
a line between the two. Every action is informed by a thought and every thought
shines a light on the action. We can act automatically without thinking about
it, sure, but that has nothing to do with voluntary actions. When we act, we act
according to a line of reasoning, and it&amp;rsquo;s that line of reasoning that
determines the value of the action. Take my choice of using Ubuntu on this Dell
XPS. A deliberate decision born out of my desire to prefer a comfortable option
instead of spending time to value more Free Software-compliant solutions.
I acted with a plan just as I acted with a plan when I chose my vegan diet.
Which choice is more pragmatic? Which one tells you more about my ethics?&lt;/p&gt;
&lt;p&gt;For years now I&amp;rsquo;ve been seeing the IT world as self-involved and rarely eager to
discuss larger issues. Problems such as the environmental crisis become material
for self-congratulatory speeches at conferences around the world, while in fact
the day after the conference we resume our lives as if nothing other than
ourselves mattered. We do that because, as Emanuele Severino says, we are scared
of what is beyond ourselves. We have replaced religious myths with the myth of
technology to find the immediate answers to deep and life-changing questions
that we do not want to investigate any further.&lt;/p&gt;
&lt;p&gt;It&amp;rsquo;s not easy to understand the weight of words like “pragmatism” and
“pragmatic” in a technocratic world. We live in an age where we believe that
technology is our ultimate saviour. We are driven to accept technology as it is
because of the benefits it brings to ourselves. We trust our technology because
not doing so would result in the effort of questioning it, which in turns may
unveil the details that the technocratic world goes a long distance to hide.
More importantly, questioning technology could disclose what we really are and
need to be, something that takes will and courage to face. In a time like this,
Emanuele Severino&amp;rsquo;s claim that &lt;em&gt;technique&lt;/em&gt; is the dominant power of our time
sounds as forceful as ever.&lt;/p&gt;
&lt;div class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;
&lt;hr&gt;
&lt;ol&gt;
&lt;li id=&#34;fn:1&#34;&gt;
&lt;p&gt;Yes, I didn&amp;rsquo;t write GNU/Linux.&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&#34;fn:2&#34;&gt;
&lt;p&gt;Yes, I am a bit of a recluse.&amp;#160;&lt;a href=&#34;#fnref:2&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    <item>
      <title>Reliable REPL switching and buffer loading with CIDER</title>
      <link>https://manueluberti.eu/posts/2020-10-16-repl-switching/</link>
      <pubDate>Fri, 16 Oct 2020 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2020-10-16-repl-switching/</guid>
      <description>&lt;p&gt;As a Clojure developer one of the most important packages in my everyday Emacs
usage is &lt;a href=&#34;https://cider.mx/&#34;&gt;CIDER&lt;/a&gt;. There are many things to love about it, chief among them the
great interactive code evaluation and a sweet integration with popular Clojure
tools. I still haven&amp;rsquo;t played with its debugging facilities, but yes, I know I should.&lt;/p&gt;
&lt;p&gt;However, there is something that has been bothering me for quite a while: REPL
switching and buffer loading. I cannot pinpoint the exact moment when these
seemingly simple operations have become so unreliable, but I still remember when
switching to the correct REPL buffer according to the file in front of me used
to work as expected and loading a buffer didn&amp;rsquo;t require dealing with sessions
first.&lt;/p&gt;
&lt;p&gt;Let me give you more details before this writing starts to look like a random
rant. My projects are usually web applications, which means I have to write both
Clojure and ClojureScript. The Clojure side can be backed by &lt;code&gt;leiningen&lt;/code&gt; or a
&lt;code&gt;deps.edn&lt;/code&gt; file, and we are set on &lt;code&gt;shadow-cljs&lt;/code&gt; for ClojureScript. The first thing
I normally do is jack-in with &lt;code&gt;C-c C-x j j&lt;/code&gt; and then bring up the dedicated
ClojureScript REPL with &lt;code&gt;C-c C-x j s&lt;/code&gt;. Opening the browser and navigate to
something along the lines of &lt;code&gt;localhost:3000&lt;/code&gt; finalises the process of setting up
the ClojureScript REPL. That&amp;rsquo;s it, another good day of coding can begin. And
soon enough frustration follows.&lt;/p&gt;
&lt;p&gt;I tend to move from Clojure to ClojureScript files and vice versa quite a lot,
and hitting &lt;code&gt;C-c C-z&lt;/code&gt; frequently results in an unpredictable behaviour. Sometimes
the REPL of the expected type pops up, sometimes the other one appears,
sometimes I get a message about a missing REPL in the current session. Manually
linking the current buffer to the correct REPL with &lt;code&gt;C-c C-s b&lt;/code&gt; seems to fix the
problem, but it&amp;rsquo;s only a matter of time. It takes a couple of buffer switching
operations to bring the issue back. It is as if the link between the buffer and
the REPL has vanished. Even worse, without that link I can forget about &lt;code&gt;C-c C-k&lt;/code&gt;
to load the buffer.&lt;/p&gt;
&lt;p&gt;To overcome my frustration, I sat back and looked at how exactly I interact with
CIDER:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;I only deal with one project at a time&lt;/li&gt;
&lt;li&gt;I need at most two running REPLs&lt;/li&gt;
&lt;li&gt;I don&amp;rsquo;t really care about firing up dedicated REPLs for other projects. If
I change project, I simply close every buffer of the current one and start
afresh&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This made me realise that the whole CIDER &lt;a href=&#34;https://docs.cider.mx/cider/0.26/usage/managing_connections.html#sessions&#34;&gt;session&lt;/a&gt; management is too much for my
basic needs.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defun mu--cider-repl-regex (type)
  &amp;quot;Return the regexp to get the CIDER REPL based on TYPE.&amp;quot;
  (if (eq type &#39;clj)
      &amp;quot;\`*cider-repl .*clj[*]&amp;quot;
    &amp;quot;\`*cider-repl .*cljs&amp;quot;))

(defun mu--cider-repl-buffer-name (type)
  &amp;quot;Get buffer from `buffer-list&#39; according to TYPE.&amp;quot;
  (let ((regex (mu--cider-repl-regex type)))
    (car (seq-filter (lambda (s) (string-match-p regex s))
                     (mapcar #&#39;buffer-name (buffer-list))))))

(defun mu-cider-switch-to-repl (&amp;amp;optional type)
  &amp;quot;Open a CIDER REPL for TYPE.
If TYPE is not passed, open a Clojure REPL.&amp;quot;
  (interactive &amp;quot;P&amp;quot;)
  (let ((type (or type &#39;clj)))
    (if-let (buffer (mu--cider-repl-buffer-name type))
        (pop-to-buffer buffer)
      (message &amp;quot;No CIDER REPL available&amp;quot;))))

(defun mu-cider-switch-to-cljs-repl ()
  &amp;quot;Open a CIDER REPL for ClojureScript.&amp;quot;
  (interactive)
  (mu-cider-switch-to-repl &#39;cljs))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note that I changed the value of &lt;code&gt;nrepl-repl-buffer-name-template&lt;/code&gt; to &lt;code&gt;*cider-repl %j %r:%S*&lt;/code&gt;, so you may have to change &lt;code&gt;mu--cider-repl-regex&lt;/code&gt; according to the value
in your setup.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;C-c C-z&lt;/code&gt; is bound to &lt;code&gt;mu-cider-switch-to-repl&lt;/code&gt; in &lt;code&gt;clojure-mode-map&lt;/code&gt; and
&lt;code&gt;clojurec-mode-map&lt;/code&gt;, and to &lt;code&gt;mu-cider-switch-to-cljs-repl&lt;/code&gt; in
&lt;code&gt;clojurescript-mode-map&lt;/code&gt;. This of course means that in &lt;code&gt;.cljc&lt;/code&gt; files I always get to
a Clojure REPL, but that&amp;rsquo;s fine. The code in there has to be tested on both
REPLs anyway, so it doesn&amp;rsquo;t matter which one comes up first.&lt;/p&gt;
&lt;p&gt;Now, let&amp;rsquo;s fix &lt;code&gt;C-c C-k&lt;/code&gt; as well.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defun mu--cider-session-by-type (type)
  &amp;quot;Return the current CIDER session by TYPE.&amp;quot;
  (let* ((regex (mu--cider-repl-regex type))
         (system (sesman--system))
         (sessions (sesman-current-sessions system &#39;(buffer))))
    (car
     (seq-filter (lambda (s)
                   (string-match-p regex (buffer-name (cadr s))))
                 sessions))))

(defun mu--cider-load-buffer (session)
  &amp;quot;Load the current buffer according to SESSION.&amp;quot;
  (if session
      (let ((system (sesman--system))
            (buf (current-buffer)))
        (sesman--clear-links)
        (sesman-link-session system session &#39;buffer buf)
        (cider-load-buffer buf))
    (message &amp;quot;No CIDER REPL available&amp;quot;)))

(defun mu-cider-load-clj-buffer ()
  &amp;quot;Load the current Clojure buffer.&amp;quot;
  (interactive)
  (mu--cider-load-buffer (mu--cider-session-by-type &#39;clj)))

(defun mu-cider-load-cljc-buffer ()
  &amp;quot;Load the current ClojureC buffer.&amp;quot;
  (interactive)
  (let ((clj-session (mu--cider-session-by-type &#39;clj))
        (cljs-session (mu--cider-session-by-type &#39;cljs)))
    (if (and (null clj-session)
             (null cljs-session))
        (message &amp;quot;No CIDER REPL available&amp;quot;)
      (when clj-session
        (mu--cider-load-buffer clj-session))
      (when cljs-session
        (mu--cider-load-buffer cljs-session)))))

(defun mu-cider-load-cljs-buffer ()
  &amp;quot;Load the current ClojureScript buffer.&amp;quot;
  (interactive)
  (mu--cider-load-buffer (mu--cider-session-by-type &#39;cljs)))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Just like for &lt;code&gt;C-c C-z&lt;/code&gt;, &lt;code&gt;C-c C-k&lt;/code&gt; is now bound to these commands according to the
mode map. For the sake of completeness, I have also disabled both &lt;code&gt;C-c C-k&lt;/code&gt; and
&lt;code&gt;C-c C-z&lt;/code&gt; in &lt;code&gt;cider-mode-map&lt;/code&gt; in order to avoid any kind of overshadowing by CIDER.&lt;/p&gt;
&lt;p&gt;Note that this approach works well with my intended CIDER usage. It may not be
what you are looking for if you are experiencing the same problems with REPL
switching and buffer loading. Still, I have been using these commands for a
while now and I am happy with them. CIDER has become my trusted Clojure IDE
again.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>We can fly with what we have</title>
      <link>https://manueluberti.eu/posts/2020-09-23-flymake/</link>
      <pubDate>Wed, 23 Sep 2020 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2020-09-23-flymake/</guid>
      <description>&lt;p&gt;There was a time when I just didn&amp;rsquo;t trust Emacs. This lack of confidence was the
result of mixing good and evil: listening to other reliable Emacsers&amp;rsquo; opinions
while being too lazy to see for myself what Emacs could do. The outcome of this
endeavour was a frenetic copying-and-pasting of code snippets in my &lt;code&gt;init.el&lt;/code&gt;,
blindly dragging in more and more external packages.&lt;/p&gt;
&lt;p&gt;Don&amp;rsquo;t get me wrong, external packages made Emacs what it is today for me.
I can&amp;rsquo;t even imagine using it without the likes of &lt;a href=&#34;https://magit.vc/&#34;&gt;Magit&lt;/a&gt; or
&lt;a href=&#34;https://cider.mx/&#34;&gt;CIDER&lt;/a&gt;. However, ignoring what is already there and reaching
for MELPA every time I have an itch to scratch has made me overlook built-in
niceties like &lt;a href=&#34;https://manueluberti.eu/posts/2020-09-18-project/&#34;&gt;project.el&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://www.gnu.org/software/manual/html_node/flymake/index.html#Top&#34;&gt;Flymake&lt;/a&gt;
did fell prey of this line of reasoning.
&lt;a href=&#34;https://www.flycheck.org/en/latest/&#34;&gt;Flycheck&lt;/a&gt; has always seemed like the way
go, so much so that I have barely registered João Távora&amp;rsquo;s and other Emacs
developers&amp;rsquo; efforts to improve Flymake. Since my recent experiments with
&lt;code&gt;project.el&lt;/code&gt; have turned my eyes inwards again, I wanted to see if I can live
without Flycheck.&lt;/p&gt;
&lt;p&gt;There are three places where I need on-the-fly syntax checking:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Emacs Lisp package files with &lt;a href=&#34;https://github.com/purcell/package-lint&#34;&gt;package-lint&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Clojure files with &lt;a href=&#34;https://github.com/borkdude/clj-kondo&#34;&gt;clj-kondo&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Markdown files with &lt;a href=&#34;https://github.com/amperser/proselint&#34;&gt;proselint&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Kind people took care of Emacs Lisp and Clojure for me: &lt;code&gt;package-lint-flymake&lt;/code&gt;
comes with &lt;code&gt;package-lint&lt;/code&gt; and
&lt;a href=&#34;https://github.com/turbo-cafe/flymake-kondor&#34;&gt;flymake-kondor&lt;/a&gt; is a valid
alternative to
&lt;a href=&#34;https://github.com/borkdude/flycheck-clj-kondo&#34;&gt;flycheck-clj-kondo&lt;/a&gt;. But
I wasn&amp;rsquo;t able to find an existing integration with &lt;code&gt;proselint&lt;/code&gt;, so I decided to
provide one.&lt;/p&gt;
&lt;p&gt;My first tries with &lt;a href=&#34;https://github.com/purcell/flymake-easy&#34;&gt;flymake-easy&lt;/a&gt;
didn&amp;rsquo;t go very well. I asked for help on &lt;a href=&#34;https://emacs.stackexchange.com/questions/60769/configure-flymake-for-proselint&#34;&gt;Emacs
StackExchange&lt;/a&gt;,
before realizing I could use
&lt;a href=&#34;https://github.com/karlotness/flymake-quickdef&#34;&gt;flymake-quickdef&lt;/a&gt; like
&lt;code&gt;flymake-kondor&lt;/code&gt; does and &lt;a href=&#34;https://emacs.stackexchange.com/a/60771/5514&#34;&gt;answer to
myself&lt;/a&gt;. The next step was making
the solution available to everyone in the form of a package, and so I published
the little
&lt;a href=&#34;https://github.com/manuel-uberti/flymake-proselint&#34;&gt;flymake-proselint&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Flymake may not have the extensive support for checkers that its bigger brother
has, and it doesn&amp;rsquo;t seem to have the same huge community behind, but it&amp;rsquo;s still
a great library to play with. There is a comparison between the two projects on
the &lt;a href=&#34;https://www.flycheck.org/en/latest/user/flycheck-versus-flymake.html&#34;&gt;Flycheck
website&lt;/a&gt;,
so have a look there before making your choice. Note that the comparison doesn&amp;rsquo;t
mention &lt;code&gt;flymake-quickdef&lt;/code&gt;, which I find easier to use for extending Flymake.&lt;/p&gt;
&lt;p&gt;As for me, my requirements for on-the-fly syntax checking are met by Flymake. At
the end of the day it&amp;rsquo;s good to know that after all these years together Emacs
can still surprise me.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>It’s never too late</title>
      <link>https://manueluberti.eu/posts/2020-09-18-project/</link>
      <pubDate>Fri, 18 Sep 2020 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2020-09-18-project/</guid>
      <description>&lt;p&gt;In his article &lt;a href=&#34;https://www.masteringemacs.org/article/whats-new-in-emacs-27-1&#34;&gt;What&amp;rsquo;s new in Emacs
27.1?&lt;/a&gt; Mickey
Petersen wrote that the built-in &lt;code&gt;project.el&lt;/code&gt;&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt; is a library “not widely used”
and “about 20 years too late”, concluding that it is “a missed opportunity”.&lt;/p&gt;
&lt;p&gt;From what I can tell &lt;code&gt;project.el&lt;/code&gt; has been around since 2015. As everything else
in our Emacs world, it&amp;rsquo;s an effort from volunteers offered back to the
community. I see no reason to avoid it because it has been lacking the attention
of other well-known alternatives such as Projectile. On the contrary, I believe
that the more users try it and report what is missing back to the developers or
perhaps contribute with lines of code, the more chances this tiny library has to
grow and to get better.&lt;/p&gt;
&lt;p&gt;Instead of replacing &lt;code&gt;helm-ls-git&lt;/code&gt; with &lt;code&gt;project.el&lt;/code&gt;, I decided to leave Helm
aside for a moment and try my luck with Icomplete. I trust &lt;a href=&#34;https://protesilaos.com/&#34;&gt;Protesilaos
Stavrou&lt;/a&gt;&amp;rsquo;s opinion on it, anyway, so that&amp;rsquo;s another
good point to give it a shot. If you want a detailed setup for Icomplete be sure
to follow his lead. I limited myself to installing
&lt;a href=&#34;https://github.com/oantolin/icomplete-vertical&#34;&gt;icomplete-vertical&lt;/a&gt; and
&lt;a href=&#34;https://github.com/oantolin/orderless&#34;&gt;orderless&lt;/a&gt; to make my life easier.&lt;/p&gt;
&lt;p&gt;The entry point in &lt;code&gt;project.el&lt;/code&gt; is the prefix &lt;code&gt;C-x p&lt;/code&gt;. You can hit &lt;code&gt;C-h&lt;/code&gt; after that to
see the available key bindings. If you press &lt;code&gt;C-x p p&lt;/code&gt; a list of known projects
will appear. You will see that an option to select a new project is always
available, so it&amp;rsquo;s trivial to add new elements here.&lt;/p&gt;
&lt;p&gt;Once you land on your candidate hit &lt;code&gt;RET&lt;/code&gt; to be presented with a customizable list
of commands to act on the selected project. The keys to activate the commands
are highlighted so, for instance, you can press &lt;code&gt;f&lt;/code&gt; to start exploring your
project files.&lt;/p&gt;
&lt;p&gt;The defaults key bindings provided by &lt;code&gt;project.el&lt;/code&gt; suit me well enough, but I did
apply some changes to tune its behaviour to my needs.&lt;/p&gt;
&lt;p&gt;First, I don&amp;rsquo;t want to rely on &lt;code&gt;find&lt;/code&gt; for &lt;code&gt;project--files-in-directory&lt;/code&gt; when the
faster &lt;a href=&#34;https://github.com/sharkdp/fd&#34;&gt;fd&lt;/a&gt; is around the corner.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(el-patch-defun project--files-in-directory (dir ignores &amp;amp;optional files)
  (el-patch-remove
    (require &#39;find-dired)
    (require &#39;xref)
    (defvar find-name-arg))
  (let* ((default-directory dir)
         ;; Make sure ~/ etc. in local directory name is
         ;; expanded and not left for the shell command
         ;; to interpret.
         (localdir (file-local-name (expand-file-name dir)))
         (command (el-patch-swap
                    (format &amp;quot;%s %s %s -type f %s -print0&amp;quot;
                            find-program
                            localdir
                            (xref--find-ignores-arguments ignores localdir)
                            (if files
                                (concat (shell-quote-argument &amp;quot;(&amp;quot;)
                                        &amp;quot; &amp;quot; find-name-arg &amp;quot; &amp;quot;
                                        (mapconcat
                                         #&#39;shell-quote-argument
                                         (split-string files)
                                         (concat &amp;quot; -o &amp;quot; find-name-arg &amp;quot; &amp;quot;))
                                        &amp;quot; &amp;quot;
                                        (shell-quote-argument &amp;quot;)&amp;quot;))
                              &amp;quot;&amp;quot;))
                    (format &amp;quot;fd -t f -0 . %s&amp;quot; localdir))))
    (project--remote-file-names
     (sort (split-string (shell-command-to-string command) &amp;quot;\0&amp;quot; t)
           #&#39;string&amp;lt;))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then I had to tweak &lt;code&gt;project-kill-buffer-conditions&lt;/code&gt; for buffers in
&lt;code&gt;cider-repl-mode&lt;/code&gt; to ensure &lt;code&gt;project-kill-buffers&lt;/code&gt; catches them.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(add-to-list &#39;project-kill-buffer-conditions &#39;(major-mode . cider-repl-mode) t)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The last customization was adding quick keys for &lt;code&gt;magit-status&lt;/code&gt;, &lt;code&gt;project-shell&lt;/code&gt;,
and &lt;code&gt;ripgrep&lt;/code&gt; to &lt;code&gt;project-switch-commands&lt;/code&gt;. You don&amp;rsquo;t need my Elisp for that.&lt;/p&gt;
&lt;p&gt;As little and work-in-progress as it is, &lt;code&gt;project.el&lt;/code&gt; already covers everything
I usually need to handle my projects. It&amp;rsquo;s good to know that right within our
beloved text editor comes a tool like this. And no, Pat Benatar, this time is
not too little too late.&lt;/p&gt;
&lt;div class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;
&lt;hr&gt;
&lt;ol&gt;
&lt;li id=&#34;fn:1&#34;&gt;
&lt;p&gt;Note that &lt;code&gt;project.el&lt;/code&gt; is also available on
&lt;a href=&#34;https://elpa.gnu.org/packages/project.html&#34;&gt;ELPA&lt;/a&gt;.&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    <item>
      <title>The end of an era?</title>
      <link>https://manueluberti.eu/posts/2020-09-08-end-of-era/</link>
      <pubDate>Tue, 08 Sep 2020 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2020-09-08-end-of-era/</guid>
      <description>&lt;p&gt;Yesterday I noticed it has been a while since I wrote something here. I can
easily blame the lack of time and concentration, point the finger at my cinema
obsession, or even rant against Plato and Hegel for the energy-draining efforts
they require from me. Or I can simply be honest and say the truth out loud: my
journey with Emacs has come to a halt. Before calling me names and put the GNU
police on my back, hear me out.&lt;/p&gt;
&lt;p&gt;After years on a constant tinkering diet, my configuration has reached a point
where everything I need from it is covered. The key word in the previous
statement is &lt;em&gt;everything&lt;/em&gt;. What is this &lt;em&gt;everything&lt;/em&gt; I use Emacs for? Well, contrary
to the popular Emacs-centric workflows of many fellow Elisp lovers, &lt;em&gt;everything&lt;/em&gt;
is just prose (Markdown, LaTeX) and Clojure programming with some Elisp on the
side. What happens outside of my beloved text editor is up to Firefox,
Thunderbird, GNOME Terminal on some occasions, Slack for work and Gajim for
personal use, and KeePassXC. 99% of the times this is what my computing is about
these days.&lt;/p&gt;
&lt;p&gt;Although Emacs can be used for some of the things the aforementioned external
programs do, I am fine with this setup for a couple of reasons.&lt;/p&gt;
&lt;p&gt;Firstly, I like to keep my configuration as simple as possible. It used to sport
over 200 packages, but refinement after refinement has taken me to half that
number. It&amp;rsquo;s even a smaller total if I don&amp;rsquo;t count the package dependencies for
which there is no &lt;code&gt;use-package&lt;/code&gt; snippet in my &lt;code&gt;init.el&lt;/code&gt;. I am still far from
minimalism but maintenance is much easier now, because I know what I want from
Emacs and I want it to do just that.&lt;/p&gt;
&lt;p&gt;Secondly, but maybe more importantly, I don&amp;rsquo;t want any kind of distraction in my
text editor. This may be just me, but most of the times the Web, reading emails,
and messaging interfere with my concentration without adding real value. Emacs
is my peace of mind. I turn to it just for writing, knowing well it is not ready
to fetch emails or chatting with my wife or a co-worker because that&amp;rsquo;s how it is
set up. There is no technological secret here. It&amp;rsquo;s all about the psychological
pleasure of a maximized Emacs window with little more than my precious text in
it.&lt;/p&gt;
&lt;p&gt;This line of reasoning has led me to an Emacs configuration that does not
require that much fiddling with any more. I have to admit that not seeing
buffers from my &lt;code&gt;.emacs.d&lt;/code&gt; always presented by &lt;code&gt;helm-mini&lt;/code&gt; feels a bit strange.
At the same time, though, I am sure they will pop up again as soon as the next
irresistible package will reach ELPA or MELPA. Until then, Elisp can go on a
well-deserved holiday and have a couple of drinks on me.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Paper Emacs</title>
      <link>https://manueluberti.eu/posts/2020-07-24-paper/</link>
      <pubDate>Fri, 24 Jul 2020 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2020-07-24-paper/</guid>
      <description>&lt;p&gt;Since I moved to
&lt;a href=&#34;https://manueluberti.eu/posts/2019-08-25-bujo/&#34;&gt;bullet-journaling&lt;/a&gt;, most of the
time I have been writing on paper. Even though I&amp;rsquo;ve not restricted my Emacs time
to Clojure programming, paper and fountain pen have changed the way I approach
my favourite text editor for prose.&lt;/p&gt;
&lt;p&gt;As I was writing articles for my blogs, I&amp;rsquo;ve discovered that I wanted my
text-editing environment as close as possible to the beautiful, distraction-free
feeling of a blank page. There are plenty of themes and modes out there to suit
this particular need, but the combination of settings and packages I am about to
describe has proven to be the most satisfying so far.&lt;/p&gt;
&lt;h2 id=&#34;theme&#34;&gt;Theme&lt;/h2&gt;
&lt;p&gt;A light theme is the obvious choice to mirror the paper look. Since I have been
using &lt;a href=&#34;https://manueluberti.eu/posts/2020-03-16-modus-themes/&#34;&gt;modus-operandi&lt;/a&gt; for
a while now, there is no reason to look for something else. Everything in
&lt;code&gt;markdown-mode&lt;/code&gt; is supported, and with a &lt;code&gt;variable-pitch&lt;/code&gt; font
(&lt;a href=&#34;https://bboxtype.com/typefaces/FiraGO/#!layout=specimen&#34;&gt;FiraGO&lt;/a&gt; in my case)
the buffer stops resembling code for once.&lt;/p&gt;
&lt;h2 id=&#34;editing-modes&#34;&gt;Editing modes&lt;/h2&gt;
&lt;p&gt;I write all my articles in Markdown, but to achieve the desired distraction-free
effect I rely on Protesilaos Stavrou&amp;rsquo;s tips, slightly adjusted to my
preferences: &lt;a href=&#34;https://protesilaos.com/codelog/2020-07-16-emacs-focused-editing/&#34;&gt;&amp;ldquo;Focused editing tools&amp;rdquo; for
Emacs&lt;/a&gt; and
&lt;a href=&#34;https://protesilaos.com/codelog/2020-07-17-emacs-mixed-fonts-org/&#34;&gt;Emacs: configuring mixed fonts in Org
mode&lt;/a&gt;. I am
using a variant of
&lt;a href=&#34;https://github.com/rnkn/olivetti/issues/39#issuecomment-660606677&#34;&gt;Olivetti&lt;/a&gt;
like him, the only difference being the use of &lt;code&gt;text-scale-increase&lt;/code&gt; to increase
the text size and &lt;code&gt;text-scale-decrease&lt;/code&gt; to restore it back to normal when
leaving the mode.&lt;/p&gt;
&lt;p&gt;On top of that I use &lt;a href=&#34;https://github.com/rnkn/freeze-it&#34;&gt;freeze-it&lt;/a&gt;, which is
like having someone slapping my hands away from the text before the current
paragraph. Harsh, yes, but for the obsessive-compulsive writer an effective way
to keep the mind focused on one thing at the time. I can always review the
previous paragraphs later, and with the big picture in front of me editing often
becomes deleting.&lt;/p&gt;
&lt;h2 id=&#34;mode-line&#34;&gt;Mode-line&lt;/h2&gt;
&lt;p&gt;Once again, I find myself tweaking the mode-line. Setting
&lt;code&gt;modus-operandi-theme-3d-modeline&lt;/code&gt; has been enough thus far, but something less
prominent can be closer to the no-frills of my Bujo. Luckily &lt;a href=&#34;https://github.com/rnkn/freeze-it&#34;&gt;William
Rankin&lt;/a&gt;, the author of Olivetti and
&lt;code&gt;freeze-it&lt;/code&gt;, &lt;a href=&#34;https://github.com/rnkn/olivetti/issues/39#issuecomment-660606677&#34;&gt;shared his magic
tricks&lt;/a&gt; and
I followed his lead. I merely threw in coloured indicators for modified,
read-only, and remote buffers. Sorry, I can&amp;rsquo;t resist a little bit of fanciness.&lt;/p&gt;
&lt;h2 id=&#34;final-notes&#34;&gt;Final notes&lt;/h2&gt;
&lt;p&gt;There is more than this to my writing environment. For instance, I wrote about
&lt;a href=&#34;https://manueluberti.eu/posts/2020-03-07-ispell-with-helm/&#34;&gt;spell-checking&lt;/a&gt;
before and I use Artur Malabarba&amp;rsquo;s suggestions on &lt;a href=&#34;http://endlessparentheses.com/meta-binds-part-2-a-peeve-with-paragraphs.html&#34;&gt;paragraph
movements&lt;/a&gt;.
Not to mention the default Emacs facilities for marking, killing, yanking, and
moving around the buffer. Nonetheless, this should be enough to write prose in a
quieter and more fruitful way.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>My reliable English dictionary</title>
      <link>https://manueluberti.eu/posts/2020-06-13-helm-wordnut/</link>
      <pubDate>Sat, 13 Jun 2020 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2020-06-13-helm-wordnut/</guid>
      <description>&lt;p&gt;Despite my best efforts, my English needs constant work.&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt; I mostly write in
this language when I am online, but good prose is a matter of trying, failing,
trying again, failing again, and never give up. A bloody battle of words.&lt;/p&gt;
&lt;p&gt;An ever-present companion during my writing sessions is the dictionary. Since
I don&amp;rsquo;t want distractions of any kind, I want the dictionary to be offline and
easy to use. The more time I spend away from my text, the easier it is for my
mind to drift off.&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://wordnet.princeton.edu&#34;&gt;WordNet&lt;/a&gt; meets my expectations almost exactly. It&amp;rsquo;s quickly installable on my
Ubuntu machine, a breeze to use, and it comes with a command-line tool (&lt;code&gt;wn&lt;/code&gt;) and
a graphical one (&lt;code&gt;wnb&lt;/code&gt;) which are simple and fast.&lt;/p&gt;
&lt;p&gt;However, I don&amp;rsquo;t want to leave Emacs for a task like this. I want to be able to
search for the word at point or to type something and see if what I have in mind
makes any sense at all. Why not taking advantage of the power of Helm?
That&amp;rsquo;s why I wrote &lt;a href=&#34;https://github.com/emacs-helm/helm-wordnut&#34;&gt;helm-wordnut&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;As I explain in the README, using WordNet within Emacs was already possible
through &lt;a href=&#34;https://github.com/raghavgautam/helm-wordnet&#34;&gt;helm-wordnet&lt;/a&gt; and &lt;a href=&#34;https://github.com/gromnitsky/wordnut&#34;&gt;wordnut&lt;/a&gt;, but in both cases it doesn&amp;rsquo;t look like there
is much maintenance going on. I liked the idea of the former and the nice output
of the latter, and so I devised a package with what in my opinion is the
simplest and ideal Helm interface for WordNet. I can type what I want or just
hit &lt;code&gt;M-n&lt;/code&gt; to pick up the word a point. Pressing &lt;code&gt;RET&lt;/code&gt; on the desired candidate opens
a buffer with a detailed definition of the word. How much detail one needs is
customizable through &lt;code&gt;helm-wordnut-cmd-options&lt;/code&gt;, but the default covers more than
enough already for my usual writings.&lt;/p&gt;
&lt;p&gt;Given the existence of &lt;code&gt;helm-wordnet&lt;/code&gt; and &lt;code&gt;wordnut&lt;/code&gt;, I have not published
&lt;code&gt;helm-wordnut&lt;/code&gt; on any package archive at the moment. If somebody else finds it a
better alternative to the existing solutions, do reach out and let me know. I&amp;rsquo;ll
see what I can do about convincing the MELPA masterminds to accept yet another
WordNet front-end.&lt;/p&gt;
&lt;div class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;
&lt;hr&gt;
&lt;ol&gt;
&lt;li id=&#34;fn:1&#34;&gt;
&lt;p&gt;The same can be said for my Italian, but let&amp;rsquo;s not dig too deep into my
shortcomings please.&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    <item>
      <title>Search only in visible buffers</title>
      <link>https://manueluberti.eu/posts/2020-06-05-helm-occur-visible-buffers/</link>
      <pubDate>Fri, 05 Jun 2020 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2020-06-05-helm-occur-visible-buffers/</guid>
      <description>&lt;p&gt;Among the things that I dropped when I moved to Helm,
&lt;a href=&#34;https://github.com/abo-abo/swiper&#34;&gt;Swiper&lt;/a&gt; was one of the first ones to go.
Actually, the built-in Isearch replaced Swiper first. Then I found out about
&lt;a href=&#34;https://github.com/raxod502/ctrlf&#34;&gt;CTRLF&lt;/a&gt;, and now I have the best of both
worlds: I can use CTRLF for no-fuss searches and I can rely on &lt;code&gt;helm-occur&lt;/code&gt; for
a Swiper-like feeling.&lt;/p&gt;
&lt;p&gt;However, I often find myself with two buffers in the same window, and sometimes
I want to restrict my searches to just those two buffers. CTRLF and &lt;code&gt;helm-occur&lt;/code&gt;
are not suitable for this task, because they both work on a single buffer. And
&lt;a href=&#34;https://manueluberti.eu/posts/2020-03-13-helm-rg-refactoring/&#34;&gt;mu-helm-rg&lt;/a&gt; is way
too much for this, because it is best used in specific directories or
project-wise.&lt;/p&gt;
&lt;p&gt;Luckily enough, Thierry Volpiatto has recently introduced
&lt;code&gt;helm-occur-visible-buffers&lt;/code&gt; in Helm. Like the name says, this command runs
&lt;code&gt;helm-occur&lt;/code&gt; on all visible buffers. The results are grouped by buffer, making
them really easy and clear to navigate. When run in one buffer,
&lt;code&gt;helm-occur-visible-buffers&lt;/code&gt; behaves just like &lt;code&gt;helm-occur&lt;/code&gt;, so if you have a
key binding for the latter you can safely point it to the former and retain the
functionality you were accustomed to.&lt;/p&gt;
&lt;p&gt;I don&amp;rsquo;t know if my use-case is a niche one, but it&amp;rsquo;s good to know Helm got me
covered once again.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Lockdown Beam: volatile-highlights</title>
      <link>https://manueluberti.eu/posts/2020-04-27-lockdown-beam-volatile-highlights/</link>
      <pubDate>Mon, 27 Apr 2020 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2020-04-27-lockdown-beam-volatile-highlights/</guid>
      <description>&lt;p&gt;In the middle of a frantic editing session one can use some help. You are there
sweating, firing key bindings with a smugness you can barely keep at bay, with
buffers and windows appearing and disappearing. Point is visibly tired of your
powerful skills because, let&amp;rsquo;s face it, jumping around is not always
pleasurable.&lt;/p&gt;
&lt;p&gt;In situations such as this, you may find yourself killing a paragraph or a block
of code in order to yank it somewhere else. If that “somewhere else” is another
buffer (e.g., a Clojure file others worked on), I for one don&amp;rsquo;t want to make a
mess. This is precisely where Keitaro
Miyazaki&amp;rsquo;s &lt;a href=&#34;https://github.com/k-talo/volatile-highlights.el&#34;&gt;volatile-highlights&lt;/a&gt;
finds its place.&lt;/p&gt;
&lt;p&gt;Keitaro&amp;rsquo;s package adds a temporary highlight to the yanked text which makes the
addition stand out briefly, and so I get a sense of what I am doing in a buffer
I&amp;rsquo;m not entirely familiar with yet. There are other commands that benefit from
it, as the &lt;code&gt;volatile-highlights&lt;/code&gt; README explains. For instance, I find the
highlights around undo operations and &lt;code&gt;occur-mode&lt;/code&gt; occurrences very helpful.&lt;/p&gt;
&lt;p&gt;Although I didn&amp;rsquo;t play with it, &lt;code&gt;volatile-highlights&lt;/code&gt; can be extended to support
other packages and commands. Check out &lt;code&gt;vhl/define-extension&lt;/code&gt; and
&lt;code&gt;vhl/install-extension &lt;/code&gt;if you want to go down that road.&lt;/p&gt;
&lt;p&gt;This is the last entry in my “Lockdown Beam” series. I was hoping to outlast the
lockdown, but I lost the battle eventually. Anyway, do give these packages a
chance. It&amp;rsquo;s easy to overlook a little gem in the ever-growing Emacs ecosystem.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Lockdown Beam: native-complete</title>
      <link>https://manueluberti.eu/posts/2020-04-20-lockdown-beam-native-complete/</link>
      <pubDate>Mon, 20 Apr 2020 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2020-04-20-lockdown-beam-native-complete/</guid>
      <description>&lt;p&gt;If you have followed this blog long enough, you know it&amp;rsquo;s been a while since &lt;a href=&#34;https://manueluberti.eu/posts/2017-10-07-m-x-shell/&#34;&gt;I
embraced shell-mode&lt;/a&gt;.
I even have a nice setup to &lt;a href=&#34;https://manueluberti.eu/posts/2019-07-01-bury/&#34;&gt;handle its
windows&lt;/a&gt; and to apply &lt;a href=&#34;https://manueluberti.eu/posts/2019-06-14-xterm/&#34;&gt;better
colours&lt;/a&gt; to it.&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;However, before Troy
Hinckley&amp;rsquo;s &lt;a href=&#34;https://github.com/CeleritasCelery/emacs-native-shell-complete&#34;&gt;native-complete&lt;/a&gt;
fixed it for me, tab-completion in &lt;code&gt;shell-mode&lt;/code&gt; wasn&amp;rsquo;t quite the same experience
as the one on a separate terminal emulator. To be honest, I didn&amp;rsquo;t investigate
far enough to understand whether this was due to my Bash configuration or to
Emacs itself. The only thing I know is that Troy&amp;rsquo;s package got me where I wanted
to be.&lt;/p&gt;
&lt;p&gt;On MELPA you will find two packages: &lt;code&gt;native-complete&lt;/code&gt; and
&lt;code&gt;company-native-complete&lt;/code&gt;. I use both, but if you are not a Company user you can
live with the former alone.&lt;/p&gt;
&lt;p&gt;Anyway, I set up &lt;code&gt;native-complete&lt;/code&gt; with a hook to &lt;code&gt;shell-mode&lt;/code&gt; that runs
&lt;code&gt;native-complete-setup-bash&lt;/code&gt;, then another hook adds &lt;code&gt;company-native-complete&lt;/code&gt;
to &lt;code&gt;company-backends&lt;/code&gt;. Tom explained everything you need to start and other
useful details in the package README, so head over there for more details. The
only thing I can add is that I have &lt;code&gt;TAB&lt;/code&gt; bound to &lt;code&gt;company-complete&lt;/code&gt;
in &lt;code&gt;shell-mode-map&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Now that there is a &lt;a href=&#34;https://github.com/akermu/emacs-libvterm&#34;&gt;libvterm
integration&lt;/a&gt; for Emacs, staying with
&lt;code&gt;shell-mode&lt;/code&gt; may sound anachronistic, because proper terminal emulation with
your favourite shell is just a package away. But if you, like me, are happy with
Bash in &lt;code&gt;shell-mode&lt;/code&gt;, I can&amp;rsquo;t recommend &lt;code&gt;native-complete&lt;/code&gt; and
&lt;code&gt;company-native-complete&lt;/code&gt; enough. By the way, Troy&amp;rsquo;s work supports &lt;code&gt;csh&lt;/code&gt; and
other fancy things too, so you&amp;rsquo;re not strictly limited to Bash.&lt;/p&gt;
&lt;p&gt;Next time we will see highlights disappear suddenly. Is the &lt;a href=&#34;https://en.wikipedia.org/wiki/Evil_demon&#34;&gt;Evil
Genius&lt;/a&gt; operating my Emacs? Who knows.&lt;/p&gt;
&lt;p&gt;Stay safe.&lt;/p&gt;
&lt;div class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;
&lt;hr&gt;
&lt;ol&gt;
&lt;li id=&#34;fn:1&#34;&gt;
&lt;p&gt;Note that the &lt;a href=&#34;https://manueluberti.eu/posts/2020-03-16-modus-themes/&#34;&gt;Modus Themes&lt;/a&gt; have
built-in support for that, so I don&amp;rsquo;t customise &lt;code&gt;xterm-color-names&lt;/code&gt; and
&lt;code&gt;xterm-color-names-bright&lt;/code&gt; any more.&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    <item>
      <title>Lockdown Beam: mark-thing-at</title>
      <link>https://manueluberti.eu/posts/2020-04-13-lockdown-beam-mark-thing-at/</link>
      <pubDate>Mon, 13 Apr 2020 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2020-04-13-lockdown-beam-mark-thing-at/</guid>
      <description>&lt;p&gt;Until I noticed that I was hardly using everything it has to offer, Leo
Liu&amp;rsquo;s &lt;a href=&#34;https://github.com/leoliu/easy-kill&#34;&gt;easy-kill&lt;/a&gt; was one of the packages
I used the most. Specifically, I wasn&amp;rsquo;t really taking advantage of its
capability of repeating mark commands, nor its keys to modify the current
selection. Although it doesn&amp;rsquo;t seem actively maintained this day, check it out
if you want to extend your mark/kill actions.&lt;/p&gt;
&lt;p&gt;As for me, Paul
Landes&amp;rsquo;s &lt;a href=&#34;https://github.com/plandes/mark-thing-at&#34;&gt;mark-thing-at&lt;/a&gt; has become my
best pal when it comes to marking. Granted, it&amp;rsquo;s way less powerful than
&lt;code&gt;easy-kill&lt;/code&gt;, but combine it with Emacs regular key bindings for killing and
there is nothing more that I need.&lt;/p&gt;
&lt;p&gt;You will find &lt;code&gt;mark-thing-at&lt;/code&gt; on MELPA, and if you follow my lead, you can
enable &lt;code&gt;mark-thing-at-mode&lt;/code&gt; and be happy with it. Note that if you do not
configure &lt;code&gt;mark-thing-at-keymap-prefix&lt;/code&gt; you end up with &lt;code&gt;C-x m&lt;/code&gt; as a
prefix for all the &lt;code&gt;mark-*&lt;/code&gt; commands now available at your fingertips. This
means that you will lose the key binding for &lt;code&gt;compose-mail&lt;/code&gt;, but I&amp;rsquo;m fine with
it.&lt;/p&gt;
&lt;p&gt;Whatever the prefix you end up with just append &lt;code&gt;C-h&lt;/code&gt; to it and you
will see the many commands at your disposal. You probably won&amp;rsquo;t need them all,
but it&amp;rsquo;s good to have a nice way to leverage these marking facilities.&lt;/p&gt;
&lt;p&gt;Next time we will explore a better completion system for &lt;code&gt;shell-mode&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Stay safe.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Lockdown Beam: hide-mode-line</title>
      <link>https://manueluberti.eu/posts/2020-04-06-lockdown-beam-hide-mode-line/</link>
      <pubDate>Mon, 06 Apr 2020 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2020-04-06-lockdown-beam-hide-mode-line/</guid>
      <description>&lt;p&gt;Fun fact: the mode-line is the one Emacs thing I&amp;rsquo;ve probably spent most of my
tinkering time on. Why? Hard to tell. I consider it a place for useful
information, but the only interaction I have with it is &lt;em&gt;looking&lt;/em&gt; at it.
It&amp;rsquo;s not like some of those fancy packages offering you all manners of
interactive commands and assorted key bindings.&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt; It&amp;rsquo;s a, well, it&amp;rsquo;s a &lt;em&gt;line&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;Among the several iterations, &lt;a href=&#34;https://manueluberti.eu/posts/2018-03-10-moody-and-minions/&#34;&gt;this
one&lt;/a&gt; has lasted the
longest. But then again, not too long ago I felt the irresistible call of
minimalism, and so I ended up with &lt;a href=&#34;https://manueluberti.eu/posts/2020-03-01-helm-ripgrep-mode-line/&#34;&gt;this other
one&lt;/a&gt;. And yet,
despite the immoderate amount of care I spent on it, there are times where
I just want it out of my way.&lt;/p&gt;
&lt;p&gt;For instance, I have no use for the mode-line in &lt;code&gt;shell-mode&lt;/code&gt; or when I am
reading the latest news via Elfeed. Luckily, Henrik
Lissner&amp;rsquo;s &lt;a href=&#34;https://github.com/hlissner/emacs-hide-mode-line&#34;&gt;hide-mode-line&lt;/a&gt; is
out there for this kind of messy work.&lt;/p&gt;
&lt;p&gt;Provided the mode you don&amp;rsquo;t want to see the mode-line in has a hook, you can add
&lt;code&gt;#&#39;hide-mode-line-mode&lt;/code&gt; to it with
&lt;a href=&#34;http://doc.endlessparentheses.com/Fun/add-hook.html&#34;&gt;add-hook&lt;/a&gt;. For Elfeed,
however, a different solution is needed:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defun mu-elfeed-open ()
  &amp;quot;Open elfeed and hide the mode-line.&amp;quot;
  (interactive)
  (mu-save-window-config-then-call #&#39;elfeed)
  (hide-mode-line-mode 1))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Have a look at &lt;a href=&#34;https://manueluberti.eu/posts/2019-06-21-windows/&#34;&gt;Passing the prefix argument
around&lt;/a&gt; if you want to know
what &lt;code&gt;mu-save-window-config-then-call&lt;/code&gt; does.&lt;/p&gt;
&lt;p&gt;Obviously you can go berserk and hide the mode-line everywhere with
Henrik&amp;rsquo;s package. But would you &lt;em&gt;really&lt;/em&gt; do that? Don&amp;rsquo;t be cruel and think about
it.&lt;/p&gt;
&lt;p&gt;Next time we are going to mark things, so keep your markers around.&lt;/p&gt;
&lt;p&gt;Stay safe.&lt;/p&gt;
&lt;div class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;
&lt;hr&gt;
&lt;ol&gt;
&lt;li id=&#34;fn:1&#34;&gt;
&lt;p&gt;&lt;code&gt;M-x&lt;/code&gt; &lt;code&gt;^mode-line&lt;/code&gt; actually gives me ten entries, so what do
I know?&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    <item>
      <title>Lockdown Beam: git-identity</title>
      <link>https://manueluberti.eu/posts/2020-03-30-lockdown-beam-git-identity/</link>
      <pubDate>Mon, 30 Mar 2020 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2020-03-30-lockdown-beam-git-identity/</guid>
      <description>&lt;p&gt;The situation doesn&amp;rsquo;t seem to get any better, does it? We are still confined in
our homes, still wary about our movements and contacts. Since not even running
outside is allowed, I am getting lazy, to the point that I&amp;rsquo;ve never thought I&amp;rsquo;d
miss the gym so much. It&amp;rsquo;s time to resort to in-house crunches and push-ups,
I suppose.&lt;/p&gt;
&lt;p&gt;Meanwhile, let&amp;rsquo;s not forget about Emacs. Last time I hinted at a Git-related
package, but at this point wouldn&amp;rsquo;t writing about Magit again be out of
fashion?&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;When it comes to Git repository, the only thing I am not using Magit for is
checking and setting my identity. I&amp;rsquo;m not sure this is a common problem, but
I have to handle two Git identities on the same machine, one for personal
repositories and one for work projects.&lt;/p&gt;
&lt;p&gt;Without Akira
Komamura&amp;rsquo;s &lt;a href=&#34;https://github.com/akirak/git-identity.el&#34;&gt;git-identity&lt;/a&gt; this
situation was leading me to confusion, because more often than not I found
myself committing and pushing work stuff with my personal identity. One could
manually edit &lt;code&gt;.git/config&lt;/code&gt; every time or use Git own commands to deal with
this, but to me these are both cumbersome alternatives compared to the
simplicity of Konamura&amp;rsquo;s package.&lt;/p&gt;
&lt;p&gt;The only configuration needed for me after the installation was binding
&lt;code&gt;I&lt;/code&gt; to &lt;code&gt;git-identity-info&lt;/code&gt; in &lt;code&gt;magit-status-mode-map&lt;/code&gt;. Now once
I cloned a new repository I can easily check whether the identity is correct or
not.&lt;/p&gt;
&lt;p&gt;&lt;figure&gt;
  &lt;img src=&#34;https://manueluberti.eu/images/git-identity.png&#34; alt=&#34;&#34;&gt;
  &lt;figcaption class=&#34;center&#34;&gt;
    &lt;small&gt;&lt;em&gt;&lt;/em&gt;&lt;/small&gt;    
  &lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/p&gt;
&lt;p&gt;Furthermore, &lt;code&gt;git-identity&lt;/code&gt; can help even if for some random reason I didn&amp;rsquo;t
rely on &lt;code&gt;git-identity-info&lt;/code&gt;. With &lt;code&gt;git-identity-magit-mode&lt;/code&gt; enabled,
&lt;code&gt;git-identity&lt;/code&gt; makes sure that on &lt;code&gt;magit-commit&lt;/code&gt; a global or a local identity is
actually set.&lt;/p&gt;
&lt;p&gt;Next time we are going to play hide and seek with the mode-line.&lt;/p&gt;
&lt;p&gt;Stay safe.&lt;/p&gt;
&lt;div class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;
&lt;hr&gt;
&lt;ol&gt;
&lt;li id=&#34;fn:1&#34;&gt;
&lt;p&gt;I am kidding, Magit is always stylish.&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    <item>
      <title>Lockdown Beam: eldoc-eval</title>
      <link>https://manueluberti.eu/posts/2020-03-23-lockdown-beam-eldoc-eval/</link>
      <pubDate>Mon, 23 Mar 2020 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2020-03-23-lockdown-beam-eldoc-eval/</guid>
      <description>&lt;p&gt;As mentioned briefly at the end of the &lt;a href=&#34;https://manueluberti.eu/posts/2020-03-19-lockdown-beam-bm/&#34;&gt;previous
entry&lt;/a&gt;, today we are
going to play with Emacs&#39;
&lt;a href=&#34;http://doc.endlessparentheses.com/Fun/eldoc-mode.html&#34;&gt;Eldoc&lt;/a&gt;. Sometimes
I forget about it, but &lt;code&gt;eldoc-mode&lt;/code&gt; is one of those subtle things which improve
my daily Emacs routine. Besides giving me useful information in Elisp,
&lt;code&gt;eldoc-mode&lt;/code&gt; is always helpful when I am programming in Clojure thanks to its
integration with CIDER.&lt;/p&gt;
&lt;p&gt;However, there is another place where Eldoc comes in handy. You surely know that
when you press &lt;code&gt;M-:&lt;/code&gt; you can type an expression in the minibuffer and
then evaluate it by pressing &lt;code&gt;RET&lt;/code&gt;. But wouldn&amp;rsquo;t it be great to have
Eldoc for these quick runs to?&lt;/p&gt;
&lt;p&gt;The answer is not “Well, yes!”, but “Hey, there is a mode for it!”, which is
what an Emacser regularly replies when asked about any matter whatsoever. This
time the mode comes with the package of the day: Thierry
Volpiatto&amp;rsquo;s &lt;a href=&#34;https://github.com/thierryvolpiatto/eldoc-eval&#34;&gt;eldoc-eval&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Once installed, activating &lt;code&gt;eldoc-eval&lt;/code&gt; is easy. Turn on &lt;code&gt;eldoc-in-minibuffer-mode&lt;/code&gt;
and everything is set.&lt;/p&gt;
&lt;p&gt;&lt;figure&gt;
  &lt;img src=&#34;https://manueluberti.eu/images/eldoc-eval.png&#34; alt=&#34;&#34;&gt;
  &lt;figcaption class=&#34;center&#34;&gt;
    &lt;small&gt;&lt;em&gt;&lt;/em&gt;&lt;/small&gt;    
  &lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/p&gt;
&lt;p&gt;Nice and simple. You may not like the Eldoc information appearing in the
mode-line, but Thierry got you covered with &lt;code&gt;eldoc-in-minibuffer-show-fn&lt;/code&gt;. If
you use tooltips, try setting this to &lt;code&gt;#&#39;tooltip-show&lt;/code&gt;. There are other features
in &lt;code&gt;eldoc-eval&lt;/code&gt; worth of notice, so be sure to check out its README if you want
more juice.&lt;/p&gt;
&lt;p&gt;As for me, I am happy with just enabling &lt;code&gt;eldoc-in-minibuffer-mode&lt;/code&gt;. I patched
&lt;code&gt;eldoc-show-in-mode-line&lt;/code&gt; to fit the help message properly in my custom
mode-line, but that&amp;rsquo;s it. If you are using your own mode-line too, I am leaving
that as a little exercise.&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;Next time we will meet a Git-related package which doesn&amp;rsquo;t include the letters
“m” and “a” in its name.&lt;/p&gt;
&lt;p&gt;Stay safe.&lt;/p&gt;
&lt;div class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;
&lt;hr&gt;
&lt;ol&gt;
&lt;li id=&#34;fn:1&#34;&gt;
&lt;p&gt;I used &lt;code&gt;el-patch&lt;/code&gt; for this.&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    <item>
      <title>Lockdown Beam: bm.el</title>
      <link>https://manueluberti.eu/posts/2020-03-19-lockdown-beam-bm/</link>
      <pubDate>Thu, 19 Mar 2020 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2020-03-19-lockdown-beam-bm/</guid>
      <description>&lt;p&gt;I guess there is no need to explain the choice of the word “lockdown” in the
title. I don&amp;rsquo;t know about you, but here in Italy things are getting worse and
worse. Every time I look outside the window I see desolation, and for a George
Romero fan this is getting scarier and scarier. I am lucky, though. I can work
from home (thank you, &lt;a href=&#34;https://7bridges.eu&#34;&gt;7bridges&lt;/a&gt;) and study from home
(thank you, &lt;a href=&#34;https://www.unive.it/&#34;&gt;Ca&amp;rsquo; Foscari&lt;/a&gt;). But I can also take the time
to spread words of love about some Emacs packages I rarely talk about.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Lockdown Beam&lt;/em&gt; aims to be a series of small articles on packages that deserve
more attention, but I can&amp;rsquo;t tell now how long this series is going to run.
I tend to use &lt;em&gt;all&lt;/em&gt; the packages configured in my &lt;code&gt;init.el&lt;/code&gt;, and most of them
are fairly popular, so it&amp;rsquo;s not like digging obscure entries from the dust of my
setup. However, out of more than 100 packages, I am pretty sure I can find a
decent amount of poor neglected things in there.&lt;/p&gt;
&lt;p&gt;Let&amp;rsquo;s start with Jo Odland&amp;rsquo;s &lt;a href=&#34;https://github.com/joodland/bm&#34;&gt;bm.el&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;There are many great ways to bookmark things in Emacs,&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt; but sometimes a
visual clue just adds a good feeling of immediacy one (e.g., myself) can find
pleasant. The README says this is a feature from Visual Studio that the author
was missing in Emacs, but you will have to check for yourself whether this is
something Visual Studio does. You know there is no such thing as a different
text editor for me.&lt;/p&gt;
&lt;p&gt;Following the documentation, setting up &lt;code&gt;bm.el&lt;/code&gt; is easy. If you use
&lt;code&gt;use-package&lt;/code&gt;, there is a nice example ready for copy-and-paste at &lt;a href=&#34;https://github.com/joodland/bm#configuring-bmel-with-use-package&#34;&gt;Configuring
bm.el with
use-package&lt;/a&gt;.
I started from there, but I replaced the hook on &lt;code&gt;vc-before-checkin-hook&lt;/code&gt; with a
hook on &lt;code&gt;magit-pre-refresh-hook&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;I find &lt;code&gt;bm.el&lt;/code&gt; really useful when studying source code from others, or when
I want to quickly set jumping points in a log file cluttered with stacktraces.
It&amp;rsquo;s quicker then moving around with Isearch or &lt;code&gt;helm-occur&lt;/code&gt;, and unlike
&lt;a href=&#34;https://github.com/abo-abo/avy&#34;&gt;avy&lt;/a&gt; it&amp;rsquo;s not limited to what is currently
visible on the screen.&lt;/p&gt;
&lt;p&gt;That&amp;rsquo;s all for today. Next time a little friend will help me exploit Eldoc.&lt;/p&gt;
&lt;p&gt;Stay safe.&lt;/p&gt;
&lt;div class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;
&lt;hr&gt;
&lt;ol&gt;
&lt;li id=&#34;fn:1&#34;&gt;
&lt;p&gt;Check out what Protesilaos Stavrou has to say about
&lt;a href=&#34;https://protesilaos.com/codelog/2020-03-08-emacs-registers/&#34;&gt;registers&lt;/a&gt;.&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    <item>
      <title>Light is right, alright?</title>
      <link>https://manueluberti.eu/posts/2020-03-16-modus-themes/</link>
      <pubDate>Mon, 16 Mar 2020 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2020-03-16-modus-themes/</guid>
      <description>&lt;p&gt;For a long, long while I was a happy &lt;a href=&#34;https://github.com/bbatsov/solarized-emacs&#34;&gt;Solarized
Light&lt;/a&gt; user. Then, somehow,
I switched to Steve Purcell&amp;rsquo;s version of &lt;a href=&#34;https://github.com/purcell/color-theme-sanityinc-tomorrow&#34;&gt;Tomorrow
Night&lt;/a&gt;, and no other
theme has been able to take me away from that colour scheme. There were times
where I found myself looking for a new light theme, but the lack of a pleasant
one&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt; left me in the comfortable palettes of Tomorrow Night. I even put on
MELPA what at first looked like &lt;a href=&#34;https://github.com/manuel-uberti/doneburn-theme&#34;&gt;the light
I needed&lt;/a&gt;, but the dark side
still kept me within its reach.&lt;/p&gt;
&lt;p&gt;Why didn&amp;rsquo;t I go back to Solarized Light if the experience had been so joyful?
I guess getting older distanced me somehow from the pleasures of a yellowish
background. Don&amp;rsquo;t get fooled by my grumpiness, though. It&amp;rsquo;s still one of the
best Emacs themes out there, so be sure to check it out if you are after a light
theme.&lt;/p&gt;
&lt;p&gt;As for me, I&amp;rsquo;ve recently seen &lt;em&gt;the light&lt;/em&gt; again. Protesilaos Stavrou open
sourced a couple of beautiful themes, &lt;code&gt;modus-vivendi&lt;/code&gt; and &lt;code&gt;modus-operandi&lt;/code&gt;, both
available at &lt;a href=&#34;https://gitlab.com/protesilaos/modus-themes&#34;&gt;modus-themes&lt;/a&gt;, on
ELPA, and on MELPA. I am sure the apt readers remember that &lt;code&gt;modus-vivendi&lt;/code&gt;
first appeared on these pages right at the end of &lt;a href=&#34;https://manueluberti.eu/posts/2020-03-01-helm-ripgrep-mode-line/&#34;&gt;Ripgrepping with Helm: the
mode-line&lt;/a&gt;, but
since then &lt;code&gt;modus-operandi&lt;/code&gt; has become the default.&lt;/p&gt;
&lt;p&gt;&lt;figure&gt;
  &lt;img src=&#34;https://manueluberti.eu/images/modus-operandi.png&#34; alt=&#34;&#34;&gt;
  &lt;figcaption class=&#34;center&#34;&gt;
    &lt;small&gt;&lt;em&gt;&lt;/em&gt;&lt;/small&gt;    
  &lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/p&gt;
&lt;p&gt;What I found intriguing in Protesilaos&amp;rsquo; work is the reasoning behind the themes.
I have never cared about the &lt;a href=&#34;https://www.w3.org/WAI/standards-guidelines/wcag/&#34;&gt;Web Content Accessibility
Guidelines&lt;/a&gt;, which is a shame
considering how poor my eyesight has been since I was a kid. The Modus Themes
are built with those guidelines in mind and it shows immediately. The text is
always readable, it doesn&amp;rsquo;t matter what face is applied over it. It&amp;rsquo;s not only a
matter of being able to read, but to always distinguish specific contexts. For
instance, comments are clearly separated from the rest of the code without
sacrificing legibility. I know this sounds reasonable and it may already be the
case for the theme you are currently using, but for my eyes it has never been so
easy. And yes, I did tend to prefer beauty over accessibility.&lt;/p&gt;
&lt;p&gt;Another remarkable thing about the Modus Themes is that both variants cover a
wide range of Emacs packages, something not so axiomatic in the Emacs theme
world. Admittedly, I bothered Protesilaos with some issues about Helm and few
other packages, but he quickly tamed my wild sensibility. &lt;em&gt;“If a compromise is
ever necessary between aesthetics and accessibility, it shall always be made in
the interest of latter”&lt;/em&gt;, the README points out. So far no complaints from the
aesthetics department, though.&lt;/p&gt;
&lt;p&gt;Protesilaos explained his ideas in &lt;a href=&#34;https://www.youtube.com/watch?v=gz8yifu6pGo&#34;&gt;My accessible Emacs
themes&lt;/a&gt;, a valuable presentation
which you should watch before &lt;a href=&#34;https://www.youtube.com/watch?v=TIUXYDaq9AY&#34;&gt;My Modus Themes are in
ELPA&lt;/a&gt;. Considering that I came from
years with a dark background, the switch to a light one has been less traumatic
than it may seem. It could be due to the fact that Solarized Light was there way
before the dark age, why not? Nevertheless, the new colour scheme is as simple
and beautiful as it is effective. See you around, Sith Lord.&lt;/p&gt;
&lt;div class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;
&lt;hr&gt;
&lt;ol&gt;
&lt;li id=&#34;fn:1&#34;&gt;
&lt;p&gt;An obvious matter of personal taste.&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    <item>
      <title>A better approach at searching with Helm</title>
      <link>https://manueluberti.eu/posts/2020-03-13-helm-rg-refactoring/</link>
      <pubDate>Fri, 13 Mar 2020 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2020-03-13-helm-rg-refactoring/</guid>
      <description>&lt;p&gt;When I wrote about how I use &lt;code&gt;ripgrep&lt;/code&gt; with Helm in &lt;a href=&#34;https://manueluberti.eu/posts/2020-02-22-ripgrepping-with-helm/&#34;&gt;Ripgrepping with Helm&lt;/a&gt;, I overlooked something. Actually,
let&amp;rsquo;s be honest. I didn&amp;rsquo;t study my usual search habits like I should&amp;rsquo;ve had to.&lt;/p&gt;
&lt;p&gt;Looking closely at my per-project searches, there are two patterns I tend to
follow:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;searching for the thing at point in the current project;&lt;/li&gt;
&lt;li&gt;searching for &lt;em&gt;something&lt;/em&gt; in the current project.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The first pattern is somehow addressed by the previous incarnation of
&lt;code&gt;mu-helm-rg&lt;/code&gt;, but it can be improved by leveraging &lt;code&gt;helm&lt;/code&gt;&amp;rsquo;s &lt;code&gt;:input&lt;/code&gt;
&lt;a href=&#34;https://github.com/emacs-helm/helm/wiki/Developing&#34;&gt;option&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;For the second pattern &lt;code&gt;helm-sources-using-default-as-input&lt;/code&gt; needs to be
temporarily disabled, otherwise &lt;code&gt;helm&lt;/code&gt; would start with the thing at point as
&lt;code&gt;:default&lt;/code&gt; and would run an initial search that most of the times is not what I
need. I can still pick up the thing at point with &lt;code&gt;M-n&lt;/code&gt; if needed, but
in this case I prefer typing what I want to find.&lt;/p&gt;
&lt;p&gt;To achieve this, I decided to reimplement &lt;code&gt;helm-grep-ag-1&lt;/code&gt; according to my needs:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defun mu--helm-rg (directory &amp;amp;optional with-tap type)
  &amp;quot;Build the Helm command for `mu-helm-rg&#39;.

For DIRECTORY, WITH-TAP, and TYPE see `mu-helm-rg&#39;. This command
disables `helm-sources-using-default-as-input&#39; temporarily to
avoid the automatic search which starts when :default is set to
`thing-at-point&#39; (the default behaviour). The search starts
automatically only with WITH-TAP.&amp;quot;
  (let ((helm-sources-using-default-as-input nil)
        (command (helm-grep--ag-command))
        (input (when with-tap
                 (thing-at-point &#39;symbol &#39;no-properties))))
    (setq helm-source-grep-ag
          (helm-make-source (upcase command) &#39;helm-grep-ag-class
            :header-name (lambda (name)
                           (format &amp;quot;%s in %s&amp;quot;
                                   name (abbreviate-file-name directory)))
            :candidates-process (lambda ()
                                  (helm-grep-ag-init directory type))))
    (helm-set-local-variable &#39;helm-input-idle-delay helm-grep-input-idle-delay)
    (helm :sources &#39;helm-source-grep-ag
          :keymap helm-grep-map
          :history &#39;helm-grep-ag-history
          :input input
          :truncate-lines helm-grep-truncate-lines
          :buffer (format &amp;quot;*helm %s*&amp;quot; command))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now &lt;code&gt;mu-helm-rg&lt;/code&gt; must be updated, but the changes are trivial. I only need to
consider a new parameter, &lt;code&gt;with-tap&lt;/code&gt;, and call &lt;code&gt;mu--helm-rg&lt;/code&gt; properly.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defun mu-helm-rg (directory &amp;amp;optional with-tap with-types)
  &amp;quot;Search in DIRECTORY with RG.

With WITH-TAP, search for thing at point. With WITH-TYPES, ask
for file types to search in.&amp;quot;
  (interactive &amp;quot;P&amp;quot;)
  (require &#39;helm-adaptive)
  (mu--helm-rg (expand-file-name directory)
               with-tap
               (helm-aif (and with-types
                              (helm-grep-ag-get-types))
                   (helm-comp-read
                    &amp;quot;RG type: &amp;quot; it
                    :must-match t
                    :marked-candidates t
                    :fc-transformer &#39;helm-adaptive-sort
                    :buffer &amp;quot;*helm rg types*&amp;quot;))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Finally, let&amp;rsquo;s see the new &lt;code&gt;mu-helm-rg&lt;/code&gt; in action:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defun mu-helm-project-search (&amp;amp;optional with-types)
  (interactive &amp;quot;P&amp;quot;)
  (mu-helm-rg (mu--project-root) nil with-types))

(defun mu-helm-project-search-at-point (&amp;amp;optional with-types)
  (interactive &amp;quot;P&amp;quot;)
  (mu-helm-rg (mu--project-root) t with-types))

(defun mu-helm-file-search (&amp;amp;optional with-types)
  (interactive &amp;quot;P&amp;quot;)
  (mu-helm-rg default-directory nil with-types))
&lt;/code&gt;&lt;/pre&gt;
</description>
    </item>
    <item>
      <title>Spell-checking and Helm</title>
      <link>https://manueluberti.eu/posts/2020-03-07-ispell-with-helm/</link>
      <pubDate>Sat, 07 Mar 2020 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2020-03-07-ispell-with-helm/</guid>
      <description>&lt;p&gt;Helm provides so many great commands I am still discovering new gems in it, like
the useful &lt;code&gt;helm-regexp&lt;/code&gt;, which lets you build your regular expression pattern,
see the results of your search live in the Helm buffer, and optionally pass the
query to &lt;code&gt;query-replace-regexp&lt;/code&gt;. So neat.&lt;/p&gt;
&lt;p&gt;This is why I haven&amp;rsquo;t written a Helm command of my own until recently. To be
fair, as I am going to show there is not even the need for this command to
exist, but coding it has been a fun exercise anyway.&lt;/p&gt;
&lt;p&gt;When it comes to spell-checking my buffers, I have been relying on
&lt;a href=&#34;https://manueluberti.eu/posts/2017-02-04-guess-language/&#34;&gt;mu-cycle-ispell-languages&lt;/a&gt;
to change dictionaries and
&lt;a href=&#34;https://github.com/d12frosted/flyspell-correct&#34;&gt;flyspell-correct-helm&lt;/a&gt; to pick
the correct word I happened to misspell. Since I am already using Helm with
Flyspell, then, why not using it to select the dictionary too?&lt;/p&gt;
&lt;p&gt;First, the actual dictionaries.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defvar mu-dictionaries &#39;((&amp;quot;en_GB&amp;quot; . &amp;quot;English&amp;quot;)
                          (&amp;quot;it_IT&amp;quot; . &amp;quot;Italian&amp;quot;)))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note that I use &lt;code&gt;hunspell&lt;/code&gt; for spell-checking as I explained in &lt;a href=&#34;https://manueluberti.eu/posts/2016-06-06-spellchecksetup/&#34;&gt;Spell-checking
with Hunspell and
flyspell-correct&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Next, my new command.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defun mu-select-dictionary ()
  &amp;quot;Select the dictionary for the spell-checker.&amp;quot;
  (interactive)
  (helm :sources
        (helm-build-sync-source &amp;quot;Dictionaries&amp;quot;
          :candidates (map-values mu-dictionaries)
          :action (lambda (candidate)
                    (let ((dict (car (rassoc candidate mu-dictionaries))))
                      (ispell-set-spellchecker-params)
                      (setq ispell-dictionary dict
                            ispell-local-dictionary dict
                            ispell-local-dictionary-overridden t)
                      (ispell-internal-change-dictionary)
                      (setq ispell-buffer-session-localwords nil)
                      (run-hooks &#39;ispell-change-dictionary-hook))))
        :preselect (map-elt mu-dictionaries ispell-dictionary)
        :buffer &amp;quot;*helm select dictionary*&amp;quot;)
  (flyspell-buffer))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I merely followed the guidelines on the &lt;a href=&#34;https://github.com/emacs-helm/helm/wiki/Developing&#34;&gt;Helm
wiki&lt;/a&gt;, but let&amp;rsquo;s break it
down.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(helm :source
      (helm-build-sync-source &amp;quot;Dictionaries&amp;quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The source of my Helm command comes from the simple &lt;code&gt;alist&lt;/code&gt; defined before
(&lt;code&gt;mu-dictionaries&lt;/code&gt;), so &lt;code&gt;helm-build-sync-source&lt;/code&gt; is enough.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;:candidates (map-values mu-dictionaries)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Here I am using the excellent
&lt;a href=&#34;https://github.com/emacs-mirror/emacs/blob/master/lisp/emacs-lisp/map.el&#34;&gt;map.el&lt;/a&gt;
to get the clearer “English” and “Italian” labels as &lt;code&gt;:candidates&lt;/code&gt; for the Helm
buffer.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;:action (lambda (candidate)
          (let ((dict (car (rassoc candidate mu-dictionaries))))
            (ispell-set-spellchecker-params)
            (setq ispell-dictionary dict
                  ispell-local-dictionary dict
                  ispell-local-dictionary-overridden t)
            (ispell-internal-change-dictionary)
            (setq ispell-buffer-session-localwords nil)
            (run-hooks &#39;ispell-change-dictionary-hook)))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The anonymous function for &lt;code&gt;:action&lt;/code&gt; is a small version of
&lt;code&gt;ispell-change-dictionary&lt;/code&gt;, containing only what I need for this operation to
complete successfully. Note the use of &lt;code&gt;rassoc&lt;/code&gt;: this is how I get the key
corresponding to the value of &lt;code&gt;candidate&lt;/code&gt; in &lt;code&gt;mu-dictionaries&lt;/code&gt;. I didn&amp;rsquo;t find a
similar facility in &lt;code&gt;map.el&lt;/code&gt;, but &lt;code&gt;rassoc&lt;/code&gt; and &lt;code&gt;car&lt;/code&gt; get the job done.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;:preselect (map-elt mu-dictionaries ispell-dictionary)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Here I am using the current dictionary as the preselected element in the Helm
buffer. I could use &lt;code&gt;:input&lt;/code&gt; to have it offered on the prompt, but I prefer to
have the prompt empty in this case.&lt;/p&gt;
&lt;p&gt;If you look closely at &lt;code&gt;ispell-change-dictionary&lt;/code&gt; source code, you can
understand the triviality of &lt;code&gt;mu-select-dictionary&lt;/code&gt;: &lt;code&gt;ispell-change-dictionary&lt;/code&gt;
uses &lt;code&gt;completing-read&lt;/code&gt;, so in my case it already pops up a Helm buffer. But I am
still happy with this solution, and not just because I prefer “Dictionaries”
instead of “ispell-change-dictionary” as the source name displayed in my Helm
buffer. (Yes, of course it&amp;rsquo;s mostly because of it.)&lt;/p&gt;
&lt;p&gt;As a bonus, thanks to &lt;code&gt;flyspell-buffer&lt;/code&gt; the current buffer is spell-checked
right after the new dictionary is selected.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Ripgrepping with Helm: the mode-line</title>
      <link>https://manueluberti.eu/posts/2020-03-01-helm-ripgrep-mode-line/</link>
      <pubDate>Sun, 01 Mar 2020 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2020-03-01-helm-ripgrep-mode-line/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;https://manueluberti.eu/posts/2020-02-22-ripgrepping-with-helm/&#34;&gt;Last time&lt;/a&gt;
I tailored my own &lt;code&gt;helm-do-grep-ag&lt;/code&gt; to show you how I use &lt;code&gt;ripgrep&lt;/code&gt; within Helm.
However, I missed something: the mode-line.&lt;/p&gt;
&lt;p&gt;The default mode-line Helm offers for &lt;code&gt;helm-do-grep-ag&lt;/code&gt; doesn&amp;rsquo;t fit well with my
custom one, which is a minimal&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt; version of the excellent
&lt;a href=&#34;https://github.com/seagle0128/doom-modeline&#34;&gt;doom-modeline&lt;/a&gt;. It&amp;rsquo;s a two-fold
issue: my mode-line is bigger than the default one and I don&amp;rsquo;t need all the
information usually printed by &lt;code&gt;helm-do-grep-ag&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;By inspecting Helm source code one can easily find out what &lt;code&gt;helm-do-grep-ag&lt;/code&gt;
does on
&lt;a href=&#34;http://doc.endlessparentheses.com/Var/mode-line-format.html&#34;&gt;mode-line-format&lt;/a&gt;.
Basically, among other things &lt;code&gt;helm-grep-ag-init&lt;/code&gt; sets up the value for
&lt;code&gt;mode-line-format&lt;/code&gt; according to the number of results. Very well, then, it&amp;rsquo;s
time to bring &lt;a href=&#34;https://manueluberti.eu/posts/2019-12-01-el-patch/&#34;&gt;el-patch&lt;/a&gt; back
in the game.&lt;/p&gt;
&lt;p&gt;First, though, aesthetics.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(set-face-bold &#39;helm-grep-finish t)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I am just making &lt;code&gt;helm-grep-finish&lt;/code&gt; bold, nothing serious.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(el-patch-defun helm-grep-ag-init (directory &amp;amp;optional type)
  &amp;quot;Start AG process in DIRECTORY maybe searching only files of type TYPE.&amp;quot;
  (let ((default-directory (or (el-patch-swap
                                 helm-ff-default-directory
                                 (mu--project-root))
                               (helm-default-directory)
                               default-directory))
        (cmd-line (helm-grep-ag-prepare-cmd-line
                   helm-pattern (or (file-remote-p directory &#39;localname)
                                    directory)
                   type))
        (el-patch-remove
          (start-time (float-time)))
        (proc-name (helm-grep--ag-command)))
    (set (make-local-variable &#39;helm-grep-last-cmd-line) cmd-line)
    (el-patch-remove
      (helm-log &amp;quot;Starting %s process in directory `%s&#39;&amp;quot;
                proc-name directory)
      (helm-log &amp;quot;Command line used was:\n\n%s&amp;quot;
                (concat &amp;quot;&amp;gt;&amp;gt;&amp;gt; &amp;quot; cmd-line &amp;quot;\n\n&amp;quot;)))
    (prog1
        (start-file-process-shell-command proc-name helm-buffer cmd-line)
      (set-process-sentinel
       (get-buffer-process helm-buffer)
       (lambda (process event)
         (let* ((err (process-exit-status process))
                (noresult (= err 1))
                (el-patch-add
                  (proc (concat &amp;quot; HELM &amp;quot; proc-name))))
           (el-patch-swap
             (cond (noresult
                    (with-helm-buffer
                      (insert (concat &amp;quot;* Exit with code 1, no result found,&amp;quot;
                                      &amp;quot; command line was:\n\n &amp;quot;
                                      (propertize helm-grep-last-cmd-line
                                                  &#39;face &#39;helm-grep-cmd-line)))
                      (setq mode-line-format
                            `(&amp;quot; &amp;quot; mode-line-buffer-identification &amp;quot; &amp;quot;
                              (:eval (format &amp;quot;L%s&amp;quot; (helm-candidate-number-at-point))) &amp;quot; &amp;quot;
                              (:eval (propertize
                                      (format
                                       &amp;quot;[%s process finished - (no results)] &amp;quot;
                                       ,(upcase proc-name))
                                      &#39;face &#39;helm-grep-finish))))))
                   ((string= event &amp;quot;finished\n&amp;quot;)
                    (helm-log &amp;quot;%s process finished with %s results in %fs&amp;quot;
                              proc-name
                              (helm-get-candidate-number)
                              (- (float-time) start-time))
                    (helm-maybe-show-help-echo)
                    (with-helm-window
                      (setq mode-line-format
                            `(&amp;quot; &amp;quot; mode-line-buffer-identification &amp;quot; &amp;quot;
                              (:eval (format &amp;quot;L%s&amp;quot; (helm-candidate-number-at-point))) &amp;quot; &amp;quot;
                              (:eval (propertize
                                      (format
                                       &amp;quot;[%s process finished in %.2fs - (%s results)] &amp;quot;
                                       ,(upcase proc-name)
                                       ,(- (float-time) start-time)
                                       (helm-get-candidate-number))
                                      &#39;face &#39;helm-grep-finish))))
                      (force-mode-line-update)
                      (when helm-allow-mouse
                        (helm--bind-mouse-for-selection helm-selection-point))))
                   (t (helm-log
                       &amp;quot;Error: %s %s&amp;quot;
                       proc-name
                       (replace-regexp-in-string &amp;quot;\n&amp;quot; &amp;quot;&amp;quot; event))))
             (if noresult
                 (with-helm-buffer
                   (setq mode-line-format
                         `(&amp;quot;&amp;quot;
                           mu-mode-line-bar
                           &amp;quot; &amp;quot;
                           (:eval
                            (propertize
                             (format &amp;quot;%s [no results]&amp;quot; ,proc)
                             &#39;face &#39;helm-grep-finish)))))
               (with-helm-window
                 (setq mode-line-format
                       `(&amp;quot;&amp;quot;
                         mu-mode-line-bar
                         &amp;quot; &amp;quot;
                         (:eval
                          (propertize
                           (format &amp;quot;%s [%s results]&amp;quot;
                                   ,proc (helm-get-candidate-number))
                           &#39;face &#39;helm-grep-finish))))
                 (force-mode-line-update))))))))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Let&amp;rsquo;s break down my changes:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(default-directory (el-patch-swap
                     (or helm-ff-default-directory
                         (helm-default-directory)
                         default-directory)
                     (or (mu--project-root)
                         (helm-default-directory)
                         default-directory)))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This has nothing do to with the mode-line, actually, but why not re-use
&lt;a href=&#34;https://manueluberti.eu/posts/2020-02-22-ripgrepping-with-helm/&#34;&gt;mu–-project-root&lt;/a&gt;
here? Exactly.&lt;/p&gt;
&lt;p&gt;I also removed all the &lt;code&gt;helm-log&lt;/code&gt; references, because I am confident my Elisp-fu
will not need debugging.&lt;sup id=&#34;fnref:2&#34;&gt;&lt;a href=&#34;#fn:2&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;2&lt;/a&gt;&lt;/sup&gt; Anyway, I want the buffer identification to look
like the rest of the Helm buffer identifications in my mode-line:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(proc (concat &amp;quot; HELM &amp;quot; proc-name))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I am going to use only &lt;code&gt;ripgrep&lt;/code&gt; for my searches, so &lt;code&gt;proc-name&lt;/code&gt; is usually &lt;code&gt;rg&lt;/code&gt;
here, but one never knows what will come next.&lt;/p&gt;
&lt;p&gt;When there are no results to be shown, I don&amp;rsquo;t want a message in the Helm
buffer, just a clean feedback:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(setq mode-line-format
      `((:eval mu-mode-line-bar)
        &amp;quot; &amp;quot;
        (:eval
         (propertize
          (format &amp;quot;%s [no results]&amp;quot; ,proc)
          &#39;face &#39;helm-grep-finish))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The same goes for one or more results:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(setq mode-line-format
      `((:eval mu-mode-line-bar)
        &amp;quot; &amp;quot;
        (:eval
         (propertize
          (format &amp;quot;%s [%s results]&amp;quot;
                  ,proc
                  (helm-get-candidate-number))
          &#39;face &#39;helm-grep-finish))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;mu-mode-line-bar&lt;/code&gt; is what makes my mode-line bigger and I borrowed it from
&lt;code&gt;doom-mode-line&lt;/code&gt;, so go check its fantastic code to find out about this magic
trick.&lt;/p&gt;
&lt;p&gt;Finally, this is how the mode-line looks after &lt;code&gt;M-?&lt;/code&gt; when the
&lt;code&gt;ripgrep&lt;/code&gt; process finishes:&lt;/p&gt;
&lt;p&gt;&lt;figure&gt;
  &lt;img src=&#34;https://manueluberti.eu/images/helm-rg-finished.png&#34; alt=&#34;&#34;&gt;
  &lt;figcaption class=&#34;center&#34;&gt;
    &lt;small&gt;&lt;em&gt;&lt;/em&gt;&lt;/small&gt;    
  &lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/p&gt;
&lt;p&gt;And for the sake of completeness, this is how it looks when I move through the
results with &lt;code&gt;C-p&lt;/code&gt; and &lt;code&gt;C-n&lt;/code&gt;:&lt;/p&gt;
&lt;p&gt;&lt;figure&gt;
  &lt;img src=&#34;https://manueluberti.eu/images/helm-rg.png&#34; alt=&#34;&#34;&gt;
  &lt;figcaption class=&#34;center&#34;&gt;
    &lt;small&gt;&lt;em&gt;&lt;/em&gt;&lt;/small&gt;    
  &lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/p&gt;
&lt;p&gt;By the way, the colours are courtesy of
&lt;a href=&#34;https://gitlab.com/protesilaos/modus-themes&#34;&gt;modus-vivendi&lt;/a&gt;, a great theme by
Protesilaos Stavrou I&amp;rsquo;ve recently switched to.&lt;/p&gt;
&lt;div class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;
&lt;hr&gt;
&lt;ol&gt;
&lt;li id=&#34;fn:1&#34;&gt;
&lt;p&gt;As in &amp;ldquo;what is enough for me?&amp;rdquo;.&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&#34;fn:2&#34;&gt;
&lt;p&gt;It&amp;rsquo;s not that I am &lt;em&gt;that&lt;/em&gt; good, it&amp;rsquo;s just that I can worry about debugging
later.&amp;#160;&lt;a href=&#34;#fnref:2&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    <item>
      <title>Ripgrepping with Helm</title>
      <link>https://manueluberti.eu/posts/2020-02-22-ripgrepping-with-helm/</link>
      <pubDate>Sat, 22 Feb 2020 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2020-02-22-ripgrepping-with-helm/</guid>
      <description>&lt;p&gt;Sometimes curiosity leads me to use alternative packages for built-in solutions
which I should have explored better. For instance, it took me moving through
&lt;a href=&#34;https://github.com/syohex/emacs-helm-ag&#34;&gt;helm-ag&lt;/a&gt; and
&lt;a href=&#34;https://github.com/cosmicexplorer/helm-rg&#34;&gt;helm-rg&lt;/a&gt;&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt; before realising Helm
already comes with a functionality suitable for my needs: &lt;code&gt;helm-do-grep-ag&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;By now I expect you to be familiar with the wonders of
&lt;a href=&#34;https://github.com/BurntSushi/ripgrep&#34;&gt;ripgrep&lt;/a&gt;. I was heavily relying on
&lt;code&gt;counsel-rg&lt;/code&gt; back in my Ivy days, and I needed a similar command in Helm. Truth
be told, &lt;code&gt;helm-do-grep-ag&lt;/code&gt; is not the replacement I was looking for, but
understanding its code helped me devise my own utilities for super fast
searches.&lt;/p&gt;
&lt;p&gt;First of all, let&amp;rsquo;s use &lt;code&gt;ripgrep&lt;/code&gt; instead of &lt;code&gt;ag&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(setq helm-grep-ag-command (concat &amp;quot;rg&amp;quot;
                                   &amp;quot; --color=never&amp;quot;
                                   &amp;quot; --smart-case&amp;quot;
                                   &amp;quot; --no-heading&amp;quot;
                                   &amp;quot; --line-number %s %s %s&amp;quot;)
      helm-grep-file-path-style &#39;relative)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note that the string for &lt;code&gt;helm-grep-ag-command&lt;/code&gt; comes from its documentation.
I chose &lt;code&gt;relative&lt;/code&gt; for &lt;code&gt;helm-grep-file-path-style&lt;/code&gt; because I find relative file
paths in the search result buffer more useful than their base name.&lt;/p&gt;
&lt;p&gt;Now, &lt;code&gt;helm-do-grep-ag&lt;/code&gt; defers to &lt;code&gt;helm-grep-ag&lt;/code&gt;, which in turns defers to
&lt;code&gt;helm-grep-ag-1&lt;/code&gt;, and this is the Helm facility I can leverage for my own
&lt;code&gt;ripgrep&lt;/code&gt; variant.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defun mu-helm-rg (directory &amp;amp;optional with-types)
  &amp;quot;Search in DIRECTORY with RG.
With WITH-TYPES, ask for file types to search in.&amp;quot;
  (interactive &amp;quot;P&amp;quot;)
  (require &#39;helm-adaptive)
  (helm-grep-ag-1 (expand-file-name directory)
                  (helm-aif (and with-types
                                 (helm-grep-ag-get-types))
                      (helm-comp-read
                       &amp;quot;RG type: &amp;quot; it
                       :must-match t
                       :marked-candidates t
                       :fc-transformer &#39;helm-adaptive-sort
                       :buffer &amp;quot;*helm rg types*&amp;quot;))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It&amp;rsquo;s basically &lt;code&gt;helm-grep-ag&lt;/code&gt; with minor aesthetic changes, but &lt;a href=&#34;https://manueluberti.eu/posts/2019-12-01-el-patch/&#34;&gt;you know
me&lt;/a&gt;. Note the &lt;code&gt;with-types&lt;/code&gt;
parameter. If I use this command with &lt;code&gt;C-u&lt;/code&gt; I get to pick one or more file types
to narrow the search down to. I don&amp;rsquo;t remember if this is possible with
&lt;code&gt;counsel-rg&lt;/code&gt;, but in large projects it is an absolute must have. Furthermore,
the symbol at point, if any, is the default search parameter. Why is this
awesome? Keep reading.&lt;/p&gt;
&lt;p&gt;With &lt;code&gt;mu-helm-rg&lt;/code&gt; in place, I can build a couple of commands to make my life
easier.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defun mu-helm-project-search (&amp;amp;optional with-types)
  &amp;quot;Search in current project with RG.
With WITH-TYPES, ask for file types to search in.&amp;quot;
  (interactive &amp;quot;P&amp;quot;)
  (mu-helm-rg (mu--project-root) with-types))

(defun mu-helm-file-search (&amp;amp;optional with-types)
  &amp;quot;Search in `default-directory&#39; with RG.
With WITH-TYPES, ask for file types to search in.&amp;quot;
  (interactive &amp;quot;P&amp;quot;)
  (mu-helm-rg default-directory with-types))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In case you are wondering, &lt;code&gt;mu–-project-root&lt;/code&gt; is a trivial function to figure out
the current project&amp;rsquo;s root directory.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defun mu--project-root ()
  &amp;quot;Return the project root directory or `helm-current-directory&#39;.&amp;quot;
  (require &#39;helm-ls-git)
  (if-let (dir (helm-ls-git-root-dir))
      dir
    (helm-current-directory)))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I don&amp;rsquo;t need &lt;code&gt;mu-helm-file-search&lt;/code&gt; as often as &lt;code&gt;mu-helm-project-search&lt;/code&gt;, which
is why I&amp;rsquo;ve bound the latter to &lt;code&gt;M-?&lt;/code&gt;. I use this key binding so
much it must be a quick one. And this is why having the symbol at point
automatically picked up by &lt;code&gt;mu-helm-rg&lt;/code&gt; is so important: it just makes the whole
search operation as simple as possible.&lt;/p&gt;
&lt;p&gt;Oh wait, the symbol at point is not what you are after? No problem, you can
start typing whatever you want and have Helm &lt;em&gt;ripgrepping&lt;/em&gt; your files.&lt;/p&gt;
&lt;div class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;
&lt;hr&gt;
&lt;ol&gt;
&lt;li id=&#34;fn:1&#34;&gt;
&lt;p&gt;Both packages seem hardly maintained these days.&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    <item>
      <title>Helmify some completion mechanisms</title>
      <link>https://manueluberti.eu/posts/2019-12-30-helm-dabbrev/</link>
      <pubDate>Mon, 30 Dec 2019 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2019-12-30-helm-dabbrev/</guid>
      <description>&lt;p&gt;Last year I wrote about &lt;a href=&#34;https://manueluberti.eu/posts/2019-01-17-company-on-demand/&#34;&gt;making Company completion popup appear on
demand&lt;/a&gt;. There I also
briefly mentioned &lt;code&gt;dabbrev-expand&lt;/code&gt; and &lt;code&gt;dabbrev-completion&lt;/code&gt;, but I have never
mentioned &lt;code&gt;hippie-expand&lt;/code&gt;, and that it has been pretty much covering my
completion needs.&lt;/p&gt;
&lt;p&gt;However, &lt;a href=&#34;https://manueluberti.eu/posts/2019-11-16-helm/&#34;&gt;moving to Helm&lt;/a&gt; prompted
me to give &lt;code&gt;helm-dabbrev&lt;/code&gt; a try. &lt;code&gt;helm-dabbrev&lt;/code&gt; works similarly to
&lt;code&gt;dabbrev-completion&lt;/code&gt;, but when you hit &lt;code&gt;helm-dabbrev-cycle-threshold&lt;/code&gt; (which
defaults to 5), it takes you to a Helm buffer with all the benefits that come
with it.&lt;/p&gt;
&lt;p&gt;Two settings are necessary to have &lt;code&gt;helm-dabbrev&lt;/code&gt; behave like I want to. First,
I turned off Helm&amp;rsquo;s show completion, a feature which displays candidates in the
current buffer. I don&amp;rsquo;t like popups, as you may have noticed, and I prefer Helm
to always show candidates in the same position of the screen.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(setq helm-turn-on-show-completion nil)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then, I made &lt;code&gt;helm-dabbrev&lt;/code&gt; look for completions in all the available buffers.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(setq helm-dabbrev-related-buffer-fn nil)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;By default, &lt;code&gt;helm-dabbrev&lt;/code&gt; scans buffers with the same major mode as the current
one, but this doesn&amp;rsquo;t help when, for instance, I am writing a commit message and
I want a symbol to be completed. Binding &lt;code&gt;helm-dabbrev&lt;/code&gt; to &lt;code&gt;C-.&lt;/code&gt; is all
that&amp;rsquo;s left to do.&lt;/p&gt;
&lt;p&gt;Moreover, Helm improves on Company too. With the help of
&lt;a href=&#34;https://github.com/Sodel-the-Vociferous/helm-company&#34;&gt;helm-company&lt;/a&gt;&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt; is
possible to narrow down the candidates through Helm smart UI. &lt;code&gt;C-TAB&lt;/code&gt;
is my go-to key binding for &lt;code&gt;helm-company&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Since Helm has become a great companion during my Emacs sessions, it makes sense
to rely on it for everything concerning completion.&lt;/p&gt;
&lt;div class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;
&lt;hr&gt;
&lt;ol&gt;
&lt;li id=&#34;fn:1&#34;&gt;
&lt;p&gt;I used to maintain &lt;code&gt;helm-company&lt;/code&gt; before discovering Ivy, and now I&amp;rsquo;m back
to it. The Emacs world is full of surprises.&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    <item>
      <title>Developing Helm actions</title>
      <link>https://manueluberti.eu/posts/2019-12-23-helm-actions/</link>
      <pubDate>Mon, 23 Dec 2019 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2019-12-23-helm-actions/</guid>
      <description>&lt;p&gt;One of the central pieces of my recent &lt;a href=&#34;https://manueluberti.eu/posts/2019-11-16-helm/&#34;&gt;return to
Helm&lt;/a&gt; is
&lt;a href=&#34;https://github.com/emacs-helm/helm-ls-git&#34;&gt;helm-ls-git&lt;/a&gt;, which empowers
&lt;code&gt;helm-browse-project&lt;/code&gt; with everything I need to move through my Git projects
smoothly. Combine that with &lt;code&gt;helm-projects-history&lt;/code&gt;, and you can see why I don&amp;rsquo;t
need Projectile any more. Well, sort of. It&amp;rsquo;s true that I&amp;rsquo;ve stopped using
Projectile since Helm took over my Emacs configuration, but it&amp;rsquo;s also true that
I had to code the “helmified” version of a couple of features I was heavily
relying upon.&lt;/p&gt;
&lt;p&gt;In Helm, you can leverage
&lt;a href=&#34;https://github.com/emacs-helm/helm/wiki/Developing#writing-actions&#34;&gt;actions&lt;/a&gt; to
extend the available utilities.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defun mu--candidate-directory (candidate)
  &amp;quot;Find the directory containing CANDIDATE.
Default to `helm-current-directory&#39; when none can be found.&amp;quot;
  (if (fboundp &#39;helm-ls-git-root-dir)
      (let* ((dir (cond ((stringp candidate)
                         (file-name-directory candidate))
                        ((and (bufferp candidate)
                              (buffer-file-name candidate))
                         (file-name-directory (buffer-file-name candidate)))
                        (t default-directory)))
             (root-dir (helm-ls-git-root-dir dir)))
        (if root-dir
            root-dir
          (helm-current-directory)))
    (helm-current-directory)))

(defun mu-helm-project-dired ()
  &amp;quot;Open Dired buffers at project root from a Helm session.&amp;quot;
  (interactive)
  (dolist (cand (helm-marked-candidates))
    (dired (mu--candidate-directory cand))))

(defun mu-helm-project-shell ()
  &amp;quot;Open shell buffers at project root from a Helm session.&amp;quot;
  (interactive)
  (dolist (cand (helm-marked-candidates))
    (let* ((default-directory (mu--candidate-directory cand))
           (buffer (concat &amp;quot;*shell &amp;quot;
                           (file-name-nondirectory
                            (directory-file-name default-directory))
                           &amp;quot;*&amp;quot;)))
      (mu-shell-open buffer))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The actions are self-explanatory (see &lt;a href=&#34;https://manueluberti.eu/posts/2019-06-21-windows/&#34;&gt;Passing the prefix argument
around&lt;/a&gt; for &lt;code&gt;mu-shell-open&lt;/code&gt;).
I often need to jump to a Dired or a shell-mode buffer of a project different
from the current one, so I want the possibility to use the current candidate in
&lt;code&gt;helm-projects-history&lt;/code&gt; as a starting point.&lt;/p&gt;
&lt;p&gt;To be fair, &lt;code&gt;mu--candidate-directory&lt;/code&gt; does a little more than what I need here.
That&amp;rsquo;s because I use &lt;code&gt;mu-helm-project-dired&lt;/code&gt; and &lt;code&gt;mu-helm-project-shell&lt;/code&gt; in
&lt;code&gt;helm-mini&lt;/code&gt; and &lt;code&gt;helm-browse-project&lt;/code&gt; too. The latter lists special buffers
(e.g., &lt;code&gt;*scratch*&lt;/code&gt;) as buffers of the current project. Since they do not live in
any specific directory,
&lt;a href=&#34;http://doc.endlessparentheses.com/Var/default-directory.html&#34;&gt;default-directory&lt;/a&gt;
is the obvious choice.&lt;/p&gt;
&lt;p&gt;Now I have to plug the actions into &lt;code&gt;helm-projects-history&lt;/code&gt;. Unfortunately, it
doesn&amp;rsquo;t have a &lt;code&gt;keymap&lt;/code&gt; to extend, so I need another solution.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defvar mu-helm-projects-history-map
  (let ((map (make-sparse-keymap)))
    (set-keymap-parent map helm-map)
    (define-key map (kbd &amp;quot;C-c d&amp;quot;) (helm-exit-and-run! (mu-helm-project-dired)))
    (define-key map (kbd &amp;quot;C-c s&amp;quot;) (helm-exit-and-run! (mu-helm-project-shell)))
    map)
  &amp;quot;Keymap for `mu-helm-projects-history&#39;.&amp;quot;)

(defun mu-helm-projects-history (arg)
  &amp;quot;A `helm-projects-history&#39; with custom actions.&amp;quot;
  (interactive &amp;quot;P&amp;quot;)
  (require &#39;helm-ls-git)
  (helm :sources
        (helm-build-sync-source &amp;quot;Project history&amp;quot;
          :candidates helm-browse-project-history
          :action (lambda (candidate)
                    (with-helm-default-directory candidate
                      (helm-browse-project
                       (or arg helm-current-prefix-arg))))
          :keymap mu-helm-projects-history-map)
        :buffer &amp;quot;*helm browse project history*&amp;quot;))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;mu-helm-projects-history&lt;/code&gt; adds only two things to the original
&lt;code&gt;helm-projects-history&lt;/code&gt;. I require &lt;code&gt;helm-ls-git&lt;/code&gt; early because I need its
capabilities inside my actions, and I use my own &lt;code&gt;mu-helm-projects-history-map&lt;/code&gt;
to make them available in the Helm buffer opened by this command.&lt;/p&gt;
&lt;p&gt;Last but not least, &lt;code&gt;helm-exit-and-run!&lt;/code&gt; is a helpful macro to avoid dry
repetitions:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defmacro helm-exit-and-run! (&amp;amp;rest body)
  &amp;quot;Define an action with BODY to be run after exiting Helm.&amp;quot;
  (declare (doc-string 1))
  `(lambda ()
     (interactive)
     (with-helm-alive-p
       (helm-exit-and-execute-action (lambda (_candidate) ,@body)))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note that in my actions I am ignoring the &lt;code&gt;_candidate&lt;/code&gt; parameter on purpose.
Since &lt;code&gt;helm-marked-candidates&lt;/code&gt; grabs the current candidate when none of them is
selected, I can use my actions on multiple candidates if I feel wild enough.
Yeah, sometimes I can be crazy like that.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>The aesthetics of patching</title>
      <link>https://manueluberti.eu/posts/2019-12-01-el-patch/</link>
      <pubDate>Sun, 01 Dec 2019 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2019-12-01-el-patch/</guid>
      <description>&lt;p&gt;In describing &lt;a href=&#34;https://manueluberti.eu/posts/2019-11-16-helm/&#34;&gt;my move to Helm&lt;/a&gt; I quickly
mentioned another package from Thierry Volpiatto: &lt;code&gt;psession&lt;/code&gt;. &lt;code&gt;psession&lt;/code&gt; is a
light session saving mechanism and it comes with built-in integration for Helm
among other things, which of course renders it a valuable improvement to my
setup. The installation instructions are pretty clear, so there is no need to
bother you with obvious code snippets.&lt;/p&gt;
&lt;p&gt;Instead, I want to bother you with my obsessive-compulsive disorder. You see,
I am fond of how my beloved text editor looks, especially after boot. I disabled
every message, toolbar, scrollbar, menu, and buffer Emacs can throw at me on
startup, and the theme is applied as late as possible to ensure nothing
obstructs my way to another great day of text editing.&lt;/p&gt;
&lt;p&gt;What&amp;rsquo;s “wrong” with &lt;code&gt;psession&lt;/code&gt; then? In order to make the previous sessions
available, &lt;code&gt;psession&lt;/code&gt; loads some compiled files when Emacs starts. This is what
I expect it to do, because there would be no point in saving sessions without
restoring them. My only “problem” with this behaviour is the file loading
itself.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(cl-defun psession--restore-objects-from-directory
    (&amp;amp;optional (dir psession-elisp-objects-default-directory))
  (let ((file-list (directory-files dir t directory-files-no-dot-files-regexp)))
    (cl-loop for file in file-list do (and file (load file)))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The code is not hard to understand. What constitutes a rude attack at my
delicate aesthetic feelings is that &lt;code&gt;(load file)&lt;/code&gt; right before the good-looking
closing parentheses. Calling &lt;code&gt;load&lt;/code&gt; in this manner causes a bunch of messages to
“interfere” with a clean Emacs boot: they show up in the echo area during the
loading of my &lt;code&gt;init.el&lt;/code&gt; and they hurt so bad!&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;Let&amp;rsquo;s examine the documentation of the function &lt;code&gt;load&lt;/code&gt;:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;load is a function defined in lread.c.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Signature&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;(load FILE &amp;amp;optional NOERROR NOMESSAGE NOSUFFIX MUST-SUFFIX)&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Documentation&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Execute a file of Lisp code named FILE.&lt;/p&gt;
&lt;p&gt;[…]&lt;/p&gt;
&lt;p&gt;Print messages at start and end of loading unless
optional third arg NOMESSAGE is non-nil (but force-load-messages
overrides that).&lt;/p&gt;
&lt;p&gt;[…]&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Perfect. Now I just have to hack &lt;code&gt;psession--restore-objects-from-directory&lt;/code&gt; and
make sure &lt;code&gt;load&lt;/code&gt; is called with a non-nil value for &lt;code&gt;NOMESSAGE&lt;/code&gt;. Usually when
I want to silence a command I rely on &lt;code&gt;inhibit-message&lt;/code&gt;. Let&amp;rsquo;s say I want to
silence the activation of &lt;code&gt;helm-adaptive-mode&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(let ((inhibit-message t))
  (helm-adaptive-mode 1))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;However, &lt;code&gt;psession--restore-objects-from-directory&lt;/code&gt; is sort of a private
function, so I need something else to change it according to my plans. There are
probably several good ways to patch &lt;code&gt;psession--restore-objects-from-directory&lt;/code&gt;,
but my go-to package in these situations is Radon Rosborough&amp;rsquo;s el-patch.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(el-patch-feature psession)
(with-eval-after-load &#39;psession
  (el-patch-cl-defun psession--restore-objects-from-directory
    (&amp;amp;optional (dir psession-elisp-objects-default-directory))
    (let ((file-list (directory-files dir t directory-files-no-dot-files-regexp)))
      (cl-loop for file
               in file-list
               do (and file (el-patch-swap (load file)
                                           (load file nil &#39;nomessage nil)))))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Only nine lines of code to please my sense of aesthetic. Beauty is always within
reach when we are dealing with Emacs.&lt;/p&gt;
&lt;p&gt;Note that at the moment of this writing, &lt;code&gt;el-patch-cl-defun&lt;/code&gt; is on the &lt;code&gt;develop&lt;/code&gt;
&lt;a href=&#34;https://github.com/raxod502/el-patch/issues/39&#34;&gt;branch&lt;/a&gt; of &lt;code&gt;el-patch&lt;/code&gt;.&lt;/p&gt;
&lt;div class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;
&lt;hr&gt;
&lt;ol&gt;
&lt;li id=&#34;fn:1&#34;&gt;
&lt;p&gt;I know this is silly, but I hope the double quotation marks and the light
tone make the irony clear enough. The point is having fun at hacking Emacs,
not insulting Thierry.&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    <item>
      <title>At the helm of my configuration</title>
      <link>https://manueluberti.eu/posts/2019-11-16-helm/</link>
      <pubDate>Sat, 16 Nov 2019 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2019-11-16-helm/</guid>
      <description>&lt;p&gt;It was a cold winter back in December 2014. If memory serves me well, it was
time spent at tinkering with old hardware and obscure window managers, reading
my first books on functional programming, and dealing with something about text
editors I can&amp;rsquo;t quite put my finger on.&lt;/p&gt;
&lt;p&gt;I was also reading about &lt;a href=&#34;https://emacs-helm.github.io/helm/&#34;&gt;Helm&lt;/a&gt; and the
praises everywhere in the Emacs community for this package: it can do this, it
improves that, it will take you closer to Emacs Nirvana. So yeah, I believed the
hype, because it came from trusted sources, especially the Nirvana-guy. Soon
Helm took over my configuration and I was using it for everything: switching
buffers, selecting bookmarks, in-buffer and per-project searches. Anything
involving candidate completion was in the wise hands of Helm.&lt;/p&gt;
&lt;p&gt;After a while &lt;a href=&#34;https://github.com/abo-abo/swiper&#34;&gt;Ivy&lt;/a&gt; came along, and the rest
is history. I have been using Ivy/Counsel for such a long a time I might as well
say they have become the central drivers of my Emacs setup. Along with the likes
of &lt;a href=&#34;https://github.com/ericdanan/counsel-projectile&#34;&gt;counsel-projectile&lt;/a&gt;, these
are the packages I use the most during the day.&lt;/p&gt;
&lt;p&gt;Lately I&amp;rsquo;ve been following some conversations about
&lt;a href=&#34;http://doc.endlessparentheses.com/Var/completion-styles.html&#34;&gt;completion-styles&lt;/a&gt;,
and when I learned that &lt;a href=&#34;https://github.com/thierryvolpiatto&#34;&gt;Thierry Volpiatto&lt;/a&gt;
was working on leveraging Helm for this I just could not resist. Note that
Thierry is still devising the implementation, so there is no need to rush at
opening issues and scream at him. Anyway, Helm was back in my radar now, and so
I took the chance to see if I could come up with a setup which would mirror my
everyday workflow with Ivy/Counsel.&lt;/p&gt;
&lt;p&gt;I immediately noticed that the theme I use lacked proper support for some Helm
faces, but nothing stopped me to &lt;a href=&#34;https://github.com/purcell/color-theme-sanityinc-tomorrow/pull/144&#34;&gt;do something about
it&lt;/a&gt;. Much
like Ivy/Counsel, Helm provides its own version for common operations such as
&lt;code&gt;helm-M-x&lt;/code&gt;, &lt;code&gt;helm-find-files&lt;/code&gt;, &lt;code&gt;helm-mini&lt;/code&gt;, &lt;code&gt;helm-recentf&lt;/code&gt;, &lt;code&gt;helm-bookmarks&lt;/code&gt;,
&lt;code&gt;helm-show-kill-ring&lt;/code&gt;, and &lt;code&gt;helm-resume&lt;/code&gt;. These are the core features for me,
and they work as expected. I also enabled &lt;code&gt;helm-adaptive-mode&lt;/code&gt; and
&lt;code&gt;helm-autoresize-mode&lt;/code&gt;, fixing the Helm window height to my preferences.&lt;/p&gt;
&lt;p&gt;As I did with Ivy/Counsel, I made buffer switching (i.e., &lt;code&gt;helm-mini&lt;/code&gt;) ignore
some files:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(require &#39;helm-buffers)
(setq helm-ff-skip-boring-files t)
(dolist (regexp &#39;(&amp;quot;\\`\\*direnv&amp;quot; &amp;quot;\\`\\*straight&amp;quot; &amp;quot;\\`\\*xref&amp;quot;))
  (cl-pushnew regexp helm-boring-buffer-regexp-list))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;My projects are all Git-versioned, hence I installed
&lt;a href=&#34;https://github.com/emacs-helm/helm-ls-git&#34;&gt;helm-ls-git&lt;/a&gt;, which superseded
Projectile and the related &lt;code&gt;helm-projectile&lt;/code&gt; in an instant. In order to make
per-project lookups with Helm as easy as they were with Ivy/Counsel, I went with
&lt;a href=&#34;https://github.com/syohex/emacs-helm-ag&#34;&gt;helm-ag&lt;/a&gt; and
&lt;a href=&#34;https://github.com/brotzeit/helm-xref&#34;&gt;helm-xref&lt;/a&gt;. To make it even better,
I added &lt;a href=&#34;https://github.com/thierryvolpiatto/psession&#34;&gt;psession&lt;/a&gt; and configured
it to persist the things I need from my Emacs sessions. The only goodies I put
on top of this setup are &lt;a href=&#34;https://github.com/tmalsburg/helm-bibtex&#34;&gt;helm-bibtex&lt;/a&gt;
and &lt;a href=&#34;https://github.com/masasam/emacs-helm-tramp&#34;&gt;helm-tramp&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Back in the day, Helm felt heavier and more bloated than Ivy/Counsel, but that
is nonsense and was probably due to me being still young and inexperienced at
Emacs tweaking. In fact, it still takes less than one second for my Emacs to
boot, and so far there is nothing in terms of functionalities I have been
missing from my previous configuration. We could argue about UI minimalism and
design choices as long as we want, or we could simply try what the Emacs
ecosystem offers and decide for ourselves what suits our text editor best.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Thirty straight days</title>
      <link>https://manueluberti.eu/posts/2019-11-02-thirty-straight-days/</link>
      <pubDate>Sat, 02 Nov 2019 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2019-11-02-thirty-straight-days/</guid>
      <description>&lt;p&gt;It&amp;rsquo;s already been a month since I moved from &lt;code&gt;package.el&lt;/code&gt; to &lt;code&gt;straight.el&lt;/code&gt;, and
if it wasn&amp;rsquo;t for the constant fiddling with my Emacs configuration, I would have
hardly noticed the differences in package management. A proof of the solid work
behind &lt;code&gt;straight.el&lt;/code&gt;, sure, but also a demonstration of how painless package
management can be for someone who bypasses the provided UI and relies on
&lt;code&gt;use-package&lt;/code&gt; snippets to install and setup their packages.&lt;/p&gt;
&lt;p&gt;However, with &lt;code&gt;straight.el&lt;/code&gt; a new approach to updates is needed. First of all,
I compulsively track the state of the packages I have installed, and I tend to
update all of them every morning. This is an operation that follows the pulling
of the latest developments on the Emacs &lt;code&gt;master&lt;/code&gt; branch.&lt;/p&gt;
&lt;p&gt;On the one hand, this approach could lead to breaking changes and tears of
sadness. On the other hand, I like to report bugs as soon as I discover them,
and hopefully help the great developers out there who make my text editing a
wonder.&lt;/p&gt;
&lt;p&gt;Considering how vital to my computing Emacs is, this may sound like complete
madness, I know. In my defence, I mostly rely on stable and long-term support
software on my computer. Emacs is just the special kind of madness that drags me
to it in spite of the risks. Furthermore, as I wrote &lt;a href=&#34;https://manueluberti.eu/posts/2019-10-04-straight/&#34;&gt;last time&lt;/a&gt;, &lt;code&gt;straight.el&lt;/code&gt; makes it easier to revert to a
previous unbroken version of a package, so I can find a functional environment
without too much of a hassle.&lt;/p&gt;
&lt;p&gt;In my &lt;code&gt;package.el&lt;/code&gt; days, package updating was handled by Paradox. In a matter of
a couple of key bindings, it took care of notifying me about new versions and
installing the selected updates. &lt;code&gt;straight.el&lt;/code&gt; is less fancy, though. It
provides the necessary commands to install and update a package, as well as the
big brother that will pull every package in, but all the UI it offers is the
user&amp;rsquo;s &lt;code&gt;completing-read&lt;/code&gt; framework—&lt;code&gt;ivy-read&lt;/code&gt; in my case.&lt;/p&gt;
&lt;p&gt;Well, like the first line of the README says, &lt;code&gt;straight.el&lt;/code&gt; is a tool for the
Emacs hacker, so let&amp;rsquo;s play with it. All I had to do to get a more &lt;em&gt;interactive&lt;/em&gt;
user experience when updating packages was devising a small wrapper around
&lt;code&gt;straight.el&lt;/code&gt;&amp;rsquo;s facilities.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defun mu-straight-pull-or-prune (&amp;amp;optional prune)
  &amp;quot;Update all available packages via `straight&#39;.
With PRUNE, prune the build cache and the build directory.&amp;quot;
  (interactive &amp;quot;P&amp;quot;)
  (if prune
      (when (y-or-n-p &amp;quot;Prune build cache and build directory?&amp;quot;)
        (straight-prune-build-cache)
        (straight-prune-build-directory))
    (when (y-or-n-p &amp;quot;Update all available packages?&amp;quot;)
      (straight-pull-all))))

(bind-key* &amp;quot;&amp;lt;f7&amp;gt;&amp;quot; #&#39;mu-straight-pull-or-prune)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Pretty straightforward, isn&amp;rsquo;t it? (Pun intended.)&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Straight ahead</title>
      <link>https://manueluberti.eu/posts/2019-10-04-straight/</link>
      <pubDate>Fri, 04 Oct 2019 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2019-10-04-straight/</guid>
      <description>&lt;p&gt;I have never found Emacs appealing without external packages. From the colour
theme to the best Git UI one could ask for, I can&amp;rsquo;t imagine using Emacs without
external packages. The built-in &lt;code&gt;package.el&lt;/code&gt; has served me well for a long time.
Configured with the usual package archives, it has offered me easy access to new
packages and updates for the currently installed ones.&lt;/p&gt;
&lt;p&gt;However, digging a little deeper reveals some of its shortcomings. For instance,
downgrading has to be done manually, because &lt;code&gt;package.el&lt;/code&gt; gives access only to
the latest version of a package. This also means it is impossible to get a
specific version of said package without getting the source and loading it by
yourself.&lt;/p&gt;
&lt;p&gt;As you install and configure more and more tools to enhance your Emacs
experience, you are adding layers of complexity. Dependencies are pulled in and
new releases could bring breaking changes: either you never upgrade your
packages, or you learn to live on the bleeding edge. I love that edge as much as
your next Emacs hacker, but to approach it with steadiness I need more control
over the packages I use.&lt;/p&gt;
&lt;p&gt;This is where &lt;a href=&#34;https://github.com/raxod502/straight.el&#34;&gt;straight.el&lt;/a&gt; fits in.
I have to admit that &lt;a href=&#34;https://github.com/raxod502&#34;&gt;Radon Rosborough&lt;/a&gt; played
dirty with my feelings: by describing &lt;code&gt;straight.el&lt;/code&gt; as purely functional he knew
perfectly well a developer in love with functional programming could not resist.
But there is more to it, of course.&lt;/p&gt;
&lt;p&gt;First of all, I love the documentation. The effort put into explaining the
rationale behind it, the comparisons with other package managers, and the basics
to get started is simply amazing. Even the process of reproducing bugs is
documented. It may seem like a lot to take in, but it&amp;rsquo;s clear and it&amp;rsquo;s something
I want to know before changing one of the key features of my text editor.&lt;/p&gt;
&lt;p&gt;Moreover, it takes a few lines of code to bootstrap &lt;code&gt;straight.el&lt;/code&gt;. It would
probably take fewer lines to set up &lt;code&gt;package.el&lt;/code&gt;, that&amp;rsquo;s true, but &lt;code&gt;straight.el&lt;/code&gt;
is far more customisable. It also works seamlessly with &lt;code&gt;use-package&lt;/code&gt;, so
I didn&amp;rsquo;t have to reinvent my Emacs configuration just to try a new package
manager.&lt;/p&gt;
&lt;p&gt;Finally, you can freeze your package state at any time with
&lt;code&gt;straight-freeze-versions&lt;/code&gt;. This creates a lockfile with the current versions of
your packages, meaning you can reproduce your exact configuration with a simple
&lt;code&gt;straight-thaw-versions&lt;/code&gt;. Stability is just a couple of commands away.&lt;/p&gt;
&lt;p&gt;There must (should?) be a moment when the Emacs hacker knows they exploited
their beloved editor as much as possible, the eureka light bulb leading the way
through a thick fog of &lt;code&gt;setq&lt;/code&gt; and &lt;code&gt;defun&lt;/code&gt;. Valhalla is there, Emacs hacker, you
know it. As for me, I decided to accept the murkiness for now, and look for the
bulb that will get me out of here eventually another time.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Open Magit from Ibuffer</title>
      <link>https://manueluberti.eu/posts/2019-08-07-ibuffer-magit/</link>
      <pubDate>Wed, 07 Aug 2019 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2019-08-07-ibuffer-magit/</guid>
      <description>&lt;p&gt;It&amp;rsquo;s amazing how many packages for our beloved editor exist out there. ELPA and
MELPA keep growing and growing, and curiosity is always pushing me out to look
for a new package to try.&lt;/p&gt;
&lt;p&gt;Last year I wrote about &lt;a href=&#34;https://manueluberti.eu/posts/2017-08-02-eyebrowse/&#34;&gt;Eyebrowse&lt;/a&gt;, a cool
workspace manager that has proven to be a reliable friend until recently.
Eyebrowse is a helpful extension, but as it turns out the built-in Ibuffer is
enough to make sense of all of the buffers available. I open it with `C-x C-b,
which is one of the most used key bindings in my everyday Emacs interactions.&lt;/p&gt;
&lt;p&gt;Ibuffer presents a customizable list of buffers on which, much like Dired, we
can apply different kinds of operations: filter, sort, group, mark, delete,
bury, visit. Just press &lt;code&gt;h&lt;/code&gt; in Ibuffer to get an idea.&lt;/p&gt;
&lt;p&gt;Since I mainly work on projects versioned on Git, ibuffer-vc helps with grouping
the buffers in a project-based fashion and operate on them. For instance, to
quickly close a project and its related buffers, mark the project header for
deletion with &lt;code&gt;d&lt;/code&gt; and then press &lt;code&gt;x&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;One thing I was missing in Ibuffer was an integration with Magit. I wanted to
open &lt;code&gt;magit-status&lt;/code&gt; in the project the current buffer (i.e., the buffer where
point is on) belongs to.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defun mu-ibuffer-magit ()
  &amp;quot;Open `magit-status&#39; for the current buffer.&amp;quot;
  (interactive)
  (let ((buf (ibuffer-current-buffer t)))
    (magit-status (cdr (ibuffer-vc-root buf)))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I&amp;rsquo;ve bound this function to &lt;code&gt;v&lt;/code&gt; in &lt;code&gt;ibuffer-mode-map&lt;/code&gt;. Note that
&lt;code&gt;v&lt;/code&gt; was previously calling &lt;code&gt;ibuffer-do-view&lt;/code&gt;, so you may want to pick
the key that suits you best.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Format XML like a pro</title>
      <link>https://manueluberti.eu/posts/2019-07-18-reformatter/</link>
      <pubDate>Thu, 18 Jul 2019 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2019-07-18-reformatter/</guid>
      <description>&lt;p&gt;Years ago I wrote about a &lt;a href=&#34;https://manueluberti.eu/posts/2016-12-03-xmllint/&#34;&gt;custom function&lt;/a&gt;
that uses &lt;code&gt;shell-command-on-region&lt;/code&gt; to run &lt;code&gt;xmllint&lt;/code&gt; on an XML buffer.&lt;/p&gt;
&lt;p&gt;There is nothing wrong with this function, but a simpler approach is using
&lt;code&gt;reformatter&lt;/code&gt;, a nice tool from the prolific mind of Steve Purcell.&lt;/p&gt;
&lt;p&gt;Once installed, defining a new formatter is trivial:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(reformatter-define xml-format
  :program &amp;quot;xmllint&amp;quot;
  :args &#39;(&amp;quot;--format&amp;quot; &amp;quot;-&amp;quot;)
  :mode nil)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now I can add a key binding for &lt;code&gt;xml-format&lt;/code&gt; or simply type &lt;code&gt;M-x&lt;/code&gt;
&lt;code&gt;xml-format&lt;/code&gt; in an XML buffer to have it nicely printed.&lt;/p&gt;
&lt;p&gt;Note that setting &lt;code&gt;:mode&lt;/code&gt; to &lt;code&gt;nil&lt;/code&gt; tells &lt;code&gt;reformatter-define&lt;/code&gt; to not create a
minor mode, which I don&amp;rsquo;t need in this particular case. The minor mode could be
useful if you want your formatter to be called automatically when you save a
buffer. For instance, without changing the default setting for &lt;code&gt;:mode&lt;/code&gt; you could
set up the formatter in a project via &lt;code&gt;.dir-locals.el&lt;/code&gt; with:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;((nxml-mode
  (mode . xml-format-on-save)))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You can also specify other options when creating a formatter, so be sure to
check the documentation of &lt;code&gt;reformatter-define&lt;/code&gt; (&lt;code&gt;C-h f reformatter-define&lt;/code&gt;).&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Motivate yourself</title>
      <link>https://manueluberti.eu/posts/2019-07-06-memento-mori/</link>
      <pubDate>Sat, 06 Jul 2019 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2019-07-06-memento-mori/</guid>
      <description>&lt;p&gt;Life is such an ephemeral thing. When you really think about it, the time spent
on the planet we are destroying day after day is not that much, especially
compared to the entire history of humankind. Luckily enough, I can allow myself
to indulge in thoughts about life and time. I tend to avoid laziness as much as
possible, saving spare time for &lt;a href=&#34;https://manueluberti.eu/posts/2019-04-10-digital-minimalism/&#34;&gt;gratifying leisure&lt;/a&gt;: morning runs and basic workout, books,
cinema, collecting vinyls, occasional cooking. I like to think of myself as
someone who is not set on a predictable path for the rest of his life.&lt;/p&gt;
&lt;p&gt;Lassi Kortela&amp;rsquo;s &lt;code&gt;memento-mori&lt;/code&gt; has recently appeared on MELPA. It&amp;rsquo;s a small
package which aims to display your age in the mode-line. The age is displayed
with two decimals and it gets updated after a few days once you turned on
&lt;code&gt;memento-mori-mode&lt;/code&gt;. Thus you have a reminder of how long you have been on
Earth, a somehow inspirational indicator to question the time at your disposal.
We are entering philosophical worlds here.&lt;/p&gt;
&lt;p&gt;However, I don&amp;rsquo;t like having too much stuff in my mode-line. I want it simple
and with only the information I need. That&amp;rsquo;s why I use &lt;code&gt;minions&lt;/code&gt; to hide all the
minor-modes. But I can still use &lt;code&gt;memento-mori&lt;/code&gt; to display a message on Emacs
startup.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defun mu-display-memento-mori ()
  &amp;quot;Display my current age by leveraging `memento-mori-age-string&#39;.&amp;quot;
  (interactive)
  (let ((first-name (car (s-split-words user-full-name)))
        (age (s-trim memento-mori-age-string))
        (msg &amp;quot;%s, you are %s, don&#39;t waste your time!&amp;quot;))
    (run-with-timer 2 nil
                    (lambda ()
                      (message msg first-name age)
                      (run-with-timer 3 nil
                                      (lambda ()
                                        (message nil)))))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I am using &lt;code&gt;s&lt;/code&gt; facilities to manipulate strings, but more importantly the trick
is using &lt;code&gt;run-with-timer&lt;/code&gt; as explained on
&lt;a href=&#34;https://emacs.stackexchange.com/a/28243/5514&#34;&gt;Emacs.StackExchange&lt;/a&gt;. After two
seconds, the message is shown, and three seconds after being visible it will
disappear.&lt;/p&gt;
&lt;p&gt;Provided you set &lt;code&gt;memento-mori-birth-date&lt;/code&gt; and activate &lt;code&gt;memento-mori-mode&lt;/code&gt;,
adding the function to &lt;code&gt;after-init-hook&lt;/code&gt; does the rest.&lt;/p&gt;
&lt;p&gt;Note that you need to activate &lt;a href=&#34;https://www.gnu.org/software/emacs/manual/html_node/elisp/Using-Lexical-Binding.html#Using-Lexical-Binding&#34;&gt;lexical
binding&lt;/a&gt;
in your init file to use &lt;code&gt;mu-display-memento-mori&lt;/code&gt;.&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;div class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;
&lt;hr&gt;
&lt;ol&gt;
&lt;li id=&#34;fn:1&#34;&gt;
&lt;p&gt;Thanks to Martin Buchmann for pointing this out.&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    <item>
      <title>Bury shell buffers</title>
      <link>https://manueluberti.eu/posts/2019-07-01-bury/</link>
      <pubDate>Mon, 01 Jul 2019 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2019-07-01-bury/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;https://manueluberti.eu/posts/2019-06-21-windows/&#34;&gt;Last time&lt;/a&gt; I refactored my windows restoring
configuration in order to pass the prefix argument around. This is a nice
solution to leverage my wrappers for commands like &lt;code&gt;shell&lt;/code&gt;, but I can push it a
little further.&lt;/p&gt;
&lt;p&gt;I have already discussed &lt;a href=&#34;https://manueluberti.eu/posts/2018-02-24-restore-windows/&#34;&gt;a couple of functions&lt;/a&gt; to restore my windows configuration when
I exit a fullframed buffer.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defun mu-restore-window-configuration (config)
  &amp;quot;Kill current buffer and restore window configuration in CONFIG.&amp;quot;
  (interactive)
  (kill-this-buffer)
  (set-window-configuration config))

(defun mu-pop-window-configuration ()
  &amp;quot;Restore previous window configuration and clear current window.&amp;quot;
  (interactive)
  (let ((config (pop mu-saved-window-configuration)))
    (if config
        (mu-restore-window-configuration config)
      (if (&amp;gt; (length (window-list)) 1)
          (delete-window)
        (bury-buffer)))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;However, with these functions the buffer I am leaving gets killed. This is fine
when moving away from, say, Ibuffer or Paradox, but it&amp;rsquo;s less than optimal for
shell buffers which may be running a long-run process.&lt;/p&gt;
&lt;p&gt;Once again, the prefix argument can help:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defun mu--restore-window-configuration (config &amp;amp;optional bury-buffer)
  &amp;quot;Kill current buffer and restore the window configuration in CONFIG.
With BURY-BUFFER bury the buffer instead of killing it.&amp;quot;
  (if bury-buffer
      (bury-buffer)
    (kill-this-buffer))
  (set-window-configuration config))

(defun mu-pop-window-configuration (&amp;amp;optional bury-buffer)
  &amp;quot;Restore the previous window configuration and clear current window.
With BURY-BUFFER bury the buffer instead of killing it.&amp;quot;
  (interactive &amp;quot;P&amp;quot;)
  (let ((config (pop mu--saved-window-configuration)))
    (if config
        (mu--restore-window-configuration config bury-buffer)
      (if (&amp;gt; (length (window-list)) 1)
          (delete-window)
        (bury-buffer)))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now that the functions can make use of the prefix argument, I just need to call
them properly from a shell buffer:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defun mu-shell-bury ()
  &amp;quot;Bury the shell window.&amp;quot;
  (interactive)
  (let ((current-prefix-arg 4))
    (call-interactively #&#39;mu-pop-window-configuration)))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I&amp;rsquo;ve bound this to &lt;code&gt;C-c C-q&lt;/code&gt;, so I can still kill a shell buffer
using &lt;code&gt;C-x k&lt;/code&gt; (&lt;code&gt;kill-this-buffer&lt;/code&gt; in my configuration) if needed.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Passing the prefix argument around</title>
      <link>https://manueluberti.eu/posts/2019-06-21-windows/</link>
      <pubDate>Fri, 21 Jun 2019 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2019-06-21-windows/</guid>
      <description>&lt;p&gt;Last year I blogged about a solution to a common problem I had with &lt;a href=&#34;https://manueluberti.eu/posts/2018-03-03-winner-undo/&#34;&gt;windows in
Emacs&lt;/a&gt;. I wanted to be able to exit
particular fullframed buffers and restore the windows as they were before
opening those buffers.&lt;/p&gt;
&lt;p&gt;The core of my solution is the following function:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defun mu-save-wins-then-call (func &amp;amp;optional args)
  &amp;quot;Save current window configuration, then call FUNC optionally with ARGS.&amp;quot;
  (interactive)
  (push (current-window-configuration) mu-saved-window-configuration)
  (cond
   ;; We have arguments for the function
   ((bound-and-true-p args) (funcall func args))
   ;; The function requires exactly one argument, and we want it to be nil
   ((equal args &amp;quot;nil&amp;quot;) (funcall func nil))
   ;; The function does not expect arguments
   (t (funcall func))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This function works fine for most of my cases, but it doesn&amp;rsquo;t take the &lt;a href=&#34;https://www.gnu.org/software/emacs/manual/html_node/elisp/Prefix-Command-Arguments.html&#34;&gt;prefix
argument&lt;/a&gt;
into account. Since I rely heavily on &lt;code&gt;shell-mode&lt;/code&gt;, at times I need to open more
than one shell buffer, and the documentation of the &lt;code&gt;shell&lt;/code&gt; command specifies
that the prefix argument can be used to open new buffers on demand:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Run an inferior shell, with I/O through BUFFER (which defaults to `&lt;em&gt;shell&lt;/em&gt;&#39;).
Interactively, a prefix arg means to prompt for BUFFER.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Hence, I need to mimic &lt;code&gt;C-u M-x&lt;/code&gt; &lt;code&gt;shell&lt;/code&gt; in
&lt;code&gt;mu-save-wins-then-call&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defun mu-save-wins-then-call (func &amp;amp;optional args)
  &amp;quot;Save current window configuration, then call FUNC optionally with ARGS.&amp;quot;
  (interactive &amp;quot;P&amp;quot;)
  (push (current-window-configuration) mu--saved-window-configuration)
  (cond
   ;; We have the prefix argument
   ((= (prefix-numeric-value args) 4)
    (let ((current-prefix-arg 4))
      (call-interactively func)))
   ;; We have arguments for the function
   ((or (bound-and-true-p args) 
        (stringp args)) 
    (funcall func args))
   ;; The function does not expect arguments
   (t (funcall func))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now I can open as many fullframed shell buffers as I want with &lt;code&gt;C-u F1&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defun mu-shell-open (&amp;amp;optional new-buffer)
  &amp;quot;Save window configuration and call `shell&#39;.
With NEW-BUFFER open a new buffer.&amp;quot;
  (interactive &amp;quot;P&amp;quot;)
  (mu-save-wins-then-call #&#39;shell new-buffer))

(with-eval-after-load &#39;shell
  (fullframe shell mu-pop-window-configuration))

(bind-key &amp;quot;&amp;lt;f1&amp;gt;&amp;quot; mu-shell-open)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;mu-pop-window-configuration&lt;/code&gt; is detailed over at &lt;a href=&#34;https://manueluberti.eu/posts/2018-02-24-restore-windows/&#34;&gt;Restoring the window
configuration in Emacs&lt;/a&gt;.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Better colours in Emacs shell</title>
      <link>https://manueluberti.eu/posts/2019-06-14-xterm/</link>
      <pubDate>Fri, 14 Jun 2019 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2019-06-14-xterm/</guid>
      <description>&lt;p&gt;I have ve been using &lt;code&gt;shell-mode&lt;/code&gt; regularly for almost &lt;a href=&#34;https://manueluberti.eu/posts/2017-10-07-m-x-shell/&#34;&gt;two years&lt;/a&gt; now. It has helped me a lot in staying focused on
what I&amp;rsquo;ve been doing in Emacs instead of switching back and forth between the
buffer and GNOME Terminal.&lt;/p&gt;
&lt;p&gt;A recent discovery made &lt;code&gt;shell-mode&lt;/code&gt; even snappier and more pleasant to use:
&lt;a href=&#34;https://github.com/atomontage/xterm-color&#34;&gt;xterm-color&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;By simply following the guidelines in the README you get a working setup for
&lt;code&gt;shell-mode&lt;/code&gt;. Note that there are also examples for EShell and compilation
buffers, so it&amp;rsquo;s up to you to decide where you want to use &lt;code&gt;xterm-color&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Honestly I complied. I only changed the default colours to match those of my
&lt;a href=&#34;https://github.com/purcell/color-theme-sanityinc-tomorrow&#34;&gt;favourite theme&lt;/a&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defvar mu--tomorrow-night-colours [&amp;quot;#1d1f21&amp;quot; &amp;quot;#cc6666&amp;quot;
                                    &amp;quot;#b5bd68&amp;quot; &amp;quot;#f0c674&amp;quot;
                                    &amp;quot;#81a2be&amp;quot; &amp;quot;#b294bb&amp;quot;
                                    &amp;quot;#8abeb7&amp;quot; &amp;quot;#c5c8c6&amp;quot;])
(setq xterm-color-names mu--tomorrow-night-colours
      xterm-color-names-bright mu--tomorrow-night-colours)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;By the way, the &lt;code&gt;ls&lt;/code&gt; &lt;a href=&#34;https://manueluberti.eu/posts/2017-10-07-m-x-shell/&#34;&gt;alias&lt;/a&gt; I was using is
not needed any more.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>It never occurred to me</title>
      <link>https://manueluberti.eu/posts/2019-05-14-occur/</link>
      <pubDate>Tue, 14 May 2019 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2019-05-14-occur/</guid>
      <description>&lt;p&gt;Years of Emacs, and I am still learning something new that improves my daily
workflow.&lt;/p&gt;
&lt;p&gt;Recently I&amp;rsquo;ve had to deal with CSV files, generated by a little Clojure program
using data from different databases. The CSV files are then imported in another
database through a new shiny application bought by our customer. Data
integration, exactly.&lt;/p&gt;
&lt;p&gt;While the data extraction is just a matter of SQL queries, the CSV files must
match the stringent requirements of the new application. We ended up with messy
CSV files, close but not &lt;em&gt;that&lt;/em&gt; close to the expected results. Needless to say,
sometimes we have to edit the files manually, and this is where Emacs once again
shines.&lt;/p&gt;
&lt;p&gt;The problem is simple: how can I list only the matches I am looking for in a CSV
file, without printing the whole lines the matches belong to? I need a clean
list of occurrences, nothing more, because debugging these files is already
painful as it is.&lt;/p&gt;
&lt;p&gt;I am so used to &lt;a href=&#34;https://github.com/abo-abo/swiper&#34;&gt;swiper-isearch&lt;/a&gt; and
&lt;a href=&#34;https://github.com/abo-abo/swiper&#34;&gt;counsel-rg&lt;/a&gt; that I tend to forget Emacs
built-in &lt;a href=&#34;https://doc.endlessparentheses.com/Fun/occur.html&#34;&gt;occur&lt;/a&gt;. As per the
documentation:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;When NLINES is a string or when the function is called interactively with
prefix argument without a number (`C-u&#39; alone as prefix) the matching
strings are collected into the *Occur* buffer by using NLINES as a
replacement regexp.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Hence, I just need to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;press &lt;code&gt;C-u M-s o&lt;/code&gt; (or the equivalent but longish of &lt;code&gt;C-u M-x&lt;/code&gt; &lt;code&gt;occur&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;type the string I am looking for&lt;/li&gt;
&lt;li&gt;hit &lt;code&gt;RET&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;It doesn&amp;rsquo;t get easier than this.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Switching buffers (Take 2)</title>
      <link>https://manueluberti.eu/posts/2019-03-16-switch-buffers/</link>
      <pubDate>Sat, 16 Mar 2019 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2019-03-16-switch-buffers/</guid>
      <description>&lt;p&gt;Last month I wrote about the neat &lt;a href=&#34;https://manueluberti.eu/posts/2019-02-05-nswbuff/&#34;&gt;nswbuff&lt;/a&gt;,
but there is another way to implement buffer switching without introducing a new
package.&lt;/p&gt;
&lt;p&gt;Since I already use counsel-projectile, why not leverage it to my needs?&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defun mu-switch-to-project-buffer-if-in-project (arg)
    &amp;quot;Custom switch to buffer.
With universal argument ARG or when not in project, rely on
`ivy-switch-buffer&#39;.
Otherwise, use `counsel-projectile-switch-to-buffer&#39;.&amp;quot;
    (interactive &amp;quot;P&amp;quot;)
    (if (or arg
            (not (projectile-project-p)))
        (ivy-switch-buffer)
      (counsel-projectile-switch-to-buffer)))

(bind-key* &amp;quot;C-x b&amp;quot; #&#39;mu-switch-to-project-buffer-if-in-project)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Pretty self-explanatory. By default, when not in a project
&lt;code&gt;counsel-projectile-switch-to-buffer&lt;/code&gt; asks you for the project to switch to.&lt;/p&gt;
&lt;p&gt;However, if I am not in a project chances are I want to switch to a buffer that
doesn&amp;rsquo;t belong to a project, especially since I usually enter a project before
switching to one of its buffers.&lt;/p&gt;
&lt;p&gt;nswbuff has previews and back-and-forth navigation, so it still offers a nicer
solution to buffer switching. This is Emacs, of course, so you know the deal:
endless possibilities.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Jump around</title>
      <link>https://manueluberti.eu/posts/2019-02-14-avy/</link>
      <pubDate>Thu, 14 Feb 2019 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2019-02-14-avy/</guid>
      <description>&lt;p&gt;Last time I shared my preferred choice for &lt;a href=&#34;https://manueluberti.eu/posts/2019-02-05-nswbuff/&#34;&gt;buffer switching&lt;/a&gt;, so let&amp;rsquo;s keep jumping around. The House of Pain
reference is a bit tacky, I know, but 90s nostalgia is still flying pretty high
from what I&amp;rsquo;ve heard.&lt;/p&gt;
&lt;p&gt;Quickly moving in a buffer is something every Emacs knight do multiple times a
day. I distinguish in-buffer jumps in two tags:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;jumps that encompass all the buffer content&lt;/li&gt;
&lt;li&gt;jumps limited to what is currently visible&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The first movements are covered by Oleh Krehel&amp;rsquo;s Swiper, but I am more
interested in the second kind of jumps this time. There are plenty of solutions
both bundled in Emacs (e.g., pop/mark commands) and in the wild. My favourite is
Avy, again from Oleh Krehel.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(use-package avy-jump                   ; Jump to characters in buffers
  :ensure avy
  :bind ((&amp;quot;C-j&amp;quot; . avy-goto-char-in-line)
         (&amp;quot;M-j&amp;quot; . avy-goto-char)))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As it always happens with Oleh&amp;rsquo;s packages, &lt;code&gt;avy&lt;/code&gt; is well-documented, easy to
extend, and full of useful commands. I only added bindings for the ones I use
the most, and I really use these two all the time.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;avy-goto-char&lt;/code&gt; allows me to move anywhere following the character I am after.
It&amp;rsquo;s quicker than typing the whole candidate in Swiper, and obviously better
than manually moving
&lt;a href=&#34;https://www.gnu.org/software/emacs/manual/html_node/emacs/Point.html&#34;&gt;point&lt;/a&gt;
with &lt;code&gt;C-p&lt;/code&gt;/&lt;code&gt;C-n&lt;/code&gt; or, worse, the arrow keys.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;avy-goto-char-in-line&lt;/code&gt; behaves in much the same way, but it is limited to the
current line. If you remember &lt;code&gt;iy-go-to-char&lt;/code&gt; mentioned years ago on &lt;a href=&#34;https://emacsrocks.com/e04.html&#34;&gt;Emacs
Rocks&lt;/a&gt;, this is Oleh&amp;rsquo;s own variant.&lt;/p&gt;
&lt;p&gt;Both commands push point to the &lt;code&gt;mark-ring&lt;/code&gt;, so the default Emacs key binding
&lt;code&gt;C-u C-SPC&lt;/code&gt; takes you back to your original position.&lt;/p&gt;
&lt;p&gt;However, there is an even quicker alternative when I want to jump between
occurrences of the symbol where point currently is, which turns out to be pretty
handy when coding.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(use-package symbol-overlay             ; Highlight symbols
  :ensure t
  :bind (:map symbol-overlay-mode-map
              (&amp;quot;M-h&amp;quot; . symbol-overlay-put)
              (&amp;quot;M-n&amp;quot; . symbol-overlay-jump-next)
              (&amp;quot;M-p&amp;quot; . symbol-overlay-jump-prev))
  :hook ((conf-mode . symbol-overlay-mode)
         (html-mode . symbol-overlay-mode)
         (prog-mode . symbol-overlay-mode)
         (yaml-mode . symbol-overlay-mode)))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Symbol Overlay not only highlights all the occurrences of the current symbol,
but it lets you move quickly among them with &lt;code&gt;symbol-overlay-jump-prev&lt;/code&gt; and
&lt;code&gt;symbol-overlay-jump-next&lt;/code&gt; without asking for a character to look for.&lt;/p&gt;
&lt;p&gt;Moreover, Symbol Overlay works on all the buffer content, so in this particular
case is quicker than Swiper too.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Switching buffers</title>
      <link>https://manueluberti.eu/posts/2019-02-05-nswbuff/</link>
      <pubDate>Tue, 05 Feb 2019 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2019-02-05-nswbuff/</guid>
      <description>&lt;p&gt;One of the most valuable packages I rely on everyday is
&lt;a href=&#34;https://github.com/ericdanan/counsel-projectile&#34;&gt;counsel-projectile&lt;/a&gt;. Combining
the power of &lt;a href=&#34;https://github.com/abo-abo/swiper&#34;&gt;counsel&lt;/a&gt; and
&lt;a href=&#34;https://github.com/bbatsov/projectile&#34;&gt;Projectile&lt;/a&gt;, this great work from Eric
Danan has been governing my project management in Emacs for quite a while.&lt;/p&gt;
&lt;p&gt;One nifty feature of &lt;code&gt;counsel-projectile&lt;/code&gt; is
&lt;code&gt;counsel-projectile-switch-to-buffer&lt;/code&gt;, bound to &lt;code&gt;C-c p b&lt;/code&gt;, which lets
you pick the buffer to switch to from the current project&amp;rsquo;s open buffers.&lt;/p&gt;
&lt;p&gt;However, old habits never die. Years and years of &lt;code&gt;Ctrl-TAB&lt;/code&gt; and
&lt;code&gt;Ctrl-Shift-TAB&lt;/code&gt; in my web browser window are hard to forget. And so
enters Joost Kremers&amp;rsquo; &lt;a href=&#34;https://github.com/joostkremers/nswbuff&#34;&gt;nswbuff&lt;/a&gt;.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(use-package nswbuff                    ; Quick switching between buffers
  :ensure t
  :bind* ((&amp;quot;&amp;lt;C-tab&amp;gt;&amp;quot;           . nswbuff-switch-to-next-buffer)
          (&amp;quot;&amp;lt;C-S-iso-lefttab&amp;gt;&amp;quot; . nswbuff-switch-to-previous-buffer))
  :config (setq nswbuff-buffer-list-function #&#39;nswbuff-projectile-buffer-list
                nswbuff-display-intermediate-buffers t
                nswbuff-exclude-buffer-regexps &#39;(&amp;quot;^ .*&amp;quot; &amp;quot;^\\*.*\\*&amp;quot;)))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;del&gt;I am loading it from a specific path, because at the time of this writing &lt;a href=&#34;https://github.com/melpa/melpa/pull/6005&#34;&gt;the
package is not on MELPA&lt;/a&gt;.&lt;/del&gt;&lt;/p&gt;
&lt;p&gt;The key setting here is the value of &lt;code&gt;nswbuff-buffer-list-function&lt;/code&gt;. Using
&lt;code&gt;nswbuff-projectile-buffer-list&lt;/code&gt; activates &lt;code&gt;nswbuff&lt;/code&gt; integration with
&lt;code&gt;Projectile&lt;/code&gt;, and so I can quickly move between my project buffers hitting the
good ol&amp;rsquo; &lt;code&gt;Ctrl-TAB&lt;/code&gt;.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Make your company behave</title>
      <link>https://manueluberti.eu/posts/2019-01-17-company-on-demand/</link>
      <pubDate>Thu, 17 Jan 2019 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2019-01-17-company-on-demand/</guid>
      <description>&lt;p&gt;Sometimes it just takes a little thing to make your day.&lt;/p&gt;
&lt;p&gt;I have been using &lt;a href=&#34;https://company-mode.github.io/&#34;&gt;company-mode&lt;/a&gt; for ages,
becoming accustomed to the list of candidates popping up whenever the automatic
completion kicks in.&lt;/p&gt;
&lt;p&gt;However, more often than not what I need is in-buffer, context-aware completion,
and in this case &lt;code&gt;dabbrev-expand&lt;/code&gt; or &lt;code&gt;dabbrev-completion&lt;/code&gt;, which I have bound to
&lt;code&gt;C-,&lt;/code&gt; and &lt;code&gt;C-.&lt;/code&gt; respectively, are enough.&lt;/p&gt;
&lt;p&gt;It&amp;rsquo;s pretty simple to turn off &lt;code&gt;company-mode&lt;/code&gt; automatic completion:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(setq company-idle-delay nil)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;That&amp;rsquo;s it.&lt;/p&gt;
&lt;p&gt;To get the list of candidates back when I need, I have &lt;code&gt;company-complete&lt;/code&gt; bound
to &lt;code&gt;C-c c&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Nice and easy.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Playing hide-and-seek with my REPLs</title>
      <link>https://manueluberti.eu/posts/2018-12-19-hide-repl/</link>
      <pubDate>Wed, 19 Dec 2018 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2018-12-19-hide-repl/</guid>
      <description>&lt;p&gt;Emacs users know their beloved editor has a penchant for throwing windows and
buffers around. Smart Emacs users know how to make Emacs behave with a careful
configuration of
&lt;a href=&#34;http://doc.endlessparentheses.com/Var/display-buffer-alist.html&#34;&gt;display-buffer-alist&lt;/a&gt;.
For instance, I like to have all of my REPLs in a bottom side window, taking up
half of the screen size.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(setq display-buffer-alist
      `((,(rx bos (or &amp;quot;*cider-repl&amp;quot;     ; CIDER REPL
                      &amp;quot;*intero&amp;quot;         ; Intero REPL
                      &amp;quot;*idris-repl&amp;quot;     ; Idris REPL
                      &amp;quot;*ielm&amp;quot;           ; IELM REPL
                      &amp;quot;*SQL&amp;quot;))          ; SQL REPL
         (display-buffer-reuse-window display-buffer-in-side-window)
         (side . bottom)
         (reusable-frames . visible)
         (window-height . 0.50))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I then have a couple of custom functions, lifted from &lt;a href=&#34;https://github.com/lunaryorn/old-emacs-configuration&#34;&gt;Sebastian
Wiesner&amp;rsquo;s archived
configuration&lt;/a&gt;, to quickly
close the REPL and go back to the buffer I was editing.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defun mu-find-side-windows (&amp;amp;optional side)
  &amp;quot;Get all side window if any.
If SIDE is non-nil only get windows on that side.&amp;quot;
  (let (windows)
    (walk-window-tree
     (lambda (window)
       (let ((window-side (window-parameter window &#39;window-side)))
         (when (and window-side (or (not side) (eq window-side side)))
           (push window windows)))))
    windows))

;;;###autoload
(defun mu-quit-side-windows ()
  &amp;quot;Quit side windows of the current frame.&amp;quot;
  (interactive)
  (dolist (window (mu-find-side-windows))
    (when (window-live-p window)
      (quit-window nil window)
      ;; When the window is still live, delete it
      (when (window-live-p window)
        (delete-window window)))))

(bind-key &amp;quot;C-c w q&amp;quot; #&#39;mu-quit-side-windows)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;All of this usually works fine. However,
&lt;a href=&#34;https://github.com/clojure-emacs/cider&#34;&gt;CIDER&lt;/a&gt; has recently introduced a new
&lt;a href=&#34;https://github.com/vspinu/sesman&#34;&gt;session system&lt;/a&gt; which doesn&amp;rsquo;t play well with
this setup. Basically, using &lt;code&gt;quit-window&lt;/code&gt; on a CIDER REPL results in a buffer
without its related REPL available.&lt;/p&gt;
&lt;p&gt;The solution is trivial.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;;;;###autoload
(defun mu-hide-side-windows ()
  &amp;quot;Hide side windows of the current frame.&amp;quot;
  (interactive)
  (dolist (window (mu-find-side-windows))
    (when (window-live-p window)
      (delete-window window))))

(bind-key &amp;quot;C-c w h&amp;quot; #&#39;mu-hide-side-windows)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now I just hide the side windows of the current buffer, and the linked REPL is
always a key binding away.&lt;/p&gt;
&lt;p&gt;Notice that if you are only visiting one buffer and a REPL, pressing &lt;code&gt;C-x 0&lt;/code&gt; in
the REPL window or &lt;code&gt;C-x 1&lt;/code&gt; in the buffer where the REPL window was opened has
the same effect of &lt;code&gt;C-c w h&lt;/code&gt;.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>What’s the theme?</title>
      <link>https://manueluberti.eu/posts/2018-06-01-get-colour-theme/</link>
      <pubDate>Fri, 01 Jun 2018 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2018-06-01-get-colour-theme/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;https://manueluberti.eu/posts/2018-05-25-display-version/&#34;&gt;Last time&lt;/a&gt; I explained how to display
your Emacs version with extra useful details. I closed the article saying that
there could be more interesting stuff to display, and here I am with something
new.&lt;/p&gt;
&lt;p&gt;Sometimes I happen to report &lt;a href=&#34;https://github.com/clojure-emacs/clojure-mode/issues/474&#34;&gt;missing
font-locking&lt;/a&gt; or other
small issues with faces in a mode I use. Why not have my current colour theme
name displayed along with the bits and pieces gathered in the previous article?&lt;/p&gt;
&lt;p&gt;As Steve Purcell explained &lt;a href=&#34;https://superuser.com/a/320289&#34;&gt;on StackExchange&lt;/a&gt;,
the concept of &lt;em&gt;current theme&lt;/em&gt; is a bit fuzzy in Emacs. You can have multiple
themes on at the same time, just have a look at &lt;code&gt;M-x&lt;/code&gt;
&lt;code&gt;customize-themes&lt;/code&gt;. Moreover, activating a theme means applying its settings to
the faces and variables it specifies.&lt;/p&gt;
&lt;p&gt;Thus I came up with this little function:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defun mu--colour-theme ()
  &amp;quot;Get the currently applied colour theme.&amp;quot;
  (replace-regexp-in-string
   &amp;quot;[\t\n\r ]+&amp;quot; &amp;quot;&amp;quot;
   (let* ((command (concat &amp;quot;rg load-theme &amp;quot; user-emacs-directory))
          (res (shell-command-to-string command)))
     (nth 1 (split-string res &amp;quot;&#39;&amp;quot;)))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Basically I run &lt;code&gt;ripgrep&lt;/code&gt; in my &lt;code&gt;.emacs.d&lt;/code&gt; to get the lines containing
&lt;code&gt;load-theme&lt;/code&gt;. Obviously this will return the line in &lt;code&gt;mu–-colour-theme&lt;/code&gt; as well.
However, since I use &lt;code&gt;split-string&lt;/code&gt; with &lt;code&gt;&#39;&lt;/code&gt; as separator I can get the element
I need from the result of &lt;code&gt;ripgrep&lt;/code&gt;. &lt;code&gt;nth 1&lt;/code&gt; gives me what I am looking for:
&lt;code&gt;sanityinc-tomorrow-night&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Now I can have the active colour theme displayed in my environment details
buffer:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;;;;###autoload
(defun mu-env-info ()
  &amp;quot;Display Emacs version and system details in a temporary buffer.&amp;quot;
  (interactive)
  (let ((buffer-name &amp;quot;*env-info*&amp;quot;))
    (with-help-window buffer-name
      (with-current-buffer buffer-name
        (insert (emacs-version) &amp;quot;\n\n&amp;quot;)
        (insert &amp;quot;Repository revision: &amp;quot; emacs-repository-version &amp;quot;\n&amp;quot;)
        (when (and system-configuration-options
                   (not (equal system-configuration-options &amp;quot;&amp;quot;)))
          (insert &amp;quot;Configured using:\n&amp;quot;
                  system-configuration-options))
        (insert &amp;quot;\n\nEmacs uptime: &amp;quot; (emacs-uptime) &amp;quot;\n&amp;quot;)
        (insert &amp;quot;Colour theme: &amp;quot; (mu--colour-theme) &amp;quot;\n&amp;quot;)
        (insert &amp;quot;Operating system: &amp;quot; (mu--os-version) &amp;quot;\n&amp;quot;)
        (insert &amp;quot;Window system: &amp;quot; (getenv &amp;quot;XDG_SESSION_TYPE&amp;quot;) &amp;quot;\n&amp;quot;)
        (insert &amp;quot;Desktop environment: &amp;quot; (mu--gnome-version))))))
&lt;/code&gt;&lt;/pre&gt;
</description>
    </item>
    <item>
      <title>A fancy Emacs version</title>
      <link>https://manueluberti.eu/posts/2018-05-25-display-version/</link>
      <pubDate>Fri, 25 May 2018 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2018-05-25-display-version/</guid>
      <description>&lt;p&gt;If you like to play diligently and kindly with the Emacs community, you will end
up reporting bugs or asking for new features to your favourite package
maintainers.&lt;/p&gt;
&lt;p&gt;My skills at bug reporting have improved over the years. From the angry &lt;em&gt;“it
doesn&amp;rsquo;t work, man!!1!”&lt;/em&gt; to more polite questions, I am always looking for better
reports to help debug and solve the problems I encounter.&lt;/p&gt;
&lt;p&gt;Usually, package maintainers ask you to reproduce the bug in a clean &lt;code&gt;emacs -Q&lt;/code&gt;
environment. And that&amp;rsquo;s good. But they are also happy when you provide as much
information as possible about the system you are using.&lt;/p&gt;
&lt;p&gt;That&amp;rsquo;s why I came up with a custom function to gather details about my Emacs
version and where I am running it. It all started with &lt;a href=&#34;https://emacs.stackexchange.com/questions/35497/does-emacs-have-an-option-to-display-build-settings/35500#35500&#34;&gt;this
answer&lt;/a&gt;
from Drew Adams on Emacs StackExchange. His code does way much more than I need,
though, so I stripped down the inessential and turned everything into this:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defun mu--os-version ()
  &amp;quot;Call `lsb_release&#39; to retrieve OS version.&amp;quot;
  (replace-regexp-in-string
   &amp;quot;Description:\\|[\t\n\r]+&amp;quot; &amp;quot;&amp;quot;
   (shell-command-to-string &amp;quot;lsb_release -d&amp;quot;)))

(defun mu--gnome-version ()
  &amp;quot;Call `gnome-shell&#39; to retrieve GNOME version.&amp;quot;
  (replace-regexp-in-string
   &amp;quot;[\t\n\r]+&amp;quot; &amp;quot;&amp;quot;
   (shell-command-to-string &amp;quot;gnome-shell --version&amp;quot;)))

;;;###autoload
(defun mu-display-version ()
  &amp;quot;Display Emacs version and system details in a temporary buffer.&amp;quot;
  (interactive)
  (let ((buffer-name &amp;quot;*version*&amp;quot;))
    (with-help-window buffer-name
      (with-current-buffer buffer-name
        (insert (emacs-version) &amp;quot;\n&amp;quot;)
        (insert &amp;quot;\nRepository revision: &amp;quot; emacs-repository-version &amp;quot;\n&amp;quot;)
        (when (and system-configuration-options
                   (not (equal system-configuration-options &amp;quot;&amp;quot;)))
          (insert &amp;quot;\nConfigured using:\n&amp;quot;
                  system-configuration-options))
        (insert &amp;quot;\n\nOperating system: &amp;quot; (mu--os-version) &amp;quot;\n&amp;quot;)
        (insert &amp;quot;Window system: &amp;quot; (getenv &amp;quot;XDG_SESSION_TYPE&amp;quot;) &amp;quot;\n&amp;quot;)
        (insert &amp;quot;Desktop environment: &amp;quot; (mu--gnome-version))))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;By using &lt;code&gt;M-x&lt;/code&gt; &lt;code&gt;mu-display-version&lt;/code&gt; I now get a handy temporary
buffer with all the details I want.&lt;/p&gt;
&lt;p&gt;&lt;figure&gt;
  &lt;img src=&#34;https://manueluberti.eu/images/version.png&#34; alt=&#34;&#34;&gt;
  &lt;figcaption class=&#34;center&#34;&gt;
    &lt;small&gt;&lt;em&gt;&lt;/em&gt;&lt;/small&gt;    
  &lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/p&gt;
&lt;p&gt;A simple &lt;code&gt;q&lt;/code&gt; will close the buffer, and I am pretty sure I can add more
useful stuff in there. For now, it suffices.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Beauty lies in the segments of the mode line</title>
      <link>https://manueluberti.eu/posts/2018-03-10-moody-and-minions/</link>
      <pubDate>Sat, 10 Mar 2018 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2018-03-10-moody-and-minions/</guid>
      <description>&lt;p&gt;Since I basically spend much of my computing in Emacs, it&amp;rsquo;s no surprise I have
come to love customizing it. One Emacs facet I keep returning to is the mode
line.&lt;/p&gt;
&lt;p&gt;To be honest, it&amp;rsquo;s hard to remember everything I tried on this little but very
useful tool. For a long while &lt;code&gt;smart-mode-line&lt;/code&gt; has been my go-to package.
I considered &lt;code&gt;powerline&lt;/code&gt; briefly, but even &lt;code&gt;spaceline&lt;/code&gt; didn&amp;rsquo;t last long.
Eventually, I rolled my own spin and never looked for an external solution
again.&lt;/p&gt;
&lt;p&gt;Recently, Jonas Bernoulli — of Magit fame — unveiled two new packages expressly
dedicated to the mode line: &lt;code&gt;minions&lt;/code&gt; and &lt;code&gt;moody&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Ever being annoyed by the long list of minor modes taking up precious space? Or
are you just tired of adding &lt;code&gt;:diminish&lt;/code&gt; every time you install a new package
via &lt;code&gt;use-package&lt;/code&gt;? &lt;code&gt;minions&lt;/code&gt; to the rescue.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;minions&lt;/code&gt; replaces the minor mode list with a customizable lighter, which upon
click reveals a menu with an entry for every minor mode available. You can
enable or disable a specific mode or explore its settings in a breeze. &lt;code&gt;minions&lt;/code&gt;
reduces the clutter while making it easier to check on your minor modes.&lt;/p&gt;
&lt;p&gt;On the other hand, &lt;code&gt;moody&lt;/code&gt; is for the true artist. I love sparkling Emacs with
some beauty, but as much as &lt;code&gt;sanityinc-tomorrow-night&lt;/code&gt; helps me with that,
I haven&amp;rsquo;t been able to accomplish something really satisfying with the mode line
before trying &lt;code&gt;moody&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;figure&gt;
  &lt;img src=&#34;https://manueluberti.eu/images/modeline.png&#34; alt=&#34;&#34;&gt;
  &lt;figcaption class=&#34;center&#34;&gt;
    &lt;small&gt;&lt;em&gt;&lt;/em&gt;&lt;/small&gt;    
  &lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/p&gt;
&lt;p&gt;Now look at that. It &lt;em&gt;feels&lt;/em&gt; awesome.&lt;/p&gt;
&lt;p&gt;The number &lt;code&gt;2&lt;/code&gt; on the left is my little variation on the Eyebrowse segment I
found in &lt;code&gt;spaceline&lt;/code&gt;.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Refactoring my windows restoring solution</title>
      <link>https://manueluberti.eu/posts/2018-03-03-winner-undo/</link>
      <pubDate>Sat, 03 Mar 2018 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2018-03-03-winner-undo/</guid>
      <description>&lt;p&gt;Following &lt;a href=&#34;https://manueluberti.eu/posts/2018-02-24-restore-windows/&#34;&gt;my last article&lt;/a&gt; on
restoring window configurations with custom functions, Clément Pit-Claudel got
in touch with me and suggested a little improvement. Clément pointed out the
built-in Emacs command &lt;code&gt;winner-undo&lt;/code&gt;, which I promptly used to simplify my
solution.&lt;/p&gt;
&lt;p&gt;Let&amp;rsquo;s enable &lt;code&gt;winner-mode&lt;/code&gt;, first, because &lt;code&gt;winner-undo&lt;/code&gt; comes with it.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(use-package winner                     ; Restore old window configurations
  :init (winner-mode t))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;winner-mode&lt;/code&gt; automatically takes care of storing window configurations, thus
I can safely remove functions like &lt;code&gt;mu-ibuffer-open&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defun mu-ibuffer-open ()
  &amp;quot;Open Ibuffer after storing the current window configuration.&amp;quot;
  (interactive)
  (mu-push-window-configuration)
  (ibuffer))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now I only need to call &lt;code&gt;winner-undo&lt;/code&gt; when I exit the desired, &lt;em&gt;fullframed&lt;/em&gt;
buffer.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defun mu-pop-window-configuration ()
  &amp;quot;Kill current buffer and restore the previous window configuration.&amp;quot;
  (interactive)
  (kill-this-buffer)
  (let ((inhibit-message t))
    (winner-undo)))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I wrapped &lt;code&gt;(winner-undo)&lt;/code&gt; with &lt;code&gt;(inhibit-message t)&lt;/code&gt; to get rid of the
superfluous message about the restored window configuration number.&lt;/p&gt;
&lt;p&gt;This is a much cleaner solution. I still have to use &lt;code&gt;fullframe&lt;/code&gt;, of course, but
by reusing an inner Emacs functionality I get the same result with less code.&lt;/p&gt;
&lt;p&gt;However, this code has a problem. &lt;code&gt;winner-mode&lt;/code&gt; does not save the configuration
of a frame with a single window. In this case &lt;code&gt;winner-undo&lt;/code&gt; has nothing to
&lt;em&gt;undo&lt;/em&gt; and it usually takes me back to a completely different buffer than the
one I started from.&lt;/p&gt;
&lt;p&gt;Therefore I revised my functions and made them a bit more general. Basically,
I removed &lt;code&gt;mu-push-window-configuration&lt;/code&gt; and added &lt;code&gt;mu-save-wins-then-call&lt;/code&gt;.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defun mu-save-wins-then-call (func &amp;amp;optional args)
  &amp;quot;Save current window configuration, then call FUNC optionally with ARGS.&amp;quot;
  (interactive)
  (push (current-window-configuration) mu-saved-window-configuration)
  (cond
   ;; We have arguments for the function
   ((bound-and-true-p args) (funcall func args))
   ;; The function requires exactly one argument, and we want it to be nil
   ((equal args &amp;quot;nil&amp;quot;) (funcall func nil))
   ;; The function does not expect arguments
   (t (funcall func))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;&amp;quot;nil&amp;quot; &lt;/code&gt;check is kind of a hack just for &lt;code&gt;paradox-list-packages&lt;/code&gt;, which
expects one non-optional argument. Since &lt;code&gt;&amp;amp;optional args&lt;/code&gt; evaluates to &lt;code&gt;nil&lt;/code&gt;
when non present, I need the check to avoid calling &lt;code&gt;(funcall func)&lt;/code&gt; in this
particular case. I am sure there is a better solution, but I&amp;rsquo;ll leave that for
another time.&lt;/p&gt;
&lt;p&gt;Nonetheless, functions like the previously mentioned &lt;code&gt;mu-ibuffer-open&lt;/code&gt; becomes
cleaner.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defun mu-ibuffer-open ()
  &amp;quot;Save window configuration and call `ibuffer&#39;.&amp;quot;
  (interactive)
  (mu-save-wins-then-call &#39;ibuffer))

(defun mu-elfeed-open ()
  &amp;quot;Save window configuration and call `elfeed&#39;.&amp;quot;
  (interactive)
  (mu-save-wins-then-call &#39;elfeed))

(defun mu-paradox-open ()
  &amp;quot;Save window configuration and call `paradox-list-packages&#39;.&amp;quot;
  (interactive)
  (mu-save-wins-then-call &#39;paradox-list-packages &amp;quot;nil&amp;quot;))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;With the help of &lt;code&gt;funcall&lt;/code&gt; I have a generic wrapper that can be applied wherever
I need.&lt;/p&gt;
&lt;p&gt;Thanks again to Clément Pit-Claudel who helped me dig further into my idea and
explore new paths.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Restoring the window configuration in Emacs</title>
      <link>https://manueluberti.eu/posts/2018-02-24-restore-windows/</link>
      <pubDate>Sat, 24 Feb 2018 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2018-02-24-restore-windows/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;https://manueluberti.eu/posts/2018-02-17-magit-bury-buffer/&#34;&gt;Last time&lt;/a&gt; I explained how
I customised Magit to kill its buffers upon quitting &lt;code&gt;magit-status&lt;/code&gt;. My solution
uses &lt;code&gt;magit-restore-window-configuration&lt;/code&gt;, which does exactly what the name
suggests. Wouldn&amp;rsquo;t it be great if a similar handy trick could be applied to any
Emacs functionality?&lt;/p&gt;
&lt;p&gt;Specifically:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;I&amp;rsquo;d like to run some modes in a window that takes up the whole frame&lt;/li&gt;
&lt;li&gt;I&amp;rsquo;d like to quit them with the previous window configuration completely
restored&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Two modes that I use daily would definitely become more pleasant: &lt;code&gt;ibuffer-mode&lt;/code&gt;
and &lt;code&gt;org-agenda-mode&lt;/code&gt;. Fortunately, the Emacs community has already devised
everything I need.&lt;/p&gt;
&lt;p&gt;First, I have to save the current window configuration.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defvar mu-saved-window-configuration nil)

(defun mu-push-window-configuration ()
  &amp;quot;Save current window configuration.&amp;quot;
  (interactive)
  (push (current-window-configuration) mu-saved-window-configuration))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I can now create a command to open the desired mode.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defun mu-ibuffer-open ()
  &amp;quot;Open Ibuffer after storing current window configuration.&amp;quot;
  (interactive)
  (mu-push-window-configuration)
  (ibuffer))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;A buffer can be visited in a single window per frame with &lt;code&gt;fullframe&lt;/code&gt;.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(with-eval-after-load &#39;ibuffer
    (fullframe ibuffer mu-pop-window-configuration))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The first argument to &lt;code&gt;fullframe&lt;/code&gt; indicates that I want the function &lt;code&gt;ibuffer&lt;/code&gt; to be
executed in a single window of the current frame. The second argument is the
command[^1] invoked when quitting Ibuffer, which will have to restore the
previous window configuration.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defun mu-restore-window-configuration (config)
  &amp;quot;Kill current buffer and restore window configuration in CONFIG.&amp;quot;
  (interactive)
  (kill-this-buffer)
  (set-window-configuration config))

(defun mu-pop-window-configuration ()
  &amp;quot;Restore previous window configuration and clear current window.&amp;quot;
  (interactive)
  (let ((config (pop mu-saved-window-configuration)))
    (if config
        (mu-restore-window-configuration config)
      (if (&amp;gt; (length (window-list)) 1)
          (delete-window)
        (bury-buffer)))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;These little functions are just my &lt;em&gt;personal take&lt;/em&gt; on the awesome gems I
discovered in &lt;a href=&#34;https://github.com/jwiegley/dot-emacs/commit/654e2dd5a8667cff58061c3212b787720fc04804&#34;&gt;John Wiegley&amp;rsquo;s Emacs
configuration&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Nothing can stop me now from applying the same pattern to any mode I want. Once
again, Emacs shows a degree of customizability second to none.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Exterminate Magit buffers</title>
      <link>https://manueluberti.eu/posts/2018-02-17-magit-bury-buffer/</link>
      <pubDate>Sat, 17 Feb 2018 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2018-02-17-magit-bury-buffer/</guid>
      <description>&lt;p&gt;Some say that Emacs users rarely kill buffers. Instead they smoothly dance away
to another buffer using their preferred switching mechanism, and just keep on
working with no hiccups whatsoever. In my case &lt;code&gt;ivy-switch-buffer&lt;/code&gt; is usually
doing all the the dancing, with Ibuffer coming in when the situation gets out of
hand.&lt;/p&gt;
&lt;p&gt;However, I do not enjoy having more open buffers than what I really need. Call
it obsessive-compulsive disorder, call it whatever you like, I want my buffers
list clean and on point.&lt;/p&gt;
&lt;p&gt;Magit has a penchant for open buffers. Jonas Bernoulli already explained &lt;a href=&#34;https://github.com/magit/magit/issues/2124#issuecomment-125987469&#34;&gt;the
reasoning&lt;/a&gt;
behind this behaviour, but he also suggested &lt;a href=&#34;https://emacs.stackexchange.com/a/35832/5514&#34;&gt;a
solution&lt;/a&gt; to clean up
Magit-related buffers when the work is done.&lt;/p&gt;
&lt;p&gt;Following Jonas&amp;rsquo; tip, this is what I devised:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defun mu-magit-kill-buffers (param)
  &amp;quot;Restore window configuration and kill all Magit buffers.&amp;quot;
  (let ((buffers (magit-mode-get-buffers)))
    (magit-restore-window-configuration)
    (mapc #&#39;kill-buffer buffers)))

(validate-setq magit-bury-buffer-function #&#39;mu-magit-kill-buffers)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The function is simple: first it collects the available Magit buffers, then
restores the window configuration as it was before calling &lt;code&gt;magit-status&lt;/code&gt;, and
finally applies &lt;code&gt;kill-buffer&lt;/code&gt; on the buffers previously collected. &lt;code&gt;kill-buffer&lt;/code&gt;
will not ask for confirmation, so now pressing &lt;code&gt;q&lt;/code&gt; in &lt;code&gt;magit-status&lt;/code&gt;
has the desired effect.&lt;/p&gt;
&lt;p&gt;Something is weird in that function, though. Why pass &lt;code&gt;param&lt;/code&gt; to
&lt;code&gt;mu-magit-kill-buffers&lt;/code&gt; if there is no need for it in the function body?&lt;/p&gt;
&lt;p&gt;Let&amp;rsquo;s break this down. The value of &lt;code&gt;magit-bury-buffer-function&lt;/code&gt; is a
function.[^1]&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defcustom magit-bury-buffer-function &#39;magit-restore-window-configuration
  &amp;quot;The function used to bury or kill the current Magit buffer.&amp;quot;
  :package-version &#39;(magit . &amp;quot;2.3.0&amp;quot;)
  :group &#39;magit-buffers
  :type &#39;(radio (function-item quit-window)
                (function-item magit-mode-quit-window)
                (function-item magit-restore-window-configuration)
                (function :tag &amp;quot;Function&amp;quot;)))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Looking at the code of &lt;code&gt;magit-restore-window-configuration&lt;/code&gt;, we can see that it
accepts an optional argument.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defun magit-restore-window-configuration (&amp;amp;optional kill-buffer)
  &amp;quot;Bury or kill the current buffer and restore previous window configuration.&amp;quot;
  (let ((winconf magit-previous-window-configuration)
        (buffer (current-buffer))
        (frame (selected-frame)))
    (quit-window kill-buffer (selected-window))
    (when (and winconf (equal frame (window-configuration-frame winconf)))
      (set-window-configuration winconf)
      (when (buffer-live-p buffer)
        (with-current-buffer buffer
          (setq magit-previous-window-configuration nil))))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Thus &lt;code&gt;param&lt;/code&gt; in &lt;code&gt;mu-magit-kill-buffers&lt;/code&gt; is only there to match the signature of the
function passed to &lt;code&gt;magit-bury-buffer-function&lt;/code&gt;. If I leave it out, I will get
this error message:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;magit-mode-bury-buffer: Wrong number of arguments: ((t) nil &amp;quot;Kill all Magit buffers.&amp;quot; (let ((buffers (magit-mode-get-buffers))) (magit-restore-window-configuration) (mapc #&#39;kill-buffer buffers))), 1
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you&amp;rsquo;re wondering why I am using the sharp quote (&lt;code&gt;#&#39;&lt;/code&gt;) when setting the value
of &lt;code&gt;magit-bury-buffer-function&lt;/code&gt;, you can simply trust the sage
&lt;a href=&#34;http://endlessparentheses.com/get-in-the-habit-of-using-sharp-quote.html&#34;&gt;advice&lt;/a&gt;
of Artur Malabarba.&lt;/p&gt;
&lt;p&gt;There is still one problem to solve. Setting &lt;code&gt;magit-bury-buffer-function&lt;/code&gt; this
way makes &lt;code&gt;q&lt;/code&gt; always kill &lt;em&gt;every&lt;/em&gt; Magit buffer. This is not what I need
when I am using, for instance, &lt;code&gt;magit-log-buffer-file&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Hence it&amp;rsquo;s better to make my custom function
&lt;a href=&#34;https://www.gnu.org/software/emacs/manual/html_node/elisp/Using-Interactive.html&#34;&gt;interactive&lt;/a&gt;
and apply it only for &lt;code&gt;magit-status-mode-map&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defun mu-magit-kill-buffers ()
  &amp;quot;Restore window configuration and kill all Magit buffers.&amp;quot;
  (interactive)
  (let ((buffers (magit-mode-get-buffers)))
    (magit-restore-window-configuration)
    (mapc #&#39;kill-buffer buffers)))

(bind-key &amp;quot;q&amp;quot; #&#39;mu-magit-kill-buffers magit-status-mode-map)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Bonus point: the unused &lt;code&gt;param&lt;/code&gt; is gone.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Refactoring power-ups</title>
      <link>https://manueluberti.eu/posts/2018-02-10-occur/</link>
      <pubDate>Sat, 10 Feb 2018 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2018-02-10-occur/</guid>
      <description>&lt;p&gt;Any programmer knows the importance of refactoring. It&amp;rsquo;s even hard to believe a
programmer can live without it. There are plenty of use cases for refactoring,
but the following happens often enough that I am glad Emacs sits next to me
every day.&lt;/p&gt;
&lt;p&gt;Imagine you are working on a medium-to-big size project. You have functions
everywhere, maybe constants here and there to make your life easier. Functional
programmers have no time for variables, so I won&amp;rsquo;t go down that road.&lt;/p&gt;
&lt;p&gt;At one point you discover a function that could use a different name. Clarity,
readability, or just mere kindness towards your fellow co-workers prompts you to
come up with something better. Naturally, the function is used in many places
around the codebase, so it&amp;rsquo;s time to bring out the heavy guns.&lt;/p&gt;
&lt;p&gt;There are plenty of ways to solve this problem, especially in Emacs, but this is
how I approach the situation:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;C-c p s r&lt;/code&gt; brings up &lt;code&gt;counsel-projectile-rg&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;If point is on the function name, I just hit &lt;code&gt;M-n&lt;/code&gt; to use it as the
search term, otherwise I type it in&lt;/li&gt;
&lt;li&gt;&lt;code&gt;C-c C-o&lt;/code&gt; now runs &lt;code&gt;ivy-occur&lt;/code&gt; and all the candidates end up in a
dedicated buffer&lt;/li&gt;
&lt;li&gt;&lt;code&gt;C-x C-q&lt;/code&gt;, bound to &lt;code&gt;ivy-wgrep-change-to-wgrep-mode&lt;/code&gt;, makes the new
buffer editable. It&amp;rsquo;s easy to remember because it&amp;rsquo;s the same key binding to
enable
&lt;a href=&#34;https://www.gnu.org/software/emacs/manual/html_node/emacs/Wdired.html&#34;&gt;Wdired&lt;/a&gt;
from Dired&lt;/li&gt;
&lt;li&gt;&lt;code&gt;C-s&lt;/code&gt; invokes &lt;code&gt;counsel-grep-or-swiper&lt;/code&gt; and I type in the function
name&lt;/li&gt;
&lt;li&gt;&lt;code&gt;M-q&lt;/code&gt; takes me to &lt;code&gt;swiper-query-replace&lt;/code&gt;, and I just need to enter
the new function name, hit &lt;code&gt;RET&lt;/code&gt; and then &lt;code&gt;C-c C-c&lt;/code&gt; to
confirm my modifications&lt;/li&gt;
&lt;li&gt;&lt;code&gt;C-x s&lt;/code&gt; followed by &lt;code&gt;!&lt;/code&gt; is all it takes now to save
the files involved in my refactoring&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If it looks like a lot to remember, well, it is. Only the first times,
though. After a while it becomes second nature, and editing an occurrence in
multiple files feels like a gentle breeze down your neck.&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://github.com/bbatsov/projectile&#34;&gt;Projectile&lt;/a&gt; and
&lt;a href=&#34;https://github.com/abo-abo/swiper&#34;&gt;Ivy/Counsel/Swiper&lt;/a&gt; are really invaluable
tools.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Inspecting log files with Emacs</title>
      <link>https://manueluberti.eu/posts/2017-11-11-logs/</link>
      <pubDate>Sat, 11 Nov 2017 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2017-11-11-logs/</guid>
      <description>&lt;p&gt;As a software developer, I cannot avoid log files. Application servers and LAMP
machines are always around the corner waiting for me, so I must accept log files
and do my best.&lt;/p&gt;
&lt;p&gt;There are two kinds of log files I work with:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;static: the server wrote the content and never touched the file again&lt;/li&gt;
&lt;li&gt;dynamic: the server keeps appending content as the monitored process continues&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The log files could be on my hard disk or located on a remote machine. During my
workflow, a “remote machine” can also be a Docker container.&lt;/p&gt;
&lt;p&gt;I leave the math to you, but it should be clear that different combinations
arise. Luckily, with Emacs everything goes smoothly and I can move seamlessly
across any scenario.&lt;/p&gt;
&lt;p&gt;When it comes to static files there are no surprises. If the log file is local,
inspecting it with &lt;code&gt;counsel-grep-or-swiper&lt;/code&gt; is pretty much all I need. Since
I rarely need to modify a log file, I usually enable &lt;code&gt;read-only-mode&lt;/code&gt; with
&lt;code&gt;C-x C-q&lt;/code&gt; to prevent accidental edits. For a remote static file, the
same easily applies thanks to TRAMP.&lt;/p&gt;
&lt;p&gt;Things get more interesting with dynamic logs. On local files, with
&lt;code&gt;auto-revert-mode&lt;/code&gt; I can see the changes in the buffer as soon as the underlying
file changes. If I want something fancier, &lt;code&gt;auto-revert-tail-mode&lt;/code&gt; behaves like
the good old &lt;code&gt;tail -f&lt;/code&gt;. Dynamic remote logs, however, require a different
approach. Activating &lt;code&gt;auto-revert-mode&lt;/code&gt; is not enough, I also need to set
&lt;code&gt;auto-revert-remote-files&lt;/code&gt; to &lt;code&gt;t&lt;/code&gt; for the desired behaviour.&lt;/p&gt;
&lt;p&gt;What if years of &lt;code&gt;tail -f&lt;/code&gt; made you totally indifferent to such niceties?  You
can follow &lt;a href=&#34;https://emacs.stackexchange.com/a/15213/5514&#34;&gt;Michael Albinus
suggestion&lt;/a&gt; and use
&lt;code&gt;dired-do-shell-command&lt;/code&gt; in Dired.&lt;/p&gt;
&lt;p&gt;Actually, you can even improve a little on his tip. Leave the ending &lt;code&gt;&amp;amp;&lt;/code&gt; out,
and go straight with &lt;code&gt;dired-do-async-shell-command&lt;/code&gt; which in Dired is aptly
bound to &lt;code&gt;&amp;amp;&lt;/code&gt;. Refer to the manual for further details: &lt;a href=&#34;https://www.gnu.org/software/emacs/manual/html_node/emacs/Shell-Commands-in-Dired.html&#34;&gt;Shell
Commands in
Dired&lt;/a&gt;.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Magit, the one and only</title>
      <link>https://manueluberti.eu/posts/2017-11-09-magit/</link>
      <pubDate>Thu, 09 Nov 2017 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2017-11-09-magit/</guid>
      <description>&lt;p&gt;Nowadays it is basically impossible to land in a group of Emacs enthusiasts
without someone talking rapturously about the wonders of
&lt;a href=&#34;https://github.com/magit/magit&#34;&gt;Magit&lt;/a&gt;. If you listen closely, the words
resemble a chant: &lt;em&gt;“You wish you could do it with Git, until you experience the
great Magit.”&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Be warned: the following story goes along those &lt;em&gt;magic&lt;/em&gt; lines.&lt;/p&gt;
&lt;p&gt;Magit makes me look back at my experiences with CVS, SVN and Mercurial and laugh
about my clumsiness with tools like Tortoise. Before Magit, I touched the
regular Git command-line interface for simple tasks such as cloning a
repository, always scared away by the large number of options at my disposal.
I had to deal with Eclipse&amp;rsquo;s own Git client when I was working with Java, but
please let me spare you the gruesome details.&lt;/p&gt;
&lt;p&gt;Magit has never been so necessary and useful as it has been since I started my
new job back in April. Git is our only version-control sytem, and the
command-line is still the preferred tool in the office. Not for me, though.
Magit has become a natural extension of pretty much all of my coding.&lt;/p&gt;
&lt;p&gt;I regularly create branches, being it for an issue to fix or a new feature to
implement. If the project is based on
&lt;a href=&#34;http://nvie.com/posts/a-successful-git-branching-model/&#34;&gt;gitflow&lt;/a&gt;, we are
covered in Magit thanks to
&lt;a href=&#34;https://github.com/jtatarik/magit-gitflow&#34;&gt;magit-gitflow&lt;/a&gt;. Otherwise, rebasing
and merging on master are just a few key bindings away.&lt;/p&gt;
&lt;p&gt;Although impressive, it is not only a matter of speed. Magit taught me more
about Git than every tutorial out in the wild. Especially when it comes to
rebasing and cherry-picking, both of which are hard to get wrong now. Rewording
a commit, exploring the repository history, dealing with submodules: it all
makes sense through an interface that could not be more helpful.&lt;/p&gt;
&lt;p&gt;The one thing &lt;em&gt;against&lt;/em&gt; Magit I have for the haters is this:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(unbind-key &amp;quot;C-c C-w&amp;quot; git-commit-mode-map)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;That binding is my prefix for &lt;a href=&#34;https://manueluberti.eu/posts/2017-08-02-eyebrowse/&#34;&gt;Eyebrowse&lt;/a&gt;.
Not much of a complaint, I know.&lt;/p&gt;
&lt;p&gt;Magit brings order, balance and elegance to the powers of Git. It is the only
version-control system I need.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Simplify my Docker workflow with Emacs</title>
      <link>https://manueluberti.eu/posts/2017-10-19-docker/</link>
      <pubDate>Thu, 19 Oct 2017 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2017-10-19-docker/</guid>
      <description>&lt;p&gt;Up until a few weeks ago, I had never messed with Docker. Not that I had
anything against it &lt;em&gt;per se&lt;/em&gt;, but never before had I felt the need to isolate my
work in containers that can be readily built up and torn down.&lt;/p&gt;
&lt;p&gt;Docker and its helpful companion Docker Compose come with a rich command-line
interface. Nonetheless, I don&amp;rsquo;t want to leave Emacs for simple tasks such as
building a Docker image or preparing the containers with Docker Compose.&lt;/p&gt;
&lt;p&gt;Fortunately, the Emacs ecosystem is ready to help. Four packages have improved
my workflow with Docker:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://github.com/spotify/dockerfile-mode&#34;&gt;dockerfile-mode&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://github.com/meqif/docker-compose-mode&#34;&gt;docker-compose-mode&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://github.com/emacs-pe/docker-tramp.el&#34;&gt;docker-tramp&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://github.com/Fuco1/eshell-bookmark&#34;&gt;eshell-bookmark&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The first two packages add syntax highlighting, completion and a bunch of useful
key bindings to work with &lt;code&gt;Dockerfile&lt;/code&gt; and &lt;code&gt;docker-compose.yml&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The real magic, though, happens with &lt;code&gt;docker-tramp&lt;/code&gt;. The beauty of interacting
directly with the contents of a container is impressive. Combine &lt;code&gt;docker-tramp&lt;/code&gt;
with the handy completion of &lt;a href=&#34;https://github.com/abo-abo/swiper&#34;&gt;counsel&lt;/a&gt; and
the power of Dired and you might feel like Henry Dorsett Case in his ecstatic
hunt for the Neuromancer.&lt;/p&gt;
&lt;p&gt;Through &lt;code&gt;docker-tramp&lt;/code&gt; I can also run EShell on any available container and that
is where &lt;code&gt;eshell-bookmark&lt;/code&gt; shines. I just have to bookmark a remote EShell
buffer and use &lt;code&gt;counsel-bookmark&lt;/code&gt; to jump back to it. Managing containers hardly
gets any faster than this.&lt;/p&gt;
&lt;p&gt;A little advice if you use both &lt;code&gt;counsel&lt;/code&gt; and &lt;code&gt;eshell-bookmark&lt;/code&gt;: do
not set &lt;code&gt;counsel-bookmark-avoid-dired&lt;/code&gt; to &lt;code&gt;t&lt;/code&gt;, otherwise selecting a bookmark
with &lt;code&gt;counsel-bookmark&lt;/code&gt; will take you to &lt;code&gt;counsel-find-file&lt;/code&gt; instead of opening
the desired EShell buffer.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>To shell or not to shell</title>
      <link>https://manueluberti.eu/posts/2017-10-07-m-x-shell/</link>
      <pubDate>Sat, 07 Oct 2017 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2017-10-07-m-x-shell/</guid>
      <description>&lt;p&gt;As much as most of my daily workflow revolves around Emacs, I always have GNOME
terminal ready to fly with &lt;a href=&#34;https://fishshell.com&#34;&gt;Fish shell&lt;/a&gt; and
&lt;a href=&#34;https://github.com/tmux/tmux&#34;&gt;tmux&lt;/a&gt;. I keep EShell next to me for quick tasks,
but I have never relied on &lt;code&gt;shell-mode&lt;/code&gt; or &lt;code&gt;ansi-term&lt;/code&gt; for other CLI-intensive
work.&lt;/p&gt;
&lt;p&gt;I don&amp;rsquo;t know what happened to the lovely “Emacs Chat” series from Sacha Chua,
but more than three years ago &lt;a href=&#34;https://www.youtube.com/watch?v=JA4dqmDFt5Y&#34;&gt;she interviewed Mickey
Petersen&lt;/a&gt;. Mickey talked with great
enthusiasm about &lt;code&gt;shell-mode&lt;/code&gt; and at the time I admittedly made a mental note
about giving it a try. Regretfully, I have only recently come back to that note.&lt;/p&gt;
&lt;p&gt;My first &lt;code&gt;M-x&lt;/code&gt; &lt;code&gt;shell&lt;/code&gt; didn&amp;rsquo;t look that great. I haven&amp;rsquo;t debugged
the compatibility issues with Fish, probably something related to my heavily
customised &lt;code&gt;config.fish&lt;/code&gt;. Anyway, falling back to Bash is enough.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(validate-setq explicit-shell-file-name &amp;quot;/bin/bash&amp;quot;)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note that I am using &lt;code&gt;validate-setq&lt;/code&gt; as &lt;a href=&#34;https://manueluberti.eu/posts/2016-09-17-validate/&#34;&gt;I have already explained&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Another thing I have noticed is the lack of colours for the output of &lt;code&gt;ls&lt;/code&gt;.
Fortunately, Emacs StackExchange has an
&lt;a href=&#34;https://emacs.stackexchange.com/a/17484/5514&#34;&gt;answer&lt;/a&gt; for that, so I have added
this line to my &lt;code&gt;.bash_aliases&lt;/code&gt; file:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-shell&#34;&gt;alias ls=&amp;quot;TERM=ansi ls --color=always&amp;quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The input echoing is easily turned off following &lt;a href=&#34;https://www.gnu.org/software/emacs/manual/html_node/efaq-w32/Shell-echo.html&#34;&gt;the
instructions&lt;/a&gt;
on the manual. Also, the history is much cleaner and easier to navigate with
&lt;code&gt;counsel-shell-history&lt;/code&gt;.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(unbind-key &amp;quot;C-c C-l&amp;quot; shell-mode-map)
(bind-key &amp;quot;C-c C-l&amp;quot; #&#39;counsel-shell-history shell-mode-map)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note that &lt;code&gt;unbind-key&lt;/code&gt; and &lt;code&gt;bind-key&lt;/code&gt; are macros from &lt;code&gt;bind-key.el&lt;/code&gt;, which is
part of the fantastic &lt;code&gt;use-package&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Last but not least, I like to have my shell buffer filling the whole window in
the current frame. Thus, &lt;code&gt;display-buffer-alist&lt;/code&gt; to the rescue.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(validate-setq
 display-buffer-alist
 `(
   ;; … other stuff …
   (,(rx bos &amp;quot;*shell&amp;quot;)
    (display-buffer-same-window)
    (reusable-frames . nil))
   ;; … other stuff …
  ))
&lt;/code&gt;&lt;/pre&gt;
</description>
    </item>
    <item>
      <title>Taming closing delimiters in my s-expressions</title>
      <link>https://manueluberti.eu/posts/2017-09-17-syntactic-close/</link>
      <pubDate>Sun, 17 Sep 2017 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2017-09-17-syntactic-close/</guid>
      <description>&lt;p&gt;As I explained when I wrote about &lt;a href=&#34;https://manueluberti.eu/posts/2017-04-29-clojureenv/&#34;&gt;my daily Clojure workflow&lt;/a&gt; I rely heavily on Smartparens for my editing. With
Lisp-like languages in particular, I enable &lt;code&gt;smartparens-strict-mode&lt;/code&gt; to keep my
s-expressions balanced even when I happen to use &lt;code&gt;delete-char&lt;/code&gt; or &lt;code&gt;kill-word&lt;/code&gt;
dangerously near a closing parenthesis.&lt;/p&gt;
&lt;p&gt;I have &lt;code&gt;sp-kill-sexp&lt;/code&gt; bound to &lt;code&gt;C-M-k&lt;/code&gt;, however out of habit I often
use &lt;code&gt;C-k&lt;/code&gt; to kill a line, which in my configuration is set up as
Artur Malabarba
&lt;a href=&#34;http://endlessparentheses.com/kill-entire-line-with-prefix-argument.html&#34;&gt;explained&lt;/a&gt;.
Doing that in the middle of an s-expression creates unnerving chaos.&lt;/p&gt;
&lt;p&gt;Smartparens comes with a handy binding to temporarily disable the enforced
balancing and let me insert a closing delimiter. Just pressing &lt;code&gt;C-q&lt;/code&gt;
followed by the desired matching parenthesis brings the order back.&lt;/p&gt;
&lt;p&gt;Unfortunately, it&amp;rsquo;s not always that easy. Take this snippet which appears at the
end of a ClojureScript function:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-clojure&#34;&gt;(when-not (empty? @data)
            [:div
             {:style {:padding &amp;quot;1em&amp;quot; :text-align &amp;quot;center&amp;quot;}}
             [graph]])]]))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Carelessly hitting &lt;code&gt;C-k&lt;/code&gt; near &lt;code&gt;[graph]&lt;/code&gt; disrupts an otherwise elegant
s-expression. I could undo, of course, but what if after &lt;code&gt;C-k&lt;/code&gt; I do
other kill-and-yank edits?&lt;/p&gt;
&lt;p&gt;This is exactly why I have come to love &lt;a href=&#34;https://github.com/emacs-berlin/syntactic-close&#34;&gt;syntactic-close&lt;/a&gt;.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(use-package syntactic-close            ; Automatically insert closing delimiter
  :ensure t
  :bind (&amp;quot;C-c x c&amp;quot; . syntactic-close))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As soon as I discover an unbalanced s-expression, I can use &lt;code&gt;C-c x c&lt;/code&gt;
as many times as needed to add back the right closing delimiters.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>A better workflow with workspaces</title>
      <link>https://manueluberti.eu/posts/2017-08-02-eyebrowse/</link>
      <pubDate>Wed, 02 Aug 2017 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2017-08-02-eyebrowse/</guid>
      <description>&lt;p&gt;I am not a big fan of workspaces on my desktop environments, maybe because to me
&lt;code&gt;Alt-Tab&lt;/code&gt; is enough. To be honest, I was using workspaces back in my
&lt;a href=&#34;http://www.nongnu.org/ratpoison/&#34;&gt;Ratpoison&lt;/a&gt; days, but that is not the case any
more.&lt;/p&gt;
&lt;p&gt;Nevertheless, my daily workflow in Emacs improved so much with
&lt;a href=&#34;https://github.com/wasamasa/eyebrowse&#34;&gt;eyebrowse&lt;/a&gt; I can&amp;rsquo;t imagine going back to
a configuration without it.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(use-package eyebrowse                  ; Easy workspaces creation and switching
  :ensure t
  :config
  (validate-setq eyebrowse-mode-line-separator &amp;quot; &amp;quot;
                 eyebrowse-new-workspace t)

  (eyebrowse-mode t))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As you can see, I am pretty much leaving &lt;code&gt;eyebrowse&lt;/code&gt; with its default
settings. I removed the comma that was used as a separator between the workspace
numbers and made switching to a new workspace start from the &lt;code&gt;*scratch*&lt;/code&gt; buffer.&lt;/p&gt;
&lt;p&gt;Now my daily workflow in Emacs is thus organised:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Workspace #1: this is dedicated to my GTD project, which simply follows the
steps Nicolas Petton describes in &lt;a href=&#34;https://emacs.cafe/emacs/orgmode/gtd/2017/06/30/orgmode-gtd.html&#34;&gt;Orgmode for
GTD&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Workspace #2: this is for Clojure and ClojureScript development, so everything
from CIDER to project specific Magit buffers and EShells ends up here. In the
rare case I need to work on a different project, I create a new workspace.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Workspace #3: this is the “I need a break!” place. Elfeed is my preferred
choice for a quiet and informative distraction. Otherwise, if I just want to
hack on my Emacs configuration I do it here.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Combined with &lt;a href=&#34;https://github.com/bbatsov/projectile&#34;&gt;Projectile&lt;/a&gt;, &lt;code&gt;eyebrowse&lt;/code&gt;
is the definitive piece of the puzzle I was missing to have an optimised work
environment.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Every feed in its right place</title>
      <link>https://manueluberti.eu/posts/2017-08-01-elfeed/</link>
      <pubDate>Tue, 01 Aug 2017 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2017-08-01-elfeed/</guid>
      <description>&lt;p&gt;Writing about Christopher Wellons&amp;rsquo; &lt;a href=&#34;https://github.com/skeeto/elfeed&#34;&gt;elfeed&lt;/a&gt; is
the least I can do to describe how thankful I am for this gem, especially since
it&amp;rsquo;s one of the Emacs packages I use the most.&lt;/p&gt;
&lt;p&gt;Up until last month, Twitter was useful to keep in touch with the IT and the
film criticism communities. However, for a while I had been finding myself in
dire need of a vacation from social media. The amount of time lost in pointless
time-line scrolling looking for the latest hip comment screamed to be spent
otherwise.&lt;/p&gt;
&lt;p&gt;I have always been a fan of RSS feeds, because having the news aggregated in one
place spares me the time of wandering the Internet. Twitter fought against my
feeds, giving the impression it was offering more up-to-date content along with
the false promise of an interaction that in fact was rarely happening.&lt;/p&gt;
&lt;p&gt;Before &lt;code&gt;elfeed&lt;/code&gt;, I tried my luck with different feed readers. Since a carefully
&lt;em&gt;tmux-ed&lt;/em&gt; terminal window is always part of my daily workflow, I fell in love
with &lt;a href=&#34;http://www.newsbeuter.org&#34;&gt;Newsbeuter&lt;/a&gt; a couple of years ago.&lt;/p&gt;
&lt;p&gt;However, as any Emacs fanatic would tell you, why leave the comfort of your
favourite text editor for something as mundane as RSS feeds?&lt;/p&gt;
&lt;p&gt;&lt;code&gt;elfeed&lt;/code&gt; is more than a Newsbeuter replacement, though. Tags, filters and the
power of Emacs beneath its lean interface make feeds management easier than
ever. It&amp;rsquo;s also trivially extensible. Look at this simple trick to mark all the
feeds read when I am feeling too lazy.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defun mu-elfeed-mark-all-read ()
  &amp;quot;Mark all feeds as read.&amp;quot;
  (interactive)
  (call-interactively &#39;mark-whole-buffer)
  (elfeed-search-untag-all-unread))

(bind-key &amp;quot;R&amp;quot; #&#39;mu-elfeed-mark-all-read elfeed-search-mode-map)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;elfeed&lt;/code&gt; sorts feeds by time, with the most recent on top. This had been a bit
confusing at first, as I was used to having the feeds grouped by items with
Newsbeuter. Nevertheless, after a while this approach felt more natural, maybe
because it reminds me of the Twitter time-line.&lt;/p&gt;
&lt;p&gt;RSS feeds are an essential tool in this age of perennial distractions. Having
them readily available at my fingertips is invaluable.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Keeping your .emacs.d clean</title>
      <link>https://manueluberti.eu/posts/2017-06-17-nolittering/</link>
      <pubDate>Sat, 17 Jun 2017 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2017-06-17-nolittering/</guid>
      <description>&lt;p&gt;How often do you have a look at your &lt;code&gt;.emacs.d&lt;/code&gt; directory? If you&amp;rsquo;re anything like
me, not that often. It&amp;rsquo;s no wonder then that upon opening it I was horrified to
see it cluttered with all sorts of files from all the packages I regularly use.&lt;/p&gt;
&lt;p&gt;Jonas Bernoulli, of &lt;a href=&#34;https://magit.vc/&#34;&gt;Magit&lt;/a&gt; fame, must be feeling similar concerns. Otherwise, why
did he come up with a package like &lt;a href=&#34;https://github.com/tarsius/no-littering&#34;&gt;no-littering&lt;/a&gt;?&lt;/p&gt;
&lt;p&gt;Installation is trivial, especially if you use the great &lt;code&gt;use-package&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(use-package no-littering               ; Keep .emacs.d clean
  :ensure t
  :config
  (require &#39;recentf)
  (add-to-list &#39;recentf-exclude no-littering-var-directory)
  (add-to-list &#39;recentf-exclude no-littering-etc-directory))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;No extra setup is required. Place this snippet somewhere at the beginning of
your &lt;code&gt;init.el&lt;/code&gt; file and you are set. Use Emacs for a while and then go back
checking &lt;code&gt;.emacs.d&lt;/code&gt;: nice, huh?&lt;/p&gt;
&lt;p&gt;To be honest, I wiped out my &lt;code&gt;.emacs.d&lt;/code&gt; directory and started from fresh with
&lt;code&gt;no-littering&lt;/code&gt; installed. Too much, maybe, but I was eager to see how good this
package is. And yes, it is good.&lt;/p&gt;
&lt;p&gt;House-cleaning has never been so easy.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Dynamically change font size in Emacs</title>
      <link>https://manueluberti.eu/posts/2017-02-26-dynamicfonts/</link>
      <pubDate>Sun, 26 Feb 2017 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2017-02-26-dynamicfonts/</guid>
      <description>&lt;p&gt;I take my Emacs configuration with me on every computer I use. I also plug a big
external display —and the awesome Das Keyboard 4 Ultimate— during long coding
sessions, so it is only natural that I have to tailor my setup to accommodate
different font sizes.&lt;/p&gt;
&lt;p&gt;Being the customizable editor that Emacs is, it wasn&amp;rsquo;t hard to devise a neat
trick to please my needs.&lt;/p&gt;
&lt;p&gt;First, a simple function to set the default fonts.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defun mu-setup-main-fonts (default-height variable-pitch-height)
  &amp;quot;Set up default fonts.

Use DEFAULT-HEIGHT for default face and VARIABLE-PITCH-HEIGHT
for variable-pitch face.&amp;quot;
  (set-face-attribute &#39;default nil
                      :family &amp;quot;Source Code Pro&amp;quot;
                      :height default-height)
  (set-face-attribute &#39;variable-pitch nil
                      :family &amp;quot;Fira Sans&amp;quot;
                      :height variable-pitch-height
                      :weight &#39;regular))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now I just have to call this function with the proper values for &lt;code&gt;:height&lt;/code&gt;
according to the screen size.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(when window-system
  (if (&amp;gt; (x-display-pixel-width) 1800)
      (mu-setup-main-fonts 150 160)
    (mu-setup-main-fonts 130 140)))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Of course, more specific settings for various display resolutions are just a
&lt;code&gt;cond&lt;/code&gt; away.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Automatic language detection for Flyspell</title>
      <link>https://manueluberti.eu/posts/2017-02-04-guess-language/</link>
      <pubDate>Sat, 04 Feb 2017 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2017-02-04-guess-language/</guid>
      <description>&lt;p&gt;I am always looking for new ways to improve my Emacs experience. Months ago, it
happened to my spell-checking configuration thanks to the work
of &lt;a href=&#34;https://github.com/NicolasPetton&#34;&gt;Nicolas Petton&lt;/a&gt;.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defvar mu-languages-ring nil &amp;quot;Languages ring for Ispell&amp;quot;)

(let ((languages &#39;(&amp;quot;en_GB&amp;quot; &amp;quot;it_IT&amp;quot;)))
  (validate-setq mu-languages-ring (make-ring (length languages)))
  (dolist (elem languages) (ring-insert mu-languages-ring elem)))

(defun mu-cycle-ispell-languages ()
  (interactive)
  (let ((language (ring-ref mu-languages-ring -1)))
    (ring-insert mu-languages-ring language)
    (ispell-change-dictionary language)))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This handy code lets me cycle quickly through the languages I need in
Flyspell. However, wouldn&amp;rsquo;t it be easier if Emacs was capable of automatic
language detection?&lt;/p&gt;
&lt;p&gt;That&amp;rsquo;s the hole
the &lt;a href=&#34;https://github.com/tmalsburg/guess-language.el&#34;&gt;guess-language&lt;/a&gt; package
fills.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(use-package guess-language         ; Automatically detect language for Flyspell
  :ensure t
  :defer t
  :init (add-hook &#39;text-mode-hook #&#39;guess-language-mode)
  :config
  (setq guess-language-langcodes &#39;((en . (&amp;quot;en_GB&amp;quot; &amp;quot;English&amp;quot;))
                                   (it . (&amp;quot;it_IT&amp;quot; &amp;quot;Italian&amp;quot;)))
        guess-language-languages &#39;(en it)
        guess-language-min-paragraph-length 45)
  :diminish guess-language-mode)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Notice how I set &lt;code&gt;guess-language-langcodes&lt;/code&gt;. It has to be set this way to make
&lt;code&gt;guess-language&lt;/code&gt; work with &lt;a href=&#34;https://manueluberti.eu/posts/2016-06-06-spellchecksetup/&#34;&gt;my setup for Hunspell&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Support for different languages and language detection for multiple languages in
the same document are provided out of the box. &lt;code&gt;guess-language&lt;/code&gt; is still young,
but it&amp;rsquo;s already making spell-checking in Emacs so much easier.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Format XML in Emacs</title>
      <link>https://manueluberti.eu/posts/2016-12-03-xmllint/</link>
      <pubDate>Sat, 03 Dec 2016 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2016-12-03-xmllint/</guid>
      <description>&lt;p&gt;Since I deal with many SOAP web services for work, I also have to deal with lots
of XML files. In the application server log they usually appear on one line,
which makes the reading unnecessarily painful. Fortunately, Emacs coupled with
the handy &lt;code&gt;xmllint&lt;/code&gt; comes to the rescue.&lt;/p&gt;
&lt;p&gt;First, I installed &lt;code&gt;xmllint&lt;/code&gt; with: &lt;code&gt;sudo apt-get install libxml2-utils&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Now I could format my XML buffers with: &lt;code&gt;C-x h C-u M-|&lt;/code&gt; &lt;code&gt;xmllint -format -&lt;/code&gt; &lt;code&gt;RET&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;However, this is Emacs, so there is always a more productive way to solve
problems. Why should I have to input the options for &lt;code&gt;xmllint&lt;/code&gt; or remember the
necessary key bindings all the times?&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defun mu-xml-format ()
  &amp;quot;Format an XML buffer with `xmllint&#39;.&amp;quot;
  (interactive)
  (shell-command-on-region (point-min) (point-max)
                           &amp;quot;xmllint -format -&amp;quot;
                           (current-buffer) t
                           &amp;quot;*Xmllint Error Buffer*&amp;quot; t))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Since I only need this utility in XML buffers, I bound it for &lt;code&gt;nxml-mode-map&lt;/code&gt;.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(use-package nxml-mode                  ; XML editing
  :mode &amp;quot;\\.xml\\&#39;&amp;quot;
  :bind (:map nxml-mode-map
              (&amp;quot;C-c m f&amp;quot; . mu-xml-format))
…
&lt;/code&gt;&lt;/pre&gt;
</description>
    </item>
    <item>
      <title>Scala in Emacs with ENSIME</title>
      <link>https://manueluberti.eu/posts/2016-11-01-ensime/</link>
      <pubDate>Tue, 01 Nov 2016 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2016-11-01-ensime/</guid>
      <description>&lt;p&gt;As an amateur Clojure developer, I am particularly fond
of &lt;a href=&#34;https://github.com/clojure-emacs/cider&#34;&gt;CIDER&lt;/a&gt;. It brings everything I need
to program with Clojure right inside my favourite text editor.&lt;/p&gt;
&lt;p&gt;Therefore, when I approached Scala one of the first things I did was looking for
something similar to CIDER. I hate leaving Emacs for programming tasks, so
having it ready for Scala was paramount. Fortunately, it did not take me long to
find my way: &lt;a href=&#34;https://ensime.github.io/&#34;&gt;ENSIME&lt;/a&gt; was right around the corner.&lt;/p&gt;
&lt;p&gt;ENSIME supports the famous &lt;a href=&#34;http://www.scala-sbt.org/&#34;&gt;sbt&lt;/a&gt; build tool, and the
documentation gently guides you through all the necessary steps to achieve a
working setup. It is really a matter of minutes.&lt;/p&gt;
&lt;p&gt;&lt;figure&gt;
  &lt;img src=&#34;https://manueluberti.eu/images/ensime.png&#34; alt=&#34;&#34;&gt;
  &lt;figcaption class=&#34;center&#34;&gt;
    &lt;small&gt;&lt;em&gt;&lt;/em&gt;&lt;/small&gt;    
  &lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/p&gt;
&lt;p&gt;A nice trick I grabbed straight from &lt;a href=&#34;https://github.com/fommil&#34;&gt;Sam Halliday&lt;/a&gt;
&lt;code&gt;init.el&lt;/code&gt; is:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(remove-hook &#39;post-self-insert-hook
             &#39;scala-indent:indent-on-parentheses)

(sp-local-pair &#39;scala-mode &amp;quot;(&amp;quot; nil
               :post-handlers &#39;((&amp;quot;||\n[i]&amp;quot; &amp;quot;RET&amp;quot;)))
(sp-local-pair &#39;scala-mode &amp;quot;{&amp;quot; nil
               :post-handlers &#39;((&amp;quot;||\n[i]&amp;quot; &amp;quot;RET&amp;quot;) (&amp;quot;| &amp;quot; &amp;quot;SPC&amp;quot;)))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This code lets the awesome &lt;a href=&#34;https://github.com/Fuco1/smartparens&#34;&gt;Smartparens&lt;/a&gt;
take care of parentheses in Scala buffers. Another handy solution comes from
&lt;a href=&#34;https://github.com/lunaryorn&#34;&gt;Sebastian Wiesner&lt;/a&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(defun mu-scala-pop-to-sbt (new-frame)
    &amp;quot;Open SBT REPL for this project, optionally in a NEW-FRAME.

Select the SBT REPL for the current project in a new window.  If
the REPL is not yet running, start it.  With prefix arg, select
the REPL in a new frame instead.&amp;quot;
(interactive &amp;quot;P&amp;quot;)
;; Start SBT when no running, taken from `sbt:command&#39;
(when (not (comint-check-proc (sbt:buffer-name)))
  (sbt:run-sbt))
(let ((display-buffer-overriding-action
       (if new-frame &#39;(display-buffer-pop-up-frame) nil)))
  (pop-to-buffer (sbt:buffer-name))))

(with-eval-after-load &#39;scala-mode
  (bind-key &amp;quot;C-c m s&amp;quot; #&#39;mu-scala-pop-to-sbt scala-mode-map))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I just started my journey with Scala but I can safely say ENSIME could be the
perfect companion.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Schema validation for my Emacs configuration</title>
      <link>https://manueluberti.eu/posts/2016-09-17-validate/</link>
      <pubDate>Sat, 17 Sep 2016 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2016-09-17-validate/</guid>
      <description>&lt;p&gt;Maintaining an ever-growing Emacs configuration is both fun and exhausting. It
is easy to forget why I picked &lt;em&gt;that&lt;/em&gt; value for a variable or how in the name of
Elisp that weird snippet ended up in my init.el. The more packages I install to
extend my beloved text editor, the harder it is to keep track of all the changes
the prolific authors put out every day.&lt;/p&gt;
&lt;p&gt;Artur Malabarba must understand my frustration pretty well, or at least that was
my first reaction to his
recent &lt;a href=&#34;https://github.com/Malabarba/validate.el&#34;&gt;validate&lt;/a&gt; library.&lt;/p&gt;
&lt;p&gt;The library has a pretty neat API, which I am sure will turn out to come in
handy for all the Elisp developers out there. However, so far I have been
focusing on the &lt;code&gt;validate-setq&lt;/code&gt; macro only. &lt;code&gt;validate-setq&lt;/code&gt; adds validation to
the regular &lt;code&gt;setq&lt;/code&gt;, making it super-easy to catch mistakes that can be
surprisingly hard to find.&lt;/p&gt;
&lt;p&gt;An example:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(use-package nrepl-client               ; Client for Clojure nREPL
  :ensure cider
  :defer t
  :config (validate-setq nrepl-hide-special-buffers &#39;yes))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If I evaluate this expression, I get a clear error message:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Error (use-package): nrepl-client :config: Looking for ‘(boolean)&#39; in
‘yes&#39; failed because: not a boolean
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I was setting a lot of variables before the related package was required. I also
found settings for variables that do not exist any more. Why Emacs was not
catching these errors upon loading is still an ongoing investigation.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;validate&lt;/code&gt; is available on GNU ELPA. Do not miss it.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Adding CHICKEN Scheme support to Flycheck</title>
      <link>https://manueluberti.eu/posts/2016-07-23-flycheckchicken/</link>
      <pubDate>Sat, 23 Jul 2016 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2016-07-23-flycheckchicken/</guid>
      <description>&lt;p&gt;There is no need for me to tell you how great &lt;a href=&#34;http://www.flycheck.org/&#34;&gt;Flycheck&lt;/a&gt; is. If you do not trust
me, at least trust &lt;a href=&#34;https://www.masteringemacs.org/article/spotlight-flycheck-a-flymake-replacement&#34;&gt;Mickey Petersen&lt;/a&gt; on this.&lt;/p&gt;
&lt;p&gt;Since I have been playing around with &lt;a href=&#34;http://call-cc.org/&#34;&gt;CHICKEN Scheme&lt;/a&gt; for quite some time now, it
seemed only natural to wish for on-the-fly syntax checking. Why limit myself to
wishing, though? Why do not push it a little further and try to help Flycheck
maintainers?&lt;/p&gt;
&lt;p&gt;Before starting any coding, I took the time to read the &lt;a href=&#34;http://www.flycheck.org/en/latest/contributor/contributing.html&#34;&gt;Contributor&amp;rsquo;s Guide&lt;/a&gt;.
Like all of Flycheck documentation, the Contributor&amp;rsquo;s Guide is well-written and
easy to understand. The guidelines about &lt;a href=&#34;http://www.flycheck.org/en/latest/contributor/contributing.html#pull-requests&#34;&gt;pull requests&lt;/a&gt; and &lt;a href=&#34;http://www.flycheck.org/en/latest/contributor/contributing.html#commit-guidelines&#34;&gt;commit messages&lt;/a&gt;, in
particular, put me on the right track.&lt;/p&gt;
&lt;p&gt;I forked the Flycheck&amp;rsquo;s repository and started going through the code in
&lt;a href=&#34;https://github.com/flycheck/flycheck/blob/master/flycheck.el&#34;&gt;flycheck.el&lt;/a&gt;. The lack of experience brought me to shamelessly copying the Racket
checker and trying to figure out how it worked. It was not too hard to
understand, but maybe starting with the Perl checker — see &lt;a href=&#34;http://www.flycheck.org/en/latest/user/flycheck-versus-flymake.html&#34;&gt;here&lt;/a&gt; — would have
been a better choice. Nonetheless, I stole the idea of having &lt;a href=&#34;http://www.nongnu.org/geiser/&#34;&gt;Geiser&lt;/a&gt; as a
requirement from the Racket checker.&lt;/p&gt;
&lt;p&gt;Anyway, it was not time to code yet. I needed to understand if on-the-fly syntax
checking in CHICKEN Scheme would be possible at all. Flycheck gives you the
power to work with different syntax checkers within the same interface, but
I didn&amp;rsquo;t know of a similar checker for CHICKEN Scheme.&lt;/p&gt;
&lt;p&gt;With some help on the &lt;code&gt;#chicken&lt;/code&gt; IRC channel and from &lt;a href=&#34;https://twitter.com/vbuaraujo&#34;&gt;Vítor De Araújo&lt;/a&gt; on Twitter,
I was able to devise my first attempt and create the proper &lt;a href=&#34;https://github.com/flycheck/flycheck/pull/987&#34;&gt;pull request&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;And that is when the real magic started.&lt;/p&gt;
&lt;p&gt;I knew Flycheck maintainers are kind and helpful because I had already had some
chances to interact with them, but I cannot remember the last time I worked on
something with &lt;em&gt;this&lt;/em&gt; kind of patient assistance.&lt;/p&gt;
&lt;p&gt;Questions promptly answered, suggestions readily available. My code kept getting
better and better. Useless lines were removed, documentation was added and the
integration test felt like the right thing to do.&lt;/p&gt;
&lt;p&gt;I learnt a lot and could not be happier with the result. I hope I will be able
to contribute to Flycheck again. Moreover, I do hope every project I wish to
contribute to can follow the Flycheck&amp;rsquo;s community example.&lt;/p&gt;
&lt;p&gt;Now go enjoy your on-the-fly syntax checking with CHICKEN Scheme.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Spell-checking with Hunspell and flyspell-correct</title>
      <link>https://manueluberti.eu/posts/2016-06-06-spellchecksetup/</link>
      <pubDate>Mon, 06 Jun 2016 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2016-06-06-spellchecksetup/</guid>
      <description>&lt;p&gt;In order to simplify the portability of my Emacs setup, I devised a useful shell
script to install everything my needs.&lt;/p&gt;
&lt;p&gt;Recently I abandoned &lt;code&gt;aspell&lt;/code&gt; in favour of &lt;code&gt;hunspell&lt;/code&gt;, so the script has been
updated accordingly. However, &lt;code&gt;hunspell&lt;/code&gt; needs some dictionaries to work with
and they are not readily available as Debian packages, but as &lt;a href=&#34;http://extensions.libreoffice.org/&#34;&gt;LibreOffice
Extensions&lt;/a&gt;. Therefore, I just need to copy
the files over to &lt;code&gt;/usr/share/hunspell&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;A quick test with &lt;code&gt;hunspell -D&lt;/code&gt; shows all is set up correctly.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-console&#34;&gt;$ hunspell -D
[…]
AVAILABLE DICTIONARIES (path is not mandatory for -d option):
/usr/share/hunspell/en_GB
/usr/share/hunspell/it_IT
/usr/share/hunspell/en_US
[…]

&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Emacs Lisp takes care of the rest.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(setq ispell-program-name (executable-find &amp;quot;hunspell&amp;quot;)
      ispell-dictionary &amp;quot;en_GB&amp;quot;)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I write both in English and Italian, so the spell-checker must be able to switch
dictionary on demand.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(bind-key &amp;quot;C-c I&amp;quot;
          (lambda ()
            (interactive)
            (ispell-change-dictionary &amp;quot;it_IT&amp;quot;)
            (flyspell-buffer)))

(bind-key &amp;quot;C-c E&amp;quot;
          (lambda ()
            (interactive)
            (ispell-change-dictionary &amp;quot;en_GB&amp;quot;)
            (flyspell-buffer)))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To make things nicer,
&lt;a href=&#34;https://github.com/d12frosted/flyspell-correct&#34;&gt;flyspell-correct&lt;/a&gt; makes
Flyspell propose the suggested corrections via the always reliable Ivy.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;(use-package flyspell-correct-ivy
  :ensure t
  :demand t
  :bind (:map flyspell-mode-map
              (&amp;quot;C-c $&amp;quot; . flyspell-correct-word-generic)))
&lt;/code&gt;&lt;/pre&gt;
</description>
    </item>
    <item>
      <title>Recentre the buffer when leaving Swiper</title>
      <link>https://manueluberti.eu/posts/2016-05-30-swiperrecenter/</link>
      <pubDate>Mon, 30 May 2016 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2016-05-30-swiperrecenter/</guid>
      <description>&lt;p&gt;I always talk enthusiastically about
&lt;a href=&#34;https://github.com/abo-abo/swiper&#34;&gt;Ivy&lt;/a&gt;. As a once heavy Helm user, I remember
being afraid of regretting the complete switch to Ivy after a few days. It did
not happen, and since I made the move I have only found Ivy — and the related
packages Swiper and Counsel — consistently getting better and better.&lt;/p&gt;
&lt;p&gt;Swiper has soon become my preferred in-buffer searching tool. Only one minor
thing was disturbing me. After selecting the right candidate with
&lt;code&gt;RET&lt;/code&gt;, the screen scrolled unpredictably at the top, centre, or bottom
of the buffer.&lt;/p&gt;
&lt;p&gt;This is due to calculations behind the scenes about windows size, as Oleh Krehel
explained
&lt;a href=&#34;https://github.com/abo-abo/swiper/issues/116#issuecomment-218381046&#34;&gt;here&lt;/a&gt;. Fortunately,
he was kind enough to introduce a handy &lt;code&gt;defcustom&lt;/code&gt;.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;;; Always recentre when leaving Swiper
(setq swiper-action-recenter t)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now every time I leave Swiper the screen is left centred. Furthermore, it is
possible to keep the screen centred even during candidate selection in Swiper by
pressing &lt;code&gt;C-M-n&lt;/code&gt; or &lt;code&gt;C-M-p&lt;/code&gt; instead of &lt;code&gt;C-n&lt;/code&gt; or
&lt;code&gt;C-p&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;I do not mind the scrolling when Swiper is active, but I do like having my eyes
focused on one point of the screen when I find what I am looking for.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Ignore some buffers in Ivy</title>
      <link>https://manueluberti.eu/posts/2016-05-23-ivyignore/</link>
      <pubDate>Mon, 23 May 2016 00:00:00 +0000</pubDate><author>manuel.uberti@inventati.org (Manuel Uberti)</author>
      <guid>https://manueluberti.eu/posts/2016-05-23-ivyignore/</guid>
      <description>&lt;p&gt;If you use the great
&lt;a href=&#34;https://github.com/company-mode/company-statistics&#34;&gt;company-statistics&lt;/a&gt; to
improve your experience with &lt;a href=&#34;https://company-mode.github.io/&#34;&gt;company-mode&lt;/a&gt;,
chances are that you already noticed an entry called
&lt;code&gt;company-statistics-cache.el&lt;/code&gt; when you switch buffers with your favourite key
binding.&lt;/p&gt;
&lt;p&gt;Hitting &lt;code&gt;RET&lt;/code&gt; on &lt;code&gt;company-statistics-cache.el&lt;/code&gt; could result in
unpleasant consequences. In my case, Emacs hangs indefinitely, distracting me
from my work and forcing me to a horrible restart.&lt;/p&gt;
&lt;p&gt;Fortunately, &lt;a href=&#34;https://github.com/abo-abo&#34;&gt;Oleh Krehel&lt;/a&gt; introduced a new value
for &lt;code&gt;ivy-use-ignore-default&lt;/code&gt;: &lt;code&gt;&#39;always&lt;/code&gt;.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-emacs-lisp&#34;&gt;;; Always ignore buffers set in `ivy-ignore-buffers&#39;
(setq ivy-use-ignore-default &#39;always)
;; Ignore some buffers in `ivy-switch-buffer&#39;
(setq ivy-ignore-buffers &#39;(&amp;quot;company-statistics-cache.el&amp;quot;))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;With the above setup, &lt;code&gt;company-statistics-cache.el&lt;/code&gt; will never sneak in your
buffer switching again.&lt;/p&gt;
</description>
    </item>
  </channel>
</rss>
