From ccac9892002978c153f3ca9ba9357470e516459e Mon Sep 17 00:00:00 2001 From: "Vagn Johansen (S440)" Date: Sat, 30 May 2015 21:41:57 +0200 Subject: [PATCH] New file vj-magit.el: vj-git-diff and unicode * New function vj-git-diff for use with magit log. Press tab to quickly show the commit info. Repeated tab presses scrolls the other window. Use nice round unicode character for * replacement in magit log display (requires magit-log-format-graph-function to be set to magit-log-format-unicode-graph). --- vj-magit.el | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 vj-magit.el diff --git a/vj-magit.el b/vj-magit.el new file mode 100644 index 0000000..8901826 --- /dev/null +++ b/vj-magit.el @@ -0,0 +1,29 @@ + +(require 'magit) + +(setq magit-last-seen-setup-instructions "1.4.0") + +(when (equal magit-log-format-graph-function 'magit-log-format-unicode-graph) + (setcdr (assoc ?* magit-log-format-unicode-graph-alist) ?●)) + + +(define-key magit-log-mode-map (kbd "TAB") 'vj-git-diff) + +(defvar vj-git-diff-last-commit nil) + +(defun vj-git-diff () + (interactive) + (if (thing-at-point-looking-at "\\b[0-9a-z]\\{7\\}\\b") + (if (equal (match-string-no-properties 0) vj-git-diff-last-commit) + ;; same commit id + (scroll-other-window) + ;; show diff + (setq vj-git-diff-last-commit (match-string-no-properties 0)) + (shell-command + (format "git show %s" vj-git-diff-last-commit) + "*vj-git-diff*") + (with-current-buffer "*vj-git-diff*" + (diff-mode))) + (setq vj-git-diff-last-commit nil))) + +