GNU bug report logs -
#66464
Vc mode-line
Previous Next
Reported by: Juri Linkov <juri <at> linkov.net>
Date: Wed, 11 Oct 2023 16:36:02 UTC
Severity: normal
Fixed in version 30.0.50
Done: Juri Linkov <juri <at> linkov.net>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 66464 in the body.
You can then email your comments to 66464 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#66464
; Package
emacs
.
(Wed, 11 Oct 2023 16:36:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Juri Linkov <juri <at> linkov.net>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Wed, 11 Oct 2023 16:36:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
In order to prepare for making the vc mode-line more customizable,
here is refactoring that helps to avoid code duplication in
vc-hg-mode-line-string, and at the same time makes
vc-git-mode-line-string less hackish while keeping it short.
[vc-mode-line-string.patch (text/x-diff, inline)]
diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index 5c21a5b884e..80c79db93ca 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -416,15 +416,22 @@ vc-git--symbolic-ref
(defun vc-git-mode-line-string (file)
"Return a string for `vc-mode-line' to put in the mode line for FILE."
- (let* ((rev (vc-working-revision file 'Git))
+ (let* ((backend-name "Git")
+ (state (vc-state file))
+ (status (vc-mode-line-status state))
+ (state-echo (nth 0 status))
+ (face (nth 1 status))
+ (indicator (nth 2 status))
+ (rev (vc-working-revision file 'Git))
(disp-rev (or (vc-git--symbolic-ref file)
(and rev (substring rev 0 7))))
- (def-ml (vc-default-mode-line-string 'Git file))
- (help-echo (get-text-property 0 'help-echo def-ml))
- (face (get-text-property 0 'face def-ml)))
- (propertize (concat (substring def-ml 0 4) disp-rev)
- 'face face
- 'help-echo (concat help-echo "\nCurrent revision: " rev))))
+ (state-string (concat backend-name indicator disp-rev)))
+ (propertize
+ state-string
+ 'face face
+ 'help-echo (concat state-echo " under the " backend-name
+ " version control system"
+ "\nCurrent revision: " rev))))
(cl-defstruct (vc-git-extra-fileinfo
(:copier nil)
diff --git a/lisp/vc/vc-hg.el b/lisp/vc/vc-hg.el
index c3e563a1f10..a749a4b02f7 100644
--- a/lisp/vc/vc-hg.el
+++ b/lisp/vc/vc-hg.el
@@ -354,8 +354,10 @@ vc-hg-mode-line-string
(let* ((backend-name "Hg")
(truename (file-truename file))
(state (vc-state truename))
- (state-echo nil)
- (face nil)
+ (status (vc-mode-line-status state))
+ (state-echo (nth 0 status))
+ (face (nth 1 status))
+ (indicator (nth 2 status))
(rev (and state
(let ((default-directory
(expand-file-name (vc-hg-root truename))))
@@ -363,33 +365,10 @@ vc-hg-mode-line-string
"."
(and vc-hg-use-file-version-for-mode-line-version
truename)))))
- (rev (or rev "???")))
+ (rev (or rev "???"))
+ (state-string (concat backend-name indicator rev)))
(propertize
- (cond ((or (eq state 'up-to-date)
- (eq state 'needs-update))
- (setq state-echo "Up to date file")
- (setq face 'vc-up-to-date-state)
- (concat backend-name "-" rev))
- ((eq state 'added)
- (setq state-echo "Locally added file")
- (setq face 'vc-locally-added-state)
- (concat backend-name "@" rev))
- ((eq state 'conflict)
- (setq state-echo "File contains conflicts after the last merge")
- (setq face 'vc-conflict-state)
- (concat backend-name "!" rev))
- ((eq state 'removed)
- (setq state-echo "File removed from the VC system")
- (setq face 'vc-removed-state)
- (concat backend-name "!" rev))
- ((eq state 'missing)
- (setq state-echo "File tracked by the VC system, but missing from the file system")
- (setq face 'vc-missing-state)
- (concat backend-name "?" rev))
- (t
- (setq state-echo "Locally modified file")
- (setq face 'vc-edited-state)
- (concat backend-name ":" rev)))
+ state-string
'face face
'help-echo (concat state-echo " under the " backend-name
" version control system"))))
diff --git a/lisp/vc/vc-hooks.el b/lisp/vc/vc-hooks.el
index a4de0a6e791..94c3682b4aa 100644
--- a/lisp/vc/vc-hooks.el
+++ b/lisp/vc/vc-hooks.el
@@ -705,6 +733,46 @@ vc-mode-line
(force-mode-line-update)
backend)
+(defun vc-mode-line-status (state)
+ (let (state-echo face indicator)
+ (cond ((or (eq state 'up-to-date)
+ (eq state 'needs-update))
+ (setq state-echo "Up to date file")
+ (setq face 'vc-up-to-date-state)
+ (setq indicator "-"))
+ ((stringp state)
+ (setq state-echo (concat "File locked by" state))
+ (setq face 'vc-locked-state)
+ (setq indicator (concat ":" state ":")))
+ ((eq state 'added)
+ (setq state-echo "Locally added file")
+ (setq face 'vc-locally-added-state)
+ (setq indicator "@"))
+ ((eq state 'conflict)
+ (setq state-echo "File contains conflicts after the last merge")
+ (setq face 'vc-conflict-state)
+ (setq indicator "!"))
+ ((eq state 'removed)
+ (setq state-echo "File removed from the VC system")
+ (setq face 'vc-removed-state)
+ (setq indicator "!"))
+ ((eq state 'missing)
+ (setq state-echo "File tracked by the VC system, but missing from the file system")
+ (setq face 'vc-missing-state)
+ (setq indicator "?"))
+ ((eq state 'ignored)
+ (setq state-echo "File tracked by the VC system, but ignored")
+ (setq face 'vc-ignored-state)
+ (setq indicator "!"))
+ (t
+ ;; Not just for the 'edited state, but also a fallback
+ ;; for all other states. Think about different symbols
+ ;; for 'needs-update and 'needs-merge.
+ (setq state-echo "Locally modified file")
+ (setq face 'vc-edited-state)
+ (setq indicator ":")))
+ (list state-echo face indicator)))
+
(defun vc-default-mode-line-string (backend file)
"Return a string for `vc-mode-line' to put in the mode line for FILE.
Format:
@@ -718,47 +786,15 @@ vc-default-mode-line-string
This function assumes that the file is registered."
(let* ((backend-name (symbol-name backend))
- (state (vc-state file backend))
- (state-echo nil)
- (face nil)
- (rev (vc-working-revision file backend)))
+ (state (vc-state file backend))
+ (rev (vc-working-revision file backend))
+ (status (vc-mode-line-status state))
+ (state-echo (nth 0 status))
+ (face (nth 1 status))
+ (indicator (nth 2 status))
+ (state-string (concat backend-name indicator rev)))
(propertize
- (cond ((or (eq state 'up-to-date)
- (eq state 'needs-update))
- (setq state-echo "Up to date file")
- (setq face 'vc-up-to-date-state)
- (concat backend-name "-" rev))
- ((stringp state)
- (setq state-echo (concat "File locked by" state))
- (setq face 'vc-locked-state)
- (concat backend-name ":" state ":" rev))
- ((eq state 'added)
- (setq state-echo "Locally added file")
- (setq face 'vc-locally-added-state)
- (concat backend-name "@" rev))
- ((eq state 'conflict)
- (setq state-echo "File contains conflicts after the last merge")
- (setq face 'vc-conflict-state)
- (concat backend-name "!" rev))
- ((eq state 'removed)
- (setq state-echo "File removed from the VC system")
- (setq face 'vc-removed-state)
- (concat backend-name "!" rev))
- ((eq state 'missing)
- (setq state-echo "File tracked by the VC system, but missing from the file system")
- (setq face 'vc-missing-state)
- (concat backend-name "?" rev))
- ((eq state 'ignored)
- (setq state-echo "File tracked by the VC system, but ignored")
- (setq face 'vc-ignored-state)
- (concat backend-name "!" rev))
- (t
- ;; Not just for the 'edited state, but also a fallback
- ;; for all other states. Think about different symbols
- ;; for 'needs-update and 'needs-merge.
- (setq state-echo "Locally modified file")
- (setq face 'vc-edited-state)
- (concat backend-name ":" rev)))
+ state-string
'face face
'help-echo (concat state-echo " under the " backend-name
" version control system"))))
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#66464
; Package
emacs
.
(Mon, 16 Oct 2023 01:12:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 66464 <at> debbugs.gnu.org (full text, mbox):
On 11/10/2023 19:29, Juri Linkov wrote:
> In order to prepare for making the vc mode-line more customizable,
> here is refactoring that helps to avoid code duplication in
> vc-hg-mode-line-string, and at the same time makes
> vc-git-mode-line-string less hackish while keeping it short.
LGTM, thanks!
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#66464
; Package
emacs
.
(Mon, 16 Oct 2023 17:18:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 66464 <at> debbugs.gnu.org (full text, mbox):
>> In order to prepare for making the vc mode-line more customizable,
>> here is refactoring that helps to avoid code duplication in
>> vc-hg-mode-line-string, and at the same time makes
>> vc-git-mode-line-string less hackish while keeping it short.
>
> LGTM, thanks!
Ok, now pushed to master.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#66464
; Package
emacs
.
(Tue, 31 Oct 2023 07:42:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 66464 <at> debbugs.gnu.org (full text, mbox):
close 66464 30.0.50
stop
> In order to prepare for making the vc mode-line more customizable,
> here is refactoring that helps to avoid code duplication in
> vc-hg-mode-line-string, and at the same time makes
> vc-git-mode-line-string less hackish while keeping it short.
After more thinking I see no way to join project and vc
indicators on the mode line, so I'm closing this feature request.
bug marked as fixed in version 30.0.50, send any further explanations to
66464 <at> debbugs.gnu.org and Juri Linkov <juri <at> linkov.net>
Request was from
Juri Linkov <juri <at> linkov.net>
to
control <at> debbugs.gnu.org
.
(Tue, 31 Oct 2023 07:42:03 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#66464
; Package
emacs
.
(Thu, 09 Nov 2023 16:45:02 GMT)
Full text and
rfc822 format available.
Message #19 received at 66464 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
reopen 66464
thanks
>> In order to prepare for making the vc mode-line more customizable,
>> here is refactoring that helps to avoid code duplication in
>> vc-hg-mode-line-string, and at the same time makes
>> vc-git-mode-line-string less hackish while keeping it short.
>
> After more thinking I see no way to join project and vc
> indicators on the mode line, so I'm closing this feature request.
It would be a pity not to add this handy feature.
So here is a small patch that joins the project name and vc status
on the mode line:
[vc-display-status-with-project.patch (text/x-diff, inline)]
diff --git a/lisp/vc/vc-hooks.el b/lisp/vc/vc-hooks.el
index c16fb63b2ff..63d7036f299 100644
--- a/lisp/vc/vc-hooks.el
+++ b/lisp/vc/vc-hooks.el
@@ -153,7 +153,9 @@ 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
+ :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 +685,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 No longer marked as fixed in versions 30.0.50 and reopened.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Thu, 09 Nov 2023 16:45:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#66464
; Package
emacs
.
(Fri, 10 Nov 2023 02:06:01 GMT)
Full text and
rfc822 format available.
Message #24 received at 66464 <at> debbugs.gnu.org (full text, mbox):
On 09/11/2023 18:41, Juri Linkov wrote:
> It would be a pity not to add this handy feature.
> So here is a small patch that joins the project name and vc status
> on the mode line:
Could you described the intended look?
Two mode-line entries one right by another, without a space between?
And with the backend name removed? Wouldn't you say we're losing some
useful information this way? Or perhaps the backend name is not essential.
In any case, it seems like
(const :tag "Show project name and status" with-project)
describes the option inaccurately, since VC's mode line doesn't show the
project name. 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.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#66464
; Package
emacs
.
(Fri, 10 Nov 2023 07:52:02 GMT)
Full text and
rfc822 format available.
Message #27 received at 66464 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
>> It would be a pity not to add this handy feature.
>> So here is a small patch that joins the project name and vc status
>> on the mode line:
>
> Could you described the intended look?
Here is the screenshot how the mode line looks like:
[project_branch.png (image/png, inline)]
[Message part 3 (text/plain, inline)]
> Two mode-line entries one right by another, without a space between?
The format is "project-branch" instead of "backend-branch".
> And with the backend name removed? Wouldn't you say we're losing some
> useful information this way? Or perhaps the backend name is not essential.
I'm sure that showing the backend name in all file buffers is useless
for most users and wastes the precious screen space.
But I don't propose to change the default.
> In any case, it seems like
>
> (const :tag "Show project name and status" with-project)
>
> describes the option inaccurately, since VC's mode line doesn't show the
> project name.
Technically it's not vc-mode that shows the project name indeed.
I already tried such things as calling '(project-mode-line-format)'
from 'vc-mode-line-string'. But it's an unnecessary complication.
> 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))
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#66464
; Package
emacs
.
(Fri, 10 Nov 2023 23:56:01 GMT)
Full text and
rfc822 format available.
Message #30 received at 66464 <at> debbugs.gnu.org (full text, mbox):
On 10/11/2023 09:33, Juri Linkov wrote:
>>> It would be a pity not to add this handy feature.
>>> So here is a small patch that joins the project name and vc status
>>> on the mode line:
>>
>> Could you described the intended look?
>
> Here is the screenshot how the mode line looks like:
Thanks.
>> Two mode-line entries one right by another, without a space between?
>
> 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.
>> And with the backend name removed? Wouldn't you say we're losing some
>> useful information this way? Or perhaps the backend name is not essential.
>
> 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...
> But I don't propose to change the default.
>
>> In any case, it seems like
>>
>> (const :tag "Show project name and status" with-project)
>>
>> describes the option inaccurately, since VC's mode line doesn't show the
>> project name.
>
> Technically it's not vc-mode that shows the project name indeed.
> I already tried such things as calling '(project-mode-line-format)'
> from 'vc-mode-line-string'. But it's an unnecessary complication.
That's probably an overkill indeed, also because the user would have to
customize project-mode-line to nil, and then some projects might not be
VC-controlled, which would result in no mode-line element at all.
>> 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.
It's probably not terrible not to support that (after all, that would be
a combination of two non-default customizations).
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)
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.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#66464
; Package
emacs
.
(Sat, 11 Nov 2023 19:07:02 GMT)
Full text and
rfc822 format available.
Message #33 received at 66464 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
>> 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".
[vc-display-status-with-project.patch (text/x-diff, inline)]
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"
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#66464
; Package
emacs
.
(Sat, 11 Nov 2023 22:07:02 GMT)
Full text and
rfc822 format available.
Message #36 received at 66464 <at> debbugs.gnu.org (full text, mbox):
On 11/11/2023 20:50, Juri Linkov wrote:
> 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.
I don't like the semantics of this sentence (it implies that VC's mode
line item will show the project name but it doesn't), but I'm not going
to argue more.
> Probably it should be sufficient to describe this in the docstring
> like in this patch?
It's good, thank you.
> 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.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#66464
; Package
emacs
.
(Sun, 12 Nov 2023 08:34:02 GMT)
Full text and
rfc822 format available.
Message #39 received at 66464 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
>> 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)))
[vc-display-status-no-backend.patch (text/x-diff, inline)]
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"))))
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#66464
; Package
emacs
.
(Sun, 12 Nov 2023 11:01:02 GMT)
Full text and
rfc822 format available.
Message #42 received at 66464 <at> debbugs.gnu.org (full text, mbox):
On 12/11/2023 10:07, Juri Linkov wrote:
> 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)))
That certainly works for me.
Thanks!
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#66464
; Package
emacs
.
(Mon, 13 Nov 2023 07:14:02 GMT)
Full text and
rfc822 format available.
Message #45 received at 66464 <at> debbugs.gnu.org (full text, mbox):
close 66464 30.0.50
thanks
>> 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)))
>
> That certainly works for me.
Thanks for helping to arrive at this good solution.
bug marked as fixed in version 30.0.50, send any further explanations to
66464 <at> debbugs.gnu.org and Juri Linkov <juri <at> linkov.net>
Request was from
Juri Linkov <juri <at> linkov.net>
to
control <at> debbugs.gnu.org
.
(Mon, 13 Nov 2023 07:14:02 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Mon, 11 Dec 2023 12:24:07 GMT)
Full text and
rfc822 format available.
This bug report was last modified 1 year and 151 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.