Make the magic fields in the commit message more explicit.

* magit.el (magit-log-header-end): New.
(magit-log-edit-get-fields, magit-log-edit-set-fields): Look for and
insert it.
This commit is contained in:
Marius Vollmer 2008-11-09 23:13:17 +02:00
parent 7defaab319
commit 88baa2e066

View file

@ -1781,6 +1781,8 @@ Prefix arg means justify as well."
(goto-char (point-max)) (goto-char (point-max))
(insert str "\n"))) (insert str "\n")))
(defconst magit-log-header-end "-- End of Magit header --\n")
(defun magit-log-edit-get-fields () (defun magit-log-edit-get-fields ()
(let ((buf (get-buffer "*magit-log-edit*")) (let ((buf (get-buffer "*magit-log-edit*"))
(result nil)) (result nil))
@ -1792,7 +1794,9 @@ Prefix arg means justify as well."
(setq result (acons (intern (downcase (match-string 1))) (setq result (acons (intern (downcase (match-string 1)))
(match-string 2) (match-string 2)
result)) result))
(forward-line)))) (forward-line))
(if (not (looking-at (regexp-quote magit-log-header-end)))
(setq result nil))))
(nreverse result))) (nreverse result)))
(defun magit-log-edit-set-fields (fields) (defun magit-log-edit-set-fields (fields)
@ -1800,7 +1804,9 @@ Prefix arg means justify as well."
(save-excursion (save-excursion
(set-buffer buf) (set-buffer buf)
(goto-char (point-min)) (goto-char (point-min))
(if (search-forward-regexp "^\\([A-Za-z0-9]+:.*\n\\)+\n?" nil t) (if (search-forward-regexp (format "^\\([A-Za-z0-9]+:.*\n\\)+%s"
(regexp-quote magit-log-header-end))
nil t)
(delete-region (match-beginning 0) (match-end 0))) (delete-region (match-beginning 0) (match-end 0)))
(goto-char (point-min)) (goto-char (point-min))
(when fields (when fields
@ -1808,7 +1814,7 @@ Prefix arg means justify as well."
(insert (capitalize (symbol-name (caar fields))) ": " (insert (capitalize (symbol-name (caar fields))) ": "
(cdar fields) "\n") (cdar fields) "\n")
(setq fields (cdr fields))) (setq fields (cdr fields)))
(insert "\n"))))) (insert magit-log-header-end)))))
(defun magit-log-edit-set-field (name value) (defun magit-log-edit-set-field (name value)
(let* ((fields (magit-log-edit-get-fields)) (let* ((fields (magit-log-edit-get-fields))