unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: David Caldwell <david@porkrind.org>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 21364@debbugs.gnu.org
Subject: bug#21364: [PATCH] Add vc-activate (interactive) to activate VC mode on the current buffer
Date: Sun, 30 Aug 2015 03:22:07 -0700	[thread overview]
Message-ID: <20150830102159.GA5832@porkrind.org> (raw)
In-Reply-To: <jwvtwrhsf2p.fsf-monnier+emacsbugs@gnu.org>

[-- 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


  reply	other threads:[~2015-08-30 10:22 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150830102159.GA5832@porkrind.org \
    --to=david@porkrind.org \
    --cc=21364@debbugs.gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).