GNU bug report logs - #21364
[PATCH] Add vc-activate (interactive) to activate VC mode on the current buffer

Previous Next

Package: emacs;

Reported by: David Caldwell <david <at> porkrind.org>

Date: Thu, 27 Aug 2015 18:34:02 UTC

Severity: wishlist

Tags: patch

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

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 21364 in the body.
You can then email your comments to 21364 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#21364; Package emacs. (Thu, 27 Aug 2015 18:34:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to David Caldwell <david <at> porkrind.org>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 27 Aug 2015 18:34:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: David Caldwell <david <at> porkrind.org>
To: bug-gnu-emacs <at> gnu.org
Subject: [PATCH] Add vc-activate (interactive) to activate VC mode on the
 current buffer
Date: Thu, 27 Aug 2015 11:32:56 -0700
[Message part 1 (text/plain, inline)]
Hello,

Attached is a patch (in git am format) to add a new interactive function
`vc-activate`, which simply calls `vc-find-file-hook` to activate VC
mode on a buffer.

The motivation comes from the fact that I don't consistently use VC for
everything. I often pop back and forth to the command line, depending on
the situation. This ends up with a lot of "git add" commands being run
behind emacs's back. I've been using `M-x revert-buffer` or `C-x C-v`,
but both of them seem too harsh for what I really want, which is for VC
to just check again real quick. I could `M-: RET (vc-find-file-hook)`
but that doesn't roll off the tongue very well.

`vc-activate` is a nicely named interactive wrapper around
vc-find-file-hook so that I can just do `M-x vc-activate RET` and I'm in
business.

Thanks,
  David
