<?xml version="1.0"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>Flaky Goodness</title>
		<link>https://goykhman.ca/gene/blog/</link>
		<atom:link href="https://goykhman.ca/gene/blog/emacs.xml" rel="self" type="application/rss+xml" />
		<copyright>Copyright &#xA9; 2012-2026, Gene Goykhman and Indigo Technologies Ltd.</copyright>
		<language>en-US</language>
		<description>I'm Gene Goykhman, software developer, entrepreneur and principal at Indigo Technologies Ltd. I work on the TimeTiger time and project tracking system and some tasty projects on the side. I have lots of opinions about stuff.</description>

<item>
<pubDate>Wed, 10 Dec 2025 00:00:00 -0500</pubDate>
<title>Building Emacs 30 on macOS</title>
<guid isPermaLink="true">https://goykhman.ca/gene/blog/2025-12-10-building-emacs-30-on-macos.html</guid>
<description><![CDATA[<p class="pubDate">December 10, 2025</p>
<p>
This is an update to my post about <a href="2024-08-17-upgrading-to-emacs-294-on-apple-silicon-macs.html">compiling Emacs 29.4 from source</a>. Emacs has been moving forward but unfortunately my beloved <a href="https://bitbucket.org/mituharu/emacs-mac/src/master/">Mitsuharu Emacs Mac Port</a> has not. Happily JD Smith has picked up the mantle and there is an up-to-date (albeit experimental) <a href="https://github.com/jdtsmith/emacs-mac">Emacs 30 fork on GitHub</a>. This post documents the steps I took to build Emacs 30.2 on my M3 MacBook Pro.
</p>
<div id="outline-container-orgcafe295" class="outline-2">
<h2 id="orgcafe295">Remove existing Emacs</h2>
<div class="outline-text-2" id="text-orgcafe295">
<p>
Backup and delete <code>/Applications/Emacs.app</code> if you have one. I highly encourage you to keep a backup of your old Emacs around for a while in case you hit any snags building the new one.
</p>
</div>
</div>
<div id="outline-container-org7476d2d" class="outline-2">
<h2 id="org7476d2d">Update Xcode command-line tools</h2>
<div class="outline-text-2" id="text-org7476d2d">
<p>
Don&rsquo;t skip this step of reinstalling the latest version of the tools. You&rsquo;ll need to install <a href="https://xcodereleases.com">Xcode</a> first if you don&rsquo;t already have it. I was using Xcode 16.4 when I went through this process.
</p>

<div class="org-src-container">
<pre class="src src-emacs-lisp">sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install
</pre>
</div>
</div>
</div>
<div id="outline-container-org5bdc830" class="outline-2">
<h2 id="org5bdc830">Install/re-install dependencies</h2>
<div class="outline-text-2" id="text-org5bdc830">
<div class="org-src-container">
<pre class="src src-sh">brew update
brew reinstall gcc
brew install libgccjit pkgconf texinfo tree-sitter
</pre>
</div>
</div>
</div>
<div id="outline-container-org14dead9" class="outline-2">
<h2 id="org14dead9">Get a fresh clone of Emacs</h2>
<div class="outline-text-2" id="text-org14dead9">
<p>
The only branch I was able to successfully build was emacs-mac-30.2, but that might have changed by the time you read this.
</p>

<div class="org-src-container">
<pre class="src src-sh">git clone https://github.com/jdtsmith/emacs-mac
<span style="color: #dcdcdc; font-weight: bold; font-style: italic;">cd</span> emacs-mac
git checkout emacs-mac-30.2
</pre>
</div>
</div>
</div>
<div id="outline-container-orgb2f4a59" class="outline-2">
<h2 id="orgb2f4a59">Configure and make</h2>
<div class="outline-text-2" id="text-orgb2f4a59">
<p>
I used the self-contained configuration and followed the instructions in the README.md on the GitHub page.
</p>

<div class="org-src-container">
<pre class="src src-sh">./autogen.sh

<span style="color: #269cee;">CFLAGS</span>=<span style="color: #2aa198;">"-O2 -mcpu=native"</span> ./configure --with-native-compilation <span style="color: #ebcc2a; font-weight: bold;">\</span>
  --with-tree-sitter <span style="color: #ebcc2a; font-weight: bold;">\</span>
  --with-xwidgets <span style="color: #ebcc2a; font-weight: bold;">\</span>
  --enable-mac-app=yes <span style="color: #ebcc2a; font-weight: bold;">\</span>
  --enable-mac-self-contained

make -j6

make install
</pre>
</div>

<p>
I am so happy that this project has found new life and that this flavor of Emacs will continue to be available for Mac users.
</p>

<p>
<b>UPDATE 2025-12-18</b> removed jansson since JSON support is baked into Emacs 30. Thanks to <a href="https://dementedandsadbut.social/@genehack/115743280502187238">@genehack</a> for pointing this out!
</p>
</div>
</div>
]]></description>
</item>

