[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: |
Sat, 11 Nov 2023 20:50:12 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) |
>> The format is "project-branch" instead of "backend-branch".
>
> It might also be misread as a directory name. E.g. I have directories
> called "emacs" and "emacs-master" (thanks to git-worktree), and they get
> automatically assigned the corresponding project names. The new mode-line
> with your customization looks like "emacs-master-master". But that could
> just be my problem.
I had the same problem even after enabling project-mode-line,
so needed to remove the branch name from project names.
>> I'm sure that showing the backend name in all file buffers is useless
>> for most users and wastes the precious screen space.
>
> Hmm, I suppose since we're in a situation where one VCS (Git) is used 99%
> of the time, the indication might be unnecessary. But it's also a reminder
> that this mode-line item is for VC. Anyway...
The problem is that the useless word "Git" (with big G)
between the project name and the branch name is a big distraction.
>>> And if you customize 'vc-display-status' to 'with-project' but don't
>>> set project-mode-line to t, the project name won't be shown at all.
>> This is why the condition already handles this case:
>> (and (eq vc-display-status 'with-project)
>> (bound-and-true-p project-mode-line))
>
> What happens if mode-line-format doesn't contain project-mode-line-format,
> or has it in the wrong place? E.g. if the user (or third-party package)
> customized the mode-line.
Indeed, for such cases this option can't be used. I believe we should
better document such situation in the docstring.
> Anyway, I've raised the questions, but I don't have strong objections to
> your patch. Perhaps consider changing the description from
>
> (const :tag "Show project name and status" with-project)
>
> to
>
> (const :tag "Show only status next to project name" with-project)
Currently the options are aligned and provide a nice review
what the user will see on the mode line:
:type '(choice (const :tag "Show project name and status" with-project)
(const :tag "Show backend and status" t)
(const :tag "Show only backend name" nil))
So I'd rather like to describe more details in the docstring.
> and, maybe, check that project-mode-line-format precedes the vc-mode
> indicator in the current mode-line format. And otherwise keep the
> separating " ". If that makes sense to you.
Probably it should be sufficient to describe this in the docstring
like in this patch?
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".
diff --git a/lisp/vc/vc-hooks.el b/lisp/vc/vc-hooks.el
index c16fb63b2ff..6e4be6414d2 100644
--- a/lisp/vc/vc-hooks.el
+++ b/lisp/vc/vc-hooks.el
@@ -152,8 +152,15 @@ 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, it's not displayed.
+When the value is `with-project' then instead of the backend name
+a project name can be displayed before the revision number and lock
+status. This works only in case when you enable `project-mode-line'
+and don't change the default order of `project-mode-line' and
+`vc-mode' in `mode-line-format'."
+ :type '(choice (const :tag "Show project name and status" with-project)
+ (const :tag "Show backend and status" t)
+ (const :tag "Show only backend name" nil))
:group 'vc)
@@ -683,7 +690,9 @@ vc-mode-line
(ml-echo (get-text-property 0 'help-echo ml-string)))
(setq vc-mode
(concat
- " "
+ (unless (and (eq vc-display-status 'with-project)
+ (bound-and-true-p project-mode-line))
+ " ")
(propertize
ml-string
'mouse-face 'mode-line-highlight
diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index 707fc7cfc07..0313f6ec827 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -423,7 +423,10 @@ 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 (and (eq vc-display-status
'with-project)
+ (bound-and-true-p
project-mode-line))
+ backend-name)
+ indicator disp-rev)))
(propertize state-string 'face face 'help-echo
(concat state-echo " under the " backend-name
" version control system"
- bug#66464: Vc mode-line, Juri Linkov, 2023/11/09
- bug#66464: Vc mode-line, Dmitry Gutov, 2023/11/09
- bug#66464: Vc mode-line, Juri Linkov, 2023/11/10
- bug#66464: Vc mode-line, Dmitry Gutov, 2023/11/10
- bug#66464: Vc mode-line,
Juri Linkov <=
- bug#66464: Vc mode-line, Dmitry Gutov, 2023/11/11
- bug#66464: Vc mode-line, Juri Linkov, 2023/11/12
- bug#66464: Vc mode-line, Dmitry Gutov, 2023/11/12
- bug#66464: Vc mode-line, Juri Linkov, 2023/11/13