unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* HG, git and others actualize the modeline when commit form the command line
@ 2020-11-16 12:42 Uwe Brauer
  2020-11-16 13:18 ` Eli Zaretskii
  2020-11-16 13:54 ` Óscar Fuentes
  0 siblings, 2 replies; 12+ messages in thread
From: Uwe Brauer @ 2020-11-16 12:42 UTC (permalink / raw)
  To: emacs-devel


Hi

I tested this in mercurial.
If I commit a change via vc-next-action
the modeline gets actualized.

If I make the commit from the command line (using Ubuntu 16.04) the
change is not reflected in the modeline I have to close and reopen the
file.

I tried out 

(force-mode-line-update) 
via M-:
but it did  not change the modeline

Any idea what to do (besides using vc-next-command and friends).

Regards

Uwe Brauer 




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

* Re: HG, git and others actualize the modeline when commit form the command line
  2020-11-16 12:42 HG, git and others actualize the modeline when commit form the command line Uwe Brauer
@ 2020-11-16 13:18 ` Eli Zaretskii
  2020-11-16 16:02   ` Uwe Brauer
  2020-11-16 13:54 ` Óscar Fuentes
  1 sibling, 1 reply; 12+ messages in thread
From: Eli Zaretskii @ 2020-11-16 13:18 UTC (permalink / raw)
  To: emacs-devel, Uwe Brauer

On November 16, 2020 2:42:39 PM GMT+02:00, Uwe Brauer <oub@mat.ucm.es> wrote:
> 
> Hi
> 
> I tested this in mercurial.
> If I commit a change via vc-next-action
> the modeline gets actualized.
> 
> If I make the commit from the command line (using Ubuntu 16.04) the
> change is not reflected in the modeline I have to close and reopen the
> file.
> 
> I tried out 
> 
> (force-mode-line-update) 
> via M-:
> but it did  not change the modeline
> 
> Any idea what to do (besides using vc-next-command and friends).

M-x revert-buffer RET



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

* Re: HG, git and others actualize the modeline when commit form the command line
  2020-11-16 12:42 HG, git and others actualize the modeline when commit form the command line Uwe Brauer
  2020-11-16 13:18 ` Eli Zaretskii
@ 2020-11-16 13:54 ` Óscar Fuentes
  2020-11-16 16:04   ` Uwe Brauer
  1 sibling, 1 reply; 12+ messages in thread
From: Óscar Fuentes @ 2020-11-16 13:54 UTC (permalink / raw)
  To: emacs-devel

Uwe Brauer <oub@mat.ucm.es> writes:

> Hi
>
> I tested this in mercurial.
> If I commit a change via vc-next-action
> the modeline gets actualized.
>
> If I make the commit from the command line (using Ubuntu 16.04) the
> change is not reflected in the modeline I have to close and reopen the
> file.
>
> I tried out 
>
> (force-mode-line-update) 
> via M-:
> but it did  not change the modeline
>
> Any idea what to do (besides using vc-next-command and friends).

