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

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

bug#66464: Vc mode-line


From: Juri Linkov
Subject: bug#66464: Vc mode-line
Date: Sun, 12 Nov 2023 10:07:49 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu)

>> PS: Probably we could also add another option `no-backend'
>> that will show only an indicator and the branch name.
>> But the dangling indicator such as "-" or "*" before the branch name
>> doesn't look nice when there is a space that separates it
>> from the project name, e.g. "project -branch".
>
> It would probably make more sense to me, but having both might be overkill.
>
> FWIW, with the custom mode-line that I use (smart-mode-line) the results of
> these two options would look the same -- space-separated anyway.

Oh, this means that removing a space is useless for such mode-lines.

Ok, then let's add a much cleaner option `no-backend'.
Then anyone who doesn't like that space could customize
the mode line with something like

  (define-advice vc-mode-line (:after (&rest _args) remove-space)
    (setq vc-mode (string-trim-left vc-mode)))

diff --git a/lisp/vc/vc-hooks.el b/lisp/vc/vc-hooks.el
index c16fb63b2ff..f65ee150603 100644
--- a/lisp/vc/vc-hooks.el
+++ b/lisp/vc/vc-hooks.el
@@ -152,8 +152,12 @@ vc-follow-symlinks
 
 (defcustom vc-display-status t
   "If non-nil, display revision number and lock status in mode line.
-Otherwise, not displayed."
-  :type 'boolean
+If nil, only the backend name is displayed.  When the value
+is `no-backend', then no backend name is displayed before the
+revision number and lock status."
+  :type '(choice (const :tag "Show only revision/status" no-backend)
+                 (const :tag "Show backend and revision/status" t)
+                 (const :tag "Show only backend name" nil))
   :group 'vc)
 
 
@@ -766,7 +769,9 @@ vc-default-mode-line-string
                (rev (vc-working-revision file backend))
                (`(,state-echo ,face ,indicator)
                 (vc-mode-line-state state))
-               (state-string (concat backend-name indicator rev)))
+               (state-string (concat (unless (eq vc-display-status 'no-backend)
+                                       backend-name)
+                                     indicator rev)))
     (propertize state-string 'face face 'help-echo
                 (concat state-echo " under the " backend-name
                         " version control system"))))
diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index 707fc7cfc07..27eebe79148 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -423,7 +423,9 @@ vc-git-mode-line-string
                (rev (vc-working-revision file 'Git))
                (disp-rev (or (vc-git--symbolic-ref file)
                              (and rev (substring rev 0 7))))
-               (state-string (concat backend-name indicator disp-rev)))
+               (state-string (concat (unless (eq vc-display-status 'no-backend)
+                                       backend-name)
+                                     indicator disp-rev)))
     (propertize state-string 'face face 'help-echo
                 (concat state-echo " under the " backend-name
                         " version control system"
diff --git a/lisp/vc/vc-hg.el b/lisp/vc/vc-hg.el
index 89b2814a0a3..9df517ea847 100644
--- a/lisp/vc/vc-hg.el
+++ b/lisp/vc/vc-hg.el
@@ -365,7 +365,9 @@ vc-hg-mode-line-string
                             (and vc-hg-use-file-version-for-mode-line-version
                                  truename)))))
                (rev (or rev "???"))
-               (state-string (concat backend-name indicator rev)))
+               (state-string (concat (unless (eq vc-display-status 'no-backend)
+                                       backend-name)
+                                     indicator rev)))
     (propertize state-string 'face face 'help-echo
                 (concat state-echo " under the " backend-name
                         " version control system"))))

reply via email to

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