Subject: Re: bug#21364: [PATCH] Add vc-activate (interactive) to activate VC mode on the current buffer

From: David Caldwell <[email-masked]>
Date: Sun, 30 Aug 2015 03:22:07 -0700

> 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
>From 2dcff538fdebc012aac03ab37105e5374a415641 Mon Sep 17 00:00:00 2001
From: David Caldwell <[email-masked]>
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