Created
June 7, 2010 23:55
-
-
Save willert/429372 to your computer and use it in GitHub Desktop.
This file contains hidden or 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-commit-insert-header (type name email &optional note) | |
(let* ((signoff-at (git-commit-find-pseudo-header-position)) | |
(prev-line (save-excursion | |
(goto-char (- signoff-at 1)) | |
(thing-at-point 'line))) | |
(pre (if (or (string-match "^[^\s:]+:.+$" prev-line) | |
(string-match "\\`\s*$" prev-line)) | |
"" "\n")) | |
(has-content (stringp note)) | |
(insert (lambda () | |
(goto-char signoff-at) | |
(insert (format "%s%s: %s <%s>\n" pre type name email)) | |
(when note | |
(insert (format "[%s: %s]\n" email | |
(if has-content note ""))) | |
(if (not has-text) (backward-char 2))))) | |
(if (eq t note) | |
(funcall insert) | |
(save-excursion | |
(funcall insert))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment