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: Mon, 31 Aug 2015 03:05:19 -0700	[thread overview]
Message-ID: <20150831100511.GA24215@porkrind.org> (raw)
In-Reply-To: <jwvpp24qlvk.fsf-monnier+emacsbugs@gnu.org>

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


  reply	other threads:[~2015-08-31 10:05 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
2015-08-31  1:39             ` Stefan Monnier
2015-08-31 10:05               ` David Caldwell [this message]
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=20150831100511.GA24215@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).