<item>
<pubDate>Sun, 14 Sep 2025 00:00:00 -0400</pubDate>
<title>Emacs ibuffer live update</title>
<guid isPermaLink="true">https://goykhman.ca/gene/blog/2025-09-14-emacs-ibuffer-live-update.html</guid>
<description><![CDATA[<p class="pubDate">September 14, 2025</p>
<p>
Inspired by a <a href="https://olddeuteronomy.github.io/post/emacs-ibuffer-config/">a recent post by The Emacs Cat</a> about their ibuffer configuration, I was wondering why the ibuffer didn&rsquo;t update live as buffers were created and killed. With some help from <a href="https://protesilaos.com">Prot</a> here is a way to hook into the relevant function in Emacs to update the ibuffer list any time the list of buffers changes. The real-time feedback makes managing a large number of buffers more pleasant.
</p>

<p>
This code sets a timer to start every time the buffer-list is updated. The timer is debounced, so that it only fires once even if a number of buffers are updated one after another. When the timer fires, any ibuffer that is currently open gets refreshed. Very nice.
</p>

<div class="org-src-container">
<pre class="src src-emacs-lisp"><span style="color: #2aa198;">(</span><span style="color: #33b50d; font-weight: bold;">defvar</span> <span style="color: #269cee;">my/ibuffer-refresh-timer</span> nil
  <span style="color: #2aa198; font-style: italic;">"Debounce timer for ibuffer refreshes triggered by buffer list changes."</span><span style="color: #2aa198;">)</span>

<span style="color: #2aa198;">(</span><span style="color: #33b50d; font-weight: bold;">defun</span> <span style="color: #269cee;">my/ibuffer-refresh-start-timer</span> <span style="color: #ebcc2a;">()</span>
  <span style="color: #ebcc2a;">(</span><span style="color: #33b50d; font-weight: bold;">when</span> my/ibuffer-refresh-timer
    <span style="color: #269cee;">(</span>cancel-timer my/ibuffer-refresh-timer<span style="color: #269cee;">)</span><span style="color: #ebcc2a;">)</span>
  <span style="color: #ebcc2a;">(</span><span style="color: #33b50d; font-weight: bold;">setq</span> my/ibuffer-refresh-timer <span style="color: #269cee;">(</span>run-at-time 0.2 nil #'my/ibuffer-refresh<span style="color: #269cee;">)</span><span style="color: #ebcc2a;">)</span><span style="color: #2aa198;">)</span>

<span style="color: #2aa198;">(</span><span style="color: #33b50d; font-weight: bold;">defun</span> <span style="color: #269cee;">my/ibuffer-refresh</span> <span style="color: #ebcc2a;">()</span>
  <span style="color: #ebcc2a;">(</span><span style="color: #33b50d; font-weight: bold;">setq</span> my/ibuffer-refresh-timer nil<span style="color: #ebcc2a;">)</span>
  <span style="color: #ebcc2a;">(</span><span style="color: #33b50d; font-weight: bold;">when-let</span> <span style="color: #269cee;">(</span><span style="color: #6c71c4;">(</span>buffers <span style="color: #33b50d;">(</span>seq-filter
                       <span style="color: #ebcc2a;">(</span><span style="color: #33b50d; font-weight: bold;">lambda</span> <span style="color: #269cee;">(</span>buf<span style="color: #269cee;">)</span>
                         <span style="color: #269cee;">(</span><span style="color: #33b50d; font-weight: bold;">with-current-buffer</span> buf
                           <span style="color: #6c71c4;">(</span>derived-mode-p 'ibuffer-mode<span style="color: #6c71c4;">)</span><span style="color: #269cee;">)</span><span style="color: #ebcc2a;">)</span>
                       <span style="color: #ebcc2a;">(</span>buffer-list<span style="color: #ebcc2a;">)</span><span style="color: #33b50d;">)</span><span style="color: #6c71c4;">)</span><span style="color: #269cee;">)</span>

    <span style="color: #269cee;">(</span><span style="color: #33b50d; font-weight: bold;">dolist</span> <span style="color: #6c71c4;">(</span>buf buffers<span style="color: #6c71c4;">)</span>
      <span style="color: #6c71c4;">(</span><span style="color: #33b50d; font-weight: bold;">with-current-buffer</span> buf
        <span style="color: #33b50d;">(</span>ibuffer-update nil <span style="color: #dcdcdc; font-weight: bold; font-style: italic;">:silent</span><span style="color: #33b50d;">)</span><span style="color: #6c71c4;">)</span><span style="color: #269cee;">)</span><span style="color: #ebcc2a;">)</span><span style="color: #2aa198;">)</span>

<span style="color: #2aa198;">(</span>add-hook 'buffer-list-update-hook #'my/ibuffer-refresh-start-timer<span style="color: #2aa198;">)</span>
</pre>
</div>
]]></description>
</item>

<item>
<pubDate>Sun, 02 Feb 2025 00:00:00 -0500</pubDate>
<title>Quickly summing up the whole stack in Emacs Calc</title>
<guid isPermaLink="true">https://goykhman.ca/gene/blog/2025-02-02-quickly-summing-up-the-whole-stack-in-emacs-calc.html</guid>
<description><![CDATA[<p class="pubDate">February  2, 2025</p>
<p>
Here is a nice little improvement to <code>calc-mode</code> that adds up all the numbers on the stack. It&rsquo;s equivalent to hitting the + key until the stack is exhausted, and it&rsquo;s more handy than I would have expected.
</p>

<div class="org-src-container">
<pre class="src src-emacs-lisp"><span style="color: #2aa198;">(</span><span style="color: #33b50d; font-weight: bold;">defun</span> <span style="color: #269cee;">my/calc-sum-stack</span> <span style="color: #ebcc2a;">()</span>
  <span style="color: #ebcc2a;">(</span><span style="color: #33b50d; font-weight: bold;">interactive</span><span style="color: #ebcc2a;">)</span>
  <span style="color: #ebcc2a;">(</span><span style="color: #33b50d; font-weight: bold;">when-let*</span> <span style="color: #269cee;">(</span><span style="color: #6c71c4;">(</span>stack calc-stack<span style="color: #6c71c4;">)</span>
              <span style="color: #6c71c4;">(</span>additions <span style="color: #33b50d;">(</span>- <span style="color: #ebcc2a;">(</span>length stack<span style="color: #ebcc2a;">)</span> 2<span style="color: #33b50d;">)</span><span style="color: #6c71c4;">)</span>
              <span style="color: #6c71c4;">(</span>_ <span style="color: #33b50d;">(</span>&gt; additions 0<span style="color: #33b50d;">)</span><span style="color: #6c71c4;">)</span><span style="color: #269cee;">)</span>
    <span style="color: #269cee;">(</span><span style="color: #33b50d; font-weight: bold;">dotimes</span> <span style="color: #6c71c4;">(</span>i additions<span style="color: #6c71c4;">)</span> <span style="color: #6c71c4;">(</span>call-interactively 'calc-plus<span style="color: #6c71c4;">)</span><span style="color: #269cee;">)</span><span style="color: #ebcc2a;">)</span><span style="color: #2aa198;">)</span>
</pre>
</div>

<p>
I&rsquo;ve bound it to Ctrl + like this:
</p>

<div class="org-src-container">
<pre class="src src-emacs-lisp"><span style="color: #2aa198;">(</span><span style="color: #33b50d; font-weight: bold;">with-eval-after-load</span> 'calc
  <span style="color: #ebcc2a;">(</span>define-key calc-mode-map <span style="color: #269cee;">(</span>kbd <span style="color: #2aa198;">"C-+"</span><span style="color: #269cee;">)</span> #'my/calc-sum-stack<span style="color: #ebcc2a;">)</span><span style="color: #2aa198;">)</span>
</pre>
</div>
]]></description>
</item>

<item>
<pubDate>Wed, 28 Aug 2024 00:00:00 -0400</pubDate>
<title>Speeding up Emacs Lisp functions by disabling garbage collection</title>
<guid isPermaLink="true">https://goykhman.ca/gene/blog/2024-08-28-speeding-up-emacs-lisp-functions.html</guid>
<description><![CDATA[<p class="pubDate">August 28, 2024</p>
<p>
Emacs Lisp has nice <a href="https://www.gnu.org/software/emacs/manual/html_node/elisp/Profiling.html">built-in profiling tools</a> but if you&rsquo;re just curious to see how long a function takes to run, you can call it from inside <code>benchmark-run</code>:
</p>

<div class="org-src-container">
<pre class="src src-emacs-lisp"><span style="color: #2aa198;">(</span><span style="color: #33b50d; font-weight: bold;">benchmark-run</span> <span style="color: #ebcc2a;">(</span>my-slow-function<span style="color: #ebcc2a;">)</span><span style="color: #2aa198;">)</span>
</pre>
</div>

<p>
This will output a list with three elements. The first is total runtime in seconds. The second element is the number of garbage collections required during execution, and finally the time used by the garbage collector.
</p>

<p>
For example, I can see how long it takes to export my static blog site as follows:
</p>

<div class="org-src-container">
<pre class="src src-emacs-lisp"><span style="color: #2aa198;">(</span><span style="color: #33b50d; font-weight: bold;">benchmark-run</span> <span style="color: #ebcc2a;">(</span>export-my-blog<span style="color: #ebcc2a;">)</span><span style="color: #2aa198;">)</span>

<span style="color: #2aa198;">(</span>7.007418 45 3.120531000000028<span style="color: #2aa198;">)</span>
</pre>
</div>

<p>
It is taking 7 seconds total of which 3 seconds are consumed by 45 garbage collection passes.
</p>

<p>
Can we save some time by opting out of garbage collection during this process?
</p>

<p>
Here is a wrapper function that temporarily disables garbage collection while an arbitrary function is called. We do this by increasing the garbage collection threshold to a very large number.
</p>

<div class="org-src-container">
<pre class="src src-emacs-lisp"><span style="color: #2aa198;">(</span><span style="color: #33b50d; font-weight: bold;">defun</span> <span style="color: #269cee;">without-gc</span> <span style="color: #ebcc2a;">(</span><span style="color: #ebcc2a;">&amp;rest</span> args<span style="color: #ebcc2a;">)</span>
  <span style="color: #ebcc2a;">(</span><span style="color: #33b50d; font-weight: bold;">let</span> <span style="color: #269cee;">(</span><span style="color: #6c71c4;">(</span>gc-cons-threshold most-positive-fixnum<span style="color: #6c71c4;">)</span><span style="color: #269cee;">)</span>
    <span style="color: #269cee;">(</span>apply args<span style="color: #269cee;">)</span><span style="color: #ebcc2a;">)</span><span style="color: #2aa198;">)</span>
</pre>
</div>

<p>
Now we can call:
</p>

<div class="org-src-container">
<pre class="src src-emacs-lisp"><span style="color: #2aa198;">(</span><span style="color: #33b50d; font-weight: bold;">benchmark-run</span> <span style="color: #ebcc2a;">(</span>without-gc #'export-my-blog<span style="color: #ebcc2a;">)</span><span style="color: #2aa198;">)</span>

<span style="color: #2aa198;">(</span>4.881724999999999 1 1.7296989999999823<span style="color: #2aa198;">)</span>
</pre>
</div>

<p>
Down to 4.9 seconds, only 1.7 of which are used by a single garbage collection pass (presumably at the end of execution).
</p>

<p>
It is worth noting that opting out of garbage collection might not make sense for extremely long running or memory intensive processes: you don&rsquo;t want Emacs to accidentally gobble up all of your available memory. Still, this is a nice optimization for those Emacs operations that seem to drag on just a bit too long.
</p>
]]></description>
</item>

<item>
<pubDate>Mon, 19 Aug 2024 00:00:00 -0400</pubDate>
<title>Failing to share the benefits of using Emacs</title>
<guid isPermaLink="true">https://goykhman.ca/gene/blog/2024-08-19-the-compounding-benefits-of-being-an-emacs-user.html</guid>
<description><![CDATA[<p class="pubDate">August 19, 2024</p>
<p>
I&rsquo;ve become self-conscious about proselyting Emacs to my friends and in public spaces. As enthusiastic as I am about Emacs, I find it difficult to convince others to invest in the learning process. And it is undeniably an investment. I limit my pitch attempts to already technical people that I think could benefit and (more importantly) would <i>enjoy</i> the same things many of us do about Emacs. My arguments tend to get dismissed, however, and I&rsquo;ve been trying to understand why.
</p>

<p>
This has been observed before, but I particularly like the way <a href="https://protesilaos.com/codelog/2024-04-24-re-what-keeps-you-emacs/#:~:text=The%20skills%20you%20acquire%20as,you%20like%20with%20your%20tool.">Prot said it a few months ago</a>:
</p>

<blockquote>
<p>
The skills you acquire as you gain more experience with Emacs have a compounding effect. You eventually get more out of the time you invest in them, which practically means that you are empowered to design the workflow you want &#x2026;
</p>
</blockquote>

<p>
It strikes me how unusual this compounding effect is among our software tools. As technical professionals we tend to look for the best tool for the job until the tool changes or the job changes, and don&rsquo;t think much of either when we move beyond it. We&rsquo;re vocationally accustomed to, perhaps optimized for, having our technology stack swap itself out every few years and have trained ourselves out of committing too deeply to anything in the stack. Ultimately that commitment has an expiration date.
</p>

<p>
I don&rsquo;t think most people fully understand that the compounding returns of an investment in Emacs is a <i>lifetime</i> benefit. That Emacs might be the one piece of software we use that could outlive us. And when I try to make <i>that</i> argument to my Obsidian / VS Code / JetBrains using friends you should see the looks I get.
</p>
]]></description>
</item>

<item>
<pubDate>Sat, 17 Aug 2024 00:00:00 -0400</pubDate>
<title>Upgrading to Emacs 29.4 on Apple Silicon Macs</title>
<guid isPermaLink="true">https://goykhman.ca/gene/blog/2024-08-17-upgrading-to-emacs-294-on-apple-silicon-macs.html</guid>
<description><![CDATA[<p class="pubDate">August 17, 2024</p>
<p>
This is an update to my post about <a href="2023-08-13-emacs-29.1-on-apple-silicon.html">compiling Emacs 29.1 from source</a>. Probably due to shifting dependencies that procedure no longer seems to work for me in Sonoma 14.6.1, and there have also been some <a href="https://www.reddit.com/r/orgmode/comments/1dlz5zb/ann_emergency_bugfix_release_org_mode_975/">important security fixes</a> to Emacs and Org Mode that make it advantageous to update as soon as possible.
</p>

<p>
Unfortunately the <a href="https://bitbucket.org/mituharu/emacs-mac/src/master/">Mitsuharu Emacs Mac Port</a> has not yet been tagged and released for any version past 29.1. Happily, the <code>work</code> branch has been updated to 29.4 and this is what I&rsquo;m using to write this post. Because this isn&rsquo;t an officially tagged release, I am expecting that there might be issues down the road but it seems to be working well so far.
</p>
<div id="outline-container-orge4053b8" class="outline-2">
<h2 id="orge4053b8">Remove existing Emacs</h2>
<div class="outline-text-2" id="text-orge4053b8">
<p>
Backup and delete <code>/Applications/Emacs.app</code> if you have one. I highly encourage you to keep a backup of your old Emacs around for a while in case you hit any snags building the new one.
</p>
</div>
</div>
<div id="outline-container-org448f1b9" class="outline-2">
<h2 id="org448f1b9">Update Xcode command-line tools</h2>
<div class="outline-text-2" id="text-org448f1b9">
<p>
Don&rsquo;t skip this step of reinstalling the latest version of the tools. I suspect you&rsquo;ll need to install <a href="https://xcodereleases.com">Xcode</a> first if you don&rsquo;t already have it. I am currently using Xcode 15.4. 
</p>

<div class="org-src-container">
<pre class="src src-emacs-lisp">sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install
</pre>
</div>
</div>
</div>
<div id="outline-container-orgb01db4f" class="outline-2">
<h2 id="orgb01db4f">Install/re-install dependencies</h2>
<div class="outline-text-2" id="text-orgb01db4f">
<div class="org-src-container">
<pre class="src src-sh">brew update
brew reinstall gcc
brew install libgccjit texinfo tree-sitter jansson
</pre>
</div>
</div>
</div>
<div id="outline-container-orgc88398b" class="outline-2">
<h2 id="orgc88398b">Get a fresh clone of Emacs</h2>
<div class="outline-text-2" id="text-orgc88398b">
<p>
Currently the <code>work</code> branch is the one with Emacs 29.4. Hopefully there will be a tagged release soon.
</p>

<div class="org-src-container">
<pre class="src src-sh">git clone https://bitbucket.org/mituharu/emacs-mac
<span style="color: #dcdcdc; font-weight: bold; font-style: italic;">cd</span> emacs-mac
git checkout work
</pre>
</div>
</div>
</div>
<div id="outline-container-org0c9e769" class="outline-2">
<h2 id="org0c9e769">Configure and make</h2>
<div class="outline-text-2" id="text-org0c9e769">
<div class="org-src-container">
<pre class="src src-sh">autoreconf -i

./configure <span style="color: #2aa198;">\ </span>
  --with-native-compilation <span style="color: #2aa198;">\ </span>
  --with-modules <span style="color: #2aa198;">\ </span>
  --enable-mac-app <span style="color: #2aa198;">\ </span>
  --with-xwidgets <span style="color: #2aa198;">\ </span>
  --with-tree-sitter <span style="color: #2aa198;">\ </span>
  --prefix=/Applications/Emacs.app/Contents/Resources
    
make
</pre>
</div>
</div>
</div>
<div id="outline-container-org2ec229e" class="outline-2">
<h2 id="org2ec229e">Add additional required resources</h2>
<div class="outline-text-2" id="text-org2ec229e">
<p>
The build process leaves out some required lisp resources, which you will discover if you try to launch the Emacs.app bundle from Finder or from console by typing:
</p>

<p>
<code>mac/Emacs.app/Contents/MacOS/Emacs</code>
</p>

<p>
You can manually move these required files into the bundle with:
</p>

<div class="org-src-container">
<pre class="src src-sh">mkdir -p mac/Emacs.app/Contents/Resources/share/emacs/29.4
mv lisp mac/Emacs.app/Contents/Resources/share/emacs/29.4
mv etc mac/Emacs.app/Contents/Resources/share/emacs/29.4
mv native-lisp mac/Emacs.app/Contents
</pre>
</div>
</div>
</div>
<div id="outline-container-org21c5737" class="outline-2">
<h2 id="org21c5737">Move the built Emacs.app into /Applications</h2>
<div class="outline-text-2" id="text-org21c5737">
<p>
Drag Emacs.app into your Applications folder and you should be ready to go. Remember that Emacs will be slow for a while after first launch as native compilation makes its way through all the Emacs Lisp sources packaged with Emacs.
</p>

<p>
<b>UPDATE 2024-08-18</b> to move the <code>etc</code> folder (with documentation) into the app bundle
</p>
</div>
</div>
]]></description>
</item>

<item>
<pubDate>Sun, 09 Jun 2024 00:00:00 -0400</pubDate>
<title>Always Yes in Emacs Lisp</title>
<guid isPermaLink="true">https://goykhman.ca/gene/blog/2024-06-09-always-yes-in-emacs-lisp.html</guid>
<description><![CDATA[<p class="pubDate">June  9, 2024</p>
<p>
Some Emacs commands tend to ask too many confirmation questions, or at least it would be nice to have the option to skip the confirmation step. For example, saving and quitting a merge session in ediff requires quitting, confirming the quit, and then confirming the save.
</p>

<p>
I wanted to bind a single keystroke that would unconditionally commit my changes and end ediff. In the process, with the help of a <a href="https://protesilaos.com/coach/">coaching session from Prot</a>, I made a general-purpose wrapper around any Emacs function to bypass confirmation.
</p>

<div class="org-src-container">
<pre class="src src-emacs-lisp"><span style="color: #2aa198;">(</span><span style="color: #33b50d; font-weight: bold;">defun</span> <span style="color: #269cee;">always-yes</span> <span style="color: #ebcc2a;">(</span><span style="color: #ebcc2a;">&amp;rest</span> args<span style="color: #ebcc2a;">)</span>
  <span style="color: #ebcc2a;">(</span><span style="color: #33b50d; font-weight: bold;">cl-letf</span> <span style="color: #269cee;">(</span><span style="color: #6c71c4;">(</span><span style="color: #33b50d;">(</span>symbol-function 'yes-or-no-p<span style="color: #33b50d;">)</span> #'always<span style="color: #6c71c4;">)</span>
            <span style="color: #6c71c4;">(</span><span style="color: #33b50d;">(</span>symbol-function 'y-or-n-p<span style="color: #33b50d;">)</span> #'always<span style="color: #6c71c4;">)</span><span style="color: #269cee;">)</span>
    <span style="color: #269cee;">(</span>funcall-interactively <span style="color: #6c71c4;">(</span>car args<span style="color: #6c71c4;">)</span> <span style="color: #6c71c4;">(</span>cdr args<span style="color: #6c71c4;">)</span><span style="color: #269cee;">)</span><span style="color: #ebcc2a;">)</span><span style="color: #2aa198;">)</span>
</pre>
</div>

<p>
I then used it to bind <code>Q</code> to unconditionally quit ediff, which requires a little more work than other packages typically would:
</p>

<div class="org-src-container">
<pre class="src src-emacs-lisp"><span style="color: #2aa198;">(</span><span style="color: #33b50d; font-weight: bold;">defun</span> <span style="color: #269cee;">my/ediff-quit-unconditionally</span> <span style="color: #ebcc2a;">()</span>
  <span style="color: #ebcc2a;">(</span><span style="color: #33b50d; font-weight: bold;">interactive</span><span style="color: #ebcc2a;">)</span>
  <span style="color: #ebcc2a;">(</span>always-yes #'ediff-quit<span style="color: #ebcc2a;">)</span><span style="color: #2aa198;">)</span>

<span style="color: #2aa198;">(</span><span style="color: #33b50d; font-weight: bold;">defun</span> <span style="color: #269cee;">add-Q-to-ediff-mode-map</span> <span style="color: #ebcc2a;">()</span> <span style="color: #ebcc2a;">(</span>define-key ediff-mode-map <span style="color: #2aa198;">"Q"</span> 'my/ediff-quit-unconditionally<span style="color: #ebcc2a;">)</span><span style="color: #2aa198;">)</span>
<span style="color: #2aa198;">(</span>add-hook 'ediff-keymap-setup-hook 'add-Q-to-ediff-mode-map<span style="color: #2aa198;">)</span>
</pre>
</div>

<p>
This is a small improvement to be sure, but little quality of life improvements like this accrue over time. It&rsquo;s one of the things I like most about Emacs.
</p>
]]></description>
</item>

<item>
<pubDate>Sat, 23 Dec 2023 00:00:00 -0500</pubDate>
<title>Printing PostScript from Emacs in macOS Sonoma</title>
<guid isPermaLink="true">https://goykhman.ca/gene/blog/2023-12-23-postscript-printing-in-sonoma.html</guid>
<description><![CDATA[<p class="pubDate">December 23, 2023</p>
<p>
Apple <a href="https://appleinsider.com/articles/23/09/27/sonoma-puts-the-last-nail-in-the-coffin-for-postscript-on-macos">removed support for PostScript in macOS Sonoma</a>, which has broken a number of things in my daily workflow. Here is a quick roundup post of some of my workarounds.
</p>
<div id="outline-container-orge0dcbac" class="outline-2">
<h2 id="orge0dcbac">Install Ghostscript with Homebrew</h2>
<div class="outline-text-2" id="text-orge0dcbac">
<p>
First, install <a href="https://brew.sh">Homebrew</a> if you don&rsquo;t already have
it.
</p>

<p>
Now, install the Ghostscript PostScript interpreter:
</p>

<p>
<code>brew install ghostscript</code>
</p>

<p>
To confirm that it has installed correctly, open a Terminal and type:
</p>

<p>
<code>gs --version</code>
</p>

<p>
You should see something like <code>10.02.1</code>.
</p>
</div>
</div>
<div id="outline-container-org8acdb9e" class="outline-2">
<h2 id="org8acdb9e">manp script for nicer man pages in Preview</h2>
<div class="outline-text-2" id="text-org8acdb9e">
<p>
I have added this to my <code>.zshrc</code> but it should work just as well in
<code>.bash_profile</code> and similar.
</p>

<div class="org-src-container">
<pre class="src src-sh"><span style="color: #33b50d; font-weight: bold;">function</span> <span style="color: #269cee;">manp</span>() {
  [ -n <span style="color: #2aa198;">"$1"</span> ] &amp;&amp; man -t $<span style="color: #269cee;">1</span> | gs -sDEVICE=pdfwrite -o $<span style="color: #269cee;">TMPDIR</span>/$<span style="color: #269cee;">1</span>.pdf - &amp;&amp; open $<span style="color: #269cee;">TMPDIR</span>/$<span style="color: #269cee;">1</span>.pdf &amp;&amp; sleep 1 &amp;&amp; rm $<span style="color: #269cee;">TMPDIR</span>/$<span style="color: #269cee;">1</span>.pdf
}
</pre>
</div>

<p>
Now you can type <code>manp</code> instead of <code>man</code> to view your man pages as a nicely formatted PDF in Preview.
</p>
</div>
</div>
<div id="outline-container-org04827b9" class="outline-2">
<h2 id="org04827b9">Emacs PostScript Print Buffer / Region</h2>
<div class="outline-text-2" id="text-org04827b9">
<p>
Emacs depends on the system <code>lpr</code> utility to print PostScript and as of
macOS Sonoma, lpr no longer supports PostScript. The specific error
message you will see is:
</p>

<p>
<code>user-error: Spooling...done: /usr/bin/lpr: Unsupported document-format “application/postscript”.</code>
</p>

<p>
Let&rsquo;s create our own <code>lpr</code> alternative for Emacs to use.
</p>

<p>
In a convenient executable folder (in my case, <code>/Users/gene/bin</code>), create the following file and call it <code>lpr-ps</code>
</p>

<div class="org-src-container">
<pre class="src src-sh"><span style="color: #8aa1a6; font-style: italic;">#</span><span style="color: #8aa1a6;">!/bin/</span><span style="color: #33b50d; font-weight: bold;">bash</span>
<span style="color: #269cee;">uuid</span>=$(uuidgen) gs -sDEVICE=pdfwrite -o $<span style="color: #269cee;">TMPDIR</span>/$<span style="color: #269cee;">uuid</span>.pdf - &amp;&amp; open $<span style="color: #269cee;">TMPDIR</span>/$<span style="color: #269cee;">uuid</span>.pdf &amp;&amp; sleep 1 &amp;&amp; rm $<span style="color: #269cee;">TMPDIR</span>/$<span style="color: #269cee;">uuid</span>.pdf
</pre>
</div>

<p>
Make it executable:
</p>

<p>
<code>chmod +x /Users/gene/bin/lpr-ps</code>
</p>

<p>
Add the following to your Emacs configuration (with your particular path of course):
</p>

<p>
<code>(setq ps-lpr-command "/Users/gene/bin/lpr-ps")</code>
</p>

<p>
PostScript Print Buffer and PostScript Print Region (<code>M-x ps-print-buffer</code> and <code>M-x ps-print-region</code>) should now open a nicely formatted Preview document for you.
</p>

<p>
<b>NOTE:</b> if you are getting an error like <i>The file &#x2026; couldn&rsquo;t be opened because there is no such file.</i> Try changing <code>sleep 1</code> to a bigger number of seconds, like <code>sleep 10</code> or even <code>sleep 30</code>. The script tries to delete the generated temporary file as soon as possible, but sometimes this is sooner than Preview can get it onto the screen. Keep bumping this number up until the script is reliable for you. The tradeoff is that control isn&rsquo;t returned to Emacs until the full sleep timeout has elapsed.
</p>
</div>
</div>
<div id="outline-container-org123d7c4" class="outline-2">
<h2 id="org123d7c4">Emacs Org LaTeX export to PDF</h2>
<div class="outline-text-2" id="text-org123d7c4">
<p>
This might not be an issue for you, but if you use Org&rsquo;s export to PDF
via LaTeX I had to make the following additional change to my Emacs
config. Something about <code>pdflatex</code> not being a known LaTeX compiler.
</p>

<p>
<code>(setq org-latex-pdf-process '("latexmk -f -pdf -interaction=nonstopmode -output-directory=%o %f"))</code>
</p>

<p>
I&rsquo;ll continue updating this post with additional PostScript-on-Mac workarounds as I find and implement them.
</p>
</div>
</div>
]]></description>
</item>

<item>
<pubDate>Sun, 13 Aug 2023 00:00:00 -0400</pubDate>
<title>Upgrading to Emacs 29.1 on Apple Silicon Macs</title>
<guid isPermaLink="true">https://goykhman.ca/gene/blog/2023-08-13-emacs-29.1-on-apple-silicon.html</guid>
<description><![CDATA[<p class="pubDate">August 13, 2023</p>
<p>
This is an update to my post about <a href="https://goykhman.ca/gene/blog/2022-04-10-emacs-28.1-on-m1.html">compiling Emacs 28.1 from source</a>. With the recent release of Emacs 29.1, here are the steps I used to upgrade.
</p>
<div id="outline-container-org06103c5" class="outline-2">
<h2 id="org06103c5">Remove existing Emacs</h2>
<div class="outline-text-2" id="text-org06103c5">
<p>
Backup and delete <code>/Applications/Emacs.app</code> if you have one.
</p>
</div>
</div>
<div id="outline-container-org6612d36" class="outline-2">
<h2 id="org6612d36">Install/re-install dependencies</h2>
<div class="outline-text-2" id="text-org6612d36">
<div class="org-src-container">
<pre class="src src-sh">brew update
brew reinstall gcc
brew install libgccjit texinfo tree-sitter jansson
sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install
</pre>
</div>

<p>
It still seems to be necessary to re-install Xcode command-line tools to prevent Emacs from getting killed on launch.
</p>
</div>
</div>
<div id="outline-container-orgdd68d64" class="outline-2">
<h2 id="orgdd68d64">Get a fresh clone of Emacs</h2>
<div class="outline-text-2" id="text-orgdd68d64">
<p>
I don&rsquo;t tend to remote into my Emacs session any more so I didn&rsquo;t bother
updating or applying the
<a href="https://goykhman.ca/gene/blog/2020-12-06-emacs-27-multi-tty-patch.html">multi-tty
patch</a>. I may reconsider that if my needs change in the future.
</p>

<div class="org-src-container">
<pre class="src src-sh">git clone https://bitbucket.org/mituharu/emacs-mac
<span style="color: #dcdcdc; font-weight: bold; font-style: italic;">cd</span> emacs-mac
git checkout emacs-29.1-mac-10.0
</pre>
</div>
</div>
</div>
<div id="outline-container-org41e9913" class="outline-2">
<h2 id="org41e9913">Configure and make</h2>
<div class="outline-text-2" id="text-org41e9913">
<div class="org-src-container">
<pre class="src src-sh">autoreconf -i

./configure <span style="color: #2aa198;">\ </span>
  --with-native-compilation <span style="color: #2aa198;">\ </span>
  --with-modules <span style="color: #2aa198;">\ </span>
  --enable-mac-app <span style="color: #2aa198;">\ </span>
  --with-xwidgets <span style="color: #2aa198;">\ </span>
  --with-tree-sitter <span style="color: #2aa198;">\ </span>
  --prefix=/Applications/Emacs.app/Contents/Resources
    
make
</pre>
</div>
</div>
</div>
<div id="outline-container-orgad6e242" class="outline-2">
<h2 id="orgad6e242">Add additional required resources</h2>
<div class="outline-text-2" id="text-orgad6e242">
<p>
The build process seems to leave out some required lisp resources, which you will discover if you try to launch the Emacs.app bundle from Finder or from console by typing:
</p>

<p>
<code>mac/Emacs.app/Contents/MacOS/Emacs</code>
</p>

<p>
You can manually move these required files into the bundle with:
</p>

<div class="org-src-container">
<pre class="src src-sh">mkdir -p mac/Emacs.app/Contents/Resources/share/emacs/29.1
mv lisp mac/Emacs.app/Contents/Resources/share/emacs/29.1
mv lative-lisp mac/Emacs.app/Contents
</pre>
</div>
</div>
</div>
<div id="outline-container-org50d01d6" class="outline-2">
<h2 id="org50d01d6">Move the built Emacs into /Applications</h2>
<div class="outline-text-2" id="text-org50d01d6">
<p>
I didn&rsquo;t have much luck with <code>make install</code> so I just manually moved
<code>emacs-mac/mac/Emacs.app</code> into <code>/Applications</code>
</p>

<p>
This was pretty smooth for me, probably because I had things nicely wired up from <a href="https://goykhman.ca/gene/blog/2022-04-10-emacs-28.1-on-m1.html">my previous installation</a>. Good luck!
</p>

<p>
<b>UPDATE 2023-10-02</b> to add <code>--with-tree-sitter</code> configuration option and manual installation process.
<b>UPDATE 2024-08-17</b> to add additional required resources to prevent Emacs from being killed at launch
</p>
</div>
</div>
]]></description>
</item>

<item>
<pubDate>Sun, 10 Apr 2022 00:00:00 -0400</pubDate>
<title>Upgrading to Emacs 28.1 on Apple Silicon (M1) Macs</title>
<guid isPermaLink="true">https://goykhman.ca/gene/blog/2022-04-10-emacs-28.1-on-m1.html</guid>
<description><![CDATA[<p class="pubDate">April 10, 2022</p>
<p>
This is an update of sorts to my <a href="https://goykhman.ca/gene/blog/2020-12-06-emacs-27-multi-tty-patch.html">previous Emacs build recipe</a> and late-night <a href="https://mastodon.social/@genegoykhman/status/1360472500912730116">Emacs-on-M1 twitter thread</a>.
</p>

<p>
The <a href="https://bitbucket.org/mituharu/emacs-mac/src/emacs-28.1-mac-9.0/">Emacs Mac Port has been updated for Emacs 28.1</a> and here are the steps I used to build and install it on my M1 MacBook Air. Overall the process seems much smoother than the <a href="https://www.mattduck.com/2021-05-upgrading-to-emacs-28.html">pre-release build experience</a> but as always YMMV.
</p>
<div id="outline-container-org74d89ba" class="outline-2">
<h2 id="org74d89ba">Install/re-install dependencies</h2>
<div class="outline-text-2" id="text-org74d89ba">
<div class="org-src-container">
<pre class="src src-sh">brew reinstall gcc
brew install libgccjit texinfo
brew ln texinfo --force
</pre>
</div>

<p>
I&rsquo;m not sure why it was necessary to reinstall <code>gcc</code> (maybe an architecture issue?), but it seemed to help with a build error in a subsequent step. Also <code>texinfo</code> provides an updated <code>makeinfo</code> which is now no longer optional in the Emacs build process.
</p>
</div>
</div>
<div id="outline-container-org6e3db31" class="outline-2">
<h2 id="org6e3db31">Add makeinfo to path</h2>
<div class="outline-text-2" id="text-org6e3db31">
<p>
Add this to your shell path (necessary so that the <code>makeinfo</code> provided
by <code>texinfo</code> is seen before the older macOS-provided version).
</p>

<p>
<code>/opt/homebrew/opt/texinfo/bin</code>
</p>
</div>
</div>
<div id="outline-container-org54391dd" class="outline-2">
<h2 id="org54391dd">Install/re-install Xcode command-line tools</h2>
<div class="outline-text-2" id="text-org54391dd">
<div class="org-src-container">
<pre class="src src-sh">sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install
</pre>
</div>

<p>
Again, something was wedged in the subsequent build process until I took this step, as recommeded in this <a href="https://github.com/jimeh/build-emacs-for-macos/issues/20">GitHub thread</a>.
</p>
</div>
</div>
<div id="outline-container-org7af6455" class="outline-2">
<h2 id="org7af6455">Clone Emacs</h2>
<div class="outline-text-2" id="text-org7af6455">
<p>
These steps also apply the (optional)
<a href="https://goykhman.ca/gene/blog/2020-12-06-emacs-27-multi-tty-patch.html">multi-tty
patch</a> that I&rsquo;ve written about before.
</p>

<div class="org-src-container">
<pre class="src src-sh">git clone https://bitbucket.org/mituharu/emacs-mac
<span style="color: #dcdcdc; font-weight: bold; font-style: italic;">cd</span> emacs-mac git
checkout emacs-28.1-mac-9.0
autoreconf -i
wget https://gist.github.com/genegoykhman/6effe7fa25696c49d0519af877f5fb42/raw -O multi-tty.patch
git apply multi-tty.patch
</pre>
</div>
</div>
</div>
<div id="outline-container-org5dc56ac" class="outline-2">
<h2 id="org5dc56ac">Configure and build</h2>
<div class="outline-text-2" id="text-org5dc56ac">
<div class="org-src-container">
<pre class="src src-sh">./configure <span style="color: #ebcc2a; font-weight: bold;">\</span>
  --with-native-compilation <span style="color: #ebcc2a; font-weight: bold;">\</span>
  --with-modules <span style="color: #ebcc2a; font-weight: bold;">\</span>
  --enable-mac-app <span style="color: #ebcc2a; font-weight: bold;">\</span>
  --prefix=/Applications/Emacs.app/Contents/Resources

make install
</pre>
</div>
</div>
</div>
<div id="outline-container-org9868cae" class="outline-2">
<h2 id="org9868cae">Confirm your emacsclient is linked to the right place</h2>
<div class="outline-text-2" id="text-org9868cae">
<p>
The above steps will update your <code>/Applications/Emacs.app</code> in place, so
if you had <code>emacsclient</code> in a different subdirectory (as I did) you may
want to replace any symbolic links to the newly build version at
<code>/Applications/Emacs.app/Contents/Resources/bin/emacsclient</code>.
</p>
</div>
</div>
<div id="outline-container-org4810793" class="outline-2">
<h2 id="org4810793">Starting Emacs</h2>
<div class="outline-text-2" id="text-org4810793">
<p>
If all goes well you should be able to start Emacs and <code>(emacs-version)</code>
will report 28.1. The new native-compilation feature will churn through
your startup Elisp and probably spew a ton of warnings, but eventually
you&rsquo;ll notice that Emacs feels much zippier.
</p>

<p>
If you don&rsquo;t see any <code>(comp)</code> warnings on first startup you might just want to check that native compilation is working &#x2026;  <code>(fboundp 'native-compile-async)</code> should return <code>t</code>.
</p>
</div>
</div>
]]></description>
</item>

</channel>
</rss>
