Skip to content

Instantly share code, notes, and snippets.

@willert
Created June 7, 2010 23:35
Show Gist options
  • Save willert/429350 to your computer and use it in GitHub Desktop.
Save willert/429350 to your computer and use it in GitHub Desktop.
(defun git-commit-insert-header (type name email &optional note)
(let* ((signoff-at (git-commit-find-pseudo-header-position))
(prev-line (progn
(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"))
(org (pointer)))
(goto-char signoff-at)
(insert (format "%s%s: %s <%s>\n" pre type name email))
(when note
(insert (format "[%s: ]\n" email))
(backward-char 2)
(when (stringp note) (insert note) (goto-char org)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment