Function: complete
complete is an interactive and byte-compiled function defined in
completion.el.gz.
Signature
(complete &optional ARG)
Documentation
Fill out a completion of the word before point.
Point is left at end. Consecutive calls rotate through all possibilities.
Prefix args ::
control-u :: leave the point at the beginning of the completion rather
than at the end.
a number :: rotate through the possible completions by that amount
- :: same as -1 (insert previous completion)
{See the comments at the top of completion.el for more info.}
Probably introduced at or before Emacs version 23.2.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/completion.el.gz
(defun complete (&optional arg)
"Fill out a completion of the word before point.
Point is left at end. Consecutive calls rotate through all possibilities.
Prefix args ::
control-u :: leave the point at the beginning of the completion rather
than at the end.
a number :: rotate through the possible completions by that amount
`-' :: same as -1 (insert previous completion)
{See the comments at the top of `completion.el' for more info.}"
(interactive "*p")
;;; Set up variables
(cond ((eq last-command this-command)
;; Undo last one
(delete-region cmpl-last-insert-location (point))
;; get next completion
(setq cmpl-current-index (+ cmpl-current-index (or arg 1))))
(t
(if (not cmpl-initialized-p)
(completion-initialize)) ;; make sure everything's loaded
(cond ((consp current-prefix-arg) ;; control-u
(setq arg 0)
(setq cmpl-leave-point-at-start t))
(t
(setq cmpl-leave-point-at-start nil)))
;; get string
(setq cmpl-original-string (symbol-before-point-for-complete))
(cond ((not cmpl-original-string)
(setq this-command 'failed-complete)
(error "To complete, point must be after a symbol at least %d character long"
completion-prefix-min-length)))
;; get index
(setq cmpl-current-index (if current-prefix-arg arg 0))
;; reset database
(completion-search-reset cmpl-original-string)
;; erase what we've got
(delete-region cmpl-symbol-start cmpl-symbol-end)))
;; point is at the point to insert the new symbol
;; Get the next completion
(let* ((print-status-p
(and (>= baud-rate completion-prompt-speed-threshold)
(not (window-minibuffer-p))))
(insert-point (point))
(entry (completion-search-next cmpl-current-index))
string)
;; entry is either a completion entry or a string (if cdabbrev)
;; If found, insert
(cond (entry
;; Setup for proper case
(setq string (if (stringp entry)
entry (completion-string entry)))
(setq string (cmpl-merge-string-cases
string cmpl-original-string))
;; insert
(insert string)
;; accept it
(setq completion-to-accept string)
;; fixup and cache point
(cond (cmpl-leave-point-at-start
(setq cmpl-last-insert-location (point))
(goto-char insert-point))
(t;; point at end,
(setq cmpl-last-insert-location insert-point)))
;; Done ! cmpl-stat-complete-successful
;;display the next completion
(cond
((and print-status-p
;; This updates the display and only prints if there
;; is no typeahead
(sit-for 0)
(setq entry
(completion-search-peek
completion-cdabbrev-prompt-flag)))
(setq string (if (stringp entry)
entry (completion-string entry)))
(setq string (cmpl-merge-string-cases
string cmpl-original-string))
(message "Next completion: %s" string))))
(t;; none found, insert old
(insert cmpl-original-string)
;; Don't accept completions
(setq completion-to-accept nil)
;; print message
;; This used to call cmpl19-sit-for, an undefined function.
;; I hope that sit-for does the right thing; I don't know -- rms.
(if (and print-status-p (sit-for 0))
(message "No %scompletions."
(if (eq this-command last-command) "more " "")))
;; Pretend that we were never here
(setq this-command 'failed-complete)))))