Function: completion-search-next
completion-search-next is a byte-compiled function defined in
completion.el.gz.
Signature
(completion-search-next INDEX)
Documentation
Return the next completion entry.
If INDEX is out of sequence, reset and start from the top. If there are no more entries, try cdabbrev and return only a string.
Source Code
;; Defined in /usr/src/emacs/lisp/completion.el.gz
(defun completion-search-next (index)
"Return the next completion entry.
If INDEX is out of sequence, reset and start from the top.
If there are no more entries, try cdabbrev and return only a string."
(cond
((= index (setq cmpl-last-index (1+ cmpl-last-index)))
(completion-search-peek t))
((< index 0)
(completion-search-reset-1)
(setq cmpl-last-index index)
;; reverse the possibilities list
(setq cmpl-next-possibilities (reverse cmpl-starting-possibilities))
;; do a "normal" search
(while (and (completion-search-peek nil)
(< (setq index (1+ index)) 0))
(setq cmpl-next-possibility nil))
(cond ((not cmpl-next-possibilities))
;; If no more possibilities, leave it that way
((= -1 cmpl-last-index)
;; next completion is at index 0. reset next-possibility list
;; to start at beginning
(setq cmpl-next-possibilities cmpl-starting-possibilities))
(t
;; otherwise point to one before current
(setq cmpl-next-possibilities
(nthcdr (- (length cmpl-starting-possibilities)
(length cmpl-next-possibilities))
cmpl-starting-possibilities)))))
(t
;; non-negative index, reset and search
;;(prin1 'reset)
(completion-search-reset-1)
(setq cmpl-last-index index)
(while (and (completion-search-peek t)
(not (< (setq index (1- index)) 0)))
(setq cmpl-next-possibility nil))))
(prog1
cmpl-next-possibility
(setq cmpl-next-possibility nil)))