Function: log-edit-comment-to-change-log

log-edit-comment-to-change-log is an interactive and byte-compiled function defined in log-edit.el.gz.

Signature

(log-edit-comment-to-change-log &optional WHOAMI FILE-NAME)

Documentation

Insert the last VC commit comment into the change log for the current file.

This reuses the text of the last VC commit comment in log-edit-comment-ring for the change-log entry of the current file, which is handy when several related changes have the same commit comment. WHOAMI (interactively, prefix argument) non-nil means prompt for user name and email address of the person to whom to attribute the change. FILE-NAME is the name of the change log; if nil, use change-log-default-name Interactively, with prefix argument, prompt for both the name and address of the person who did the change and for FILE-NAME.

This may be useful as a vc-checkin-hook to update change logs automatically.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/vc/log-edit.el.gz
(defun log-edit-comment-to-change-log (&optional whoami file-name)
  "Insert the last VC commit comment into the change log for the current file.
This reuses the text of the last VC commit comment in `log-edit-comment-ring'
for the change-log entry of the current file, which is handy when several
related changes have the same commit comment.
WHOAMI (interactively, prefix argument) non-nil means prompt for user name
and email address of the person to whom to attribute the change.
FILE-NAME is the name of the change log; if nil, use `change-log-default-name'
Interactively, with prefix argument, prompt for both the name and address of
the person who did the change and for FILE-NAME.

This may be useful as a `vc-checkin-hook' to update change logs
automatically."
  (interactive (if current-prefix-arg
		   (list current-prefix-arg
			 (prompt-for-change-log-name))))
  (let (;; Extract the comment first so we get any error before doing anything.
	(comment (ring-ref log-edit-comment-ring 0))
	;; Don't let add-change-log-entry insert a defun name.
	(add-log-current-defun-function 'ignore)
	end)
    ;; Call add-log to do half the work.
    (add-change-log-entry whoami file-name t t)
    ;; Insert the VC comment, leaving point before it.
    (setq end (save-excursion (insert comment) (point-marker)))
    (if (looking-at "\\s *\\s(")
	;; It starts with an open-paren, as in "(foo): Frobbed."
	;; So remove the ": " add-log inserted.
	(delete-char -2))
    ;; Canonicalize the white space between the file name and comment.
    (just-one-space)
    ;; Indent rest of the text the same way add-log indented the first line.
    (let ((indentation (current-indentation)))
      (save-excursion
	(while (< (point) end)
	  (forward-line 1)
	  (indent-to indentation))
	(setq end (point))))
    ;; Fill the inserted text, preserving open-parens at bol.
    (let ((paragraph-start (concat paragraph-start "\\|\\s *\\s(")))
      (beginning-of-line)
      (fill-region (point) end))
    ;; Canonicalize the white space at the end of the entry so it is
    ;; separated from the next entry by a single blank line.
    (skip-syntax-forward " " end)
    (delete-char (- (skip-syntax-backward " ")))
    (or (eobp) (looking-at "\n\n")
	(insert "\n"))))