Commit dda61916 authored by Dmitry Gutov's avatar Dmitry Gutov
Browse files

Remember log-edit comment when the buffer is killed

* lisp/vc/log-edit.el (log-edit-add-new-comment): Rename to
`log-edit-remember-comment', make argument optional.  Adjust all
callers.
(log-edit-mode): Add `log-edit-remember-comment' to
`kill-buffer-hook' locally.
(log-edit-kill-buffer): Don't remember comment explicitly since
the buffer is killed anyway.
parent c085e5b9
2013-12-04 Dmitry Gutov <dgutov@yandex.ru>
* vc/log-edit.el (log-edit-add-new-comment): Rename to
`log-edit-remember-comment', make argument optional. Adjust all
callers.
(log-edit-mode): Add `log-edit-remember-comment' to
`kill-buffer-hook' locally.
(log-edit-kill-buffer): Don't remember comment explicitly since
the buffer is killed anyway.
2013-12-04 Juri Linkov <juri@jurta.org> 2013-12-04 Juri Linkov <juri@jurta.org>
* isearch.el (isearch-mode, isearch-done): Don't set arg LOCAL in * isearch.el (isearch-mode, isearch-done): Don't set arg LOCAL in
......
...@@ -476,6 +476,7 @@ commands (under C-x v for VC, for example). ...@@ -476,6 +476,7 @@ commands (under C-x v for VC, for example).
(set (make-local-variable 'font-lock-defaults) (set (make-local-variable 'font-lock-defaults)
'(log-edit-font-lock-keywords t)) '(log-edit-font-lock-keywords t))
(make-local-variable 'log-edit-comment-ring-index) (make-local-variable 'log-edit-comment-ring-index)
(add-hook 'kill-buffer-hook 'log-edit-remember-comment nil t)
(hack-dir-local-variables-non-file-buffer)) (hack-dir-local-variables-non-file-buffer))
(defun log-edit-hide-buf (&optional buf where) (defun log-edit-hide-buf (&optional buf where)
...@@ -488,7 +489,8 @@ commands (under C-x v for VC, for example). ...@@ -488,7 +489,8 @@ commands (under C-x v for VC, for example).
(if win (ignore-errors (delete-window win)))) (if win (ignore-errors (delete-window win))))
(bury-buffer buf)))) (bury-buffer buf))))
(defun log-edit-add-new-comment (comment) (defun log-edit-remember-comment (&optional comment)
(unless comment (setq comment (buffer-string)))
(when (or (ring-empty-p log-edit-comment-ring) (when (or (ring-empty-p log-edit-comment-ring)
(not (equal comment (ring-ref log-edit-comment-ring 0)))) (not (equal comment (ring-ref log-edit-comment-ring 0))))
(ring-insert log-edit-comment-ring comment))) (ring-insert log-edit-comment-ring comment)))
...@@ -524,7 +526,7 @@ If you want to abort the commit, simply delete the buffer." ...@@ -524,7 +526,7 @@ If you want to abort the commit, simply delete the buffer."
(save-excursion (save-excursion
(goto-char (point-max)) (goto-char (point-max))
(insert ?\n))) (insert ?\n)))
(log-edit-add-new-comment (buffer-string)) (log-edit-remember-comment)
(let ((win (get-buffer-window log-edit-files-buf))) (let ((win (get-buffer-window log-edit-files-buf)))
(if (and log-edit-confirm (if (and log-edit-confirm
(not (and (eq log-edit-confirm 'changed) (not (and (eq log-edit-confirm 'changed)
...@@ -545,7 +547,6 @@ If you want to abort the commit, simply delete the buffer." ...@@ -545,7 +547,6 @@ If you want to abort the commit, simply delete the buffer."
Also saves its contents in the comment history and hides Also saves its contents in the comment history and hides
`log-edit-files-buf'." `log-edit-files-buf'."
(interactive) (interactive)
(log-edit-add-new-comment (buffer-string))
(log-edit-hide-buf) (log-edit-hide-buf)
(let ((buf (current-buffer))) (let ((buf (current-buffer)))
(quit-windows-on buf) (quit-windows-on buf)
...@@ -659,7 +660,7 @@ can thus take some time." ...@@ -659,7 +660,7 @@ can thus take some time."
(defun log-edit-add-to-changelog () (defun log-edit-add-to-changelog ()
"Insert this log message into the appropriate ChangeLog file." "Insert this log message into the appropriate ChangeLog file."
(interactive) (interactive)
(log-edit-add-new-comment (buffer-string)) (log-edit-remember-comment)
(dolist (f (log-edit-files)) (dolist (f (log-edit-files))
(let ((buffer-file-name (expand-file-name f))) (let ((buffer-file-name (expand-file-name f)))
(save-excursion (save-excursion
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment