Skip to content

Instantly share code, notes, and snippets.

@yuutayamada
Created March 24, 2012 03:57
Show Gist options
  • Save yuutayamada/2178022 to your computer and use it in GitHub Desktop.
Save yuutayamada/2178022 to your computer and use it in GitHub Desktop.
Magit: search the commit message by anything
;;; search commit log by anything
(defvar anything-c-source-log-edit-comment
'((name . "Log-edit Comment")
(candidates . anything-c-log-edit-comment-candidates)
(action . (("Insert" . (lambda (str) (insert str)))))
(migemo)
(multiline))
"Source for browse and insert Log-edit comment.")
(defun anything-c-log-edit-comment-candidates ()
(let* ((candidates
(shell-command-to-string "\\git \\log -500 | \\grep -E '^ .+'"))
(logs (string-to-list (split-string candidates "\n "))))
(push (replace-regexp-in-string "^ " "" (pop logs)) logs)
logs))
(defun anything-show-log-edit-comment ()
"`anything' for Log-edit comment."
(interactive)
(anything-other-buffer 'anything-c-source-log-edit-comment
"*anything log-edit comment*"))
(define-key magit-log-edit-mode-map (kbd "C-s") 'anything-show-log-edit-comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment