Function: log-edit-fill-entry
log-edit-fill-entry is a byte-compiled function defined in
log-edit.el.gz.
Signature
(log-edit-fill-entry &optional JUSTIFY)
Documentation
Like M-q (fill-paragraph), but for filling ChangeLog-formatted entries.
Consecutive function entries without prose (i.e., lines of the
form "(FUNCTION):") will be combined into "(FUNC1, FUNC2):"
according to fill-column.
Source Code
;; Defined in /usr/src/emacs/lisp/vc/log-edit.el.gz
(defun log-edit-fill-entry (&optional justify)
"Like \\[fill-paragraph], but for filling ChangeLog-formatted entries.
Consecutive function entries without prose (i.e., lines of the
form \"(FUNCTION):\") will be combined into \"(FUNC1, FUNC2):\"
according to `fill-column'."
(save-excursion
(let* ((range (log-edit-changelog-paragraph))
(beg (car range))
(end (cadr range)))
(if (= beg end)
;; Not a ChangeLog entry, fill as normal.
nil
(setq end (copy-marker end))
(goto-char beg)
(let* ((defuns-beg nil)
(defuns nil))
(while
(progn
;; Match a regexp against the next ChangeLog entry.
;; `defuns-beg' will be the end of the file name,
;; which marks the beginning of the list of defuns.
(setq defuns-beg
(and (< beg end)
(re-search-forward
(concat "\\(?1:"
change-log-unindented-file-names-re
"\\)\\|^\\(?1:\\)[[:blank:]]*(")
end t)
(copy-marker (match-end 1))))
;; Fill the intervening prose between the end of the
;; last match and the beginning of the current match.
(let ((fill-indent-according-to-mode t)
(end (if defuns-beg
(match-beginning 0) end))
(beg (progn (goto-char beg)
(line-beginning-position)))
space-beg space-end)
(when (<= (line-end-position) end)
;; Replace space characters within parentheses
;; that resemble ChangeLog defun names between BEG
;; and END with non-breaking spaces to prevent
;; them from being considered break points by
;; `fill-region'.
(save-excursion
(goto-char beg)
(when (re-search-forward
;; Also replace spaces within defun lists
;; prefixed by a file name so that
;; fill-region never attempts to break
;; them, even if multiple items combine
;; with symbols to exceed the fill column
;; by the expressly permitted margin of 1
;; character.
(concat "^\\([[:blank:]]*\\|\\* .*[[:blank:]]"
"\\)(.*\\([[:space:]]\\).*):")
end t)
(replace-regexp-in-region "[[:space:]]" " "
(setq space-beg
(copy-marker
(match-beginning 0)))
(setq space-end
(copy-marker
(match-end 0))))))
(fill-region beg end justify))
;; Restore the spaces replaced by NBSPs.
(when space-beg
(replace-string-in-region " " " "
space-beg space-end)
(set-marker space-beg nil)
(set-marker space-end nil)))
defuns-beg)
(goto-char defuns-beg)
(setq defuns (change-log-read-defuns end))
(progn
(delete-region defuns-beg (point))
(log-edit--insert-filled-defuns defuns)
(setq beg (point))))
nil)
t))))