[0001-Add-vc-activate-interactive-to-activate-VC-mode-on-t.patch (text/x-diff, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21364; Package emacs. (Fri, 28 Aug 2015 02:24:01 GMT) Full text and rfc822 format available.

Message #8 received at 21364 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: David Caldwell <david <at> porkrind.org>
Cc: 21364 <at> debbugs.gnu.org
Subject: Re: bug#21364: [PATCH] Add vc-activate (interactive) to activate VC
 mode on the current buffer
Date: Thu, 27 Aug 2015 22:23:07 -0400
> The motivation comes from the fact that I don't consistently use VC for
> everything. I often pop back and forth to the command line, depending on
> the situation. This ends up with a lot of "git add" commands being run
> behind emacs's back. I've been using `M-x revert-buffer` or `C-x C-v`,
> but both of them seem too harsh for what I really want, which is for VC
> to just check again real quick. I could `M-: RET (vc-find-file-hook)`
> but that doesn't roll off the tongue very well.

Rather than vc-activate, I think you want a more general function, which
*refreshes* the VC state (i.e. the state afterwards may be "inactive" if
the file is not under the control of a VCS, for example).


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21364; Package emacs. (Fri, 28 Aug 2015 02:45:02 GMT) Full text and rfc822 format available.

Message #11 received at 21364 <at> debbugs.gnu.org (full text, mbox):

From: David Caldwell <david <at> porkrind.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 21364 <at> debbugs.gnu.org
Subject: Re: bug#21364: [PATCH] Add vc-activate (interactive) to activate VC
 mode on the current buffer
Date: Thu, 27 Aug 2015 19:43:45 -0700
[Message part 1 (text/plain, inline)]
On 8/27/15 7:23 PM, Stefan Monnier wrote:
>> The motivation comes from the fact that I don't consistently use VC for
>> everything. I often pop back and forth to the command line, depending on
>> the situation. This ends up with a lot of "git add" commands being run
>> behind emacs's back. I've been using `M-x revert-buffer` or `C-x C-v`,
>> but both of them seem too harsh for what I really want, which is for VC
>> to just check again real quick. I could `M-: RET (vc-find-file-hook)`
>> but that doesn't roll off the tongue very well.
> 
> Rather than vc-activate, I think you want a more general function, which
> *refreshes* the VC state (i.e. the state afterwards may be "inactive" if
> the file is not under the control of a VCS, for example).

Turns out vc-find-file-hook already deactivates the  VC state--I tested
by doing

   $ git rm --cached test && commit -m 'test'

followed by `M-x vc-activate` and the VC successfully went away on my
open 'test' buffer.

So it sounds like maybe it's just a question of the name?

-David


[smime.p7s (application/pkcs7-signature, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21364; Package emacs. (Sat, 29 Aug 2015 15:27:01 GMT) Full text and rfc822 format available.

Message #14 received at 21364 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: David Caldwell <david <at> porkrind.org>
Cc: 21364 <at> debbugs.gnu.org
Subject: Re: bug#21364: [PATCH] Add vc-activate (interactive) to activate VC
 mode on the current buffer
Date: Sat, 29 Aug 2015 11:26:55 -0400
> So it sounds like maybe it's just a question of the name?

Looks like it, then, yes,


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21364; Package emacs. (Sat, 29 Aug 2015 17:40:02 GMT) Full text and rfc822 format available.

Message #17 received at 21364 <at> debbugs.gnu.org (full text, mbox):

From: David Caldwell <david <at> porkrind.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 21364 <at> debbugs.gnu.org
Subject: Re: bug#21364: [PATCH] Add vc-activate (interactive) to activate VC
 mode on the current buffer
Date: Sat, 29 Aug 2015 10:39:17 -0700
[Message part 1 (text/plain, inline)]
On 8/29/15 8:26 AM, Stefan Monnier wrote:
>> So it sounds like maybe it's just a question of the name?
> 
> Looks like it, then, yes,

I was hoping you'd have a suggestion :-). How about vc-buffer-refresh?
It's not quite analogous to vc-dir-refresh, but it makes sense in
itself.

Also, I was thinking maybe it would make more sense to rename
vc-find-file-hook to vc-buffer-refresh (making it interactive along the
way) and then doing:

(add-hook 'find-file-hook 'vc-buffer-refresh)

Thoughts?

-David


[smime.p7s (application/pkcs7-signature, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21364; Package emacs. (Sun, 30 Aug 2015 02:12:02 GMT) Full text and rfc822 format available.

Message #20 received at 21364 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: David Caldwell <david <at> porkrind.org>
Cc: 21364 <at> debbugs.gnu.org
Subject: Re: bug#21364: [PATCH] Add vc-activate (interactive) to activate VC
 mode on the current buffer
Date: Sat, 29 Aug 2015 22:11:48 -0400
> How about vc-buffer-refresh?

Hm... I think that makes it sound like it'll revert the buffer's content
or something.

How 'bout `vc-refresh-state'?

> Also, I was thinking maybe it would make more sense to rename
> vc-find-file-hook to vc-buffer-refresh (making it interactive along the
> way) and then doing:

> (add-hook 'find-file-hook 'vc-buffer-refresh)

If the two are really identical, then yes, it makes sense to just rename
the existing function and make it interactive.


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21364; Package emacs. (Sun, 30 Aug 2015 10:23:01 GMT) Full text and rfc822 format available.

Message #23 received at 21364 <at> debbugs.gnu.org (full text, mbox):

From: David Caldwell <david <at> porkrind.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 21364 <at> debbugs.gnu.org
Subject: Re: bug#21364: [PATCH] Add vc-activate (interactive) to activate VC
 mode on the current buffer
Date: Sun, 30 Aug 2015 03:22:07 -0700
[Message part 1 (text/plain, inline)]
> How 'bout `vc-refresh-state'?

That sounds good to me.

> > Also, I was thinking maybe it would make more sense to rename
> > vc-find-file-hook to vc-buffer-refresh (making it interactive along the
> > way) and then doing:
>
> > (add-hook 'find-file-hook 'vc-buffer-refresh)
>
> If the two are really identical, then yes, it makes sense to just rename
> the existing function and make it interactive.

Attached is a new patch that does just that (but calling the function
vc-refresh-state.

-David
[0001-Rename-vc-find-file-hook-to-vc-refresh-state.patch (text/x-diff, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21364; Package emacs. (Mon, 31 Aug 2015 01:40:03 GMT) Full text and rfc822 format available.

Message #26 received at 21364 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: David Caldwell <david <at> porkrind.org>
Cc: 21364 <at> debbugs.gnu.org
Subject: Re: bug#21364: [PATCH] Add vc-activate (interactive) to activate VC
 mode on the current buffer
Date: Sun, 30 Aug 2015 21:39:32 -0400
> Attached is a new patch that does just that (but calling the function
> vc-refresh-state.

Looks good, thanks.  See comments below.

> -(defun vc-find-file-hook ()
> -  "Function for `find-file-hook' activating VC mode if appropriate."
> +(defun vc-refresh-state ()
> +  "Activate or deactivate VC mode as appropriate."
> +  (interactive)

I think vc-find-file-hook is called from various other places, so please
add an obsolete alias for the old name.


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21364; Package emacs. (Mon, 31 Aug 2015 10:07:01 GMT) Full text and rfc822 format available.

Message #29 received at 21364 <at> debbugs.gnu.org (full text, mbox):

From: David Caldwell <david <at> porkrind.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 21364 <at> debbugs.gnu.org
Subject: Re: bug#21364: [PATCH] Add vc-activate (interactive) to activate VC
 mode on the current buffer
Date: Mon, 31 Aug 2015 03:05:19 -0700
[Message part 1 (text/plain, inline)]
> > -(defun vc-find-file-hook ()
> > -  "Function for `find-file-hook' activating VC mode if appropriate."
> > +(defun vc-refresh-state ()
> > +  "Activate or deactivate VC mode as appropriate."
> > +  (interactive)
>
> I think vc-find-file-hook is called from various other places, so please
> add an obsolete alias for the old name.

Ok. The attached patch is updated to do just that. The only thing I
noticed was that after aliasing, vc-find-file-hook shows up in M-x since
the new function is interactive. The old one didn't, but I'm not sure
it's worth the effort to change it. If you think it is, I'll give it a
shot.

-David
[0001-Rename-vc-find-file-hook-to-vc-refresh-state-and-obsolete.patch (text/x-diff, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21364; Package emacs. (Mon, 31 Aug 2015 17:46:01 GMT) Full text and rfc822 format available.

Message #32 received at 21364 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: David Caldwell <david <at> porkrind.org>
Cc: 21364 <at> debbugs.gnu.org
Subject: Re: bug#21364: [PATCH] Add vc-activate (interactive) to activate VC
 mode on the current buffer
Date: Mon, 31 Aug 2015 13:45:36 -0400
> Ok. The attached patch is updated to do just that. The only thing I
> noticed was that after aliasing, vc-find-file-hook shows up in M-x since
> the new function is interactive.

Good point.  So I guess we should define vc-find-file-hook as an
obsolete function which just calls the new function.


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21364; Package emacs. (Tue, 01 Sep 2015 14:58:02 GMT) Full text and rfc822 format available.

Message #35 received at 21364 <at> debbugs.gnu.org (full text, mbox):

From: David Caldwell <david <at> porkrind.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 21364 <at> debbugs.gnu.org
Subject: Re: bug#21364: [PATCH] Add vc-activate (interactive) to activate VC
 mode on the current buffer
Date: Tue, 1 Sep 2015 07:56:56 -0700
[Message part 1 (text/plain, inline)]
> > Ok. The attached patch is updated to do just that. The only thing I
> > noticed was that after aliasing, vc-find-file-hook shows up in M-x since
> > the new function is interactive.
>
> Good point.  So I guess we should define vc-find-file-hook as an
> obsolete function which just calls the new function.

Ok. Attached is an updated git am patch that does just that.

-David
[0001-Rename-vc-find-file-hook-to-vc-refresh-state-and-obsolete-wrapper.patch (text/x-diff, attachment)]

Reply sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
You have taken responsibility. (Wed, 02 Sep 2015 03:46:02 GMT) Full text and rfc822 format available.

Notification sent to David Caldwell <david <at> porkrind.org>:
bug acknowledged by developer. (Wed, 02 Sep 2015 03:46:03 GMT) Full text and rfc822 format available.

Message #40 received at 21364-done <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: David Caldwell <david <at> porkrind.org>
Cc: 21364-done <at> debbugs.gnu.org
Subject: Re: bug#21364: [PATCH] Add vc-activate (interactive) to activate VC
 mode on the current buffer
Date: Tue, 01 Sep 2015 23:45:16 -0400
>> > Ok. The attached patch is updated to do just that. The only thing I
>> > noticed was that after aliasing, vc-find-file-hook shows up in M-x since
>> > the new function is interactive.

Actually, now I remember that in Emacs-25, M-x's completion was changed
to skip obsolete commands, so I installed your patch with
define-obsolete-function-alias.
Thank you.

BTW, I could still accept this patch as a tiny change, but it's already
the second one, so you should consider signing the copyright paperwork
before the next occasion.


        Stefan




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 30 Sep 2015 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 9 years and 267 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.