Created
August 14, 2013 05:33
-
-
Save fukamachi/6228274 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun git-blame-current-line () | |
(interactive) | |
(let ((blame-result | |
(shell-command-to-string | |
(format "git blame -p -L %d,+1 %s" (line-number-at-pos) (buffer-file-name)))) | |
(result (make-hash-table :test 'equal))) | |
(loop with (commit . lines) = (split-string blame-result "\n") | |
for line in lines | |
for (key . values) = (split-string (or line "") " ") | |
do (setf (gethash key result) (mapconcat 'identity values " ")) | |
finally | |
(setf (gethash "commit" result) commit)) | |
(funcall (if (fboundp 'popup-tip) | |
'popup-tip | |
'message) | |
(format "[%s] %s: %s (%s)" | |
(substring (gethash "commit" result) 0 6) | |
(gethash "author" result) | |
(gethash "summary" result) | |
(format-time-string "%Y/%m/%d %H:%M" | |
(seconds-to-time | |
(string-to-number (gethash "author-time" result)))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment