git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/4] git-blame.el: Make all line prefixes to have the same length

From
Michal Sojka <sojkam1@fel.cvut.cz>
Date
Jul 2, 2013, 17:34 UTC
Message-ID
<1372786477-13122-3-git-send-email-sojkam1@fel.cvut.cz>
In-Reply-To
<1372786477-13122-1-git-send-email-sojkam1@fel.cvut.cz>

Without this patch, the beginning of git-blame.el in emacs buffer looks like this (note the Messige-ID line):

b52ba1 <jnareb@gmail.com>:;; Authors: David Kågedal <davidk@lysator.liu.se> b52ba1 <jnareb@gmail.com>:;; Created: 31 Jan 2007 28389d <davidk@lysator.liu.se>:;; Message-ID: <87iren2vqx.fsf@morpheus.local> b52ba1 <jnareb@gmail.com>:;; License: GPL b52ba1 <jnareb@gmail.com>:;; Keywords: git, version control, release management

With this patch, all lines are aligned even if email addresses have different length.

b52ba1 <jnareb@gmail.com>: ;; Authors: David Kågedal <davidk@lysator.liu.se> b52ba1 <jnareb@gmail.com>: ;; Created: 31 Jan 2007 28389d <davidk@lysator.liu.se> ;; Message-ID: <87iren2vqx.fsf@morpheus.local> b52ba1 <jnareb@gmail.com>: ;; License: GPL b52ba1 <jnareb@gmail.com>: ;; Keywords: git, version control, release management

Signed-off-by: Michal Sojka <sojkam1@fel.cvut.cz>
---
 contrib/emacs/git-blame.el | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/contrib/emacs/git-blame.el b/contrib/emacs/git-blame.el
index 18ce241..573f408 100644
--- a/contrib/emacs/git-blame.el
+++ b/contrib/emacs/git-blame.el
@@ -116,6 +116,15 @@ mode. The format is passed to `format-spec' with the following format keys:
 "
   :group 'git-blame)
 
+(defcustom git-blame-prefix-width
+  "%-30.30s "
+  "The format for post-processing the prefix produced according
+to `git-blame-prefix-format'. This format is passed to `format'
+function. The default value ensures that all prefixes have the
+same length, i.e. the it causes the prefix to be either truncated
+or padded to 30 characters.
+"
+  :group 'git-blame)
 (defcustom git-blame-mouseover-format
   "%h %a %A: %s"
   "The format of the description shown when pointing at a line in
@@ -410,8 +419,9 @@ See also function `git-blame-mode'."
               (overlay-put ovl 'face (list :background
                                            (cdr (assq 'color (cdr info))))))
           (overlay-put ovl 'line-prefix
-                       (propertize (format-spec git-blame-prefix-format spec)
-                                   'face 'git-blame-prefix-face)))))))
+                       (propertize (format git-blame-prefix-width
+					   (format-spec git-blame-prefix-format spec))
+					   'face 'git-blame-prefix-face)))))))
 
 (defun git-blame-add-info (info key value)
   (nconc info (list (cons (intern key) value))))
-- 
1.8.3.1
Previous: Michal SojkaNext: Michal Sojka
Message 3 of 5 in “Emacs: git-blame.el fixes and enhancements”
  1. 0/4 Emacs: git-blame.el fixes and enhancementsMichal Sojka, Jul 2, 2013
  2. 1/4 git-blame.el: Fix buffer local declarationMichal Sojka, Jul 2, 2013
  3. 2/4 git-blame.el: Make all line prefixes to have the same lengthMichal Sojka, Jul 2, 2013
  4. 3/4 git-blame.el: Allow displaying author/commit timesMichal Sojka, Jul 2, 2013
  5. 4/4 git-blame.el: Change the default prefix formatMichal Sojka, Jul 2, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.