Function: git-commit-prev-message
git-commit-prev-message is an interactive and byte-compiled function
defined in git-commit.el.
Signature
(git-commit-prev-message ARG)
Documentation
Cycle backward through message history, after saving current message.
With a numeric prefix ARG, go back ARG messages.
Key Bindings
Source Code
;; Defined in ~/.emacs.d/elpa/magit-20260411.1452/git-commit.el
;;; History
(defun git-commit-prev-message (arg)
"Cycle backward through message history, after saving current message.
With a numeric prefix ARG, go back ARG messages."
(interactive "*p")
(let ((len (ring-length log-edit-comment-ring)))
(if (<= len 0)
(progn (message "Empty comment ring") (ding))
;; Unlike `log-edit-previous-comment' we save the current
;; non-empty and newly written comment, because otherwise
;; it would be irreversibly lost.
(when-let* ((message (git-commit-buffer-message))
(_(not (ring-member log-edit-comment-ring message))))
(ring-insert log-edit-comment-ring message)
(cl-incf arg)
(setq len (ring-length log-edit-comment-ring)))
;; Delete the message but not the instructions at the end.
(save-restriction
(goto-char (point-min))
(narrow-to-region
(point)
(if (re-search-forward (concat "^" comment-start) nil t)
(max 1 (- (point) 2))
(point-max)))
(delete-region (point-min) (point)))
(setq log-edit-comment-ring-index (log-edit-new-comment-index arg len))
(message "Comment %d" (1+ log-edit-comment-ring-index))
(insert (ring-ref log-edit-comment-ring log-edit-comment-ring-index)))))