Function: ido-read-file-name

ido-read-file-name is an autoloaded and byte-compiled function defined in ido.el.gz.

Signature

(ido-read-file-name PROMPT &optional DIR DEFAULT-FILENAME MUSTMATCH INITIAL PREDICATE)

Documentation

Ido replacement for the built-in read-file-name.

Read file name, prompting with PROMPT and completing in directory DIR. See read-file-name for additional parameters.

Source Code

;; Defined in /usr/src/emacs/lisp/ido.el.gz
;;;###autoload
(defun ido-read-file-name (prompt &optional dir default-filename mustmatch initial predicate)
  "Ido replacement for the built-in `read-file-name'.
Read file name, prompting with PROMPT and completing in directory DIR.
See `read-file-name' for additional parameters."
  (let (filename)
    (cond
     ((and (not (memq this-command ido-read-file-name-non-ido))
           (or (eq predicate 'file-directory-p)
	       (eq (and (symbolp this-command)
                        (get this-command 'ido))
                   'dir)
	       (memq this-command ido-read-file-name-as-directory-commands)))
      (setq filename
	    (ido-read-directory-name prompt dir default-filename mustmatch initial)))
     ((and (not (eq (and (symbolp this-command)
			 (get this-command 'ido)) 'ignore))
	   (not (memq this-command ido-read-file-name-non-ido))
	   (or (null predicate) (eq predicate 'file-exists-p)))
      (let* (ido-saved-vc-hb
	     (ido-context-switch-command
	      (if (eq (and (symbolp this-command)
			   (get this-command 'ido)) 'find-file)
		  nil 'ignore))
	     (vc-handled-backends (and (boundp 'vc-handled-backends) vc-handled-backends))
	     (minibuffer-completing-file-name t)
	     (ido-current-directory (ido-expand-directory dir))
	     (ido-directory-nonreadable (not (file-readable-p ido-current-directory)))
	     (ido-directory-too-big (and (not ido-directory-nonreadable)
					 (ido-directory-too-big-p ido-current-directory)))
	     (ido-work-directory-index -1)
	     (ido-show-dot-for-dired (and ido-show-dot-for-dired
					  (not default-filename)))
	     (ido-work-file-index -1)
	     (ido-find-literal nil))
	(setq ido-exit nil)
	(setq filename
	      (ido-read-internal 'file prompt 'ido-file-history
				 (cond	; Bug#11861.
				  ((stringp default-filename) default-filename)
				  ((consp default-filename) (car default-filename))
				  ((and (not default-filename) initial)
				   (expand-file-name initial dir))
				  (buffer-file-name buffer-file-name))
				 mustmatch initial))
	(setq dir ido-current-directory) ; See bug#1516.
	(cond
	 ((eq ido-exit 'fallback)
	  (setq filename 'fallback))
	 ((eq ido-exit 'dired)
	  (setq filename ido-current-directory))
	 (filename
	  (setq filename
		(concat ido-current-directory filename))))))
     (t
      (setq filename 'fallback)))
    (if (eq filename 'fallback)
	(let ((read-file-name-function nil))
	  (run-hook-with-args 'ido-before-fallback-functions 'read-file-name)
	  (read-file-name prompt dir default-filename mustmatch initial predicate))
      filename)))