<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Ruslan's Tech Blog</title><link>https://codelearn.me/feed/by_tag/emacs.xml</link><description>Posts about Emacs - the best text editor</description><language>en-us</language><lastBuildDate>Sun, 05 Apr 2026 14:12:53 +1000</lastBuildDate><atom:link href="https://codelearn.me/feed/by_tag/emacs.xml" rel="self" type="application/rss+xml"/><item><title>Emacs: goto-address-mode</title><link>https://codelearn.me/2026/04/05/goto-address-mode.html</link><pubDate>Sun, 05 Apr 2026 14:12:53 +1000</pubDate><guid>https://codelearn.me/2026/04/05/goto-address-mode.html</guid><description>&lt;p>In &lt;a href="https://codelearn.me/2026/03/23/github-list-my-prs.html">one of my previous blog posts&lt;/a> I mentioned a command that returns the list of all &lt;strong>open&lt;/strong>
pull requests I have ever created on github:&lt;/p>
&lt;pre tabindex="0">&lt;code>gh search prs --author @me --state open --json title,url --template &amp;#39;{{range .}}{{.title}} - {{.url}}{{&amp;#34;\n&amp;#34;}}{{end}}&amp;#39;
&lt;/code>&lt;/pre>&lt;br>
&lt;p>I wrapped this command into &lt;strong>krydos/show-my-prs&lt;/strong> elisp function that just executes the above&amp;rsquo;s snippet using &lt;strong>async-shell-command&lt;/strong>.&lt;/p>
&lt;p>Here is its output:&lt;/p>
&lt;p>&lt;a target="_blank" href="https://codelearn.me/assets/img/showmyprs.png">&lt;img width="600px" src="https://codelearn.me/assets/img/showmyprs.png"/>&lt;/a>&lt;/p>
&lt;p>Looks great and already useful for me but what&amp;rsquo;s missing is clickable links.&lt;/p>
&lt;p>Turns out Emacs, &lt;strong>as usual&lt;/strong>, have a built in answer.&lt;/p>
&lt;p>The mode is called &lt;strong>goto-address-mode&lt;/strong>. Just turn it on in the buffer and all the links become clickable (you can also &lt;strong>C-c RET&lt;/strong> on them).
&lt;br>Look:&lt;/p>
&lt;p>&lt;a target="_blank" href="https://codelearn.me/assets/img/showmyprs-with-the-mode.png">&lt;img width="600px" src="https://codelearn.me/assets/img/showmyprs-with-the-mode.png"/>&lt;/a>&lt;/p>
&lt;p>Emacs is the best!&lt;/p></description></item><item><title>Emacs: Dumb Jump Is So Good</title><link>https://codelearn.me/2026/01/03/dumb-jump-is-so-good.html</link><pubDate>Sat, 03 Jan 2026 21:22:17 +1100</pubDate><guid>https://codelearn.me/2026/01/03/dumb-jump-is-so-good.html</guid><description>&lt;p>There is a library I rely on constantly in my day to day computing, at work and at home.
This library is called &lt;a href="https://github.com/jacktasia/dumb-jump">dumb-jump&lt;/a>.&lt;/p>
&lt;p>I don&amp;rsquo;t see it is prized as often as Magit for example, which made me write this post.&lt;/p>
&lt;p>Below I explain what it does but first, let me thank to &lt;strong>Jack Angers&lt;/strong> and all the contributors.
I have used this library for 10 years. It is one of the best computer programs I have ever used.
There were periods when I was off Emacs during that time and the first thing I looked for in other editors was a plugin similar to dumb-jump.&lt;/p>
&lt;h2 id="what-does-it-do">What does it do&lt;/h2>
&lt;p>It jumps to definition of a function/method/class.&lt;/p>
&lt;p>Here is my config for it:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-lisp" data-lang="lisp">&lt;span style="display:flex;">&lt;span>(&lt;span style="color:#a6e22e">use-package&lt;/span> dumb-jump
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#e6db74">:ensure&lt;/span> &lt;span style="color:#66d9ef">t&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#e6db74">:config&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> (add-hook &lt;span style="color:#e6db74">&amp;#39;xref-backend-functions&lt;/span> &lt;span style="color:#a6e22e">#&amp;#39;&lt;/span>dumb-jump-xref-activate)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> (&lt;span style="color:#66d9ef">setq&lt;/span> dumb-jump-force-searcher &lt;span style="color:#e6db74">&amp;#39;rg&lt;/span>)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#75715e">;; use completion-read instead of a separate buffer with candidates&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> (&lt;span style="color:#66d9ef">setq&lt;/span> xref-show-definitions-function &lt;span style="color:#a6e22e">#&amp;#39;&lt;/span>xref-show-definitions-completing-read))
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Combined with &lt;a href="https://github.com/dajva/rg.el">rg&lt;/a> it eliminated my need in LSPs or ctags/etags entirely.&lt;/p>
&lt;p>Here is me using it on Emacs source code, which is big code base (click to view the video in a separate tab):&lt;/p>
&lt;p>&lt;a target="_blank" href="https://codelearn.me/assets/video/dumbjump-in-action.mov">&lt;video src="https://codelearn.me/assets/video/dumbjump-in-action.mov" width="100%"/>&lt;/a>&lt;/p>
&lt;p>In this video I:&lt;/p>
&lt;ul>
&lt;li>press &lt;code>M-.&lt;/code> to go to definition.&lt;/li>
&lt;li>In less than a second I get matching definitions that I can filter if necessary.&lt;/li>
&lt;li>I jump straight to the definition.&lt;/li>
&lt;/ul>
&lt;h2 id="how-does-it-work">How does it work&lt;/h2>
&lt;p>It just greps the entire project for the symbol at point. The best thing about it is that with LSP for example it&amp;rsquo;s impossible
(or rather I haven&amp;rsquo;t seen it working) to place my cursor over a function name in a comment somewhere and jump to it.&lt;/p>
&lt;p>Like in:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-js" data-lang="js">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e">/**
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"> * This test function is cool but
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"> * check another_function_name for more info
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"> */&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#66d9ef">function&lt;/span> &lt;span style="color:#a6e22e">test&lt;/span>() {}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>With dumb-jump - I can place my cursor at &lt;strong>another_function_name&lt;/strong>, press &lt;strong>M-.&lt;/strong> and I&amp;rsquo;m looking at the definition of it.&lt;/p>
&lt;p>It works with &lt;strong>ANY&lt;/strong> programming language.&lt;/p>
&lt;h2 id="why-not">Why not&lt;/h2>
&lt;h3 id="ctagsetags">ctags/etags&lt;/h3>
&lt;p>Every time a file is changed the ctags table must be regenerated. It can be automated but I think it&amp;rsquo;s unnecessary overhead.&lt;/p>
&lt;h3 id="lsp-eglot">LSP (Eglot)&lt;/h3>
&lt;p>I love LSP as a technology but I don&amp;rsquo;t want a background process to run on my machine while I&amp;rsquo;m working on a project.
What if during the day I work on 10 projects, which is real for me at work for example. It will spawn 10 background processes
for different languages that I have to mentally track (because I do mentally track what&amp;rsquo;s running in my computing environment).&lt;/p>
&lt;p>The amount of RAM and CPU spent on this just feels too expensive.&lt;/p>
&lt;h2 id="summary">Summary&lt;/h2>
&lt;p>If for some reason you haven&amp;rsquo;t tried this library - try. It&amp;rsquo;s so good.&lt;/p>
&lt;p>I wish I can find better words on how grateful I am that it exists. Thank you!&lt;/p></description></item><item><title>Emacs: find-file-at-point trick</title><link>https://codelearn.me/2025/11/05/find-file-at-point-trick.html</link><pubDate>Wed, 05 Nov 2025 16:29:36 +1100</pubDate><guid>https://codelearn.me/2025/11/05/find-file-at-point-trick.html</guid><description>&lt;h2 id="the-story">The story&lt;/h2>
&lt;p>Sometimes I hover over a file path in my terminal emulator (in Emacs of course) and type&lt;br>
&lt;code>M-x find-file-at-point&lt;/code>.
It&amp;rsquo;s nice command and it works reliably.&lt;/p>
&lt;p>I don&amp;rsquo;t want to type it though. I want Emacs to detect a file path at point.&lt;/p>
&lt;p>And there is a &lt;a href="https://www.gnu.org/software/emacs/manual/html_node/emacs/FFAP.html">built in package&lt;/a> for this.
Just add this line to your &lt;code>init.el&lt;/code> and it should work.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-lisp" data-lang="lisp">&lt;span style="display:flex;">&lt;span>(ffap-bindings)
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>This makes &lt;strong>C-x C-f&lt;/strong> keybinding to automatically detect a file path at point. Cool!&lt;/p>
&lt;h2 id="the-twist">The twist&lt;/h2>
&lt;p>Unfortunately it was so much worse than what I&amp;rsquo;ve expected.&lt;/p>
&lt;p>It does detect file path at point so reliably and so often (there are lots of file paths in my terminal output usually)&lt;br>
that almost 80% of time when I press &lt;strong>C-x C-f&lt;/strong> my minibuffer is already pre-filled with the path my cursor happened to be on,
which I didn&amp;rsquo;t need. I wanted it to be clean so I could type a file path there by myself.&lt;/p>
&lt;p>I noticed that using ffap package adds a bit of cognitive overload for my workflow. I have to always think about where my cursor is before I press &lt;strong>C-x C-f&lt;/strong>.&lt;/p>
&lt;p>I decicded to write my own function that should check for &lt;code>current-prefix-arg&lt;/code> and call &lt;code>find-file&lt;/code> or &lt;code>find-file-at-point&lt;/code> accordingly
but just before that I decided to read some docs.&lt;/p>
&lt;h2 id="rtfm">RTFM&lt;/h2>
&lt;p>Something that I don&amp;rsquo;t think I&amp;rsquo;ve ever done is &lt;strong>C-h f find-file&lt;/strong>.&lt;/p>
&lt;p>I learned this keybinding early on in my Emacs journey and never needed to read a documentation for it.&lt;/p>
&lt;p>But if I read it, it says something about &lt;strong>M-n&lt;/strong> keybinding that uses functions defined in &lt;code>file-name-at-point-functions&lt;/code> variable.
One of them, by default, is &lt;code>ffap-guess-file-name-at-point&lt;/code>.&lt;/p>
&lt;p>So having my cursor at a file path, I can type &lt;strong>C-x C-f&lt;/strong> get my regular &lt;code>find-file&lt;/code> behavior and then I can just press &lt;strong>M-n&lt;/strong> and the minibuffer will be pre-filled with the file path at point.&lt;br>
&lt;small>&lt;em>^here is how small this blog post could be lol&lt;/em>&lt;/small>&lt;/p>
&lt;p>Perfection.&lt;/p></description></item><item><title>Emacs: Keep journaling on the go</title><link>https://codelearn.me/2025/07/27/simple-org.html</link><pubDate>Sun, 27 Jul 2025 16:35:19 +1000</pubDate><guid>https://codelearn.me/2025/07/27/simple-org.html</guid><description>&lt;p>I&amp;rsquo;ve been journaling a lot for many years. It cools down my brain a little and helps me reflect on things better.
Emacs and org-mode are of course the tools I use to journal.&lt;/p>
&lt;h2 id="the-problem">The problem&lt;/h2>
&lt;p>I can&amp;rsquo;t easily journal on the go when I only have my phone handy.&lt;/p>
&lt;h2 id="solution">Solution&lt;/h2>
&lt;p>I&amp;rsquo;ve built incredibly minimal web page with a simple form.
When the form is submitted it is captured by a script, parses the form data and calls my Emacs with &lt;code>--eval&lt;/code> to
add the form data into my &lt;code>journal.org&lt;/code> file.&lt;/p>
&lt;p>And when I say minimal I mean it. Just look at it.
&lt;img alt="simple-org screenshot" src="https://codelearn.me/assets/img/simple-org.png" width="100%"/>&lt;/p>
&lt;p>Here is its whole source code:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-php" data-lang="php">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">&amp;lt;&lt;/span>&lt;span style="color:#a6e22e">html&lt;/span>&lt;span style="color:#f92672">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#f92672">&amp;lt;&lt;/span>&lt;span style="color:#a6e22e">head&lt;/span>&lt;span style="color:#f92672">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#f92672">&amp;lt;&lt;/span>&lt;span style="color:#a6e22e">meta&lt;/span> &lt;span style="color:#a6e22e">name&lt;/span>&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#e6db74">&amp;#34;viewport&amp;#34;&lt;/span> &lt;span style="color:#a6e22e">content&lt;/span>&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#e6db74">&amp;#34;width=device-width, initial-scale=2.0, maximum-scale=4.0&amp;#34;&lt;/span>&lt;span style="color:#f92672">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#f92672">&amp;lt;/&lt;/span>&lt;span style="color:#a6e22e">head&lt;/span>&lt;span style="color:#f92672">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#f92672">&amp;lt;&lt;/span>&lt;span style="color:#a6e22e">body&lt;/span>&lt;span style="color:#f92672">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#f92672">&amp;lt;&lt;/span>&lt;span style="color:#a6e22e">form&lt;/span> &lt;span style="color:#a6e22e">action&lt;/span>&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#e6db74">&amp;#34;&amp;#34;&lt;/span> &lt;span style="color:#a6e22e">method&lt;/span>&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#e6db74">&amp;#34;post&amp;#34;&lt;/span>&lt;span style="color:#f92672">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#f92672">&amp;lt;&lt;/span>&lt;span style="color:#a6e22e">input&lt;/span> &lt;span style="color:#a6e22e">name&lt;/span>&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#e6db74">&amp;#34;title&amp;#34;&lt;/span> &lt;span style="color:#a6e22e">type&lt;/span>&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#e6db74">&amp;#34;text&amp;#34;&lt;/span>&lt;span style="color:#f92672">/&amp;gt;&amp;lt;&lt;/span>&lt;span style="color:#a6e22e">br&lt;/span>&lt;span style="color:#f92672">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#f92672">&amp;lt;&lt;/span>&lt;span style="color:#a6e22e">textarea&lt;/span> &lt;span style="color:#a6e22e">name&lt;/span>&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#e6db74">&amp;#34;content&amp;#34;&lt;/span>&lt;span style="color:#f92672">&amp;gt;&amp;lt;/&lt;/span>&lt;span style="color:#a6e22e">textarea&lt;/span>&lt;span style="color:#f92672">&amp;gt;&amp;lt;&lt;/span>&lt;span style="color:#a6e22e">br&lt;/span>&lt;span style="color:#f92672">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#f92672">&amp;lt;&lt;/span>&lt;span style="color:#a6e22e">button&lt;/span>&lt;span style="color:#f92672">&amp;gt;&lt;/span>&lt;span style="color:#a6e22e">submit&lt;/span>&lt;span style="color:#f92672">&amp;lt;/&lt;/span>&lt;span style="color:#a6e22e">button&lt;/span>&lt;span style="color:#f92672">&amp;gt;&amp;lt;&lt;/span>&lt;span style="color:#a6e22e">br&lt;/span>&lt;span style="color:#f92672">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#f92672">&amp;lt;/&lt;/span>&lt;span style="color:#a6e22e">form&lt;/span>&lt;span style="color:#f92672">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#f92672">&amp;lt;/&lt;/span>&lt;span style="color:#a6e22e">body&lt;/span>&lt;span style="color:#f92672">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">&amp;lt;/&lt;/span>&lt;span style="color:#a6e22e">html&lt;/span>&lt;span style="color:#f92672">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">&amp;lt;?&lt;/span>&lt;span style="color:#a6e22e">php&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">if&lt;/span> ($_SERVER[&lt;span style="color:#e6db74">&amp;#39;REQUEST_METHOD&amp;#39;&lt;/span>] &lt;span style="color:#f92672">==&lt;/span> &lt;span style="color:#e6db74">&amp;#39;POST&amp;#39;&lt;/span>) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> $title &lt;span style="color:#f92672">=&lt;/span> &lt;span style="color:#a6e22e">addslashes&lt;/span>($_POST[&lt;span style="color:#e6db74">&amp;#39;title&amp;#39;&lt;/span>]);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> $content &lt;span style="color:#f92672">=&lt;/span> &lt;span style="color:#a6e22e">addslashes&lt;/span>($_POST[&lt;span style="color:#e6db74">&amp;#39;content&amp;#39;&lt;/span>]);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#75715e"># In actual file it&amp;#39;s a oneliner.
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e">&lt;/span> &lt;span style="color:#75715e"># I split it for this post purposes.
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e">&lt;/span> &lt;span style="color:#75715e"># Hope it still works in case you decide to copy/paste.
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e">&lt;/span> $cmd &lt;span style="color:#f92672">=&lt;/span> &lt;span style="color:#e6db74">&amp;#34;emacs --batch --load=&lt;/span>&lt;span style="color:#ae81ff">\&amp;#34;&lt;/span>&lt;span style="color:#e6db74">~/.emacs.d/init.el&lt;/span>&lt;span style="color:#ae81ff">\&amp;#34;&lt;/span>&lt;span style="color:#e6db74"> --eval &lt;/span>&lt;span style="color:#ae81ff">\&amp;#34;&lt;/span>&lt;span style="color:#e6db74">&amp;#34;&lt;/span>;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> $cmd &lt;span style="color:#f92672">.=&lt;/span> &lt;span style="color:#e6db74">&amp;#34;(progn &amp;#34;&lt;/span>;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> $cmd &lt;span style="color:#f92672">.=&lt;/span> &lt;span style="color:#e6db74">&amp;#34; (org-capture nil &lt;/span>&lt;span style="color:#ae81ff">\\\&amp;#34;&lt;/span>&lt;span style="color:#e6db74">j&lt;/span>&lt;span style="color:#ae81ff">\\\&amp;#34;&lt;/span>&lt;span style="color:#e6db74">)&amp;#34;&lt;/span>;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> $cmd &lt;span style="color:#f92672">.=&lt;/span> &lt;span style="color:#e6db74">&amp;#34; (insert &lt;/span>&lt;span style="color:#ae81ff">\\\&amp;#34;&lt;/span>&lt;span style="color:#e6db74">{&lt;/span>$title&lt;span style="color:#e6db74">}&lt;/span>&lt;span style="color:#ae81ff">\\\&amp;#34;&lt;/span>&lt;span style="color:#e6db74">)&amp;#34;&lt;/span>;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> $cmd &lt;span style="color:#f92672">.=&lt;/span> &lt;span style="color:#e6db74">&amp;#34; (end-of-buffer) (org-return) (org-cycle)&amp;#34;&lt;/span>;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> $cmd &lt;span style="color:#f92672">.=&lt;/span> &lt;span style="color:#e6db74">&amp;#34; (insert &lt;/span>&lt;span style="color:#ae81ff">\\\&amp;#34;&lt;/span>&lt;span style="color:#e6db74">{&lt;/span>$content&lt;span style="color:#e6db74">}&lt;/span>&lt;span style="color:#ae81ff">\\\&amp;#34;&lt;/span>&lt;span style="color:#e6db74">) (org-capture-finalize))&lt;/span>&lt;span style="color:#ae81ff">\&amp;#34;&lt;/span>&lt;span style="color:#e6db74">&amp;#34;&lt;/span>;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#a6e22e">shell_exec&lt;/span>($cmd);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e">?&amp;gt;&lt;/span>&lt;span style="color:#960050;background-color:#1e0010">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;br/>
&lt;p>I start it with &lt;code>php -S 0.0.0.0:8080&lt;/code> and it just works. It knows what templates I use and it knows where the &lt;code>org-directory&lt;/code> is. &lt;br/>
I deployed it to my home server (just a laptop in my closet) and run it using &lt;a href="https://www.portainer.io/">Portainer&lt;/a>.&lt;/p>
&lt;p>My home server is constantly available for me thanks to &lt;a href="https://tailscale.com/">Tailscale&lt;/a> so I can access it outside of my home.&lt;/p>
&lt;h2 id="why-not">Why not&lt;/h2>
&lt;h3 id="why-not-orgzly">Why not Orgzly&lt;/h3>
&lt;p>&lt;a href="https://github.com/orgzly-revived/orgzly-android-revived">Orgzly&lt;/a>, for those who doesn&amp;rsquo;t know, is an Android app that
allows to interact with org-mode files. One can import org files in it and then just update them on the go.
Synchronization among machines can be done with &lt;a href="https://syncthing.net/">Syncthing&lt;/a>.&lt;/p>
&lt;p>It&amp;rsquo;s very good app and I was using it for journaling a lot.
Often times though, I want to add a note to my journal and then I realize that I need to create
all the subheadings for today manually to follow the format I defined in my &lt;code>org-capture-templates&lt;/code>. Not a big deal and it worked
for awhile but it stopped me from dumping my thoughts into the journal quite a few times.&lt;/p>
&lt;h3 id="why-not-emacs-on-android-or-termux--emacs">Why not Emacs on Android or Termux + Emacs&lt;/h3>
&lt;p>Both are great solutions as soon as one plugs in a keyboard into their phone. Using Emacs on a touch-screen is of course possible
but the amount of frustration I get in the first 10 seconds of using it feels very much unjustified.&lt;/p>
&lt;h3 id="why-not-run-the-same-script-on-your-phone-locally">Why not run the same script on your phone locally&lt;/h3>
&lt;p>In this case I don&amp;rsquo;t need the whole home server setup with tailscale and portainer. Just syncthing which I already have would do the job.&lt;br/>
Good point. I just wanted to have a bit more fun than that :)&lt;/p></description></item><item><title>Newsticker - Emacs built-in RSS reader</title><link>https://codelearn.me/2025/04/09/emacs-newsticker.html</link><pubDate>Wed, 09 Apr 2025 16:47:34 +1000</pubDate><guid>https://codelearn.me/2025/04/09/emacs-newsticker.html</guid><description>&lt;p>I&amp;rsquo;ve been browsing Emacs&amp;rsquo;s &lt;strong>The Info Directory&lt;/strong> (C-h i) the other day and came across a menu item called &lt;strong>Newsticker&lt;/strong>.&lt;/p>
&lt;p>Turned out is a built-in RSS reader I never heard of.
I know Emacs has &lt;strong>Gnus&lt;/strong> which I tried to use as RSS reader before but didn&amp;rsquo;t succeed.
Then, as probably most of Emacs users, I moved to &lt;strong>Elfeed&lt;/strong> which is great.&lt;/p>
&lt;p>Here is how Newsticker looks like:&lt;/p>
&lt;img alt="hermit logo" src="https://codelearn.me/assets/img/newsticker-treeview.png" width="100%"/>
&lt;p>isn&amp;rsquo;t it nice? You can open it with &lt;strong>M-x newsticker-show-news&lt;/strong>.&lt;/p>
&lt;p>It&amp;rsquo;s been a few weeks since I decided to use it.&lt;/p>
&lt;h3 id="navigation">Navigation&lt;/h3>
&lt;p>Navigation is very simple:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>f&lt;/strong> and &lt;strong>F&lt;/strong> for switching feeds forward/backward&lt;/li>
&lt;li>&lt;strong>n&lt;/strong> and &lt;strong>p&lt;/strong> for switching posts&lt;/li>
&lt;li>&lt;strong>&amp;lt;RET&amp;gt;&lt;/strong> to read full article&lt;/li>
&lt;/ul>
&lt;h3 id="configuration">Configuration&lt;/h3>
&lt;p>Setting feeds is only slightly different from Elfeed:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-lisp" data-lang="lisp">&lt;span style="display:flex;">&lt;span>(&lt;span style="color:#66d9ef">setq&lt;/span> newsticker-url-list &lt;span style="color:#f92672">&amp;#39;&lt;/span>(
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> (&lt;span style="color:#e6db74">&amp;#34;Planet Emacslife&amp;#34;&lt;/span> &lt;span style="color:#e6db74">&amp;#34;https://planet.emacslife.com/atom.xml&amp;#34;&lt;/span>)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> (&lt;span style="color:#e6db74">&amp;#34;&amp;lt;name&amp;gt;&amp;#34;&lt;/span> &lt;span style="color:#e6db74">&amp;#34;&amp;lt;url&amp;gt;&amp;#34;&lt;/span>)))
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Also when &lt;strong>q&lt;/strong> is pressed the whole Newsticker is closed BUT its buffers are still there
which I don&amp;rsquo;t really like.&lt;/p>
&lt;p>So I came up with this elisp:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-lisp" data-lang="lisp">&lt;span style="display:flex;">&lt;span>(defun my/close-newsticker ()
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#e6db74">&amp;#34;Kill all tree-view related buffers.&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> (kill-buffer &lt;span style="color:#e6db74">&amp;#34;*Newsticker List*&amp;#34;&lt;/span>)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> (kill-buffer &lt;span style="color:#e6db74">&amp;#34;*Newsticker Item*&amp;#34;&lt;/span>)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> (kill-buffer &lt;span style="color:#e6db74">&amp;#34;*Newsticker Tree*&amp;#34;&lt;/span>))
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>(advice-add &lt;span style="color:#e6db74">&amp;#39;newsticker-treeview-quit&lt;/span> &lt;span style="color:#e6db74">:after&lt;/span> &lt;span style="color:#e6db74">&amp;#39;my/close-newsticker&lt;/span>)
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Now when &lt;strong>newsticker-treeview-quit&lt;/strong> function is called the Newsticker buffers getting killed too.&lt;/p>
&lt;h3 id="why-use-built-in-tools">Why use built-in tools&lt;/h3>
&lt;p>I remember I&amp;rsquo;ve read, I think in &lt;a href="https://irreal.org/blog/">Irreal&amp;rsquo;s blog&lt;/a> about not understanding some people&amp;rsquo;s obsession to use built-in tools in Emacs.&lt;/p>
&lt;p>I can&amp;rsquo;t quite explain it either but I do feel drawn towards built-in tools too haha.&lt;/p>
&lt;p>Naturally I try to track/think about every extension I add to my config
to make sure it&amp;rsquo;s up to date, not abandoned, supports my version of emacs, how much dependencies it has, etc. And even when everything is ok, I still
feel like someone can take it from me if let&amp;rsquo;s say a maintainer will decide to archive the project or something.&lt;/p>
&lt;p>It just sits in my brain on the background and slowly drains my energy.
It&amp;rsquo;s maybe silly reason but I just feel more vulnerable with more dependencies.&lt;/p>
&lt;p>Anyways, I suggest you to try &lt;strong>Newsticker&lt;/strong>, it&amp;rsquo;s very interesting mode.&lt;/p></description></item><item><title>Emacs: glasses-mode</title><link>https://codelearn.me/2025/02/24/emacs-glasses-mode.html</link><pubDate>Mon, 24 Feb 2025 00:00:00 +0000</pubDate><guid>https://codelearn.me/2025/02/24/emacs-glasses-mode.html</guid><description>&lt;p>Let&amp;rsquo;s say I have this code (TypeScript) with long &lt;strong>camelCased&lt;/strong> variable names.
&lt;a target="_blank" href="https://codelearn.me/assets/img/typescript-long.png">&lt;img alt="typescript code with long names" src="https://codelearn.me/assets/img/typescript-long.png" width="600px"/>&lt;/a>&lt;/p>
&lt;p>I&amp;rsquo;m ok with &lt;strong>camelCase&lt;/strong> variables especially if this is a convention for a language.
But at the same time I find it a bit difficult to read compared to &lt;strong>underscore_case&lt;/strong> style.&lt;/p>
&lt;p>Meet &lt;code>M-x glasses-mode&lt;/code>.&lt;/p>
&lt;p>A beautiful minor mode that is there, built-in, since Emacs 21.
Look what it does
&lt;a target="_blank" href="https://codelearn.me/assets/img/typescript-long-underscores.png">&lt;img alt="typescript code with long names but this type every name has underscores" src="https://codelearn.me/assets/img/typescript-long-underscores.png" width="600px"/>&lt;/a>&lt;/p>
&lt;p>The mode doesn&amp;rsquo;t change text in the buffer. It just makes it look like &lt;strong>camelCase&lt;/strong> variable names became &lt;strong>underscore_case&lt;/strong>.
It is possible to keep editing the buffer and variable names will adjust on the fly. You can use your &lt;code>M-x rg&lt;/code> or &lt;code>M-x grep&lt;/code> and they will search for the
text under cursor in &lt;strong>camelCase&lt;/strong> because, again, text in the buffer isn&amp;rsquo;t changed.&lt;/p>
&lt;p>Amazing.&lt;/p></description></item><item><title>Emacs: quick-calc</title><link>https://codelearn.me/2024/12/22/emacs-quick-calc.html</link><pubDate>Sun, 22 Dec 2024 00:00:00 +0000</pubDate><guid>https://codelearn.me/2024/12/22/emacs-quick-calc.html</guid><description>&lt;p>You probably have heard about famous emacs &lt;code>M-x calc&lt;/code>.
I always wanted to become a poweruser of it but never could. My needs are too simple for it, I just want to quickly add/subtract numbers.&lt;/p>
&lt;p>Recently I&amp;rsquo;ve discovered built-in &lt;code>M-x quick-calc&lt;/code> which is perfect for what I need. It is already bound to &lt;code>C-x * q&lt;/code>.&lt;/p>
&lt;p>You can quickly calculate what&amp;rsquo;s needed
and the result is going to be saved to the kill-ring. You can paste the result in place if you want by prefixing the command with &lt;code>C-u&lt;/code>.&lt;/p>
&lt;p>&lt;a target="_blank" href="https://codelearn.me/assets/img/emacs-quick-calc-1.png">&lt;img alt="emacs quick calc expression" src="https://codelearn.me/assets/img/emacs-quick-calc-1.png"/>&lt;/a>
&lt;a target="_blank" href="https://codelearn.me/assets/img/emacs-quick-calc-2.png">&lt;img alt="emacs quick calc result" src="https://codelearn.me/assets/img/emacs-quick-calc-2.png"/>&lt;/a>&lt;/p>
&lt;p>Emacs has everything :)&lt;/p></description></item><item><title>Emacs: which-function-mode</title><link>https://codelearn.me/2024/02/02/emacs-which-function-mode.html</link><pubDate>Fri, 02 Feb 2024 00:00:00 +0000</pubDate><guid>https://codelearn.me/2024/02/02/emacs-which-function-mode.html</guid><description>&lt;h2 id="the-problem">The problem&lt;/h2>
&lt;p>I sometimes work with long functions or big org subtrees and it&amp;rsquo;s not always clear
what function or org subtree I&amp;rsquo;m in right now.
I wish there is a package that can show me what function I&amp;rsquo;m in.&lt;/p>
&lt;h2 id="which-function-mode">which-function-mode&lt;/h2>
&lt;p>&lt;a target="_blank" href="https://codelearn.me/assets/img/which-function-mode.png">&lt;img alt="trace output" src="https://codelearn.me/assets/img/which-function-mode.png" width="800px"/>&lt;/a>&lt;/p>
&lt;p>Turns out Emacs has this mode built-in so this functionality is just &lt;code>M-x which-function-mode&lt;/code> away.
It shows in the status line a function name I&amp;rsquo;m currently in (see &lt;code>[encode_terminal_code]&lt;/code> on the screenshot above).
It&amp;rsquo;s global mode so as soon as it&amp;rsquo;s enabled, you&amp;rsquo;ll see it&amp;rsquo;s working for every buffer.
You can have it enabled on Emacs startup by adding &lt;code>(which-function-mode)&lt;/code> to your config file.
&lt;br>&lt;br>
I just started to get benefits of this mode but it&amp;rsquo;s already surprising how well it works:&lt;/p>
&lt;ul>
&lt;li>it works in various prog modes&lt;/li>
&lt;li>it works in org mode&lt;/li>
&lt;li>it even works in markdown files&lt;/li>
&lt;/ul>
&lt;p>It doesn&amp;rsquo;t seem to work in html files I tried it with or modes that use html (e.g. vuejs or laravel blade files).
&lt;br>It definitely not an issue for me so I&amp;rsquo;m going to continue using it and &lt;strong>I suggest you to try it out&lt;/strong>.&lt;/p></description></item><item><title>Emacs: Did you know about IBuffer?</title><link>https://codelearn.me/2023/11/15/emacs-ibuffer.html</link><pubDate>Wed, 15 Nov 2023 00:00:00 +0000</pubDate><guid>https://codelearn.me/2023/11/15/emacs-ibuffer.html</guid><description>&lt;h2 id="the-problem">The problem&lt;/h2>
&lt;p>Sometimes I use &lt;code>C-x C-b&lt;/code> to get list of buffers so I can
clean it up a little after some time.
To do it I mark some buffers with &lt;code>d&lt;/code> (to delete) and then press &lt;code>x&lt;/code>.&lt;/p>
&lt;p>Today I wanted to filter that list of buffers to a particular project/folder and turned out I can&amp;rsquo;t. &lt;br>
There is no way to filter &lt;strong>*Buffer List*&lt;/strong>.&lt;br>&lt;/p>
&lt;h2 id="ibuffer">IBuffer&lt;/h2>
&lt;p>If you look up for Buffer Menu in EmacsWiki you&amp;rsquo;ll find the &lt;a href="https://www.emacswiki.org/emacs/BufferMenu">Enhancements section&lt;/a> which mentions &lt;code>IBufferMode&lt;/code> which is built-in since Emacs 22.&lt;/p>
&lt;p>This mode is literally Buffer Menu on steroids. Looks pretty much the same so from UI perspective you&amp;rsquo;ll see no changes (almost).&lt;/p>
&lt;p>To filter buffers by directory just type &lt;code>/ F&lt;/code> and enter the project/folder name.
The only thing left is &lt;code>C-x h d x&lt;/code> to mark all buffers and delete them.&lt;br>
To remove all the applied filters just do &lt;code>/ /&lt;/code>.&lt;/p>
&lt;p>The number of filtering commands available by default is great.&lt;br>
You can find them by &lt;code>C-h m&lt;/code> (describe-mode) and then look for &amp;ldquo;Filtering commands&amp;rdquo; section. Go through other sections as well to get more familiar with ibuffer capabilities.&lt;/p>
&lt;h2 id="doom--spacemacs">Doom &amp;amp; Spacemacs&lt;/h2>
&lt;p>If you&amp;rsquo;re Doom user you probably already enjoying this mode since it&amp;rsquo;s enabled by default.&lt;br>
In Spacemacs you can enable it by turning on &lt;code>ibuffer&lt;/code> layer.&lt;/p>
&lt;p>Both of these config distributions remap standard &lt;code>C-x C-b&lt;/code> to call &lt;code>ibuffer&lt;/code> and I suggest you do the same if you use custom config like me.&lt;/p></description></item><item><title>Emacs find-grep-dired: Filter files based on content</title><link>https://codelearn.me/2023/10/17/emacs-find-grep-dired.html</link><pubDate>Tue, 17 Oct 2023 00:00:00 +0000</pubDate><guid>https://codelearn.me/2023/10/17/emacs-find-grep-dired.html</guid><description>&lt;h2 id="intro">Intro&lt;/h2>
&lt;p>We all need to search in files sometimes, right?&lt;/p>
&lt;p>I usually do it using &lt;code>grep -ri 'search term' .&lt;/code> in the terminal (often in vterm-mode)
and then I either open the file(s) in Emacs or in any other program.&lt;/p>
&lt;p>But Emacs has better solution to it.&lt;/p>
&lt;h2 id="find-grep-dired">find-grep-dired&lt;/h2>
&lt;p>There is &lt;code>M-x find-grep-dired&lt;/code> already built-in to Emacs.
If you call it from Dired buffer it will auto-complete the current folder
and then you just need to enter the search term.&lt;/p>
&lt;p>Cool thing is that result of this function is just filtered Dired buffer which means
you can perform regular Dired operations on the found files (delete them, move to another folder, etc).&lt;br>
This especially come in handy if you have &lt;code>(setq dired-dwim-target t)&lt;/code> and another Dired buffer opened in split so you
can quickly move files between splits (Far/Total Commander style).&lt;/p>
&lt;h2 id="configuration">Configuration&lt;/h2>
&lt;p>&lt;code>M-x find-grep-dired&lt;/code> is as quick as &lt;code>grep&lt;/code> is. &lt;br>
According to this function&amp;rsquo;s help page you can change &lt;code>grep-program&lt;/code> variable
if you want to use rg, ag or whatever&amp;hellip;&lt;br>
CAUTION: It&amp;rsquo;s pretty possible &lt;code>grep-program&lt;/code> may be used by other Emacs functions that may expect grep-specific output.&lt;/p></description></item><item><title>Emacs has built-in thread macros</title><link>https://codelearn.me/2023/05/28/emacs_thread_macros.html</link><pubDate>Sun, 28 May 2023 00:00:00 +0000</pubDate><guid>https://codelearn.me/2023/05/28/emacs_thread_macros.html</guid><description>&lt;h2 id="intro">Intro&lt;/h2>
&lt;p>Surprisingly for me I just discovered that Emacs Lisp has equivalent
of Clojure&amp;rsquo;s &lt;code>-&amp;gt;&lt;/code> and &lt;code>-&amp;gt;&amp;gt;&lt;/code> macros.&lt;/p>
&lt;p>And I&amp;rsquo;m not talking about &lt;code>dash.el&lt;/code>. I&amp;rsquo;m talking about built-in &lt;code>thread-first&lt;/code> and &lt;code>thread-last&lt;/code>.&lt;/p>
&lt;h2 id="what-are-these">What are these&lt;/h2>
&lt;p>If you&amp;rsquo;re not familiar with these beautiful macros, the main goal is to pipe a value through multiple functions
and return the result.&lt;/p>
&lt;p>&lt;code>-&amp;gt;&lt;/code> passes a value as first argument of next function, then takes the result and passes it as first argument to next function, etc.&lt;br>
&lt;code>-&amp;gt;&amp;gt;&lt;/code> does the same except that it passes the result as next function&amp;rsquo;s last argument&lt;/p>
&lt;h3 id="example">Example&lt;/h3>
&lt;p>Instead of having this:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-lisp" data-lang="lisp">&lt;span style="display:flex;">&lt;span>(&lt;span style="color:#a6e22e">+&lt;/span> (&lt;span style="color:#a6e22e">-&lt;/span> (&lt;span style="color:#a6e22e">/&lt;/span> (&lt;span style="color:#a6e22e">+&lt;/span> &lt;span style="color:#ae81ff">5&lt;/span> &lt;span style="color:#ae81ff">20&lt;/span>) &lt;span style="color:#ae81ff">25&lt;/span>)) &lt;span style="color:#ae81ff">40&lt;/span>)
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>we can have this:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-lisp" data-lang="lisp">&lt;span style="display:flex;">&lt;span>(-&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#ae81ff">5&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> (&lt;span style="color:#a6e22e">+&lt;/span> &lt;span style="color:#ae81ff">20&lt;/span>)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> (&lt;span style="color:#a6e22e">/&lt;/span> &lt;span style="color:#ae81ff">25&lt;/span>)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#a6e22e">-&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> (&lt;span style="color:#a6e22e">+&lt;/span> &lt;span style="color:#ae81ff">40&lt;/span>))
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>It&amp;rsquo;s way easier to modify and which is even more important - to read.&lt;/p>
&lt;h2 id="emacs-lisp-equivalent">Emacs lisp equivalent&lt;/h2>
&lt;p>There is &lt;code>dash.el&lt;/code> library that provides us with similar macros (and many more) but emacs has built-in &lt;code>thread-first&lt;/code> and &lt;code>thread-last&lt;/code>.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-lisp" data-lang="lisp">&lt;span style="display:flex;">&lt;span>(thread-first
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#ae81ff">5&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> (&lt;span style="color:#a6e22e">+&lt;/span> &lt;span style="color:#ae81ff">20&lt;/span>)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> (&lt;span style="color:#a6e22e">/&lt;/span> &lt;span style="color:#ae81ff">25&lt;/span>)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#a6e22e">-&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> (&lt;span style="color:#a6e22e">+&lt;/span> &lt;span style="color:#ae81ff">40&lt;/span>))
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>will work for you if you&amp;rsquo;re on Emacs 25 or newer.&lt;/p>
&lt;p>I don&amp;rsquo;t write much elisp but every time I do I feel like I miss those &lt;code>-&amp;gt;&lt;/code>/&lt;code>-&amp;gt;&amp;gt;&lt;/code>.&lt;/p>
&lt;p>Not anymore!&lt;/p></description></item><item><title>Emacs: A few issues of Org-Roam</title><link>https://codelearn.me/2023/05/25/org_roam_issues.html</link><pubDate>Thu, 25 May 2023 00:00:00 +0000</pubDate><guid>https://codelearn.me/2023/05/25/org_roam_issues.html</guid><description>&lt;h2 id="intro">Intro&lt;/h2>
&lt;p>It has been almost a year since I started to use Org-Roam.
I initially migrated from Obsidian even though I was incredibly happy with it.&lt;/p>
&lt;p>Recently I started to take more notes than usual and noticed that Org-Roam has some issues
that for me aren&amp;rsquo;t critical but disturbing.&lt;/p>
&lt;h2 id="issues">Issues&lt;/h2>
&lt;h3 id="no-build-in-search-functionality">No build-in search functionality&lt;/h3>
&lt;p>There is just no something like &lt;code>M-x org-roam-search&lt;/code>.&lt;/p>
&lt;p>I&amp;rsquo;m pretty sure there is no such thing because it&amp;rsquo;s Emacs and you can search any directory you want very quickly
using built-in &lt;code>grep&lt;/code>, &lt;code>rgrep&lt;/code> or other tools like that.
And of course you can make a function off of that and then bind it to a key chord you like.&lt;/p>
&lt;p>But having such function already there will not force Org-Roam users to add more
lines to their config.&lt;/p>
&lt;h3 id="org-roam-node-insert---dont-understand-a-word-at-point">org-roam-node-insert - don&amp;rsquo;t understand a word at point&lt;/h3>
&lt;p>&lt;code>org-roam-node-insert&lt;/code> is very useful. Is how you link notes together.&lt;/p>
&lt;p>At the moment when note is typed I usually quickly review it and then connect it to other notes.
In such a case I move my cursor to a word that I&amp;rsquo;m going to use as a link and type that command.&lt;/p>
&lt;p>The minibuffer starts listing all the notes but the &amp;ldquo;linking word&amp;rdquo; my cursor is at isn&amp;rsquo;t used.&lt;/p>
&lt;p>There is no such issue in case you mark a word and then call &lt;code>M-x org-roam-node-insert&lt;/code>.&lt;/p>
&lt;p>Again, since it&amp;rsquo;s Emacs it should be quite easy to fix.&lt;/p>
&lt;p>It would be nice to have it default though. I can&amp;rsquo;t find arguments against it.&lt;/p>
&lt;h3 id="note-creation-date">Note creation date&lt;/h3>
&lt;p>Yes, it is in a file name BUT&lt;/p>
&lt;p>if you use grep or even something like consult-grep for searching in your notes you will not be able to
filter your results by a date.&lt;/p>
&lt;p>It probably can be fixed with org roam templates.&lt;/p>
&lt;h3 id="note-ids">Note IDs&lt;/h3>
&lt;p>I was able to find many complains about it.&lt;/p>
&lt;p>For me it&amp;rsquo;s not that serious in terms of fear that my notes and links may stop working
if I loose the roam db (the db is just a cache) or roam is not supported anymore (org files are text).&lt;/p>
&lt;p>The main issue for me here is that I can&amp;rsquo;t understand the links if I open my notes in an editor that
doesn&amp;rsquo;t have Org Mode. It sometimes happens. It happens on my Android. It happens on my Windows machine that I barely use and I don&amp;rsquo;t even need Emacs there.&lt;/p>
&lt;p>In such a case I see the link with an ID and description of that link which sometimes doesn&amp;rsquo;t exactly match a note file name.&lt;/p>
&lt;p>If org format is pure text and intended to be human readable, it&amp;rsquo;s probably should stay this way.&lt;/p>
&lt;h2 id="conclusion">Conclusion&lt;/h2>
&lt;p>It should be understood that Org-Roam is open source and community driven. It definitely can be improved as, probably, any software.&lt;/p>
&lt;p>The only person I can blame for not implementing those functionalities I mentioned is me.
The project is opened for everyone to contribute (including me) so I hope I can fix those things somehow.&lt;/p></description></item><item><title>Org-mode archive with inherited tags</title><link>https://codelearn.me/2023/05/19/org-mode-archive-with-tags.html</link><pubDate>Fri, 19 May 2023 00:00:00 +0000</pubDate><guid>https://codelearn.me/2023/05/19/org-mode-archive-with-tags.html</guid><description>&lt;h2 id="the-issue">The issue&lt;/h2>
&lt;p>By default only the tags directly attached to an org record will be saved in the archive file.
I want to keep all the tags attached to an org record when I archive it, even the inherited ones.&lt;/p>
&lt;h2 id="explanation">Explanation&lt;/h2>
&lt;p>In org-mode tags are inherited by default. In case of org tree like this:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-markdown" data-lang="markdown">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">*&lt;/span> Header1 :tag1:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>** Sub Header1 :subtag1:
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>you may find that &lt;strong>Sub Header1&lt;/strong> has &lt;code>:tag1:subtag1:&lt;/code> tags attached to it.&lt;/p>
&lt;p>This is something reflected in Agenda view.
Also if you try to find headers with &lt;code>:tag1:&lt;/code> &lt;br/>the &lt;strong>Sub Header1&lt;/strong> will be one of those even though
we didn&amp;rsquo;t directly attach that tag to it. That&amp;rsquo;s the tag inheritance.&lt;/p>
&lt;p>If you try to archive &lt;strong>Sub Header1&lt;/strong> you will get this kind of record in the *_archive.org file:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-markdown" data-lang="markdown">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">*&lt;/span> Sub Header1 :subtag1: &amp;lt;&lt;span style="color:#f92672">---&lt;/span> &lt;span style="color:#a6e22e">this&lt;/span> &lt;span style="color:#a6e22e">is&lt;/span> &lt;span style="color:#a6e22e">the&lt;/span> &lt;span style="color:#a6e22e">tag&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#a6e22e">:PROPERTIES:&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#a6e22e">:ARCHIVE_TIME:&lt;/span> &lt;span style="color:#960050;background-color:#1e0010">&amp;lt;&lt;/span>&lt;span style="color:#a6e22e">date&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> :ARCHIVE_FILE: &amp;lt;&lt;span style="color:#f92672">original&lt;/span> &lt;span style="color:#a6e22e">org&lt;/span> &lt;span style="color:#a6e22e">file&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> :ARCHIVE_OLPATH: &amp;lt;&lt;span style="color:#f92672">org&lt;/span> &lt;span style="color:#a6e22e">path&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> :ARCHIVE_CATEGORY: &amp;lt;&lt;span style="color:#f92672">org&lt;/span> &lt;span style="color:#a6e22e">file&lt;/span> &lt;span style="color:#a6e22e">category&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> :ARCHIVE_ITAGS: tag1 &amp;lt;&lt;span style="color:#f92672">---&lt;/span> &lt;span style="color:#a6e22e">this&lt;/span> &lt;span style="color:#a6e22e">is&lt;/span> &lt;span style="color:#a6e22e">the&lt;/span> &lt;span style="color:#a6e22e">inherited&lt;/span> &lt;span style="color:#a6e22e">tags&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#a6e22e">:END:&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>As you can see the &lt;code>tag1&lt;/code> is missing in the heading. It is available in the &lt;code>ARCHIVE_ITAGS&lt;/code> though.
For me it would be much better if I can see all the tags immediately in the record heading. It will also allow me to filter
my archived records by those tags.&lt;/p>
&lt;h2 id="solution">Solution&lt;/h2>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-emacs-lisp" data-lang="emacs-lisp">&lt;span style="display:flex;">&lt;span>(setq org-archive-subtree-add-inherited-tags &lt;span style="color:#66d9ef">t&lt;/span>)
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>It&amp;rsquo;s as easy as that. Now the archived heading will look like this:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-markdown" data-lang="markdown">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">*&lt;/span> Sub Header1 :tag1:subtag1:
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>which is exactly what I wanted.&lt;/p></description></item><item><title>Doom Emacs Search Documentation</title><link>https://codelearn.me/2023/05/13/doom-search-docs.html</link><pubDate>Sat, 13 May 2023 00:00:00 +0000</pubDate><guid>https://codelearn.me/2023/05/13/doom-search-docs.html</guid><description>&lt;p>Just a quick note on how easy it is to actually navigate Doom Emacs documentation and modules.&lt;/p>
&lt;p>I initially was a little afraid that I will not be able to understand what each Doom module does
and there always will be some hidden functionaltiy that will be hard for me to find.&lt;/p>
&lt;p>Fortunately there is M-x &lt;code>M-x doom/help-search-headings&lt;/code> that allows me to search through
Doom documentation. Specifically it allows me to search through org headings of the documentation.&lt;/p>
&lt;p>I can easily find a module I&amp;rsquo;m interested in, let&amp;rsquo;s say &lt;code>lsp&lt;/code>.
Then I&amp;rsquo;ll go there and I can see all the documentation of the module. I can see what packages will be installed and what configuration
options available for the module (e.g. &lt;code>+eglot&lt;/code> for &lt;code>lsp&lt;/code>).
Being in the &lt;code>README.org&lt;/code> of a module I can also open &lt;code>config.el&lt;/code> which is in the same directory and I&amp;rsquo;ll be able to inspect
all the Elisp that module will add into my Emacs.&lt;/p>
&lt;p>If you&amp;rsquo;d like to search not just headings but everything then &lt;code>M-x doom/help-search&lt;/code> is your friend.&lt;/p>
&lt;p>I start to like Doom more and more every day.&lt;/p></description></item><item><title>Doom Emacs - Turn LSP off by default for PHP files</title><link>https://codelearn.me/2023/05/09/doom-emacs-lsp-off.html</link><pubDate>Tue, 09 May 2023 00:00:00 +0000</pubDate><guid>https://codelearn.me/2023/05/09/doom-emacs-lsp-off.html</guid><description>&lt;p>I&amp;rsquo;m trying to get used to Doom Emacs and one issue I have is that LSP (in my case Eglot) starts automatically
when I open up a php project.&lt;/p>
&lt;p>I don&amp;rsquo;t really like it because sometimes I open php files that I don&amp;rsquo;t need autocompletion for
and I don&amp;rsquo;t want to remember that there is Eglot process now running that I have to stop to save some resources of my laptop.&lt;/p>
&lt;p>It happens because I have defined &lt;code>php&lt;/code> module in &lt;code>init.el&lt;/code> as &lt;code>(php +lsp)&lt;/code>.
The reason I have it defined like this is because I need LSP.
I just don&amp;rsquo;t want to start it automatically every time I open a php file.&lt;/p>
&lt;p>I like how easy it is in Doom to inspect the module implementation so I went to Doom&amp;rsquo;s &lt;code>modules/lang/php/config.el&lt;/code> and I found
that there is no flag that can force LSP to not start automatically.&lt;/p>
&lt;p>What it has though is this line:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-emacs-lisp" data-lang="emacs-lisp">&lt;span style="display:flex;">&lt;span>(add-hook &lt;span style="color:#e6db74">&amp;#39;php-mode-local-vars-hook&lt;/span> &lt;span style="color:#a6e22e">#&amp;#39;&lt;/span>lsp! &lt;span style="color:#e6db74">&amp;#39;append&lt;/span>)
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>It looks to me like something that starts the LSP automatically. It looks like this mostly because everything else looks pretty much unrelated to LSP.&lt;/p>
&lt;p>Since there is no flag, let&amp;rsquo;s solve it in our own config by directly removing that &lt;code>lsp!&lt;/code> piece from that variable:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-emacs-lisp" data-lang="emacs-lisp">&lt;span style="display:flex;">&lt;span>(after! php-mode
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> (remove-hook &lt;span style="color:#e6db74">&amp;#39;php-mode-local-vars-hook&lt;/span> &lt;span style="color:#a6e22e">#&amp;#39;&lt;/span>lsp!))
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>This will remove that &lt;code>lsp!&lt;/code> piece from &lt;code>php-mode-local-vars-hook&lt;/code> and now LSP won&amp;rsquo;t start automatically.&lt;/p>
&lt;p>It would make sense probably to add such a flag so users can easily turn off the auto-LSP but at the same time solution to this
is just one line so maybe it wouldn&amp;rsquo;t make sense to add it.&lt;/p></description></item><item><title>Trying Doom once again</title><link>https://codelearn.me/2023/05/08/keep_trying_doom.html</link><pubDate>Mon, 08 May 2023 00:00:00 +0000</pubDate><guid>https://codelearn.me/2023/05/08/keep_trying_doom.html</guid><description>&lt;p>&lt;a href="https://codelearn.me/2022/06/04/emacs-config-from-scratch.html">Almost a year ago&lt;/a> I already tried to start using Doom config which
I eventually replaced with my own vanilla config.&lt;/p>
&lt;p>Today I decided to try it once again. I also wanted to use it in Evil mode
to make my hands feel better.&lt;/p>
&lt;p>One of my main pain point with someone else&amp;rsquo;s config is that I don&amp;rsquo;t know how to handle it,
what options are available and why things work in the way they do.&lt;/p>
&lt;p>Since I was on my own config for quite some time I believe I know enough about
Emacs configuration to attempt Doom config once again.&lt;/p>
&lt;h2 id="first-impression">First impression&lt;/h2>
&lt;p>Well, it&amp;rsquo;s not first. If I&amp;rsquo;m not mistaken it&amp;rsquo;s my third or fourth attempt to use Doom.&lt;/p>
&lt;p>So far it feels ok. I ported some configuration from my vanilla config. Added packages I need and things seems working smoothly.&lt;/p>
&lt;p>It&amp;rsquo;s interesting to see that Doom preferably switched to &lt;code>project&lt;/code> mode instead of &lt;code>projectile&lt;/code> at least this is what I see
based on keybindings that are set for &lt;code>project&lt;/code> mode and no keybindings at all for &lt;code>projectile&lt;/code>.&lt;/p>
&lt;p>My custom org agendas and some other custom functions were ported with just simple copy-paste technique.&lt;/p>
&lt;h2 id="what-i-like">What I like&lt;/h2>
&lt;ul>
&lt;li>It&amp;rsquo;s really great to see the &lt;code>M-x doom/help&lt;/code> exists. Everything is documented or at least most of the things.&lt;/li>
&lt;li>There is also &lt;code>M-x doom/help-search&lt;/code> which is very useful when you need to find a specific help.
&lt;ul>
&lt;li>The documentation can be improved probably. There is no info about how to change &lt;code>evil escape sequence&lt;/code> to something different from default. At least the &lt;code>doom/help-search&lt;/code> mentions the &lt;code>evil-escape&lt;/code> package which user then can google and find how to change that escape sequence.&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>I love doom modules. Community has already spent good amount of time tweaking every module and in most of the cases I don&amp;rsquo;t need to do much to reconfigure it.&lt;/li>
&lt;li>LSP module is nice and works with Eglot. What&amp;rsquo;s great is that other modules (like PHP for example) already aware that LSP module can use Eglot and when I open a php file my Eglot just starts and works.&lt;/li>
&lt;li>Evil mode and all keybindings that already configured are incredible.&lt;/li>
&lt;li>General look and feel is way better than I could achieve with my vanilla config.&lt;/li>
&lt;li>Org looks great and evil keybindings are very nice configured.&lt;/li>
&lt;li>I like the way configuration works and some useful macros provided by Doom&lt;/li>
&lt;/ul>
&lt;h2 id="what-i-need-to-understandchange">What I need to understand/change&lt;/h2>
&lt;ul>
&lt;li>Documentation is sometimes lacking. That&amp;rsquo;s hopefully something I can help with.&lt;/li>
&lt;li>I don&amp;rsquo;t like that LSP/Eglot starts automatically. I do believe &amp;ldquo;start automatically by default&amp;rdquo; is a good choice though.&lt;/li>
&lt;li>There are no projectile keybindings and there is no my favorite &lt;code>projectile-run-vterm&lt;/code>. Easy fix though.&lt;/li>
&lt;li>I don&amp;rsquo;t really understand a point of &lt;code>+vterm/toggle&lt;/code>. It works great in one project but when I open a second one then this function still opens up the vterm that belongs to that first project.&lt;/li>
&lt;li>&lt;code>doom/reload-theme&lt;/code> - probably doesn&amp;rsquo;t work on my end. When I set &lt;code>doom-theme&lt;/code> variable to something else/non-default and then call &lt;code>M-x doom/reload-theme&lt;/code> nothing changes. I have to use &lt;code>M-x consult-theme&lt;/code> to actually change a theme.&lt;/li>
&lt;li>I still need to figure out how to use &lt;code>after!&lt;/code>. I initially thought that this macro&amp;rsquo;s first argument is something that is mentioned in &lt;code>init.el -&amp;gt; doom!&lt;/code> call but apparently I should specify an emacs package name there.&lt;/li>
&lt;/ul>
&lt;h2 id="conclusion">Conclusion&lt;/h2>
&lt;p>In general, I love the feeling. It took me almost no time to get used to vim keybindings and keep coding like nothing&amp;rsquo;s changed.
Probably my vim past is already too deep in my muscle memory. I&amp;rsquo;m glad my emacs past is also quite deep so I feel like I can seamlessly
switch from one way of editing to another.&lt;/p></description></item><item><title>Org Agenda - show archived records by default</title><link>https://codelearn.me/2023/04/13/emcas-org-agenda-archives.html</link><pubDate>Thu, 13 Apr 2023 00:00:00 +0000</pubDate><guid>https://codelearn.me/2023/04/13/emcas-org-agenda-archives.html</guid><description>&lt;p>If you didn&amp;rsquo;t know, there are two methods of archiving subtrees
in Emacs&amp;rsquo; Org-mode.&lt;/p>
&lt;ul>
&lt;li>Internal archiving (mark an item as ARCHIVED but keep it in the file)&lt;/li>
&lt;li>Moving subtrees (move an item or subtree to *_archive.org file)&lt;/li>
&lt;/ul>
&lt;p>I often use the latter but the issue here is that all my items
got disappeared from Org Agenda view when archived.&lt;/p>
&lt;p>You can tell Org Agenda to show archived records by pressing
&lt;code>v A&lt;/code> in &lt;code>*Org Agenda*&lt;/code> buffer.
Notice upper-cased &lt;code>A&lt;/code>. If you use lowercase &lt;code>a&lt;/code> then only internally
archived records will be shown.&lt;/p>
&lt;p>What &lt;code>v A&lt;/code> does is it calling &lt;code>(org-agenda-archives-mode 'files)&lt;/code>
which internally sets &lt;code>org-agenda-archives-mode&lt;/code> variable to &lt;code>t&lt;/code>.&lt;/p>
&lt;p>This is what we can do in our &lt;code>init.el&lt;/code>:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-emacs-lisp" data-lang="emacs-lisp">&lt;span style="display:flex;">&lt;span>(setq org-agenda-archives-mode &lt;span style="color:#66d9ef">t&lt;/span>)
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Done!&lt;/p></description></item><item><title>Emacs &amp; Wgrep</title><link>https://codelearn.me/2023/04/11/emacs-wgrep.html</link><pubDate>Tue, 11 Apr 2023 00:00:00 +0000</pubDate><guid>https://codelearn.me/2023/04/11/emacs-wgrep.html</guid><description>&lt;p>So I just discovered &lt;code>wgrep&lt;/code> mode of a grep buffer in Emacs and it&amp;rsquo;s incredible.&lt;/p>
&lt;p>I often use &lt;code>projectile-ripgrep&lt;/code> if I need to find something in the project I&amp;rsquo;m working on.
But if I wanted to rename some variables or strings that I grepped I had to go and manually update them or use something like
&lt;code>projectile-replace&lt;/code>.&lt;/p>
&lt;p>But turns out there is &lt;code>wgrep&lt;/code> mode that is available from &lt;code>projectile-ripgrep&lt;/code> (&lt;code>*rg*&lt;/code>) buffer or from &lt;code>*grep*&lt;/code> buffer.&lt;/p>
&lt;p>In case of you &lt;code>ripgrep&lt;/code> you just press letter &lt;code>e&lt;/code> and now you can edit anything you want. Then you press &lt;code>C-x C-s&lt;/code> and now all the changes
are made. Amazing.&lt;/p>
&lt;p>Here is an example. Let&amp;rsquo;s try to find and replace &lt;code>projectile-&lt;/code> string in this blog:&lt;/p>
&lt;p>Here is what was found (image is clickable)&lt;/p>
&lt;p>&lt;a target="_blank" ref="/assets/img/emacs-grep-projectile.png">&lt;img alt="grep view" src="https://codelearn.me/assets/img/emacs-grep-projectile.png" width="550px"/>&lt;/a>&lt;/p>
&lt;p>now I press &lt;code>e&lt;/code> and I can edit the buffer. It says this in the message area:&lt;/p>
&lt;p>&lt;a target="_blank" href="https://codelearn.me/assets/img/emacs-wgrep-message.png">&lt;img alt="wgrep view" src="https://codelearn.me/assets/img/emacs-wgrep-message.png" width="550px"/>&lt;/a>&lt;/p>
&lt;p>Now I changed few occurrences of the &lt;code>projectile-&lt;/code> to &lt;code>project-&lt;/code> and pressed &lt;code>C-x C-s&lt;/code> and now those two files are edited without me even visiting them.&lt;/p>
&lt;p>&lt;a target="_blank" href="https://codelearn.me/assets/img/emacs-wgrep-edited.png">&lt;img alt="wgrep save" src="https://codelearn.me/assets/img/emacs-wgrep-edited.png" width="550px"/>&lt;/a>&lt;/p>
&lt;p>You can save all unsaved buffers with &lt;code>C-x s&lt;/code>&lt;/p>
&lt;p>Incredible discovery. I&amp;rsquo;m going to use it all the time now.&lt;/p>
&lt;p>I&amp;rsquo;m not sure though what kind of feature is this. It&amp;rsquo;s not a package that I had to install. It&amp;rsquo;s just there and it works.&lt;/p></description></item><item><title>Emacs 29 - Straight.el &amp; Native compilation</title><link>https://codelearn.me/2023/04/09/emacs-native-compilation-notes.html</link><pubDate>Sun, 09 Apr 2023 00:00:00 +0000</pubDate><guid>https://codelearn.me/2023/04/09/emacs-native-compilation-notes.html</guid><description>&lt;p>I just built emacs-plus@29 on my MacOS using &lt;code>--with-native-comp&lt;/code> just
to see what it is and how it works.&lt;/p>
&lt;p>I&amp;rsquo;ll talk about my impression of it later. Let&amp;rsquo;s start with the issue.&lt;/p>
&lt;p>I use straight.el + use-package and as soon as I started my
new Emacs instance I&amp;rsquo;ve got this:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-emacs-lisp" data-lang="emacs-lisp">&lt;span style="display:flex;">&lt;span>Debugger entered--Lisp error: (void-variable native-comp-deferred-compilation-deny-list)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>straight--build-native-compile((:type git :host github :repo &lt;span style="color:#e6db74">&amp;#34;radian-software/straight.el&amp;#34;&lt;/span> :files (&lt;span style="color:#e6db74">&amp;#34;straight*.el&amp;#34;&lt;/span>) :branch &lt;span style="color:#e6db74">&amp;#34;master&amp;#34;&lt;/span> :package &lt;span style="color:#e6db74">&amp;#34;straight&amp;#34;&lt;/span> :local-repo &lt;span style="color:#e6db74">&amp;#34;straight.el&amp;#34;&lt;/span>))
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>straight--build-package((:type git :host github :repo &lt;span style="color:#e6db74">&amp;#34;radian-software/straight.el&amp;#34;&lt;/span> :files (&lt;span style="color:#e6db74">&amp;#34;straight*.el&amp;#34;&lt;/span>) :branch &lt;span style="color:#e6db74">&amp;#34;master&amp;#34;&lt;/span> :package &lt;span style="color:#e6db74">&amp;#34;straight&amp;#34;&lt;/span> :local-repo &lt;span style="color:#e6db74">&amp;#34;straight.el&amp;#34;&lt;/span>) &lt;span style="color:#66d9ef">nil&lt;/span>)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#960050;background-color:#1e0010">#&lt;/span>f(compiled-function () &lt;span style="color:#960050;background-color:#1e0010">#&lt;/span>&amp;lt;bytecode 0x13b193a2e77f4e46&amp;gt;)()
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>straight--transaction-exec(use-package-\&amp;#34;c809124e9c5270ea1c72e2c3507331d1\&amp;#34;-nil-nil :now &lt;span style="color:#960050;background-color:#1e0010">#&lt;/span>f(compiled-function () &lt;span style="color:#960050;background-color:#1e0010">#&lt;/span>&amp;lt;bytecode 0x13b193a2e77f4e46&amp;gt;))
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>straight-use-package((straight :type git :host github :repo &lt;span style="color:#e6db74">&amp;#34;radian-software/straight.el&amp;#34;&lt;/span> :files (&lt;span style="color:#e6db74">&amp;#34;straight*.el&amp;#34;&lt;/span>) :branch &lt;span style="color:#e6db74">&amp;#34;master&amp;#34;&lt;/span>))
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>load-with-code-conversion(&lt;span style="color:#e6db74">&amp;#34;/Users/krydos/.emacs.d/straight/repos/straight.el/...&amp;#34;&lt;/span> &lt;span style="color:#e6db74">&amp;#34;/Users/krydos/.emacs.d/straight/repos/straight.el/...&amp;#34;&lt;/span> &lt;span style="color:#66d9ef">nil&lt;/span> &lt;span style="color:#66d9ef">t&lt;/span>)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#a6e22e">load&lt;/span>(&lt;span style="color:#e6db74">&amp;#34;/Users/krydos/.emacs.d/straight/repos/straight.el/...&amp;#34;&lt;/span> &lt;span style="color:#66d9ef">nil&lt;/span> nomessage)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>(let ((bootstrap-file (&lt;span style="color:#a6e22e">expand-file-name&lt;/span> &lt;span style="color:#e6db74">&amp;#34;straight/repos/straight.el/bootstrap.el&amp;#34;&lt;/span> user-emacs-directory)) (bootstrap-version &lt;span style="color:#ae81ff">6&lt;/span>)) (if (&lt;span style="color:#a6e22e">file-exists-p&lt;/span> bootstrap-file) &lt;span style="color:#66d9ef">nil&lt;/span> (save-current-buffer (&lt;span style="color:#a6e22e">set-buffer&lt;/span> (url-retrieve-synchronously &lt;span style="color:#e6db74">&amp;#34;https://raw.githubusercontent.com/radian-software/...&amp;#34;&lt;/span> &lt;span style="color:#e6db74">&amp;#39;silent&lt;/span> &lt;span style="color:#e6db74">&amp;#39;inhibit-cookies&lt;/span>)) (&lt;span style="color:#a6e22e">goto-char&lt;/span> (&lt;span style="color:#a6e22e">point-max&lt;/span>)) (eval-print-last-sexp))) (&lt;span style="color:#a6e22e">load&lt;/span> bootstrap-file &lt;span style="color:#66d9ef">nil&lt;/span> &lt;span style="color:#e6db74">&amp;#39;nomessage&lt;/span>))
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>load-with-code-conversion(&lt;span style="color:#e6db74">&amp;#34;/Users/krydos/.emacs.d/init.el&amp;#34;&lt;/span> &lt;span style="color:#e6db74">&amp;#34;/Users/krydos/.emacs.d/init.el&amp;#34;&lt;/span> &lt;span style="color:#66d9ef">t&lt;/span> &lt;span style="color:#66d9ef">t&lt;/span>)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#a6e22e">load&lt;/span>(&lt;span style="color:#e6db74">&amp;#34;/Users/krydos/.emacs.d/init&amp;#34;&lt;/span> noerror nomessage)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>startup--load-user-init-file(&lt;span style="color:#960050;background-color:#1e0010">#&lt;/span>f(compiled-function () &lt;span style="color:#960050;background-color:#1e0010">#&lt;/span>&amp;lt;bytecode 0x155c027c85bc7d&amp;gt;) &lt;span style="color:#960050;background-color:#1e0010">#&lt;/span>f(compiled-function () &lt;span style="color:#960050;background-color:#1e0010">#&lt;/span>&amp;lt;bytecode -0x1f3c61addc0da035&amp;gt;) &lt;span style="color:#66d9ef">t&lt;/span>)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>command-line()
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>normal-top-level()
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>It looks like for some reason straight.el expects &lt;code>native-comp-deferred-compilation-deny-list&lt;/code> variable available in Emacs while
this variable was renamed to &lt;code>native-comp-jit-compilation-deny-list&lt;/code>.&lt;/p>
&lt;p>Straight.el&amp;rsquo;s &lt;code>master&lt;/code> branch doesn&amp;rsquo;t know about the rename but the &lt;code>develop&lt;/code> branch does.
So to switch straight.el to newer branch we can define &lt;code>straight-repository-branch&lt;/code> somewhere on the top of our init.el like so:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-emacs-lisp" data-lang="emacs-lisp">&lt;span style="display:flex;">&lt;span>(setq straight-repository-branch &lt;span style="color:#e6db74">&amp;#34;develop&amp;#34;&lt;/span>)
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>I also removed my &lt;code>~/.emacs.d/straight&lt;/code> directory to make sure every other package will be pulled from scratch
and there are no conflicts between my current version of Emacs and the older one (28).&lt;/p>
&lt;h2 id="native-compilation-impression">Native compilation impression&lt;/h2>
&lt;p>I&amp;rsquo;m not sure about it. Since I use my own config and I don&amp;rsquo;t include that many packages everything was quite quick
even without the &lt;code>--with-native-comp&lt;/code>.
With native compilation I don&amp;rsquo;t see the difference, maybe I&amp;rsquo;ll notice it later.&lt;/p>
&lt;p>What I noticed is that when I first started my Emacs 29 the compilation process was running on the background (without indication) and
the whole UI was sluggish. Switching buffers was slow, reaction to my keystrokes was delayed, etc.
But in few minutes, I believe when everything was compiled, everything started to work as usual, no delays, no issues.&lt;/p></description></item><item><title>Search for hash(#) sign using Emacs' consult-grep</title><link>https://codelearn.me/2023/04/03/emacs-consult-hash-sign.html</link><pubDate>Mon, 03 Apr 2023 00:00:00 +0000</pubDate><guid>https://codelearn.me/2023/04/03/emacs-consult-hash-sign.html</guid><description>&lt;p>This is something I came across recently.
I wanted to search for &lt;code>#todo&lt;/code> using &lt;code>M-x consult-grep&lt;/code>.&lt;/p>
&lt;p>My initial &lt;code>#todo&lt;/code> query didn&amp;rsquo;t work obviously because &lt;code>#&lt;/code> sign in consult
is a &lt;em>punctuation character&lt;/em> as they call it.&lt;/p>
&lt;p>I didn&amp;rsquo;t really want to change &lt;code>#&lt;/code> sign as a punctuation character because I used to it.
I&amp;rsquo;m not also sure if there is such an option (read til the end to find out why)&lt;/p>
&lt;p>After some time spent googling
I couldn&amp;rsquo;t find how to do escape it.
Obvious things like &lt;code>#\#todo&lt;/code> didn&amp;rsquo;t work.&lt;/p>
&lt;p>Then I found this example in &lt;a href="https://github.com/minad/consult#asynchronous-search">consult readme&lt;/a>:&lt;/p>
&lt;ul>
&lt;li>&lt;code>/defun/consult&lt;/code>: It is also possible to use other punctuation characters.&lt;/li>
&lt;/ul>
&lt;p>This is not somewhere on the top of the readme. It&amp;rsquo;s under &lt;em>Asynchronous Search&lt;/em> section which
I ignored while I was looking for my use case.&lt;/p>
&lt;p>So it seems like any NON [A-Za-z0-9] character can be a punctuation character.
Though I&amp;rsquo;m not sure about it.&lt;/p>
&lt;p>In any case &lt;code>/#todo&lt;/code> worked nicely but it was unnecessary hard to find the proper syntax for it.&lt;/p></description></item><item><title>Emacs. Change inner/outer like in Vim</title><link>https://codelearn.me/2023/01/17/emacs-change-inner.html</link><pubDate>Tue, 17 Jan 2023 00:00:00 +0000</pubDate><guid>https://codelearn.me/2023/01/17/emacs-change-inner.html</guid><description>&lt;p>If you&amp;rsquo;re a former Vim user there is one feature I couldn&amp;rsquo;t find in any other editors.&lt;/p>
&lt;p>Not sure what is the proper name of it but let&amp;rsquo;s call it &lt;strong>change inside something&lt;/strong>.&lt;/p>
&lt;p>Example (&lt;code>|&lt;/code> - is a cursor):&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-javascript" data-lang="javascript">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">function&lt;/span>() {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#66d9ef">return&lt;/span> &lt;span style="color:#e6db74">&amp;#39;hello |world&amp;#39;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>If I press &lt;code>ci'&lt;/code> the result is going to be:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-javascript" data-lang="javascript">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">function&lt;/span>() {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#66d9ef">return&lt;/span> &lt;span style="color:#e6db74">&amp;#39;|&amp;#39;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>or &lt;code>ci{&lt;/code>:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-javascript" data-lang="javascript">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">function&lt;/span>() {&lt;span style="color:#f92672">|&lt;/span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>That&amp;rsquo;s incredibly useful feature because I don&amp;rsquo;t really need to think where my cursor is.
I just place it somewhere around the place I need to remove and press that magical keybinding.&lt;/p>
&lt;p>There is no such built-in function in Emacs. And this one is probably the only feature I miss the most.&lt;/p>
&lt;p>For some time I&amp;rsquo;ve been using &lt;a href="https://github.com/magnars/expand-region.el">expand-region&lt;/a> by &lt;strong>Magnar Sveen&lt;/strong>
which is a different thing really. It just expands a selection by some logical semantic blocks and can be used
as a replacement to that &lt;code>ci'&lt;/code>.
But still I need to think how many times I should call that &lt;code>expand-region&lt;/code> function before the thing I need is selected.&lt;/p>
&lt;p>So today I discovered &lt;a href="https://github.com/magnars/change-inner.el">change-inner.el&lt;/a> by already mentioned &lt;strong>Magnar Sveen&lt;/strong>.
It uses &lt;strong>expand-region&lt;/strong> internally and does exactly what &lt;code>ci&amp;lt;symbol&amp;gt;&lt;/code> does.&lt;/p>
&lt;p>Bindings suggested in the package readme, &lt;code>M-i&lt;/code> / &lt;code>M-o&lt;/code>, are pretty easy to used to.&lt;/p>
&lt;p>So if you ever missed that &lt;strong>change inner/outer&lt;/strong> Vim feature give this lib a shot.&lt;/p></description></item><item><title>Ditching Doom</title><link>https://codelearn.me/2022/06/04/emacs-config-from-scratch.html</link><pubDate>Sat, 04 Jun 2022 16:00:00 +0000</pubDate><guid>https://codelearn.me/2022/06/04/emacs-config-from-scratch.html</guid><description>&lt;p>In my previous post I&amp;rsquo;ve been talking about Doom config and that it is great and all but
I find it really difficult to fix issues there.
Doom has a lot of its own configuration, hooks here and there and functions that modifies standard behavior.&lt;/p>
&lt;p>It&amp;rsquo;s probably much easier to go with my own config. I never could stick to spacemacs or doom. I couldn&amp;rsquo;t stick to similar configs in Vim too.
Probably issue on my end :)&lt;/p>
&lt;p>Also Doom&amp;rsquo;s evil mode feels so verbose. It definitely feels more verbose than Vim itself. It feels like I have to press
much more keys to tell emacs to do something.&lt;/p>
&lt;p>At the moment I&amp;rsquo;m on my own config WITHOUT evil-mode and interesting to note, my muscle memory switched to Emacs-mode in ~30 minutes.
I didn&amp;rsquo;t expect that. For most of the actions there is no a &amp;ldquo;thinking process&amp;rdquo;. They just happen.
Last time I used Emacs was couple of years ago and I&amp;rsquo;m surprised it&amp;rsquo;s keybindings went that deep in my muscle memory.&lt;/p>
&lt;p>Maybe, which is strange for me to admit, the keybinding design in Emacs is a feature&amp;hellip;&lt;/p>
&lt;p>Anyway here is some highlight of my config:&lt;/p>
&lt;ul>
&lt;li>UI is standard-minimal. No toolbar, no scroll-bar, no bells. Automatically start maximized&lt;/li>
&lt;li>MacOS&amp;rsquo; CMD key is bound to &lt;code>meta&lt;/code>&lt;/li>
&lt;li>Trailing spaces are deleted with &lt;code>delete-trailing-whitespace&lt;/code> on every buffer save&lt;/li>
&lt;li>Indent with spaces by default&lt;/li>
&lt;li>Vertico for vertical completion (like helm or ivy)&lt;/li>
&lt;li>Consult for some nice functions like &lt;code>consult-imenu&lt;/code> or &lt;code>consult-buffer&lt;/code>&lt;/li>
&lt;li>Orderless for fuzzy-like autocompletion&lt;/li>
&lt;li>Projectile&lt;/li>
&lt;li>Magit&lt;/li>
&lt;li>Flycheck&lt;/li>
&lt;li>Company&lt;/li>
&lt;li>Vterm - possibly the greatest terminal emulation in Emacs I could fine&lt;/li>
&lt;li>Prodigy - love this tool. Allows you to manage services running on your machine.&lt;/li>
&lt;li>various lang modes&lt;/li>
&lt;/ul>
&lt;p>What&amp;rsquo;s pretty interesting and I couldn&amp;rsquo;t expect I&amp;rsquo;d like is a white color scheme.&lt;/p>
&lt;p>All of those are working pretty well and if I need to override some of their behavior
it usually something super simple, unlike Doom or Spacemacs where some functionality overridden by the &amp;ldquo;package&amp;rdquo; configuration that you gotta
go and inspect and then find some hooks that also adds additional layer of configuration.&lt;/p>
&lt;p>Screenshot (click to zoom):&lt;/p>
&lt;p>&lt;a href="https://codelearn.me/assets/img/own-emacs-config-example-white-theme.png" target="_blank">&lt;img width="400px" src="https://codelearn.me/assets/img/own-emacs-config-example-white-theme.png" />&lt;/a>&lt;/p></description></item><item><title>Getting back to Emacs</title><link>https://codelearn.me/2022/05/14/getting-back-to-emacs.html</link><pubDate>Sat, 14 May 2022 00:00:00 +0000</pubDate><guid>https://codelearn.me/2022/05/14/getting-back-to-emacs.html</guid><description>&lt;p>I do change my workflow from time to time to keep myself in shape.&lt;/p>
&lt;p>Now, once again, I&amp;rsquo;m trying to switch back to Emacs. This time I decided to go with Doom.
I already tried to install use it but it didn&amp;rsquo;t work well for me and I didn&amp;rsquo;t bother to change
the configuration.&lt;/p>
&lt;h2 id="main-functionalities-i-need">Main functionalities I need&lt;/h2>
&lt;h3 id="quick-search-in-a-project">Quick search in a project&lt;/h3>
&lt;p>That&amp;rsquo;s something I used &lt;code>ag&lt;/code> for in my Vim. I could easily look for a word under the cursor everywhere in the project.&lt;/p>
&lt;p>Projectile fortunately have something like this as well and I can search for word under cursor with &lt;code>SPC-*&lt;/code>.
The issue though is in PHP the word under cursor was including &lt;code>$&lt;/code> sign which is not want I wanted.&lt;/p>
&lt;p>Fixed by excluding &lt;code>$&lt;/code> sign from part of a keyword&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-elisp" data-lang="elisp">&lt;span style="display:flex;">&lt;span>(after! php-mode
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> (&lt;span style="color:#a6e22e">modify-syntax-entry&lt;/span> &lt;span style="color:#e6db74">?$&lt;/span> &lt;span style="color:#e6db74">&amp;#34;.&amp;#34;&lt;/span> php-mode-syntax-table))
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="git-interface">Git interface&lt;/h3>
&lt;p>I usually use &lt;code>git&lt;/code> in terminal to create a branch, for merging, branch switching.
But I need a quick way to stage files and write commit messages.&lt;/p>
&lt;p>Magit is definitely the suits my needs here.&lt;/p>
&lt;h3 id="multiple-cursors">Multiple cursors&lt;/h3>
&lt;p>Doom has &lt;code>multiple-cursors&lt;/code> package. For some reason it doesn&amp;rsquo;t bind anything and I had to manually bind &lt;code>M-d&lt;/code> to &lt;code>evil-multiedit-match-and-next&lt;/code>&lt;/p>
&lt;h3 id="tasks-management--notes">Tasks management / Notes&lt;/h3>
&lt;p>Well, in Vim I didn&amp;rsquo;t have any good tool for this. I usually switched to Obsidian to take notes.&lt;/p>
&lt;p>With Emacs there is org-mode and that&amp;rsquo;s the primary reason why I&amp;rsquo;m even switching to Emacs right now.&lt;/p>
&lt;h3 id="projects-management">Projects management&lt;/h3>
&lt;p>I used Vim with Tmux and every tmux session was created per project. Every session had windows for vim, terminal operations, background jobs.&lt;/p>
&lt;p>In Doom we already have Projectile included. There are also workspaces.&lt;/p>
&lt;p>These two packages are great for managing projects and buffers.&lt;/p>
&lt;h2 id="issues-that-i-still-need-to-solve">Issues that I still need to solve&lt;/h2>
&lt;h3 id="php-mode-is-slow">php-mode is slow&lt;/h3>
&lt;p>That&amp;rsquo;s something I didn&amp;rsquo;t notice many years ago when I was using Emacs.
Hard to tell if this is related to Evil mode enabled or some other Doom related configuration but when I try to
&lt;code>evil-shift-right&lt;/code> with more than 50 lines selected I have to wait some time for this action to happen.&lt;/p>
&lt;h3 id="magit-is-slow">magit is slow&lt;/h3>
&lt;p>Magit is pretty quick for small editings. But when I have, let&amp;rsquo;s say a merge conflict with a lot of files it takes
5-10 seconds for magit to open. It obviously depends on exact amount of files to show there but that&amp;rsquo;s pretty painful.
Of course every other subsequent command is also slow.&lt;/p>
&lt;h3 id="company-mode-doesnt-autocomplete">company-mode doesn&amp;rsquo;t autocomplete&lt;/h3>
&lt;p>Company in my case didn&amp;rsquo;t want to autocomplete by default. The reason was that company backends chosen in doom don&amp;rsquo;t really work at least on
my projects.&lt;/p>
&lt;p>Moreover when I try to set &lt;code>company-backends&lt;/code> variable to something I need and open a php file the variable updates automatically
and &lt;code>company-capf&lt;/code> with &lt;code>company-yasnippet&lt;/code> is prepended to the list of backends.&lt;/p>
&lt;h2 id="summary">Summary&lt;/h2>
&lt;p>Overall Doom experience is pretty nice. Configuration is hard sometimes because Doom sets some package variables, add hooks here and there
and changes configuration of packages to some non-default behavior.
It makes a bit more complex to setup a package/mode to something I need.&lt;/p>
&lt;p>Maybe I should have chosen Doom in the first place because I already have some habits and needs that I want to have in my editor
while Doom is probably good if you don&amp;rsquo;t have those habits or want to change them.&lt;/p></description></item><item><title>Projectile cleanup list of known projects (spacemacs)</title><link>https://codelearn.me/2018/02/19/projectile-known-projects.html</link><pubDate>Mon, 19 Feb 2018 00:00:00 +0000</pubDate><guid>https://codelearn.me/2018/02/19/projectile-known-projects.html</guid><description>&lt;p>Recently I&amp;rsquo;ve switched through a lot of different OS setups and my projects list in Spacemacs was bloated.&lt;/p>
&lt;p>Some projects were from MacOS, others were from Windows. All of them were not existed anymore.&lt;/p>
&lt;p>I&amp;rsquo;ve tried to find a file where Emacs (Spacemacs) stores list of projects but I&amp;rsquo;ve found even better elisp function
for this.&lt;/p>
&lt;p>Just call &lt;code>M-x projectile-cleanup-known-projects&lt;/code> and every path (project) that is not exists
on your current machine will be removed from the list of known projects.&lt;/p>
&lt;center>&lt;img src="https://media.giphy.com/media/e1BxgoFxAOmbK/giphy.gif"/>&lt;/center>
&lt;p>Glad there is such function and my *spacemacs* buffer looks much much better now&lt;/p></description></item><item><title>Restclient (Postman for Emacs)</title><link>https://codelearn.me/2017/10/22/restclient.html</link><pubDate>Sun, 22 Oct 2017 00:00:00 +0000</pubDate><guid>https://codelearn.me/2017/10/22/restclient.html</guid><description>&lt;p>Hi everyone.&lt;/p>
&lt;p>Here is my notes about &lt;code>restclient&lt;/code> that can help you to forget about &lt;code>Postman&lt;/code> (which is cool as well).&lt;/p>
&lt;h2 id="define-the-action">Define the action&lt;/h2>
&lt;p>Here is the example:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e">#&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># get all people from star wars&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e">#&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>GET https://swapi.co/api/people
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;br/>
&lt;br/>
&lt;p>To define an action you need to start with a comment.
&lt;img src="https://codelearn.me/assets/img/hm.webp"/>&lt;/p>
&lt;p>Then you need to set method (GET, POST, PUT and other) and the url of course.&lt;/p>
&lt;p>Now you can execute the query. Press &lt;code>C-c C-c&lt;/code> (CTRL+c twice) and new buffer (&lt;code>*HTTP Response*&lt;/code>) with the result will be opened.&lt;/p>
&lt;p>&lt;a target="_blank" href="https://codelearn.me/assets/img/restclient-output1.png">&lt;img alt="restclient output" src="https://codelearn.me/assets/img/restclient-output1.png" width="550px"/>&lt;/a>&lt;/p>
&lt;p>At the bottom of that buffer you can see response headers:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>// GET https://swapi.co/api/people
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>// HTTP/1.1 &lt;span style="color:#ae81ff">200&lt;/span> OK
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>// Date: Sun, &lt;span style="color:#ae81ff">22&lt;/span> Oct &lt;span style="color:#ae81ff">2017&lt;/span> 19:03:17 GMT
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>// Content-Type: application/json
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>// Transfer-Encoding: chunked
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>// Connection: keep-alive
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>// Allow: GET, HEAD, OPTIONS
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>// Vary: Accept, Cookie
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>// X-Frame-Options: SAMEORIGIN
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>// Etag: &lt;span style="color:#e6db74">&amp;#34;d080408a4d656729b0f52a6feb0783ca&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>// Via: 1.1 vegur
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>// Server: cloudflare-nginx
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>// CF-RAY: 3b1eb73cda7d63af-FRA
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>// Request duration: 1.663359s
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;br/>
&lt;p>Pretty simple, ha?&lt;/p>
&lt;h2 id="set-headers">Set headers&lt;/h2>
&lt;p>To define headers you need to write them just below the URL definition:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e">#&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># get all people from star wars&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e">#&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>GET https://swapi.co/api/people
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>User-Agent: Emacs Restclient
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Content-Type: application/json
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;br/>
By pressing `C-c C-c` the headers will be attached to the request.
&lt;h2 id="post-payload">Post payload&lt;/h2>
&lt;p>If you want to send data to the server you can define it right after empty line of the URL (or headers if exist) definition.&lt;/p>
&lt;p>Here is an example from &lt;code>restclient.el&lt;/code> repo.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e">#&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># Post works too, entity just goes after an empty line. Same is for PUT.&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e">#&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>POST https://jira.atlassian.com/rest/api/2/search
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Content-Type: application/json
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">{&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#e6db74">&amp;#34;jql&amp;#34;&lt;/span>: &lt;span style="color:#e6db74">&amp;#34;project = HSP&amp;#34;&lt;/span>,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#e6db74">&amp;#34;startAt&amp;#34;&lt;/span>: 0,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#e6db74">&amp;#34;maxResults&amp;#34;&lt;/span>: 15,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#e6db74">&amp;#34;fields&amp;#34;&lt;/span>: &lt;span style="color:#f92672">[&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#e6db74">&amp;#34;summary&amp;#34;&lt;/span>,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#e6db74">&amp;#34;status&amp;#34;&lt;/span>,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#e6db74">&amp;#34;assignee&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#f92672">]&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">}&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;br/>
&lt;h2 id="what-if-i-want-to-post-a-file">What if I want to post a file?&lt;/h2>
&lt;p>It&amp;rsquo;s also possible and it&amp;rsquo;s pretty easy&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e">#&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># post a file&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e">#&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>POST http://httpbin.org/post
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Content-Type: text/plain
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&amp;lt; /etc/hosts
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;br/>
&lt;h2 id="you-can-even-define-variables">You can even define variables&lt;/h2>
&lt;p>Variables are useful to define the host or test user credentials.&lt;/p>
&lt;p>Here how you can define it.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>:myvar &lt;span style="color:#f92672">=&lt;/span> https://google.com
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;br/>
&lt;p>You can also use elisp to set a value&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>:myvar :&lt;span style="color:#f92672">=&lt;/span> &lt;span style="color:#f92672">(&lt;/span>some &lt;span style="color:#f92672">(&lt;/span>artbitrary &lt;span style="color:#960050;background-color:#1e0010">&amp;#39;&lt;/span>elisp&lt;span style="color:#f92672">)&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;br/>
&lt;p>use &lt;code>:variable-name&lt;/code> syntax to get the value of variable:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e">#&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># use a variable&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e">#&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>GET :myvar/imghp
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;br/>
&lt;p>&lt;a target="_blank" href="https://github.com/pashky/restclient.el">Restclient.el&lt;/a> is a great package you definitely should try.
It allows you quickly explore or test the API without leaving the Emacs.&lt;/p>
&lt;img src="https://codelearn.me/assets/img/thumb-up.gif"/>
&lt;p>Try it &amp;lt;3&lt;/p></description></item><item><title>Emacs Projectile find and replace</title><link>https://codelearn.me/2017/10/20/projectile-search-replace.html</link><pubDate>Fri, 20 Oct 2017 00:00:00 +0000</pubDate><guid>https://codelearn.me/2017/10/20/projectile-search-replace.html</guid><description>&lt;p>Projectile is great Emacs package you definitely have to install if you didn&amp;rsquo;t.&lt;/p>
&lt;p>Along with projects management and quick switching among of them it allows you to limit grep/ack, find files and replacing commands.
Here I want to note how to quickly search and replace strings in your project.&lt;/p>
&lt;h2 id="search-grepackag">Search (grep/ack/ag)&lt;/h2>
&lt;p>If you know basics of &lt;code>grep&lt;/code> you shouldn&amp;rsquo;t get any issues with it. Just call &lt;code>projectile-grep&lt;/code> interactive function
and type the query.&lt;/p>
&lt;p>Here is how it works on this blog with &lt;code>title:&lt;/code> query:&lt;/p>
&lt;p>&lt;a target="_blank" href="https://codelearn.me/assets/img/projectile-grep.png">&lt;img alt="projectile grep output" src="https://codelearn.me/assets/img/projectile-grep.png" width="550px"/>&lt;/a>&lt;/p>
&lt;p>As you can see there is new buffer created called &lt;code>*grep*&lt;/code>. At the bottom it says that search is finished (&lt;code>:exit&lt;/code>) and have matches (&lt;code>[matched]&lt;/code>).
Filenames are links, so you can click on them and file will be opened in new buffer on the matched line.&lt;/p>
&lt;h2 id="replace">Replace&lt;/h2>
&lt;p>Projectile is also really great in replacing with its &lt;code>projectile-replace&lt;/code> and &lt;code>projectile-replace-regexp&lt;/code>.
When you call one of those functions you will be asked for an input to search for.
Let&amp;rsquo;s search the blog for &lt;code>Replace&lt;/code>.
When you typed the query, you need to input the string you want to replace on. Let&amp;rsquo;s replace our &lt;code>Replace&lt;/code> with &lt;code>Find&lt;/code>.&lt;/p>
&lt;p>When both params are entered the buffer with first match will be opened.&lt;/p>
&lt;p>You can see the info in the mini-buffer:&lt;/p>
&lt;p>&lt;a target="_blank" href="https://codelearn.me/assets/img/projectile-replace-mini-buffer.png">&lt;img alt="projectile grep output" src="https://codelearn.me/assets/img/projectile-replace-mini-buffer.png" width="550px"/>&lt;/a>&lt;/p>
&lt;p>Now you can press some keys to perform actions.
Press &lt;code>?&lt;/code> for help.&lt;/p>
&lt;p>&lt;a target="_blank" href="https://codelearn.me/assets/img/projectile-replace-help.png">&lt;img alt="projectile grep output" src="https://codelearn.me/assets/img/projectile-replace-help.png" width="550px"/>&lt;/a>&lt;/p>
&lt;p>As you can see if you click &lt;code>y&lt;/code> button then the replace action will be performed. If you see something wrong is going to be replaced just press &lt;code>n&lt;/code> button to skip the
currently highlighted match and Emacs will switch to the next match.&lt;/p>
&lt;p>Searching and replacing should be used as often as possible with minimum of manual work. It will save you from mistakes and improve your productivity a lot.&lt;/p>
&lt;p>Good luck &amp;lt;3&lt;/p></description></item><item><title>From Emacs to Intellij IDEA</title><link>https://codelearn.me/2016/03/29/from-emacs-to-intellij.html</link><pubDate>Tue, 29 Mar 2016 00:00:00 +0000</pubDate><guid>https://codelearn.me/2016/03/29/from-emacs-to-intellij.html</guid><description>&lt;p>Recently I switched from Emacs, which I used about two years, to IntelliJ.
It was pretty hard switch since my muscle memory wasn’t happy. Thanks guys from JetBrains they have Emacs keybinding-scheme.
Today I will try to describe how I configured IntelliJ to be more Emacs-like.&lt;/p>
&lt;p>First of all IntelliJ interface is pretty overloaded. Emacs had only text area with status line and mini buffer. I found very nice instructions about how to do interface more minimalistic in Laracast video. It was for PHPStorm but it also work for IntelliJ.&lt;/p>
&lt;p>So, lets start.&lt;/p>
&lt;ul>
&lt;li>I do not really use status bar at the bottom of window. If you no need it you can also remove it by checkbox in &lt;strong>View -&amp;gt; Status Bar&lt;/strong>.&lt;/li>
&lt;li>Navigation bar on top of window. Go to &lt;strong>View -&amp;gt; Navigation Bar&lt;/strong> and uncheck it.&lt;/li>
&lt;li>Toolbar. A lot of buttons for guys who use mouse. Go to &lt;strong>View -&amp;gt; Toolbar&lt;/strong> checkbox.&lt;/li>
&lt;li>Breadcrumbs probably useful feature, but I do not see a reason to use it. To disable it lets go to &lt;strong>Preferences -&amp;gt; Editor -&amp;gt; Appearance&lt;/strong>. Uncheck &lt;strong>Show HTML breadcrumbs&lt;/strong> (restart of IDE may be required).&lt;/li>
&lt;li>Tabs. Emacs has buffers. IntelliJ has “Switcher” that contains list of recently opened files. It exists by C-x C-b. Let’s remove tabs by right click on it and select &lt;strong>Tabs Placement -&amp;gt; None&lt;/strong>.&lt;/li>
&lt;/ul>
&lt;p>Now it should look something like this:&lt;/p>
&lt;p>&lt;a target="_blank" href="https://codelearn.me/assets/img/idea-now.png">&lt;img alt="idea now" src="https://codelearn.me/assets/img/idea-now.png" width="750px"/>&lt;/a>&lt;/p>
&lt;p>Much much better, right? ;)&lt;/p>
&lt;p>Since I develop mostly backend and various APIs I used to use &lt;strong>restclient-mode&lt;/strong> in Emacs.&lt;/p>
&lt;p>Intellij has something similar. Tool called &lt;strong>Test RESTful Web Service&lt;/strong>.&lt;/p>
&lt;p>&lt;a target="_blank" href="https://codelearn.me/assets/img/test-api-tool.png">&lt;img alt="test api tool" src="https://codelearn.me/assets/img/test-api-tool.png" width="750px"/>&lt;/a>&lt;/p>
&lt;p>It has pretty much all features required by me, but it still sucks compared with restclient-mode of Emacs. There are not too much keybindings (actually only ⌘ + Enter is known and frequently used by me). You can add parameters, headers, you can repeat your last (or long before) query. It sucks mostly because too much mouse involved in the process of this tool usage.&lt;/p>
&lt;p>Next thing its a &lt;strong>terminal&lt;/strong>.
The replacement of M-x shell called – &lt;strong>Terminal&lt;/strong>. It’s very functional and looks better than Emacs eshell or term modes. I can even run Emacs inside.&lt;/p>
&lt;p>&lt;a target="_blank" href="https://codelearn.me/assets/img/idea-term.png">&lt;img alt="idea term" src="https://codelearn.me/assets/img/idea-term.png" width="750px"/>&lt;/a>&lt;/p>
&lt;p>I mapped it to C-c C-t to make it more accessible. I usually use it for files creation (instead of the IDE’s sidebar and mouse right click).&lt;/p>
&lt;p>Hope it was useful. Don’t forget to switch your keybinding scheme to Emacs mode.&lt;/p></description></item></channel></rss>