emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: vc-register complains if a file is already registered in a git repos


From: Phil Hagelberg
Subject: Re: vc-register complains if a file is already registered in a git repository
Date: Tue, 28 Oct 2008 11:19:04 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

Phil Hagelberg <address@hidden> 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]