From 9a56051499da642632005c3646aad5e6cdda926a Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Sun, 2 Aug 2015 21:35:50 -0400 Subject: Add magit-find-commit-file command --- lisp/init-git.el | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'lisp') diff --git a/lisp/init-git.el b/lisp/init-git.el index a3375b1..47aec9f 100644 --- a/lisp/init-git.el +++ b/lisp/init-git.el @@ -277,6 +277,19 @@ N defaults to 20." (magit-changed-files (format "HEAD~%s..HEAD" n)) nil t)))) +(defun km/magit-find-commit-file (commit) + "Find file changed in COMMIT." + (interactive (list (or (magit-branch-or-commit-at-point) + (and (derived-mode-p 'magit-revision-mode) + (car magit-refresh-args)) + (magit-read-branch-or-commit "Commit")))) + (let ((files (magit-changed-files (format "%s~..%s" commit commit)))) + (find-file + (cl-case (length files) + (0 (user-error "No changed files in %s" commit)) + (1 (car files)) + (t (magit-completing-read "File" files nil t)))))) + (defun km/magit-insert-staged-file (&optional no-directory) "Select staged file to insert. @@ -434,6 +447,10 @@ function." (define-key magit-refs-mode-map "j" 'km/avy-goto-subword-1) (define-key magit-cherry-mode-map "j" 'km/avy-goto-subword-1) + (define-prefix-command 'km/magit-map) + (define-key magit-mode-map "." 'km/magit-map) + (define-key km/magit-map "c" 'km/magit-find-commit-file) + (define-key km/git-map "." 'km/magit-show-commit-at-point) (define-key km/git-map "d" 'magit-dispatch-popup) (define-key km/git-map "e" 'km/magit-commit-extend-all) -- cgit v1.2.3