From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thien-Thi Nguyen Newsgroups: gmane.emacs.devel Subject: Re: vc-*-root finctions Date: Wed, 20 Feb 2008 12:12:46 +0100 Message-ID: <87skzn3mq9.fsf@ambire.localdomain> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1203508533 23871 80.91.229.12 (20 Feb 2008 11:55:33 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 20 Feb 2008 11:55:33 +0000 (UTC) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Feb 20 12:55:58 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1JRnYK-00066r-9O for ged-emacs-devel@m.gmane.org; Wed, 20 Feb 2008 12:55:56 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JRnXp-0004Uo-CB for ged-emacs-devel@m.gmane.org; Wed, 20 Feb 2008 06:55:25 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JRnXk-0004UV-QU for emacs-devel@gnu.org; Wed, 20 Feb 2008 06:55:20 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JRnXj-0004UB-Ds for emacs-devel@gnu.org; Wed, 20 Feb 2008 06:55:20 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JRnXj-0004U8-7z for emacs-devel@gnu.org; Wed, 20 Feb 2008 06:55:19 -0500 Original-Received: from [151.61.141.122] (helo=ambire.localdomain) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1JRnXi-0001cR-MG for emacs-devel@gnu.org; Wed, 20 Feb 2008 06:55:19 -0500 Original-Received: from ttn by ambire.localdomain with local (Exim 4.63) (envelope-from ) id 1JRmsY-0002fA-7a; Wed, 20 Feb 2008 12:12:46 +0100 In-Reply-To: (Stefan Monnier's message of "Tue, 19 Feb 2008 17:06:09 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) X-detected-kernel: by monty-python.gnu.org: Genre and OS details not recognized. X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:89678 Archived-At: () Stefan Monnier () Tue, 19 Feb 2008 17:06:09 -0500 Could you explain what the vc-*-root are supposed to do? Would this blurb in vc.el Commentary explain things sufficiently? ;; - root (dir) ;; ;; Return DIR's "root" directory, that is, a parent directory of ;; DIR for which the same backend as used for DIR applies. If no ;; such parent exists, this function should return DIR. I am using vc-BACKEND-root for (work-in-progress, see below) `vc-status-mode' munging. thi _________________________________________________________________ (defun vc-status-mode () "Major mode for VC Status. Prepare the buffer to begin with the lines: Directory: DEFAULT-DIRECTORY Updated: YYYY-MM-DD HH:MM:SS If the `default-directory' is under the project's \"root\" directory, make its root component a button that can run command `vc-status' there. Keys do not self-insert; instead they do different things: \\{vc-status-mode-map}" (buffer-disable-undo) (erase-buffer) (let* ((backend (vc-responsible-backend default-directory)) (find-root (vc-find-backend-function backend 'root)) (root (if find-root (funcall find-root default-directory) default-directory))) (setq major-mode 'vc-status-mode) (setq mode-name (format "VC-%s Status" backend)) (insert "Directory: ") (if (or (not root) (string= root default-directory)) (insert root) (let* ((root-fn (directory-file-name root)) (parent (file-name-directory root-fn)) (leaf (file-name-nondirectory root-fn))) (insert parent) (if (featurep 'button) (insert-text-button leaf 'root root 'action (lambda (button) (vc-status (button-get button 'root))) 'follow-link t) (insert leaf)) (insert (substring default-directory (1- (length root)))))) (insert "\n") (set (make-local-variable 'vc-status) (ewoc-create #'vc-status-printer (format-time-string " Updated: %F %T\n"))) (use-local-map vc-status-mode-map) (setq buffer-read-only t)))