Function: next-completion
next-completion is an interactive and byte-compiled function defined
in simple.el.gz.
Signature
(next-completion N)
Documentation
Move to the next item in the completions buffer.
With prefix argument N, move N items (negative N means move backward).
Also see the completion-auto-wrap variable.
Probably introduced at or before Emacs version 19.29.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/simple.el.gz
(defun next-completion (n)
"Move to the next item in the completions buffer.
With prefix argument N, move N items (negative N means move
backward).
Also see the `completion-auto-wrap' variable."
(interactive "p")
(let ((tabcommand (member (this-command-keys) '("\t" [backtab])))
pos)
(catch 'bound
(when (and (bobp)
(> n 0)
(get-text-property (point) 'mouse-face)
(not (get-text-property (point) 'first-completion)))
(let ((inhibit-read-only t))
(add-text-properties (point) (1+ (point)) '(first-completion t)))
(setq n (1- n)))
(while (> n 0)
(setq pos (point))
;; If in a completion, move to the end of it.
(when (get-text-property pos 'mouse-face)
(setq pos (next-single-property-change pos 'mouse-face)))
(when pos (setq pos (next-single-property-change pos 'mouse-face)))
(if pos
;; Move to the start of next one.
(goto-char pos)
;; If at the last completion option, wrap or skip
;; to the minibuffer, if requested.
(when completion-auto-wrap
(if (and (eq completion-auto-select t) tabcommand
(minibufferp completion-reference-buffer))
(throw 'bound nil)
(first-completion))))
(setq n (1- n)))
(while (< n 0)
(setq pos (point))
;; If in a completion, move to the start of it.
(when (and (get-text-property pos 'mouse-face)
(not (bobp))
(get-text-property (1- pos) 'mouse-face))
(setq pos (previous-single-property-change pos 'mouse-face)))
(when pos (setq pos (previous-single-property-change pos 'mouse-face)))
(if pos
(progn
(goto-char pos)
;; Move to the start of that one.
(unless (get-text-property (point) 'mouse-face)
(goto-char (previous-single-property-change
(point) 'mouse-face nil (point-min)))))
;; If at the first completion option, wrap or skip
;; to the minibuffer, if requested.
(when completion-auto-wrap
(if (and (eq completion-auto-select t) tabcommand
(minibufferp completion-reference-buffer))
(progn
(throw 'bound nil))
(last-completion))))
(setq n (1+ n))))
(when (/= 0 n)
(switch-to-minibuffer))))