unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* VC registered, but ignored
@ 2023-08-31 15:24 Eli Zaretskii
  2023-08-31 16:23 ` Dr. Arne Babenhauserheide
  2023-09-01  1:03 ` Dmitry Gutov
  0 siblings, 2 replies; 7+ messages in thread
From: Eli Zaretskii @ 2023-08-31 15:24 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: emacs-devel

In a repository where *.txt files are ignored, I added to VC a file
with the .txt extension, and was surprised to see the ':' indicator on
the mode line although the file was up-to-date.  Moreover, the tooltip
said the file was "locally modified".  That had me puzzled for a few
minutes, until I saw the code in vc-hooks.el.

So WDYT about the change below?

diff --git a/lisp/vc/vc-hooks.el b/lisp/vc/vc-hooks.el
index e75165e..a4de0a6 100644
--- a/lisp/vc/vc-hooks.el
+++ b/lisp/vc/vc-hooks.el
@@ -87,6 +87,11 @@ vc-edited-state
   "Face for VC modeline state when the file is edited."
   :version "25.1")
 
+(defface vc-ignored-state
+  '((default :inherit vc-state-base))
+  "Face for VC modeline state when the file is registered, but ignored."
+  :version "30.1")
+
 ;; Customization Variables (the rest is in vc.el)
 
 (defcustom vc-ignore-dir-regexp
@@ -743,6 +748,10 @@ vc-default-mode-line-string
             (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



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: VC registered, but ignored
  2023-08-31 15:24 VC registered, but ignored Eli Zaretskii
@ 2023-08-31 16:23 ` Dr. Arne Babenhauserheide
  2023-08-31 16:49   ` Eli Zaretskii
  2023-09-01  1:03 ` Dmitry Gutov
  1 sibling, 1 reply; 7+ messages in thread
From: Dr. Arne Babenhauserheide @ 2023-08-31 16:23 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Dmitry Gutov, emacs-devel

[-- Attachment #1: Type: text/plain, Size: 905 bytes --]


Eli Zaretskii <eliz@gnu.org> writes:

> So WDYT about the change below?

This looks good, but I’m not sure about the !:

> +           ((eq state 'ignored)
> +            (setq state-echo "File tracked by the VC system, but ignored")
> +            (setq face 'vc-ignored-state)
> +            (concat backend-name "!" rev))

I know ! as meaning "missing file". How about "i"? (small ignored)

! is already used:

           ((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))

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 1125 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: VC registered, but ignored
  2023-08-31 16:23 ` Dr. Arne Babenhauserheide
@ 2023-08-31 16:49   ` Eli Zaretskii
  0 siblings, 0 replies; 7+ messages in thread
From: Eli Zaretskii @ 2023-08-31 16:49 UTC (permalink / raw)
  To: Dr. Arne Babenhauserheide; +Cc: dmitry, emacs-devel

> From: "Dr. Arne Babenhauserheide" <arne_bab@web.de>
> Cc: Dmitry Gutov <dmitry@gutov.dev>, emacs-devel@gnu.org
> Date: Thu, 31 Aug 2023 18:23:51 +0200
> 
> This looks good, but I’m not sure about the !:
> 
> > +           ((eq state 'ignored)
> > +            (setq state-echo "File tracked by the VC system, but ignored")
> > +            (setq face 'vc-ignored-state)
> > +            (concat backend-name "!" rev))
> 
> I know ! as meaning "missing file". How about "i"? (small ignored)
> 
> ! is already used:
> 
>            ((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))

My interpretation of the two cases which use "!" is that these states
are unusual and want to attract attention.  But then so is the
"registered, but ignored" situation: normally, ignored files are not
registered, and so will never have the vc-mode part on the mode line.
Which is why I used "!" for it as well.

I'm okay with any other character, but I think it has to be a
punctuation character, otherwise it might be interpreted as part of
the backend's name.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: VC registered, but ignored
  2023-08-31 15:24 VC registered, but ignored Eli Zaretskii
  2023-08-31 16:23 ` Dr. Arne Babenhauserheide
@ 2023-09-01  1:03 ` Dmitry Gutov
  2023-09-01  6:29   ` Eli Zaretskii
  1 sibling, 1 reply; 7+ messages in thread
From: Dmitry Gutov @ 2023-09-01  1:03 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

On 31/08/2023 18:24, Eli Zaretskii wrote:
> In a repository where *.txt files are ignored, I added to VC a file
> with the .txt extension, and was surprised to see the ':' indicator on
> the mode line although the file was up-to-date.  Moreover, the tooltip
> said the file was "locally modified".  That had me puzzled for a few
> minutes, until I saw the code in vc-hooks.el.

You added it with 'C-x v v'?

We have a problem of sorts, or a break in the abstration, where 
(vc-state buffer-file-name) would return nil instead of 'ignored.

So the problem is your annotation won't show up if you just open an 
ignored file (for Git backend, at least). Is that okay for your purposes?

As for which character to use, maybe a period? Although that depends on 
what you want to bring attention to: usually people are happy to keep 
ignored files ignored.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: VC registered, but ignored
  2023-09-01  1:03 ` Dmitry Gutov
@ 2023-09-01  6:29   ` Eli Zaretskii
  2023-09-01  9:16     ` Dmitry Gutov
  0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2023-09-01  6:29 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: emacs-devel

> Date: Fri, 1 Sep 2023 04:03:43 +0300
> Cc: emacs-devel@gnu.org
> From: Dmitry Gutov <dmitry@gutov.dev>
> 
> On 31/08/2023 18:24, Eli Zaretskii wrote:
> > In a repository where *.txt files are ignored, I added to VC a file
> > with the .txt extension, and was surprised to see the ':' indicator on
> > the mode line although the file was up-to-date.  Moreover, the tooltip
> > said the file was "locally modified".  That had me puzzled for a few
> > minutes, until I saw the code in vc-hooks.el.
> 
> You added it with 'C-x v v'?

No, from the shell prompt.  Would the result have been different if I
did that with "C-x v v"?

> We have a problem of sorts, or a break in the abstration, where 
> (vc-state buffer-file-name) would return nil instead of 'ignored.

Only if the file is not registered, right?  Most/all ignored files are
not registered, they are generated files that we don't want to see in
VC status displays.  Here I describe a situation that shouldn't
happen, but did.

The value nil is the expected value for a file that is not registered.
In the case I described above, vc-state returns 'ignored, not nil.
And the result was that, instead of seeing no VC information on the
mode line, I saw a revision ID preceded by ':', as if the file was
locally modified.

> So the problem is your annotation won't show up if you just open an 
> ignored file (for Git backend, at least). Is that okay for your purposes?

No, see above.

> As for which character to use, maybe a period? Although that depends on 
> what you want to bring attention to: usually people are happy to keep 
> ignored files ignored.

Again, the file was NOT supposed to be ignored!  I deliberately added
it to the repository, I just forgot that it had an extension of
ignored files.  (The solution, once I relized the cause, was to exempt
that one file from the otherwise ignored *.txt files.)



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: VC registered, but ignored
  2023-09-01  6:29   ` Eli Zaretskii
@ 2023-09-01  9:16     ` Dmitry Gutov
  2023-09-01 11:33       ` Eli Zaretskii
  0 siblings, 1 reply; 7+ messages in thread
From: Dmitry Gutov @ 2023-09-01  9:16 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

On 01/09/2023 09:29, Eli Zaretskii wrote:
>> Date: Fri, 1 Sep 2023 04:03:43 +0300
>> Cc: emacs-devel@gnu.org
>> From: Dmitry Gutov <dmitry@gutov.dev>
>>
>> On 31/08/2023 18:24, Eli Zaretskii wrote:
>>> In a repository where *.txt files are ignored, I added to VC a file
>>> with the .txt extension, and was surprised to see the ':' indicator on
>>> the mode line although the file was up-to-date.  Moreover, the tooltip
>>> said the file was "locally modified".  That had me puzzled for a few
>>> minutes, until I saw the code in vc-hooks.el.
>>
>> You added it with 'C-x v v'?
> 
> No, from the shell prompt.  Would the result have been different if I
> did that with "C-x v v"?

Not 100% sure, but that's not important -- I have my answer.

>> We have a problem of sorts, or a break in the abstration, where
>> (vc-state buffer-file-name) would return nil instead of 'ignored.
> 
> Only if the file is not registered, right?  Most/all ignored files are
> not registered, they are generated files that we don't want to see in
> VC status displays.  Here I describe a situation that shouldn't
> happen, but did.

Apparently so.

> The value nil is the expected value for a file that is not registered.

It's more subtle that that, (vc-state buffer-file-name) would return nil 
in that case, but (vc-state buffer-file-name 'Git) would return 
'ignored. That hasn't affected any practical code so far (AFAIK), but 
something to keep in mind.

> In the case I described above, vc-state returns 'ignored, not nil.
> And the result was that, instead of seeing no VC information on the
> mode line, I saw a revision ID preceded by ':', as if the file was
> locally modified.

Ok.

>> So the problem is your annotation won't show up if you just open an
>> ignored file (for Git backend, at least). Is that okay for your purposes?
> 
> No, see above.

IIUC, you mean yes, the combined solution is okay for your purposes (if 
you open an unregistered ignored file, the annotation won't be there, 
and the whole mode-line item will be absent as well).

>> As for which character to use, maybe a period? Although that depends on
>> what you want to bring attention to: usually people are happy to keep
>> ignored files ignored.
> 
> Again, the file was NOT supposed to be ignored!  I deliberately added
> it to the repository, I just forgot that it had an extension of
> ignored files.  (The solution, once I relized the cause, was to exempt
> that one file from the otherwise ignored *.txt files.)

In that case, that indeed sounds like a situation that warrants 
additional attention, and "!" might be a good choice.

So I think we can push the patch, and just be on the lookout for cases 
where it misfires. Thank you.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: VC registered, but ignored
  2023-09-01  9:16     ` Dmitry Gutov
@ 2023-09-01 11:33       ` Eli Zaretskii
  0 siblings, 0 replies; 7+ messages in thread
From: Eli Zaretskii @ 2023-09-01 11:33 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: emacs-devel

> Date: Fri, 1 Sep 2023 12:16:42 +0300
> Cc: emacs-devel@gnu.org
> From: Dmitry Gutov <dmitry@gutov.dev>
> 
> So I think we can push the patch, and just be on the lookout for cases 
> where it misfires. Thank you.

Thanks, now installed on master.



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-09-01 11:33 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-31 15:24 VC registered, but ignored Eli Zaretskii
2023-08-31 16:23 ` Dr. Arne Babenhauserheide
2023-08-31 16:49   ` Eli Zaretskii
2023-09-01  1:03 ` Dmitry Gutov
2023-09-01  6:29   ` Eli Zaretskii
2023-09-01  9:16     ` Dmitry Gutov
2023-09-01 11:33       ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).