Skip to content

Instantly share code, notes, and snippets.

@willert
Created June 7, 2010 23:55
Show Gist options
  • Save willert/429372 to your computer and use it in GitHub Desktop.
Save willert/429372 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 (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