<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>log on
A Scripter's Notes</title><link>https://scripter.co/tags/log/</link><description>Recent content in log
on A Scripter's Notes</description><language>en-us</language><managingEditor>kaushal.modi@gmail.com (Kaushal Modi)</managingEditor><webMaster>kaushal.modi@gmail.com (Kaushal Modi)</webMaster><lastBuildDate>Wed, 22 Apr 2026 08:24:58 -0400</lastBuildDate><generator>Hugo -- gohugo.io</generator><docs>https://validator.w3.org/feed/docs/rss2.html</docs><atom:link href="https://scripter.co/tags/log/index.xml" rel="self" type="application/rss+xml"/><item><title>Narrowing the Author column in Magit</title><link>https://scripter.co/narrowing-the-author-column-in-magit/</link><description>&lt;p>The Org and &lt;a href="https://orgmode.org/worg/">Worg&lt;/a> git repos can be committed to only via &lt;em>ssh&lt;/em> protocol
(and not &lt;em>https&lt;/em>), and for technical reasons, I cannot commit to those
repos via &lt;em>ssh&lt;/em> from my primary development machine. So I ended up
with a flow that involves pushing commits to those repos using my
Nexus 6p phone.&lt;/p>
&lt;p>&lt;a href="https://magit.vc/">Magit&lt;/a> is how I &lt;em>git&lt;/em>, and I love to primarily work from the
&lt;em>∗magit-log∗&lt;/em> buffer (&lt;code>M-x magit-status&lt;/code>, &lt;kbd>l&lt;/kbd> &lt;kbd>b&lt;/kbd>). But the default
column widths were not optimal on a Nexus 6p 5.7&amp;quot; screen. And that&amp;rsquo;s
what inspired this tweak, which looks great on a regular desktop
monitor too.&lt;/p>
&lt;p>Before I jump to the code, you can see in the below figure how the
author and commit age columns took up roughly half the screen width on
my phone before the tweak (left), and how much easier it is to read
the commit messages after the tweak (right).&lt;/p>
&lt;figure>
&lt;a href="https://scripter.co/images/magit_author_column.png">
&lt;img src="https://scripter.co/images/magit_author_column.png" alt="Figure 1: Org-mode Worg commit log : Before (Left), After (Right)"/> &lt;/a>&lt;figcaption>
&lt;p>
&lt;span class="figure-number">Figure 1: &lt;/span>Org-mode Worg commit log : Before (Left), After (Right)
&lt;/p>
&lt;/figcaption>&lt;/figure>
&lt;p>So the Magit Log columns tweaks are basically:&lt;/p>
&lt;ol>
&lt;li>Abbreviate the authors&amp;rsquo; first names to just their initials.&lt;/li>
&lt;li>Abbreviate the commit ages to 1-character time units.&lt;/li>
&lt;/ol>
&lt;p>To implement those tweaks, I started digging through &lt;code>magit-log.el&lt;/code>
and found that I would need to customize (i) the &lt;code>magit-log-margin&lt;/code>
variable and (ii) &lt;code>magit-log-format-margin&lt;/code> function.&lt;/p>
&lt;ul>
&lt;li>Customizing &lt;code>magit-log-margin&lt;/code> variable allows me to use the
abbreviated age instead of the verbose age strings (minute→m,
hour→h, day→d, week→w, month→M, year→Y). It&amp;rsquo;s also where I specify
how wide I want the author column to be.. I can now reduce that
column width from the default value of 18 to 11 as I am abbreviating
the author name too.&lt;/li>
&lt;li>Reviewing the &lt;code>magit-log.el&lt;/code> code, I realized that I also need to
advise the &lt;code>magit-log-format-margin&lt;/code> function to implement the
author name abbreviation.&lt;/li>
&lt;/ul>
&lt;p>In the below code snippet, I am using &lt;a href="https://github.com/jwiegley/use-package">&lt;code>use-package&lt;/code>&lt;/a>&lt;sup id="fnref:1">&lt;a href="#fn:1" class="footnote-ref" role="doc-noteref">1&lt;/a>&lt;/sup> to customize
that variable and function in &lt;code>magit-log&lt;/code>.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-emacs-lisp" data-lang="emacs-lisp">&lt;span class="line">&lt;span class="cl">&lt;span class="p">(&lt;/span>&lt;span class="nb">use-package&lt;/span> &lt;span class="nv">magit-log&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nb">:init&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">(&lt;/span>&lt;span class="nb">progn&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="c1">;; (setq magit-log-margin &amp;#39;(t age magit-log-margin-width t 18)) ;Default value&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">(&lt;/span>&lt;span class="nb">setq&lt;/span> &lt;span class="nv">magit-log-margin&lt;/span> &lt;span class="o">&amp;#39;&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="no">t&lt;/span> &lt;span class="nv">age-abbreviated&lt;/span> &lt;span class="nv">magit-log-margin-width&lt;/span> &lt;span class="nb">:author&lt;/span> &lt;span class="mi">11&lt;/span>&lt;span class="p">)))&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nb">:config&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">(&lt;/span>&lt;span class="nb">progn&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="c1">;; Abbreviate author name. I added this so that I can view Magit log without&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="c1">;; too much commit message truncation even on narrow screens (like on phone).&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">(&lt;/span>&lt;span class="nb">defun&lt;/span> &lt;span class="nv">modi/magit-log--abbreviate-author&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="kp">&amp;amp;rest&lt;/span> &lt;span class="nv">args&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="s">&amp;#34;The first arg is AUTHOR, abbreviate it.
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="s">First Last -&amp;gt; F Last
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="s">First.Last -&amp;gt; F Last
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="s">Last, First -&amp;gt; F Last
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="s">First -&amp;gt; First (no change).
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="s">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="s">It is assumed that the author has only one or two names.&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="c1">;; ARGS -&amp;gt; &amp;#39;((REV AUTHOR DATE))&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="c1">;; (car ARGS) -&amp;gt; &amp;#39;(REV AUTHOR DATE)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="c1">;; (nth 1 (car ARGS)) -&amp;gt; AUTHOR&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">(&lt;/span>&lt;span class="nb">let*&lt;/span> &lt;span class="p">((&lt;/span>&lt;span class="nv">author&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="nf">nth&lt;/span> &lt;span class="mi">1&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="nf">car&lt;/span> &lt;span class="nv">args&lt;/span>&lt;span class="p">)))&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">(&lt;/span>&lt;span class="nv">author-abbr&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="nb">if&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="nv">string-match-p&lt;/span> &lt;span class="s">&amp;#34;,&amp;#34;&lt;/span> &lt;span class="nv">author&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="c1">;; Last, First -&amp;gt; F Last&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">(&lt;/span>&lt;span class="nv">replace-regexp-in-string&lt;/span> &lt;span class="s">&amp;#34;\\(.*?\\), *\\(.\\).*&amp;#34;&lt;/span> &lt;span class="s">&amp;#34;\\2 \\1&amp;#34;&lt;/span> &lt;span class="nv">author&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="c1">;; First Last -&amp;gt; F Last&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">(&lt;/span>&lt;span class="nv">replace-regexp-in-string&lt;/span> &lt;span class="s">&amp;#34;\\(.\\).*?[. ]+\\(.*\\)&amp;#34;&lt;/span> &lt;span class="s">&amp;#34;\\1 \\2&amp;#34;&lt;/span> &lt;span class="nv">author&lt;/span>&lt;span class="p">))))&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">(&lt;/span>&lt;span class="nb">setf&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="nf">nth&lt;/span> &lt;span class="mi">1&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="nf">car&lt;/span> &lt;span class="nv">args&lt;/span>&lt;span class="p">))&lt;/span> &lt;span class="nv">author-abbr&lt;/span>&lt;span class="p">))&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">(&lt;/span>&lt;span class="nf">car&lt;/span> &lt;span class="nv">args&lt;/span>&lt;span class="p">))&lt;/span> &lt;span class="c1">;&amp;#39;(REV AUTHOR-ABBR DATE)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">(&lt;/span>&lt;span class="nv">advice-add&lt;/span> &lt;span class="ss">&amp;#39;magit-log-format-margin&lt;/span> &lt;span class="nb">:filter-args&lt;/span> &lt;span class="nf">#&amp;#39;&lt;/span>&lt;span class="nv">modi/magit-log--abbreviate-author&lt;/span>&lt;span class="p">)))&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;strong>NOTES&lt;/strong>&lt;/p>
&lt;ul>
&lt;li>I need to set the &lt;code>magit-log-margin&lt;/code> value in the &lt;code>:init&lt;/code> block
because that variable dynamically sets many other variables in
&lt;code>magit-log&lt;/code> at the time of loading. So we cannot wait for the whole
&lt;code>magit-log&lt;/code> to load before setting that variable. I wouldn&amp;rsquo;t need to
worry about this if I were using the Emacs &lt;em>Customize&lt;/em> interface to
set this variable.&lt;/li>
&lt;li>I use &lt;code>modi/magit-log--abbreviate-author&lt;/code> to add a &lt;code>:filter-args&lt;/code>
advice to &lt;code>magit-log-format-margin&lt;/code>. The signature of the advised
function is &lt;code>(magit-log-format-margin REV AUTHOR DATE)&lt;/code> (as of
&lt;em>Magit 20180809.1716&lt;/em>). So the advice basically replaces the
&lt;code>AUTHOR&lt;/code> arg with its abbreviated form as explained in the
&lt;code>modi/magit-log--abbreviate-author&lt;/code> doc-string.&lt;/li>
&lt;/ul>
&lt;div class="footnotes" role="doc-endnotes">
&lt;hr>
&lt;ol>
&lt;li id="fn:1">
&lt;p>Feel free to ask for more explanation in comments in the case
you don&amp;rsquo;t use &lt;code>use-package&lt;/code>.&amp;#160;&lt;a href="#fnref:1" class="footnote-backref" role="doc-backlink">&amp;#x21a9;&amp;#xfe0e;&lt;/a>&lt;/p>
&lt;/li>
&lt;/ol>
&lt;/div></description><author>Kaushal.Modi@fakeEmailToMakeValidatorHappy.com (Kaushal Modi)</author><category domain="https://scripter.co/categories/emacs">emacs</category><category domain="https://scripter.co/categories/elisp">elisp</category><category domain="https://scripter.co/tags/magit">magit</category><category domain="https://scripter.co/tags/git">git</category><category domain="https://scripter.co/tags/org">org</category><category domain="https://scripter.co/tags/log">log</category><guid>https://scripter.co/narrowing-the-author-column-in-magit/</guid><pubDate>Mon, 18 Dec 2017 16:36:00 -0500</pubDate></item></channel></rss>