bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#59491: 29.0.50; [PATCH] Mode-line elements too wide in some VC buffe


From: Gabriel
Subject: bug#59491: 29.0.50; [PATCH] Mode-line elements too wide in some VC buffers
Date: Tue, 22 Nov 2022 17:58:25 -0300

Severity: wishlist

Description:

Some mode-line elements are too wide in some VC buffers, which affects
the information visibility.

Steps:

1) emacs -Q

2) Open some file controlled by Git VC, e.g.: C-x f ~/git/emacs/README

The buffer named "README" will be shown, the buffer name is displayed on
the left side of the mode-line.

(length (buffer-name)) => 6

3) Annotate the buffer: C-x v g

The VC-Annotate buffer named "*Annotate README (rev 
1f39da3098a2a4cec9985e6db934ed14b7b522b7)*"
will be shown, the buffer name is displayed on the left side of the
mode-line.  The revision number might differ.

(length (buffer-name)) => 64

4) Show log revision at line: l

The Git-Log-View buffer will be shown.  The value of
`vc-parent-buffername' is " from *Annotate README (rev 
1f39da3098a2a4cec9985e6db934ed14b7b522b7)*",
displayed on the right side of the mode-line.  The revision number might
differ.

(length vc-parent-buffer-name) => 70

Analysis:

A short named buffer "README" with length of 6 had information displayed
in the mode-line with lengths of 64 (with `vc-annotate') and 70 (with
`vc-annotate-show-log-revision-at-line').  This excessive length affects
the visibility of information in mode-line, which was supposed to ease
the access of information to the user.  A long buffer name can also
affect the display and usability in other interfaces, e.g.:
`list-buffers', `ibuffer' etc.

The problem, in this case, is the long revision string used by Git.  I
am not sure how other VCs behaves in this matter (bzr, cvs, dav, hg,
rcs, sccs, src, svc etc).

Solutions:

For Git, a better option would be to use a "short revision" (by default
the first 7 characters of the "long revision"), which would reduce, for
the example above, the length from 64 to 39 (and `vc-parent-buffer-name'
from 70 to 45):

diff --git a/lisp/vc/vc-annotate.el b/lisp/vc/vc-annotate.el
index a15cf417de..63485af52e 100644
--- a/lisp/vc/vc-annotate.el
+++ b/lisp/vc/vc-annotate.el
@@ -409,7 +409,9 @@ vc-annotate
                                  nil nil "20")))))))
   (vc-ensure-vc-buffer)
   (setq vc-annotate-display-mode display-mode) ;Not sure why.  --Stef
-  (let* ((temp-buffer-name (format "*Annotate %s (rev %s)*" (buffer-name) rev))
+  (let* ((temp-buffer-name (format "*Annotate %s (rev %s)*"
+                                   (buffer-name)
+                                   (string-limit rev 7)))
          (temp-buffer-show-function 'vc-annotate-display-select)
          ;; If BUF is specified, we presume the caller maintains current line,
          ;; so we don't need to do it here.  This implementation may give

Another option would be to display additional information in the
header-line.

Another option would be to allow the user to format how the VC-Annotate
buffer name is displayed (and optionally also the
`vc-parent-buffer-name').  See attached patches.

Attachment: 0001-New-option-vc-annotate-buffer-name-function.patch
Description: Text Data

Attachment: 0001-New-option-vc-parent-buffer-name-format-function.patch
Description: Text Data

Please share your suggestions.

---
Gabriel

reply via email to

[Prev in Thread] Current Thread [Next in Thread]