Function: ido-complete

ido-complete is an interactive and byte-compiled function defined in ido.el.gz.

Signature

(ido-complete)

Documentation

Try and complete the current pattern amongst the file names.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/ido.el.gz
(defun ido-complete ()
  "Try and complete the current pattern amongst the file names."
  (interactive)
  (let (res)
    (cond
     (ido-incomplete-regexp
      ;; Do nothing
      )
     ((and (memq ido-cur-item '(file dir))
	   (string-search "$" ido-text))
      (let ((evar (substitute-in-file-name (concat ido-current-directory ido-text))))
	(if (not (file-exists-p (file-name-directory evar)))
	    (message "Expansion generates non-existing directory name")
	  (if (file-directory-p evar)
	      (ido-set-current-directory evar)
	    (let ((d (or (file-name-directory evar) "/"))
		  (f (file-name-nondirectory evar)))
	      (when (file-directory-p d)
		  (ido-set-current-directory d)
		  (setq ido-text-init f))))
	  (setq ido-exit 'refresh)
	  (exit-minibuffer))))

     (ido-directory-too-big
      (setq ido-directory-too-big nil)
      (setq ido-text-init ido-text)
      (setq ido-exit 'refresh)
      (exit-minibuffer))

     ((not ido-matches)
      (when ido-completion-buffer
	(call-interactively (setq this-command ido-cannot-complete-command))))

     ((and (= 1 (length ido-matches))
	   (not (and ido-enable-tramp-completion
		     (string-equal ido-current-directory "/")
		     (string-match ".[@:]\\'" (ido-name (car ido-matches)))))
		     (not (ido-local-file-exists-p (ido-name (car ido-matches)))))
      ;; only one choice, so select it.
      (if (not ido-confirm-unique-completion)
	  (exit-minibuffer)
	(setq ido-rescan (not ido-enable-prefix))
	(delete-region (minibuffer-prompt-end) (point))
	(insert (ido-name (car ido-matches)))))

     (t ;; else there could be some completions
      (setq res ido-common-match-string)
      (if (and (not (memq res '(t nil)))
	       (not (equal res ido-text)))
	  ;; found something to complete, so put it in the minibuffer.
	  (progn
	    ;; move exact match to front if not in prefix mode
	    (setq ido-rescan (not ido-enable-prefix))
	    (delete-region (minibuffer-prompt-end) (point))
	    (insert res))
	;; else nothing to complete
	(call-interactively (setq this-command ido-cannot-complete-command))
	)))))