* bug#21364: [PATCH] Add vc-activate (interactive) to activate VC mode on the current buffer
@ 2015-08-27 18:32 David Caldwell
2015-08-28 2:23 ` Stefan Monnier
0 siblings, 1 reply; 12+ messages in thread
From: David Caldwell @ 2015-08-27 18:32 UTC (permalink / raw)
To: 21364
[-- Attachment #1: Type: text/plain, Size: 805 bytes --]
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
[-- Attachment #2: 0001-Add-vc-activate-interactive-to-activate-VC-mode-on-t.patch --]
[-- Type: text/x-diff, Size: 1032 bytes --]
From 627c54175d9287143499ed42be91d3fcc42a74b1 Mon Sep 17 00:00:00 2001
From: David Caldwell <david@porkrind.org>
Date: Thu, 27 Aug 2015 11:04:51 -0700
Subject: [PATCH] Add vc-activate (interactive) to activate VC mode on the
current buffer
(which may have been added to revision control behind Emacs's back).
* lisp/vc/vc-hooks.el (vc-activate): New; interactive way to activate VC
mode on the current buffer.
---
lisp/vc/vc-hooks.el | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/lisp/vc/vc-hooks.el b/lisp/vc/vc-hooks.el
index bae9919..1c12b01 100644
--- a/lisp/vc/vc-hooks.el
+++ b/lisp/vc/vc-hooks.el
@@ -851,6 +851,11 @@ current, and kill the buffer that visits the link."
(add-hook 'find-file-hook 'vc-find-file-hook)
+(defun vc-activate ()
+ "Activate VC mode on current buffer if appropriate."
+ (interactive)
+ (vc-find-file-hook))
+
(defun vc-kill-buffer-hook ()
"Discard VC info about a file when we kill its buffer."
(when buffer-file-name (vc-file-clearprops buffer-file-name)))
--
2.5.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* bug#21364: [PATCH] Add vc-activate (interactive) to activate VC mode on the current buffer
2015-08-27 18:32 bug#21364: [PATCH] Add vc-activate (interactive) to activate VC mode on the current buffer David Caldwell
@ 2015-08-28 2:23 ` Stefan Monnier
2015-08-28 2:43 ` David Caldwell
0 siblings, 1 reply; 12+ messages in thread
From: Stefan Monnier @ 2015-08-28 2:23 UTC (permalink / raw)
To: David Caldwell; +Cc: 21364
> 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
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#21364: [PATCH] Add vc-activate (interactive) to activate VC mode on the current buffer
2015-08-28 2:23 ` Stefan Monnier
@ 2015-08-28 2:43 ` David Caldwell
2015-08-29 15:26 ` Stefan Monnier
0 siblings, 1 reply; 12+ messages in thread
From: David Caldwell @ 2015-08-28 2:43 UTC (permalink / raw)
To: Stefan Monnier; +Cc: 21364
[-- Attachment #1: Type: text/plain, Size: 1068 bytes --]
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
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4239 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#21364: [PATCH] Add vc-activate (interactive) to activate VC mode on the current buffer
2015-08-28 2:43 ` David Caldwell
@ 2015-08-29 15:26 ` Stefan Monnier
2015-08-29 17:39 ` David Caldwell
0 siblings, 1 reply; 12+ messages in thread
From: Stefan Monnier @ 2015-08-29 15:26 UTC (permalink / raw)
To: David Caldwell; +Cc: 21364
> So it sounds like maybe it's just a question of the name?
Looks like it, then, yes,
Stefan
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#21364: [PATCH] Add vc-activate (interactive) to activate VC mode on the current buffer
2015-08-29 15:26 ` Stefan Monnier
@ 2015-08-29 17:39 ` David Caldwell
2015-08-30 2:11 ` Stefan Monnier
0 siblings, 1 reply; 12+ messages in thread
From: David Caldwell @ 2015-08-29 17:39 UTC (permalink / raw)
To: Stefan Monnier; +Cc: 21364
[-- Attachment #1: Type: text/plain, Size: 524 bytes --]
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
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4239 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#21364: [PATCH] Add vc-activate (interactive) to activate VC mode on the current buffer
2015-08-29 17:39 ` David Caldwell
@ 2015-08-30 2:11 ` Stefan Monnier
2015-08-30 10:22 ` David Caldwell
0 siblings, 1 reply; 12+ messages in thread
From: Stefan Monnier @ 2015-08-30 2:11 UTC (permalink / raw)
To: David Caldwell; +Cc: 21364
> 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
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#21364: [PATCH] Add vc-activate (interactive) to activate VC mode on the current buffer
2015-08-30 2:11 ` Stefan Monnier
@ 2015-08-30 10:22 ` David Caldwell
2015-08-31 1:39 ` Stefan Monnier
0 siblings, 1 reply; 12+ messages in thread
From: David Caldwell @ 2015-08-30 10:22 UTC (permalink / raw)
To: Stefan Monnier; +Cc: 21364
[-- Attachment #1: Type: text/plain, Size: 500 bytes --]
> 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
[-- Attachment #2: 0001-Rename-vc-find-file-hook-to-vc-refresh-state.patch --]
[-- Type: text/x-diff, Size: 1884 bytes --]
From 2dcff538fdebc012aac03ab37105e5374a415641 Mon Sep 17 00:00:00 2001
From: David Caldwell <david@porkrind.org>
Date: Sun, 30 Aug 2015 02:59:56 -0700
Subject: [PATCH] Rename vc-find-file-hook to vc-refresh-state and make it
interactive.
This is so one can `M-x vc-refresh state' if the file is added to or removed
from version control behind Emacs's back.
* lisp/vc/vc-hooks.el (vc-refresh-state): Rename from vc-find-file-hook and
make interactive.
---
lisp/vc/vc-hooks.el | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/lisp/vc/vc-hooks.el b/lisp/vc/vc-hooks.el
index bae9919..f5e9eb4 100644
--- a/lisp/vc/vc-hooks.el
+++ b/lisp/vc/vc-hooks.el
@@ -790,8 +790,9 @@ current, and kill the buffer that visits the link."
(defun vc-default-find-file-hook (_backend)
nil)
-(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)
;; Recompute whether file is version controlled,
;; if user has killed the buffer and revisited.
(when vc-mode
@@ -838,18 +839,18 @@ current, and kill the buffer that visits the link."
(vc-follow-link)
(message "Followed link to %s" buffer-file-name)
- (vc-find-file-hook))
+ (vc-refresh-state))
(t
(if (yes-or-no-p (format
"Symbolic link to %s-controlled source file; follow link? " link-type))
(progn (vc-follow-link)
(message "Followed link to %s" buffer-file-name)
- (vc-find-file-hook))
+ (vc-refresh-state))
(message
"Warning: editing through the link bypasses version control")
)))))))))
-(add-hook 'find-file-hook 'vc-find-file-hook)
+(add-hook 'find-file-hook 'vc-refresh-state)
(defun vc-kill-buffer-hook ()
"Discard VC info about a file when we kill its buffer."
--
2.5.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* bug#21364: [PATCH] Add vc-activate (interactive) to activate VC mode on the current buffer
2015-08-30 10:22 ` David Caldwell
@ 2015-08-31 1:39 ` Stefan Monnier
2015-08-31 10:05 ` David Caldwell
0 siblings, 1 reply; 12+ messages in thread
From: Stefan Monnier @ 2015-08-31 1:39 UTC (permalink / raw)
To: David Caldwell; +Cc: 21364
> 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
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#21364: [PATCH] Add vc-activate (interactive) to activate VC mode on the current buffer
2015-08-31 1:39 ` Stefan Monnier
@ 2015-08-31 10:05 ` David Caldwell
2015-08-31 17:45 ` Stefan Monnier
0 siblings, 1 reply; 12+ messages in thread
From: David Caldwell @ 2015-08-31 10:05 UTC (permalink / raw)
To: Stefan Monnier; +Cc: 21364
[-- Attachment #1: Type: text/plain, Size: 632 bytes --]
> > -(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
[-- Attachment #2: 0001-Rename-vc-find-file-hook-to-vc-refresh-state-and-obsolete.patch --]
[-- Type: text/x-diff, Size: 1995 bytes --]
From 6cf0d2ad94666ffc14134541b6e7300f9d04ce67 Mon Sep 17 00:00:00 2001
From: David Caldwell <david@porkrind.org>
Date: Sun, 30 Aug 2015 02:59:56 -0700
Subject: [PATCH] Rename vc-find-file-hook to vc-refresh-state and make it
interactive.
This is so one can `M-x vc-refresh state' if the file is added to or removed
from version control behind Emacs's back.
* lisp/vc/vc-hooks.el (vc-refresh-state): Rename from vc-find-file-hook and
make interactive, retaining an obsolete alias.
---
lisp/vc/vc-hooks.el | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/lisp/vc/vc-hooks.el b/lisp/vc/vc-hooks.el
index bae9919..18cdbdd 100644
--- a/lisp/vc/vc-hooks.el
+++ b/lisp/vc/vc-hooks.el
@@ -790,8 +790,9 @@ current, and kill the buffer that visits the link."
(defun vc-default-find-file-hook (_backend)
nil)
-(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)
;; Recompute whether file is version controlled,
;; if user has killed the buffer and revisited.
(when vc-mode
@@ -838,18 +839,20 @@ current, and kill the buffer that visits the link."
(vc-follow-link)
(message "Followed link to %s" buffer-file-name)
- (vc-find-file-hook))
+ (vc-refresh-state))
(t
(if (yes-or-no-p (format
"Symbolic link to %s-controlled source file; follow link? " link-type))
(progn (vc-follow-link)
(message "Followed link to %s" buffer-file-name)
- (vc-find-file-hook))
+ (vc-refresh-state))
(message
"Warning: editing through the link bypasses version control")
)))))))))
-(add-hook 'find-file-hook 'vc-find-file-hook)
+(define-obsolete-function-alias 'vc-find-file-hook 'vc-refresh-state "25.1")
+
+(add-hook 'find-file-hook 'vc-refresh-state)
(defun vc-kill-buffer-hook ()
"Discard VC info about a file when we kill its buffer."
--
2.5.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* bug#21364: [PATCH] Add vc-activate (interactive) to activate VC mode on the current buffer
2015-08-31 10:05 ` David Caldwell
@ 2015-08-31 17:45 ` Stefan Monnier
2015-09-01 14:56 ` David Caldwell
0 siblings, 1 reply; 12+ messages in thread
From: Stefan Monnier @ 2015-08-31 17:45 UTC (permalink / raw)
To: David Caldwell; +Cc: 21364
> 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
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#21364: [PATCH] Add vc-activate (interactive) to activate VC mode on the current buffer
2015-08-31 17:45 ` Stefan Monnier
@ 2015-09-01 14:56 ` David Caldwell
2015-09-02 3:45 ` Stefan Monnier
0 siblings, 1 reply; 12+ messages in thread
From: David Caldwell @ 2015-09-01 14:56 UTC (permalink / raw)
To: Stefan Monnier; +Cc: 21364
[-- Attachment #1: Type: text/plain, Size: 380 bytes --]
> > 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
[-- Attachment #2: 0001-Rename-vc-find-file-hook-to-vc-refresh-state-and-obsolete-wrapper.patch --]
[-- Type: text/x-diff, Size: 2039 bytes --]
From c02a45346ed3dd83f24545e5cee0edc12f304c29 Mon Sep 17 00:00:00 2001
From: David Caldwell <david@porkrind.org>
Date: Sun, 30 Aug 2015 02:59:56 -0700
Subject: [PATCH] Rename vc-find-file-hook to vc-refresh-state and make it
interactive.
This is so one can `M-x vc-refresh state' if the file is added to or removed
from version control behind Emacs's back.
* lisp/vc/vc-hooks.el (vc-refresh-state): Rename from vc-find-file-hook and
make interactive, retaining an obsolete wrapper..
---
lisp/vc/vc-hooks.el | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/lisp/vc/vc-hooks.el b/lisp/vc/vc-hooks.el
index bae9919..edf20ae 100644
--- a/lisp/vc/vc-hooks.el
+++ b/lisp/vc/vc-hooks.el
@@ -790,8 +790,9 @@ current, and kill the buffer that visits the link."
(defun vc-default-find-file-hook (_backend)
nil)
-(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)
;; Recompute whether file is version controlled,
;; if user has killed the buffer and revisited.
(when vc-mode
@@ -838,18 +839,23 @@ current, and kill the buffer that visits the link."
(vc-follow-link)
(message "Followed link to %s" buffer-file-name)
- (vc-find-file-hook))
+ (vc-refresh-state))
(t
(if (yes-or-no-p (format
"Symbolic link to %s-controlled source file; follow link? " link-type))
(progn (vc-follow-link)
(message "Followed link to %s" buffer-file-name)
- (vc-find-file-hook))
+ (vc-refresh-state))
(message
"Warning: editing through the link bypasses version control")
)))))))))
-(add-hook 'find-file-hook 'vc-find-file-hook)
+(defun vc-find-file-hook ()
+ (vc-refresh-state))
+
+(make-obsolete 'vc-find-file-hook 'vc-refresh-state "25.1")
+
+(add-hook 'find-file-hook 'vc-refresh-state)
(defun vc-kill-buffer-hook ()
"Discard VC info about a file when we kill its buffer."
--
2.5.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* bug#21364: [PATCH] Add vc-activate (interactive) to activate VC mode on the current buffer
2015-09-01 14:56 ` David Caldwell
@ 2015-09-02 3:45 ` Stefan Monnier
0 siblings, 0 replies; 12+ messages in thread
From: Stefan Monnier @ 2015-09-02 3:45 UTC (permalink / raw)
To: David Caldwell; +Cc: 21364-done
>> > 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
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2015-09-02 3:45 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-27 18:32 bug#21364: [PATCH] Add vc-activate (interactive) to activate VC mode on the current buffer David Caldwell
2015-08-28 2:23 ` Stefan Monnier
2015-08-28 2:43 ` David Caldwell
2015-08-29 15:26 ` Stefan Monnier
2015-08-29 17:39 ` David Caldwell
2015-08-30 2:11 ` Stefan Monnier
2015-08-30 10:22 ` David Caldwell
2015-08-31 1:39 ` Stefan Monnier
2015-08-31 10:05 ` David Caldwell
2015-08-31 17:45 ` Stefan Monnier
2015-09-01 14:56 ` David Caldwell
2015-09-02 3:45 ` Stefan Monnier
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.