This is what I use for git, wrapped into a command:

              (vc-file-clearprops buffer-file-name)
              (vc-state-refresh buffer-file-name 'Git)
              (vc-mode-line buffer-file-name 'Git)

Of course, Eli's suggestion also works, although it does a lot more
than updating VC state display.




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

* Re: HG, git and others actualize the modeline when commit form the command line
  2020-11-16 13:18 ` Eli Zaretskii
@ 2020-11-16 16:02   ` Uwe Brauer
  2020-11-16 17:30     ` Eli Zaretskii
  0 siblings, 1 reply; 12+ messages in thread
From: Uwe Brauer @ 2020-11-16 16:02 UTC (permalink / raw)
  To: emacs-devel

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


> On November 16, 2020 2:42:39 PM GMT+02:00, Uwe Brauer <oub@mat.ucm.es> wrote:

> M-x revert-buffer RET


Thanks, this worked as expected.

I also tried out good old auto revert mode, which is quite old
(from 96 but shipped with GNU emacs) 
auto-revert-mode 

But it did not work concerning the modeline

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5673 bytes --]

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

* Re: HG, git and others actualize the modeline when commit form the command line
  2020-11-16 13:54 ` Óscar Fuentes
@ 2020-11-16 16:04   ` Uwe Brauer
  2020-11-16 16:36     ` Óscar Fuentes
  0 siblings, 1 reply; 12+ messages in thread
From: Uwe Brauer @ 2020-11-16 16:04 UTC (permalink / raw)
  To: emacs-devel

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


   > Uwe Brauer <oub@mat.ucm.es> writes:

   > This is what I use for git, wrapped into a command:

   >               (vc-file-clearprops buffer-file-name)
   >               (vc-state-refresh buffer-file-name 'Git)
   >               (vc-mode-line buffer-file-name 'Git)

   > Of course, Eli's suggestion also works, although it does a lot more
   > than updating VC state display.

Yeah the revert function is a bit slow. So you have something like this 

(defun my-refresh-vc-stuff ()
(interactive) 
(vc-file-clearprops buffer-file-name)
(vc-state-refresh buffer-file-name 'Git)
(vc-mode-line buffer-file-name 'Git))

And bind that to key or insert it into a hook?

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5673 bytes --]

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

* Re: HG, git and others actualize the modeline when commit form the command line
  2020-11-16 16:04   ` Uwe Brauer
@ 2020-11-16 16:36     ` Óscar Fuentes
  2020-11-17  7:21       ` Uwe Brauer
  0 siblings, 1 reply; 12+ messages in thread
From: Óscar Fuentes @ 2020-11-16 16:36 UTC (permalink / raw)
  To: emacs-devel

Uwe Brauer <oub@mat.ucm.es> writes:

>    > Uwe Brauer <oub@mat.ucm.es> writes:
>
>    > This is what I use for git, wrapped into a command:
>
>    >               (vc-file-clearprops buffer-file-name)
>    >               (vc-state-refresh buffer-file-name 'Git)
>    >               (vc-mode-line buffer-file-name 'Git)
>
>    > Of course, Eli's suggestion also works, although it does a lot more
>    > than updating VC state display.
>
> Yeah the revert function is a bit slow. So you have something like this 
>
> (defun my-refresh-vc-stuff ()
> (interactive) 
> (vc-file-clearprops buffer-file-name)
> (vc-state-refresh buffer-file-name 'Git)
> (vc-mode-line buffer-file-name 'Git))
>
> And bind that to key or insert it into a hook?

I use those functions on a magit fork of mine (for updating the modeline
after certain magit commands) but, for your use case, IMO a command like
your example above is what you need. You can even travel the buffer
list, so you don't need to execute the command for every buffer that
might be affected:

  (dolist (buffer (buffer-list))
    (when (string-prefix-p (expand-file-name default-directory)
                           (buffer-file-name buffer))
      (with-current-buffer buffer
        (with-demoted-errors "Error mientras revirtiendo (ignorado) %S"
          (if (and vc-mode (buffer-stale--default-function t)
                   (not (buffer-modified-p)))
              (revert-buffer t t)
            (vc-file-clearprops buffer-file-name)
            (vc-state-refresh buffer-file-name 'Git)
            (vc-mode-line buffer-file-name 'Git))))))

The code above travels the buffers and, for each buffer which is
visiting a file under the current directory or its childs, either
reverts the buffer (if it is not modified and its contents might have
changed) or just updates the modeline.

As you also use Hg, you need to adapt the code for using the correct
backeng on each case: (vc-backend buffer-file-name) looks like the
correct thing, but I didn't test it.




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

* Re: HG, git and others actualize the modeline when commit form the command line
  2020-11-16 16:02   ` Uwe Brauer
@ 2020-11-16 17:30     ` Eli Zaretskii
  2020-11-16 18:38       ` Uwe Brauer
  2020-11-16 18:43       ` Dmitry Gutov
  0 siblings, 2 replies; 12+ messages in thread
From: Eli Zaretskii @ 2020-11-16 17:30 UTC (permalink / raw)
  To: Uwe Brauer; +Cc: emacs-devel

> From: Uwe Brauer <oub@mat.ucm.es>
> Date: Mon, 16 Nov 2020 17:02:03 +0100
> 
> > M-x revert-buffer RET
> 
> Thanks, this worked as expected.
> 
> I also tried out good old auto revert mode

You are well advised not to use auto-revert-mode in VCS repositories.



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

* Re: HG, git and others actualize the modeline when commit form the command line
  2020-11-16 17:30     ` Eli Zaretskii
@ 2020-11-16 18:38       ` Uwe Brauer
  2020-11-16 18:43       ` Dmitry Gutov
  1 sibling, 0 replies; 12+ messages in thread
From: Uwe Brauer @ 2020-11-16 18:38 UTC (permalink / raw)
  To: emacs-devel

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

>>> "EZ" == Eli Zaretskii <eliz@gnu.org> writes:

>> From: Uwe Brauer <oub@mat.ucm.es>
>> Date: Mon, 16 Nov 2020 17:02:03 +0100
>> 
>> > M-x revert-buffer RET
>> 
>> Thanks, this worked as expected.
>> 
>> I also tried out good old auto revert mode

> You are well advised not to use auto-revert-mode in VCS repositories.

I rarely use it at all, but out of curiosity, why do you recommend not
to use it?


[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5673 bytes --]

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

* Re: HG, git and others actualize the modeline when commit form the command line
  2020-11-16 17:30     ` Eli Zaretskii
  2020-11-16 18:38       ` Uwe Brauer
@ 2020-11-16 18:43       ` Dmitry Gutov
  2020-11-16 19:26         ` Eli Zaretskii
  1 sibling, 1 reply; 12+ messages in thread
From: Dmitry Gutov @ 2020-11-16 18:43 UTC (permalink / raw)
  To: Eli Zaretskii, Uwe Brauer; +Cc: emacs-devel

On 16.11.2020 19:30, Eli Zaretskii wrote:
>> From: Uwe Brauer <oub@mat.ucm.es>
>> Date: Mon, 16 Nov 2020 17:02:03 +0100
>>
>>> M-x revert-buffer RET
>>
>> Thanks, this worked as expected.
>>
>> I also tried out good old auto revert mode
> 
> You are well advised not to use auto-revert-mode in VCS repositories.

Why not? I've been using them together for years.

Do you mean it has a problem with project of certain (big) sizes?

BTW, we also have variable auto-revert-check-vc-info, which would help 
in this scenario. That one *will* have a negative effect on performance, 
however, so I'm not as sure to recommend it.



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

* Re: HG, git and others actualize the modeline when commit form the command line
  2020-11-16 18:43       ` Dmitry Gutov
@ 2020-11-16 19:26         ` Eli Zaretskii
  2020-11-16 20:00           ` Dmitry Gutov
  0 siblings, 1 reply; 12+ messages in thread
From: Eli Zaretskii @ 2020-11-16 19:26 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: oub, emacs-devel

> Cc: emacs-devel@gnu.org
> From: Dmitry Gutov <dgutov@yandex.ru>
> Date: Mon, 16 Nov 2020 20:43:54 +0200
> 
> > You are well advised not to use auto-revert-mode in VCS repositories.
> 
> Why not?

Because a VCS repository triggers the poorly-scalable behavior of file
notifications.  We watch directories, and in a repository some
directories see a lot of file activity unrelated to the files you
actually visit.



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

* Re: HG, git and others actualize the modeline when commit form the command line
  2020-11-16 19:26         ` Eli Zaretskii
@ 2020-11-16 20:00           ` Dmitry Gutov
  0 siblings, 0 replies; 12+ messages in thread
From: Dmitry Gutov @ 2020-11-16 20:00 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: oub, emacs-devel

On 16.11.2020 21:26, Eli Zaretskii wrote:
>> Cc: emacs-devel@gnu.org
>> From: Dmitry Gutov <dgutov@yandex.ru>
>> Date: Mon, 16 Nov 2020 20:43:54 +0200
>>
>>> You are well advised not to use auto-revert-mode in VCS repositories.
>>
>> Why not?
> 
> Because a VCS repository triggers the poorly-scalable behavior of file
> notifications.  We watch directories, and in a repository some
> directories see a lot of file activity unrelated to the files you
> actually visit.

I can see how that can happen (even though it never caused a big enough 
problem for me personally), but AFAIK all modern editors provide some 
sort of counterpart to auto-revert-mode (updating the contents of files 
when they are edited externally). And of course that also works in VCS 
repositories, which is the normal case these days.

So if it's problematic in Emacs, I think it should be on the priority 
list of bugs to fix.

Worst case, we can switch over from filenotify to simple polling in 
those cases.



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

* Re: HG, git and others actualize the modeline when commit form the command line
  2020-11-16 16:36     ` Óscar Fuentes
@ 2020-11-17  7:21       ` Uwe Brauer
  0 siblings, 0 replies; 12+ messages in thread
From: Uwe Brauer @ 2020-11-17  7:21 UTC (permalink / raw)
  To: emacs-devel

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


> Uwe Brauer <oub@mat.ucm.es> writes:

> I use those functions on a magit fork of mine (for updating the modeline
> after certain magit commands) but, for your use case, IMO a command like
> your example above is what you need. You can even travel the buffer
> list, so you don't need to execute the command for every buffer that
> might be affected:

>   (dolist (buffer (buffer-list))
>     (when (string-prefix-p (expand-file-name default-directory)
>                            (buffer-file-name buffer))
>       (with-current-buffer buffer
>         (with-demoted-errors "Error mientras revirtiendo (ignorado) %S"
>           (if (and vc-mode (buffer-stale--default-function t)
>                    (not (buffer-modified-p)))
>               (revert-buffer t t)
>             (vc-file-clearprops buffer-file-name)
>             (vc-state-refresh buffer-file-name 'Git)
>             (vc-mode-line buffer-file-name 'Git))))))

> The code above travels the buffers and, for each buffer which is
> visiting a file under the current directory or its childs, either
> reverts the buffer (if it is not modified and its contents might have
> changed) or just updates the modeline.

Thanks


> As you also use Hg, you need to adapt the code for using the correct
> backeng on each case: (vc-backend buffer-file-name) looks like the
> correct thing, but I didn't test it.

Well replacing  Git by Hg does the thing!



[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5673 bytes --]

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

end of thread, other threads:[~2020-11-17  7:21 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-16 12:42 HG, git and others actualize the modeline when commit form the command line Uwe Brauer
2020-11-16 13:18 ` Eli Zaretskii
2020-11-16 16:02   ` Uwe Brauer
2020-11-16 17:30     ` Eli Zaretskii
2020-11-16 18:38       ` Uwe Brauer
2020-11-16 18:43       ` Dmitry Gutov
2020-11-16 19:26         ` Eli Zaretskii
2020-11-16 20:00           ` Dmitry Gutov
2020-11-16 13:54 ` Óscar Fuentes
2020-11-16 16:04   ` Uwe Brauer
2020-11-16 16:36     ` Óscar Fuentes
2020-11-17  7:21       ` Uwe Brauer

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