From 7a9e2182b044e96d1274ef295527b18602b4e7bc Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Tue, 30 Dec 2014 21:26:52 -0500 Subject: Add display-only version of git-rebase-show-commit Bind this version to SPC. This is more consistent with behavior in the log buffer, where RET shows the commit and switches to that buffer and SPC just displays the commit. However, the SPC variants still differ in their scrolling behavior. In the log buffer, SPC (magit-diff-show-or-scroll-up) will scroll if the buffer is already displayed, but km/git-rebase-show-commit doesn't support this. While it'd be nice to use magit-diff-show-or-scroll-up directly, this isn't easy to do because magit-diff-show-or-scroll-up doesn't take a revision argument (it pulls it directly from the magit section). --- lisp/init-git.el | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'lisp/init-git.el') diff --git a/lisp/init-git.el b/lisp/init-git.el index 5f1ab82..861d839 100644 --- a/lisp/init-git.el +++ b/lisp/init-git.el @@ -151,6 +151,20 @@ START-POINT set to the current branch. (after 'git-commit (add-hook 'git-commit-setup-hook 'git-commit-turn-on-flyspell)) +(defun km/git-rebase-show-commit () + "Show the commit on the current line if any. +Unlike `git-rebase-show-commit', display (but don't switch to) +the commit buffer. And no dinging." + (interactive) + (save-excursion + (goto-char (line-beginning-position)) + (--if-let (and (looking-at git-rebase-line) + (match-string 2)) + (magit-show-commit it t)))) + +(after 'git-rebase + (define-key git-rebase-mode-map "\s" 'km/git-rebase-show-commit)) + (after 'magit (magit-backup-mode -1) (add-hook 'magit-find-file-hook 'view-mode) -- cgit v1.2.3