From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.help Subject: Re: How to test if a directory is under version control ? Date: Wed, 05 Nov 2003 14:15:07 GMT Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: <87k76fypyo.fsf@noos.fr> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1068042008 13549 80.91.224.253 (5 Nov 2003 14:20:08 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 5 Nov 2003 14:20:08 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Nov 05 15:20:06 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1AHOVy-0000qv-00 for ; Wed, 05 Nov 2003 15:20:06 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1AHOU9-0001gw-Hw for geh-help-gnu-emacs@m.gmane.org; Wed, 05 Nov 2003 09:18:13 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!logbridge.uoregon.edu!snoopy.risq.qc.ca!charlie.risq.qc.ca!53ab2750!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 29 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 Original-NNTP-Posting-Host: 132.204.24.42 Original-X-Complaints-To: abuse@umontreal.ca Original-X-Trace: charlie.risq.qc.ca 1068041707 132.204.24.42 (Wed, 05 Nov 2003 09:15:07 EST) Original-NNTP-Posting-Date: Wed, 05 Nov 2003 09:15:07 EST Original-Xref: shelby.stanford.edu gnu.emacs.help:117882 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:13821 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:13821 > I am trying to write a simple function that would alert me when I edit > a file which is not under version-control, while the directory is. > To test if the file is under VC, I found vc-registered. For the > directory, if I do not find a more elegant way, I will end up looking > for a 'CVS' directory at the file's location, as I use CVS. But I > thought that there may be better solution ... VC has two related operations: `responsible-p' and `could-register'. They're used in the function `vc-responsible-backend'. But this function will not give you what you want because it'll always find a backend (in the worst case it'll just use RCS which does not need any `RCS' subdirectory and is thus always potentially ready to control a file). I guess your best bet is something like: (defun my-vc-responsible-backend (file) "Return the backend responsible for the unregistered FILE. Like `vc-responsible-backend' but only returns a responsible backend." (let ((bs vc-handled-backends)) (while (consp bs) (setq bs (if (vc-call-backend (car bs) 'responsible-p file) (car bs) (cdr bs)))) bs)) -- Stefan