diff options
| author | Dmitry Gutov <dgutov@yandex.ru> | 2013-12-03 00:13:51 +0200 |
|---|---|---|
| committer | Dmitry Gutov <dgutov@yandex.ru> | 2013-12-03 00:13:51 +0200 |
| commit | 0f457a371c67e28f4eb7ddc60750169badc7f8d8 (patch) | |
| tree | 696e3576cafd00991c061cf6bde1f4b0b983756c /lisp/vc/log-edit.el | |
| parent | 2595af33fce43121ddb0c2a2d5bb85b2e1b4b61a (diff) | |
| download | emacs-0f457a371c67e28f4eb7ddc60750169badc7f8d8.tar.gz | |
Support the new log-edit behavior in vc-git-log-edit-toggle-amend
* lisp/vc/log-edit.el (log-edit-set-header): Extract from
`log-edit-toggle-header'.
(log-edit-extract-headers): Separate the summary, when extracted
from header, from the rest of the message with an empty line.
* lisp/vc/vc-git.el (vc-git-log-edit-toggle-amend): Move the summary
line, if present, to the Summary header.
Diffstat (limited to 'lisp/vc/log-edit.el')
| -rw-r--r-- | lisp/vc/log-edit.el | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/lisp/vc/log-edit.el b/lisp/vc/log-edit.el index 0845284d6cc..7f66f73e9d9 100644 --- a/lisp/vc/log-edit.el +++ b/lisp/vc/log-edit.el @@ -944,10 +944,14 @@ Rename relative filenames in the ChangeLog entry as FILES." (defun log-edit-toggle-header (header value) "Toggle a boolean-type header in the current buffer. -If the value of HEADER is VALUE, clear it. Otherwise, add the -header if it's not present and set it to VALUE. Then make sure -there is an empty line after the headers. Return t if toggled -on, otherwise nil." +See `log-edit-set-header' for details." + (log-edit-set-header header value t)) + +(defun log-edit-set-header (header value &optional toggle) + "Set the value of HEADER to VALUE in the current buffer. +If TOGGLE is non-nil, and the value of HEADER already is VALUE, +clear it. Make sure there is an empty line after the headers. +Return t if toggled on (or TOGGLE is nil), otherwise nil." (let ((val t) (line (concat header ": " value "\n"))) (save-excursion @@ -958,7 +962,7 @@ on, otherwise nil." (if (re-search-forward (concat "^" header ":" log-edit-header-contents-regexp) nil t) - (if (setq val (not (string= (match-string 1) value))) + (if (setq val (not (and toggle (string= (match-string 1) value)))) (replace-match line t t) (replace-match "" t t nil 1)) (insert line))) @@ -1006,7 +1010,7 @@ line of MSG." (goto-char (point-min)) (when (looking-at "\\([ \t]*\n\\)+") (delete-region (match-beginning 0) (match-end 0))) - (if summary (insert summary "\n")) + (if summary (insert summary "\n\n")) (cons (buffer-string) res)))) (provide 'log-edit) |
