From: Juri Linkov Date: Wed, 18 Dec 2013 23:51:45 +0000 (+0200) Subject: * lisp/vc/log-edit.el (log-edit-hook): Add `log-edit-insert-message-template' X-Git-Tag: emacs-24.3.90~173^2^2~42^2~45^2~387^2~336 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=0cda6b7b136178f42510c9e4ededcbaa38c4cc19;p=emacs.git * lisp/vc/log-edit.el (log-edit-hook): Add `log-edit-insert-message-template' to the default list. Move `log-edit-show-files' to the end. Add more available functions to options. (log-edit): Move default specific settings to `log-edit-insert-message-template'. Don't move point. (log-edit-insert-message-template): New function. (log-edit-insert-changelog): Add `save-excursion' and don't move point. Fixes: debbugs:16170 --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 31161057cc8..a3e6709a228 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,14 @@ +2013-12-18 Juri Linkov + + * vc/log-edit.el (log-edit-hook): Add `log-edit-insert-message-template' + to the default list. Move `log-edit-show-files' to the end. + Add more available functions to options. + (log-edit): Move default specific settings to + `log-edit-insert-message-template'. Don't move point. + (log-edit-insert-message-template): New function. + (log-edit-insert-changelog): Add `save-excursion' and don't move point. + (Bug#16170) + 2013-12-18 Juri Linkov * help-mode.el (help-mode-map): Bind "l" to help-go-back, diff --git a/lisp/vc/log-edit.el b/lisp/vc/log-edit.el index 91390fa1123..2ee60a872e4 100644 --- a/lisp/vc/log-edit.el +++ b/lisp/vc/log-edit.el @@ -126,15 +126,18 @@ its SETUP argument is non-nil." :type 'boolean :safe 'booleanp) -(defcustom log-edit-hook '(log-edit-insert-cvs-template - log-edit-show-files - log-edit-insert-changelog) +(defcustom log-edit-hook '(log-edit-insert-message-template + log-edit-insert-cvs-template + log-edit-insert-changelog + log-edit-show-files) "Hook run at the end of `log-edit'." :group 'log-edit - :type '(hook :options (log-edit-insert-changelog - log-edit-insert-cvs-rcstemplate - log-edit-insert-cvs-template - log-edit-insert-filenames))) + :type '(hook :options (log-edit-insert-message-template + log-edit-insert-cvs-rcstemplate + log-edit-insert-cvs-template + log-edit-insert-changelog + log-edit-insert-filenames + log-edit-show-files))) (defcustom log-edit-mode-hook (if (boundp 'vc-log-mode-hook) vc-log-mode-hook) "Hook run when entering `log-edit-mode'." @@ -440,12 +443,6 @@ done. Otherwise, it uses the current buffer." (if mode (funcall mode) (log-edit-mode)) - (when setup - (erase-buffer) - (insert "Summary: ") - (when log-edit-setup-add-author - (insert "\nAuthor: ")) - (insert "\n\n")) (set (make-local-variable 'log-edit-callback) callback) (if (listp params) (dolist (crt params) @@ -456,10 +453,9 @@ done. Otherwise, it uses the current buffer." (if buffer (set (make-local-variable 'log-edit-parent-buffer) parent)) (set (make-local-variable 'log-edit-initial-files) (log-edit-files)) - (when setup (run-hooks 'log-edit-hook)) - (if setup - (message-position-point) - (goto-char (point-min))) + (when setup + (erase-buffer) + (run-hooks 'log-edit-hook)) (push-mark (point-max)) (message "%s" (substitute-command-keys "Press \\[log-edit-done] when you are done editing.")))) @@ -626,6 +622,17 @@ different header separator appropriate for `log-edit-mode'." (zerop (forward-line 1)))) (eobp)))) +(defun log-edit-insert-message-template () + "Insert the default template with Summary and Author." + (interactive) + (when (or (called-interactively-p 'interactive) + (log-edit-empty-buffer-p)) + (insert "Summary: ") + (when log-edit-setup-add-author + (insert "\nAuthor: ")) + (insert "\n\n") + (message-position-point))) + (defun log-edit-insert-cvs-template () "Insert the template specified by the CVS administrator, if any. This simply uses the local CVS/Template file." @@ -701,39 +708,39 @@ If the optional prefix arg USE-FIRST is given (via \\[universal-argument]), or if the command is repeated a second time in a row, use the first log entry regardless of user name or time." (interactive "P") - (let ((eoh (save-excursion (rfc822-goto-eoh) (point)))) - (when (<= (point) eoh) - (goto-char eoh) - (if (looking-at "\n") (forward-char 1)))) - (let ((author - (let ((log-edit-changelog-use-first - (or use-first (eq last-command 'log-edit-insert-changelog)))) - (log-edit-insert-changelog-entries (log-edit-files))))) - (log-edit-set-common-indentation) - ;; Add an Author: field if appropriate. - (when author (log-edit-add-field "Author" author)) - ;; Add a Fixes: field if applicable. - (when (consp log-edit-rewrite-fixes) - (rfc822-goto-eoh) - (when (re-search-forward (car log-edit-rewrite-fixes) nil t) - (let ((start (match-beginning 0)) - (end (match-end 0)) - (fixes (match-substitute-replacement - (cdr log-edit-rewrite-fixes)))) - (delete-region start end) - (log-edit-add-field "Fixes" fixes)))) - (and log-edit-strip-single-file-name - (progn (rfc822-goto-eoh) - (if (looking-at "\n") (forward-char 1)) - (looking-at "\\*\\s-+")) - (let ((start (point))) - (forward-line 1) - (when (not (re-search-forward "^\\*\\s-+" nil t)) - (goto-char start) - (skip-chars-forward "^():") - (skip-chars-forward ": ") - (delete-region start (point))))) - (goto-char (point-min)))) + (save-excursion + (let ((eoh (save-excursion (rfc822-goto-eoh) (point)))) + (when (<= (point) eoh) + (goto-char eoh) + (if (looking-at "\n") (forward-char 1)))) + (let ((author + (let ((log-edit-changelog-use-first + (or use-first (eq last-command 'log-edit-insert-changelog)))) + (log-edit-insert-changelog-entries (log-edit-files))))) + (log-edit-set-common-indentation) + ;; Add an Author: field if appropriate. + (when author (log-edit-add-field "Author" author)) + ;; Add a Fixes: field if applicable. + (when (consp log-edit-rewrite-fixes) + (rfc822-goto-eoh) + (when (re-search-forward (car log-edit-rewrite-fixes) nil t) + (let ((start (match-beginning 0)) + (end (match-end 0)) + (fixes (match-substitute-replacement + (cdr log-edit-rewrite-fixes)))) + (delete-region start end) + (log-edit-add-field "Fixes" fixes)))) + (and log-edit-strip-single-file-name + (progn (rfc822-goto-eoh) + (if (looking-at "\n") (forward-char 1)) + (looking-at "\\*\\s-+")) + (let ((start (point))) + (forward-line 1) + (when (not (re-search-forward "^\\*\\s-+" nil t)) + (goto-char start) + (skip-chars-forward "^():") + (skip-chars-forward ": ") + (delete-region start (point)))))))) ;;;; ;;;; functions for getting commit message from ChangeLog a file...