Function: minibuffer-next-completion

minibuffer-next-completion is an interactive and byte-compiled function defined in minibuffer.el.gz.

Signature

(minibuffer-next-completion &optional N)

Documentation

Move to the next item in its completions window from the minibuffer.

When minibuffer-completion-auto-choose is non-nil, then also insert the selected completion to the minibuffer.

View in manual

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/minibuffer.el.gz
(defun minibuffer-next-completion (&optional n)
  "Move to the next item in its completions window from the minibuffer.
When `minibuffer-completion-auto-choose' is non-nil, then also
insert the selected completion to the minibuffer."
  (interactive "p")
  (let ((auto-choose minibuffer-completion-auto-choose)
         (buf (current-buffer)))
    (with-minibuffer-completions-window
      (when completions-highlight-face
        (setq-local cursor-face-highlight-nonselected-window t))
      (next-completion (or n 1))
      (when auto-choose
        (let* ((completion-use-base-affixes t)
               ;; Backported fix for bug#62700
               (md
                (with-current-buffer buf
                  (completion--field-metadata (minibuffer--completion-prompt-end))))
               (base-suffix
                (if (eq (alist-get 'category (cdr md)) 'file)
                    (with-current-buffer buf
                      (buffer-substring
                       (save-excursion (or (search-forward "/" nil t) (point-max)))
                       (point-max)))
                  ""))
              (completion-base-affixes (list (car completion-base-affixes) base-suffix)))
          (choose-completion nil t t))))))