Function: next-line-or-history-element
next-line-or-history-element is an interactive and byte-compiled
function defined in simple.el.gz.
Signature
(next-line-or-history-element &optional ARG)
Documentation
Move cursor vertically down ARG lines, or to the next history element.
When point moves over the bottom line of multi-line minibuffer, puts ARGth next element of the minibuffer history in the minibuffer.
Probably introduced at or before Emacs version 25.1.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/simple.el.gz
(defun next-line-or-history-element (&optional arg)
"Move cursor vertically down ARG lines, or to the next history element.
When point moves over the bottom line of multi-line minibuffer, puts ARGth
next element of the minibuffer history in the minibuffer."
(interactive "^p")
(or arg (setq arg 1))
(let* ((old-point (point))
;; Don't add newlines if they have the mode enabled globally.
(next-line-add-newlines nil)
;; Remember the original goal column of possibly multi-line input
;; excluding the length of the prompt on the first line.
(prompt-end (minibuffer-prompt-end))
(old-column (unless (and (eolp) (> (point) prompt-end))
(if (= (line-number-at-pos) 1)
(max (- (current-column)
(save-excursion
(goto-char (1- prompt-end))
(current-column)))
0)
(current-column)))))
(condition-case nil
(with-no-warnings
(next-line arg))
(end-of-buffer
;; Restore old position since `line-move-visual' moves point to
;; the end of the line when it fails to go to the next line.
(goto-char old-point)
(next-history-element arg)
;; Reset `temporary-goal-column' because a correct value is not
;; calculated when `next-line' above fails by bumping against
;; the bottom of the minibuffer (bug#22544).
(setq temporary-goal-column 0)
;; Restore the original goal column on the last line
;; of possibly multi-line input.
(goto-char (point-max))
(when old-column
(if (= (line-number-at-pos) 1)
(move-to-column (+ old-column
(save-excursion
(goto-char (1- (minibuffer-prompt-end)))
(current-column))))
(move-to-column old-column)))))))