From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Phil Hagelberg Newsgroups: gmane.emacs.devel Subject: Re: vc-register complains if a file is already registered in a git repository Date: Tue, 28 Oct 2008 11:19:04 -0700 Message-ID: <87ej207fc7.fsf@hagelb.org> References: <87prlvm2ms.fsf@hagelb.org> <873aipmvt6.fsf@hagelb.org> <87od147hzj.fsf@hagelb.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1225217969 6392 80.91.229.12 (28 Oct 2008 18:19:29 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 28 Oct 2008 18:19:29 +0000 (UTC) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Oct 28 19:20:30 2008 connect(): Connection refused 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 1KutB4-00070o-GD for ged-emacs-devel@m.gmane.org; Tue, 28 Oct 2008 19:20:26 +0100 Original-Received: from localhost ([127.0.0.1]:60206 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Kut9y-0008VD-2c for ged-emacs-devel@m.gmane.org; Tue, 28 Oct 2008 14:19:18 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Kut9p-0008N0-B4 for emacs-devel@gnu.org; Tue, 28 Oct 2008 14:19:09 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Kut9o-0008Lu-F2 for emacs-devel@gnu.org; Tue, 28 Oct 2008 14:19:08 -0400 Original-Received: from [199.232.76.173] (port=51263 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Kut9o-0008Lj-BK for emacs-devel@gnu.org; Tue, 28 Oct 2008 14:19:08 -0400 Original-Received: from sd-green-bigip-83.dreamhost.com ([208.97.132.83]:37535 helo=spunkymail-a1.g.dreamhost.com) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Kut9o-0007Ix-4z for emacs-devel@gnu.org; Tue, 28 Oct 2008 14:19:08 -0400 Original-Received: from dynabook (unknown [64.81.164.191]) by spunkymail-a1.g.dreamhost.com (Postfix) with ESMTP id 6A909FE1C7; Tue, 28 Oct 2008 11:19:05 -0700 (PDT) In-Reply-To: <87od147hzj.fsf@hagelb.org> (Phil Hagelberg's message of "Tue, 28 Oct 2008 10:21:52 -0700") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 1) 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:105091 Archived-At: Phil Hagelberg writes: > I've added the vc-git-register-changes command to vc-git-extra-menu-map > and will start work on creating extra-keys functionality that works like > extra-menu. OK, here's the cumulative patch for both features. I am not sure I completely understand the use of fset for vc-prefix-map. I tried converting it to a regular function definition, but that did not work; it made the prefix command essentially a no-op. So someone who's familiar with prefix keymaps should review this patch before it's applied. -Phil diff --git a/lisp/vc-git.el b/lisp/vc-git.el index 51ccc5d..d3ac624 100644 --- a/lisp/vc-git.el +++ b/lisp/vc-git.el @@ -622,6 +622,9 @@ or BRANCH^ (where \"^\" can be repeated)." (define-key map [git-grep] '(menu-item "Git grep..." vc-git-grep :help "Run the `git grep' command")) + (define-key map [git-register-changes] + '(menu-item "Register changes" vc-git-register-changes + :help "Register the changes in the current buffer")) map)) (defun vc-git-extra-menu () vc-git-extra-menu-map) @@ -681,6 +684,18 @@ This command shares argument histories with \\[rgrep] and \\[grep]." (compilation-start command 'grep-mode)) (if (eq next-error-last-buffer (current-buffer)) (setq default-directory dir)))))) + +(defun vc-git-register-changes () + "Register the changes in the current file to the staging area." + (interactive) + (vc-git-register buffer-file-name) + (message "Registered changes to %s... " buffer-file-name)) + +(defun vc-git-append-extra-keys (original-map) + (let ((extra-keys-map (copy-keymap original-map))) + (define-key extra-keys-map "e" 'vc-git-register-changes) + extra-keys-map)) + ;;; Internal commands diff --git a/lisp/vc-hooks.el b/lisp/vc-hooks.el index 97dca35..53e0e31 100644 --- a/lisp/vc-hooks.el +++ b/lisp/vc-hooks.el @@ -970,7 +970,15 @@ Used in `find-file-not-found-functions'." (define-key map "=" 'vc-diff) (define-key map "~" 'vc-revision-other-window) map)) -(fset 'vc-prefix-map vc-prefix-map) + +(fset 'vc-prefix-map + (when vc-mode + (vc-call-backend + (if buffer-file-name + (vc-backend buffer-file-name) + (vc-responsible-backend default-directory)) + 'append-extra-keys vc-prefix-map))) + (define-key global-map "\C-xv" 'vc-prefix-map) (defvar vc-menu-map