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

From: David Caldwell <[email-masked]>
Date: Thu, 27 Aug 2015 11:32:56 -0700

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

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