ido.el 166 KB
Newer Older
Kim F. Storm's avatar
Kim F. Storm committed
1 2
;;; ido.el --- interactively do things with buffers and files.

3
;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
Glenn Morris's avatar
Glenn Morris committed
4
;;   2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
Kim F. Storm's avatar
Kim F. Storm committed
5 6 7 8 9 10 11

;; Author: Kim F. Storm <storm@cua.dk>
;; Based on: iswitchb by Stephen Eglen <stephen@cns.ed.ac.uk>
;; Keywords: extensions convenience

;; This file is part of GNU Emacs.

12
;; GNU Emacs is free software: you can redistribute it and/or modify
Kim F. Storm's avatar
Kim F. Storm committed
13
;; it under the terms of the GNU General Public License as published by
14 15
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
Kim F. Storm's avatar
Kim F. Storm committed
16 17 18 19 20 21 22

;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
23
;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
Kim F. Storm's avatar
Kim F. Storm committed
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55


;;; Commentary:

;; Ido - interactive do - switches between buffers and opens files and
;; directories with a minimum of keystrokes.  It is a superset of
;; iswitchb, the interactive buffer switching package by Stephen Eglen.

;; Interactive substring matching
;; ------------------------------
;;
;; As you type in a substring, the list of buffers or files currently
;; matching the substring are displayed as you type.  The list is
;; ordered so that the most recent buffers or files visited come at
;; the start of the list.
;;
;; The buffer or file at the start of the list will be the one visited
;; when you press RETURN.  By typing more of the substring, the list is
;; narrowed down so that gradually the buffer or file you want will be
;; at the top of the list.  Alternatively, you can use C-s and C-r (or
;; the right and left arrow keys) to rotate buffer or file names in the
;; list until the one you want is at the top of the list.
;;
;; Completion is also available so that you can see what is common to
;; all of the matching buffers or files as you type.
;;
;; Example:
;;
;; If I have two buffers called "123456" and "123", with "123456" the
;; most recent, when I use ido-switch-buffer, I first of all get
;; presented with the list of all the buffers
;;
56
;;       Buffer: {123456 | 123}
Kim F. Storm's avatar
Kim F. Storm committed
57 58
;;
;; If I then press 2:
59
;;       Buffer: 2[3]{123456 | 123}
Kim F. Storm's avatar
Kim F. Storm committed
60 61 62 63
;;
;; The list in {...} are the matching buffers, most recent first
;; (buffers visible in the current frame are put at the end of the
;; list by default).  At any time I can select the item at the head of
Kim F. Storm's avatar
Kim F. Storm committed
64 65 66
;; the list by pressing RET.  I can also put the first element at the
;; end of the list by pressing C-s or [right], or bring the last
;; element to the head of the list by pressing C-r or [left].
Kim F. Storm's avatar
Kim F. Storm committed
67 68 69 70 71
;;
;; The item in [...] indicates what can be added to my input by
;; pressing TAB.  In this case, I will get "3" added to my input.

;; So, I press TAB:
72
;;	 Buffer: 23{123456 | 123}
Kim F. Storm's avatar
Kim F. Storm committed
73 74 75 76 77 78 79
;;
;; At this point, I still have two matching buffers.
;; If I want the first buffer in the list, I simply press RET.  If I
;; wanted the second in the list, I could press C-s to move it to the
;; top of the list and then RET to select it.
;;
;; However, if I type 4, I only have one match left:
80 81 82 83 84
;;       Buffer: 234[123456]
;;
;; Since there is only one matching buffer left, it is given in [] and
;; it is shown in the `ido-only-match' face (ForestGreen).  I can now
;; press TAB or RET to go to that buffer.
Kim F. Storm's avatar
Kim F. Storm committed
85
;;
86 87
;; If I want to create a new buffer named "234", I press C-j instead of
;; TAB or RET.
Kim F. Storm's avatar
Kim F. Storm committed
88
;;
89
;; If instead, I type "a":
Kim F. Storm's avatar
Kim F. Storm committed
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
;;       Buffer: 234a [No match]
;; There are no matching buffers.  If I press RET or TAB, I can be
;; prompted to create a new buffer called "234a".
;;
;; Of course, where this function comes in really useful is when you
;; can specify the buffer using only a few keystrokes.  In the above
;; example, the quickest way to get to the "123456" file would be
;; just to type 4 and then RET (assuming there isn't any newer buffer
;; with 4 in its name).

;; Likewise, if you use C-x C-f (ido-find-file), the list of files and
;; directories in the current directory is provided in the same
;; fashion as the buffers above.  The files and directories are
;; normally sorted in alphabetical order, but the most recently
;; visited directory is placed first to speed up navigating to
;; directories that you have visited recently.
;;
;; In addition to scrolling through the list using [right] and [left],
;; you can use [up] and [down] to quickly scroll the list to the next
;; or previous subdirectory.
;;
;; To go down into a subdirectory, and continue the file selection on
;; the files in that directory, simply move the directory to the head
;; of the list and hit RET.
;;
;; To go up to the parent directory, delete any partial file name
;; already specified (e.g. using [backspace]) and hit [backspace].
;;
;; To go to the root directory (on the current drive), enter two
;; slashes.  On MS-DOS or Windows, to select the root of another
;; drive, enter X:/ where X is the drive letter.  You can also visit
;; files on other hosts using the ange-ftp notations `/host:' and
;; `/user@host:'.  See the variable `ido-slow-ftp-hosts' if you want
123
;; to inhibit the ido substring matching for ftp access.
Kim F. Storm's avatar
Kim F. Storm committed
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
;;
;; If for some reason you cannot specify the proper file using
;; ido-find-file, you can press C-f to enter the normal find-file.
;; You can also press C-b to drop into ido-switch-buffer.

;; See the doc string of ido-switch-buffer and ido-find-file for full
;; keybindings and features.
;;  (describe-function 'ido-find-file)

;; Hidden buffers and files
;; ------------------------
;;
;; Normally, ido does not include hidden buffers (whose name starts
;; with a space) and hidden files and directories (whose name starts
;; with `.') in the list of possible completions.  However, if the
;; substring you enter does not match any of the visible buffers or
;; files, ido will automatically look for completions among the hidden
;; buffers or files.
;;
;; You can toggle display of the hidden buffers and files with C-a.

;; Additional functionality
;; ------------------------
;;
;; After C-x b, the buffer at the head of the list can be killed by
;; pressing C-k.  If the buffer needs saving, you will be queried
;; before the buffer is killed.
;;
;; Likewise, after C-x C-f, you can delete (i.e. physically remove)
;; the file at the head of the list with C-k.  You will always be
;; asked for confirmation before the file is deleted.
;;
;; If you enter C-x b to switch to a buffer visiting a given file, and
;; you find that the file you are after is not in any buffer, you can
;; press C-f to immediately drop into ido-find-file.  And you can
;; switch back to buffer selection with C-b.

;; Prefix matching
;; ---------------
;;
;; The standard way of completion with Unix-shells and Emacs is to insert a
;; PREFIX and then hitting TAB (or another completion key). Cause of this
;; behavior has become second nature to a lot of emacs users `ido' offers in
;; addition to the default substring-matching-method (look above) also the
;; prefix-matching-method. The kind of matching is the only difference to
;; the description of the substring-matching above.
;;
;; You can toggle prefix matching with C-p.
;;
;; Example:
;;
;; If you have again two Buffers "123456" and "123" then hitting "2" does
Kim F. Storm's avatar
Kim F. Storm committed
176
;; not match because "2" is not a PREFIX in any of the buffer-names.
Kim F. Storm's avatar
Kim F. Storm committed
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200

;; Flexible matching
;; -----------------
;;
;; If you set ido-enable-flex-matching, ido will do a more flexible
;; matching (unless regexp matching is active) to find possible matches
;; among the available buffer or file names if no matches are found using
;; the normal prefix or substring matching.
;;
;; The flexible matching implies that any item which simply contains all
;; of the entered characters in the specified sequence will match.
;;
;; Example:
;;
;; If you have four files "alpha", "beta", "gamma", and "delta",
;; entering "aa" will match "alpha" and "gamma", while "ea" matches
;; "beta" and "delta".  If prefix matching is also active, "aa" only
;; matches "alpha", while "ea" does not match any files.

;; Regexp matching
;; ---------------
;;
;; There is limited provision for regexp matching within ido,
;; enabled through `ido-enable-regexp' (toggle with C-t).
Kim F. Storm's avatar
Kim F. Storm committed
201 202 203 204
;; This allows you to type `[ch]$' for example and see all file names
;; ending in `c' or `h'.
;;
;; Note: ido-style completion is inhibited when you enable regexp matching.
Kim F. Storm's avatar
Kim F. Storm committed
205 206 207 208 209 210 211


;; Customization
;; -------------
;;
;; Customize the `ido' group to change the `ido' functionality.
;;
Kim F. Storm's avatar
Kim F. Storm committed
212 213
;; To modify the keybindings, use the ido-setup-hook.  For example:
;;(add-hook 'ido-setup-hook 'ido-my-keys)
Kim F. Storm's avatar
Kim F. Storm committed
214 215 216
;;
;;(defun ido-my-keys ()
;;  "Add my keybindings for ido."
217
;;  (define-key ido-completion-map " " 'ido-next-match)
Kim F. Storm's avatar
Kim F. Storm committed
218 219 220 221 222 223 224 225 226 227
;;  )

;; Seeing all the matching buffers or files
;; ----------------------------------------
;;
;; If you have many matching files, they may not all fit onto one
;; line of the minibuffer.  Normally, the minibuffer window will grow
;; to show you more of the matching files (depending on the setting
;; of the variables `resize-mini-windows' and `max-mini-window-height').
;; If you want ido to behave differently from the default minibuffer
Glenn Morris's avatar
Glenn Morris committed
228
;; resizing behavior, set the variable `ido-max-window-height'.
Kim F. Storm's avatar
Kim F. Storm committed
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251
;;
;; Also, to improve the responsiveness of ido, the maximum number of
;; matching items is limited to 12, but you can increase or removed
;; this limit via the `ido-max-prospects' variable.

;; To see a full list of all matching buffers in a separate buffer,
;; hit ? or press TAB when there are no further completions to the
;; substring.  Repeated TAB presses will scroll you through this
;; separate buffer.

;; Changing the list of files
;; --------------------------

;; By default, the list of current files is most recent first,
;; oldest last, with the exception that the files visible in the
;; current frame are put at the end of the list.  A hook exists to
;; allow other functions to order the list.  For example, if you add:
;;
;; (add-hook 'ido-make-buffer-list-hook 'ido-summary-buffers-to-end)
;;
;; then all files matching "Summary" are moved to the end of the
;; list.  (I find this handy for keeping the INBOX Summary and so on
;; out of the way.)  It also moves files matching "output\*$" to the
David Kastrup's avatar
David Kastrup committed
252
;; end of the list (these are created by AUCTeX when compiling.)
Kim F. Storm's avatar
Kim F. Storm committed
253 254 255 256 257 258 259
;; Other functions could be made available which alter the list of
;; matching files (either deleting or rearranging elements.)

;; Highlighting
;; ------------

;; The highlighting of matching items is controlled via ido-use-faces.
260 261
;; The faces used are ido-first-match, ido-only-match and
;; ido-subdir.
Kim F. Storm's avatar
Kim F. Storm committed
262 263 264 265 266 267 268 269 270 271 272 273 274
;; Colouring of the matching item was suggested by
;; Carsten Dominik (dominik@strw.leidenuniv.nl).

;; Replacement for read-buffer and read-file-name
;; ----------------------------------------------

;; ido-read-buffer and ido-read-file-name have been written to be drop
;; in replacements for the normal buffer and file name reading
;; functions `read-buffer' and `read-file-name'.

;; To use ido for all buffer and file selections in Emacs, customize the
;; variable `ido-everywhere'.

Glenn Morris's avatar
Glenn Morris committed
275
;; Using ido-like behavior in other lisp packages
Kim F. Storm's avatar
Kim F. Storm committed
276 277 278 279 280 281 282
;; -----------------------------------------------

;; If you don't want to rely on the `ido-everywhere' functionality,
;; ido-read-buffer, ido-read-file-name, and ido-read-directory-name
;; can be used by other packages to read a buffer name, a file name,
;; or a directory name in the `ido' way.

283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321
;;; Acknowledgements

;; Infinite amounts of gratitude goes to Stephen Eglen <stephen@cns.ed.ac.uk>
;; who wrote iswitch-buffer mode - from which I ripped off 99% of the code
;; for ido-switch-buffer and found the inspiration for ido-find-file.
;; The ido package would never have existed without his work.

;; Also thanks to Klaus Berndl, Rohit Namjoshi, Robert Fenk, Alex
;; Schroeder, Bill Benedetto, Stephen Eglen, and many others for bug
;; fixes and improvements.

;;; History

;; Since I discovered Stephen Eglen's excellent iswitchb package, I just
;; couldn't live without it, but once being addicted to switching buffers
;; with a minimum of keystrokes, I soon found that opening files in the
;; old-fashioned way was just too slow - so I decided to write a package
;; which could open files with the same speed and ease as iswitchb could
;; switch buffers.

;; I originally wrote a separate ifindf.el package based on a copy of
;; iswitchb.el, which did for opening files what iswitchb did for
;; switching buffers.  Along the way, I corrected a few errors in
;; ifindf which could have found its way back into iswitchb, but since
;; most of the functionality of the two package was practically
;; identical, I decided that the proper thing to do was to merge my
;; ifindf package back into iswitchb.
;;
;; This is basically what ido (interactively do) is all about; but I
;; found it ackward to merge my changes into the "iswitchb-" namespace,
;; so I invented a common "ido-" namespace for the merged packages.
;;
;; This version is based on ido.el version 1.57 released on
;; gnu.emacs.sources adapted for emacs 22.1 to use command remapping
;; and optionally hooking the read-buffer and read-file-name functions.
;;
;; Prefix matching was added by Klaus Berndl <klaus.berndl@sdm.de> based on
;; an idea of Yuji Minejima <ggb01164@nifty.ne.jp> and his mcomplete-package.

Kim F. Storm's avatar
Kim F. Storm committed
322 323 324

;;; Code:

325
(defvar recentf-list)
326

Kim F. Storm's avatar
Kim F. Storm committed
327 328 329 330 331 332 333 334 335 336 337
;;; User Variables
;;
;; These are some things you might want to change.

(defun ido-fractionp (n)
  (and (numberp n) (> n 0.0) (<= n 1.0)))

(defgroup ido nil
  "Switch between files using substrings."
  :group 'extensions
  :group 'convenience
338
  :version "22.1"
Kim F. Storm's avatar
Kim F. Storm committed
339 340 341 342 343 344
  :link '(emacs-commentary-link :tag "Commentary" "ido.el")
  :link '(emacs-library-link :tag "Lisp File" "ido.el"))

;;;###autoload
(defcustom ido-mode nil
  "Determines for which functional group \(buffer and files) ido behavior
345
should be enabled.  The following values are possible:
Richard M. Stallman's avatar
Richard M. Stallman committed
346
- `buffer': Turn only on ido buffer behavior \(switching, killing,
347
  displaying...)
Richard M. Stallman's avatar
Richard M. Stallman committed
348 349 350
- `file': Turn only on ido file behavior \(finding, writing, inserting...)
- `both': Turn on ido buffer and file behavior.
- `nil': Turn off any ido switching.
Kim F. Storm's avatar
Kim F. Storm committed
351 352 353 354 355

Setting this variable directly does not take effect;
use either \\[customize] or the function `ido-mode'."
  :set #'(lambda (symbol value)
	   (ido-mode value))
356
  :initialize 'custom-initialize-default
Kim F. Storm's avatar
Kim F. Storm committed
357 358
  :require 'ido
  :link '(emacs-commentary-link "ido.el")
359
  :set-after '(ido-save-directory-list-file
360
	       ;; This will clear ido-unc-hosts-cache, so set it
361
	       ;; before loading history file.
362
	       ido-unc-hosts)
363
  :type '(choice (const :tag "Turn on only buffer" buffer)
Kim F. Storm's avatar
Kim F. Storm committed
364 365 366 367 368 369
                 (const :tag "Turn on only file" file)
                 (const :tag "Turn on both buffer and file" both)
                 (const :tag "Switch off all" nil))
  :group 'ido)

(defcustom ido-case-fold case-fold-search
Lute Kamstra's avatar
Lute Kamstra committed
370
  "Non-nil if searching of buffer and file names should ignore case."
Kim F. Storm's avatar
Kim F. Storm committed
371 372 373 374 375
  :type 'boolean
  :group 'ido)

(defcustom ido-ignore-buffers
  '("\\` ")
Lute Kamstra's avatar
Lute Kamstra committed
376
  "List of regexps or functions matching buffer names to ignore.
Kim F. Storm's avatar
Kim F. Storm committed
377 378
For example, traditional behavior is not to list buffers whose names begin
with a space, for which the regexp is `\\` '.  See the source file for
379
example functions that filter buffer names."
Kim F. Storm's avatar
Kim F. Storm committed
380 381 382 383 384
  :type '(repeat (choice regexp function))
  :group 'ido)

(defcustom ido-ignore-files
  '("\\`CVS/" "\\`#" "\\`.#" "\\`\\.\\./" "\\`\\./")
Lute Kamstra's avatar
Lute Kamstra committed
385
  "List of regexps or functions matching file names to ignore.
Kim F. Storm's avatar
Kim F. Storm committed
386 387 388 389 390 391 392
For example, traditional behavior is not to list files whose names begin
with a #, for which the regexp is `\\`#'.  See the source file for
example functions that filter filenames."
  :type '(repeat (choice regexp function))
  :group 'ido)

(defcustom ido-ignore-extensions t
Lute Kamstra's avatar
Lute Kamstra committed
393
  "Non-nil means ignore files in `completion-ignored-extensions' list."
Kim F. Storm's avatar
Kim F. Storm committed
394 395 396 397
  :type 'boolean
  :group 'ido)

(defcustom ido-show-dot-for-dired nil
Lute Kamstra's avatar
Lute Kamstra committed
398
  "Non-nil means to always put . as the first item in file name lists.
399
This allows the current directory to be opened immediately with `dired'."
Kim F. Storm's avatar
Kim F. Storm committed
400 401 402
  :type 'boolean
  :group 'ido)

403
(defcustom ido-file-extensions-order nil
Lute Kamstra's avatar
Lute Kamstra committed
404
  "List of file extensions specifying preferred order of file selections.
405 406
Each element is either a string with `.' as the first char, an empty
string matching files without extension, or t which is the default order
407
for files with an unlisted file extension."
408 409 410 411
  :type '(repeat (choice string
			 (const :tag "Default order" t)))
  :group 'ido)

Kim F. Storm's avatar
Kim F. Storm committed
412 413
(defcustom ido-ignore-directories
  '("\\`CVS/" "\\`\\.\\./" "\\`\\./")
Lute Kamstra's avatar
Lute Kamstra committed
414
  "List of regexps or functions matching sub-directory names to ignore."
Kim F. Storm's avatar
Kim F. Storm committed
415 416 417 418
  :type '(repeat (choice regexp function))
  :group 'ido)

(defcustom ido-ignore-directories-merge nil
Lute Kamstra's avatar
Lute Kamstra committed
419
  "List of regexps or functions matching directory names to ignore during merge.
420
Directory names matched by one of the regexps in this list are not inserted
Kim F. Storm's avatar
Kim F. Storm committed
421 422 423 424
in merged file and directory lists."
  :type '(repeat (choice regexp function))
  :group 'ido)

425 426 427 428 429 430 431
;; Examples for setting the value of ido-ignore-buffers
;;(defun ido-ignore-c-mode (name)
;;  "Ignore all c mode buffers -- example function for ido."
;;  (with-current-buffer name
;;    (derived-mode-p 'c-mode)))
;;
;;(setq ido-ignore-buffers '("^ " ido-ignore-c-mode))
Kim F. Storm's avatar
Kim F. Storm committed
432

433 434
;; Examples for setting the value of ido-ignore-files
;;(setq ido-ignore-files '("^ " "\\.c\\'" "\\.h\\'"))
Kim F. Storm's avatar
Kim F. Storm committed
435

436
(defcustom ido-default-file-method  'raise-frame
Lute Kamstra's avatar
Lute Kamstra committed
437
  "How to visit a new file when using `ido-find-file'.
Kim F. Storm's avatar
Kim F. Storm committed
438
Possible values:
439 440 441 442 443 444 445 446 447 448 449 450 451 452 453
`selected-window' Show new file in selected window
`other-window'	  Show new file in another window (same frame)
`display'	  Display file in another window without selecting to it
`other-frame'	  Show new file in another frame
`maybe-frame'	  If a file is visible in another frame, prompt to ask if you
		  you want to see the file in the same window of the current
  		  frame or in the other frame
`raise-frame'     If a file is visible in another frame, raise that
		  frame; otherwise, visit the file in the same window"
    :type '(choice (const :tag "Visit in selected window" selected-window)
		   (const :tag "Visit in other window" other-window)
		   (const :tag "Display (no select) in other window" display)
		   (const :tag "Visit in other frame" other-frame)
		   (const :tag "Ask to visit in other frame" maybe-frame)
		   (const :tag "Raise frame if already visited" raise-frame))
Kim F. Storm's avatar
Kim F. Storm committed
454 455
    :group 'ido)

456
(defcustom ido-default-buffer-method  'raise-frame
Lute Kamstra's avatar
Lute Kamstra committed
457
  "How to switch to new buffer when using `ido-switch-buffer'.
458
See `ido-default-file-method' for details."
459 460 461 462 463 464 465 466
    :type '(choice (const :tag "Show in selected window" selected-window)
		   (const :tag "Show in other window" other-window)
		   (const :tag "Display (no select) in other window" display)
		   (const :tag "Show in other frame" other-frame)
		   (const :tag "Ask to show in other frame" maybe-frame)
		   (const :tag "Raise frame if already shown" raise-frame))
    :type '(choice (const selected-window)
		   (const other-window)
Kim F. Storm's avatar
Kim F. Storm committed
467
		   (const display)
468
		   (const other-frame)
Kim F. Storm's avatar
Kim F. Storm committed
469
		   (const maybe-frame)
470
		   (const raise-frame))
Kim F. Storm's avatar
Kim F. Storm committed
471 472 473
    :group 'ido)

(defcustom ido-enable-flex-matching nil
Lute Kamstra's avatar
Lute Kamstra committed
474
  "Non-nil means that `ido' will do flexible string matching.
Kim F. Storm's avatar
Kim F. Storm committed
475 476 477 478 479 480 481 482
Flexible matching means that if the entered string does not
match any item, any item containing the entered characters
in the given sequence will match."
  :type 'boolean
  :group 'ido)


(defcustom ido-enable-regexp nil
Lute Kamstra's avatar
Lute Kamstra committed
483
  "Non-nil means that `ido' will do regexp matching.
Kim F. Storm's avatar
Kim F. Storm committed
484 485 486 487 488
Value can be toggled within `ido' using `ido-toggle-regexp'."
  :type 'boolean
  :group 'ido)

(defcustom ido-enable-prefix nil
Lute Kamstra's avatar
Lute Kamstra committed
489
  "Non-nil means only match if the entered text is a prefix of file name.
490
This behavior is like the standard Emacs completion.
491
If nil, match if the entered text is an arbitrary substring.
Kim F. Storm's avatar
Kim F. Storm committed
492 493 494 495
Value can be toggled within `ido' using `ido-toggle-prefix'."
  :type 'boolean
  :group 'ido)

496
(defcustom ido-enable-dot-prefix nil
Lute Kamstra's avatar
Lute Kamstra committed
497
  "Non-nil means to match leading dot as prefix.
498 499 500 501 502
I.e. hidden files and buffers will match only if you type a dot
as first char even if `ido-enable-prefix' is nil."
  :type 'boolean
  :group 'ido)

503
(defcustom ido-confirm-unique-completion nil
Lute Kamstra's avatar
Lute Kamstra committed
504
  "Non-nil means that even a unique completion must be confirmed.
505 506 507 508 509
This means that \\[ido-complete] must always be followed by \\[ido-exit-minibuffer]
even when there is only one unique completion."
  :type 'boolean
  :group 'ido)

510
(defcustom ido-cannot-complete-command 'ido-completion-help
Lute Kamstra's avatar
Lute Kamstra committed
511
  "Command run when `ido-complete' can't complete any more.
512 513 514 515 516 517 518
The most useful values are `ido-completion-help', which pops up a
window with completion alternatives, or `ido-next-match' or
`ido-prev-match', which cycle the buffer list."
  :type 'function
  :group 'ido)


Kim F. Storm's avatar
Kim F. Storm committed
519
(defcustom ido-record-commands t
Lute Kamstra's avatar
Lute Kamstra committed
520
  "Non-nil means that `ido' will record commands in command history.
Kim F. Storm's avatar
Kim F. Storm committed
521 522 523 524 525
Note that the non-ido equivalent command is recorded."
  :type 'boolean
  :group 'ido)

(defcustom ido-max-prospects 12
Lute Kamstra's avatar
Lute Kamstra committed
526
  "Non-zero means that the prospect list will be limited to that number of items.
Kim F. Storm's avatar
Kim F. Storm committed
527
For a long list of prospects, building the full list for the minibuffer can take a
528
non-negligible amount of time; setting this variable reduces that time."
Kim F. Storm's avatar
Kim F. Storm committed
529 530 531
  :type 'integer
  :group 'ido)

532
(defcustom ido-max-file-prompt-width 0.35
Lute Kamstra's avatar
Lute Kamstra committed
533
  "Non-zero means that the prompt string be limited to that number of characters.
Kim F. Storm's avatar
Kim F. Storm committed
534 535 536 537 538 539 540 541 542
If value is a floating point number, it specifies a fraction of the frame width."
  :type '(choice
	  (integer :tag "Characters" :value 20)
	  (restricted-sexp :tag "Fraction of frame width"
			   :value 0.35
			   :match-alternatives (ido-fractionp)))
  :group 'ido)

(defcustom ido-max-window-height nil
Lute Kamstra's avatar
Lute Kamstra committed
543
  "Non-nil specifies a value to override `max-mini-window-height'."
Kim F. Storm's avatar
Kim F. Storm committed
544 545 546 547 548 549 550 551 552 553
  :type '(choice
	  (const :tag "Don't override" nil)
	  (integer :tag "Number of lines" :value 1)
	  (restricted-sexp
	   :tag "Fraction of window height"
	   :value 0.25
	   :match-alternatives (ido-fractionp)))
  :group 'ido)

(defcustom ido-enable-last-directory-history t
Lute Kamstra's avatar
Lute Kamstra committed
554
  "Non-nil means that `ido' will remember latest selected directory names.
Kim F. Storm's avatar
Kim F. Storm committed
555 556 557 558 559
See `ido-last-directory-list' and `ido-save-directory-list-file'."
  :type 'boolean
  :group 'ido)

(defcustom ido-max-work-directory-list 50
Lute Kamstra's avatar
Lute Kamstra committed
560
  "Maximum number of working directories to record.
Kim F. Storm's avatar
Kim F. Storm committed
561 562 563 564 565 566
This is the list of directories where files have most recently been opened.
See `ido-work-directory-list' and `ido-save-directory-list-file'."
  :type 'integer
  :group 'ido)

(defcustom ido-work-directory-list-ignore-regexps nil
Lute Kamstra's avatar
Lute Kamstra committed
567
  "List of regexps matching directories which should not be recorded.
568
Directory names matched by one of the regexps in this list are not inserted in
Kim F. Storm's avatar
Kim F. Storm committed
569 570 571 572
the `ido-work-directory-list' list."
  :type '(repeat regexp)
  :group 'ido)

573

574
(defcustom ido-use-filename-at-point nil
Lute Kamstra's avatar
Lute Kamstra committed
575
  "Non-nil means that ido shall look for a filename at point.
576
May use `ffap-guesser' to guess whether text at point is a filename.
577
If found, use that as the starting point for filename selection."
578 579 580 581
  :type '(choice
	  (const :tag "Disabled" nil)
	  (const :tag "Guess filename" guess)
	  (other :tag "Use literal filename" t))
582 583 584 585
  :group 'ido)


(defcustom ido-use-url-at-point nil
Lute Kamstra's avatar
Lute Kamstra committed
586
  "Non-nil means that ido shall look for a URL at point.
587 588 589 590 591
If found, call `find-file-at-point' to visit it."
  :type 'boolean
  :group 'ido)


592
(defcustom ido-enable-tramp-completion t
Lute Kamstra's avatar
Lute Kamstra committed
593
  "Non-nil means that ido shall perform tramp method and server name completion.
594
A tramp file name uses the following syntax: /method:user@host:filename."
595 596 597
  :type 'boolean
  :group 'ido)

Kim F. Storm's avatar
Kim F. Storm committed
598
(defcustom ido-record-ftp-work-directories t
Lute Kamstra's avatar
Lute Kamstra committed
599
  "Non-nil means record ftp file names in the work directory list."
Kim F. Storm's avatar
Kim F. Storm committed
600 601 602 603
  :type 'boolean
  :group 'ido)

(defcustom ido-merge-ftp-work-directories nil
Lute Kamstra's avatar
Lute Kamstra committed
604
  "If nil, merging ignores ftp file names in the work directory list."
Kim F. Storm's avatar
Kim F. Storm committed
605 606 607 608
  :type 'boolean
  :group 'ido)

(defcustom ido-cache-ftp-work-directory-time 1.0
Lute Kamstra's avatar
Lute Kamstra committed
609
  "Maximum time to cache contents of an ftp directory (in hours).
610
Use C-l in prompt to refresh list.
Kim F. Storm's avatar
Kim F. Storm committed
611 612 613 614 615
If zero, ftp directories are not cached."
  :type 'number
  :group 'ido)

(defcustom ido-slow-ftp-hosts nil
Lute Kamstra's avatar
Lute Kamstra committed
616
  "List of slow ftp hosts where ido prompting should not be used.
Kim F. Storm's avatar
Kim F. Storm committed
617
If an ftp host is on this list, ido automatically switches to the non-ido
618
equivalent function, e.g. `find-file' rather than `ido-find-file'."
Kim F. Storm's avatar
Kim F. Storm committed
619 620 621 622
  :type '(repeat string)
  :group 'ido)

(defcustom ido-slow-ftp-host-regexps nil
Lute Kamstra's avatar
Lute Kamstra committed
623
  "List of regexps matching slow ftp hosts (see `ido-slow-ftp-hosts')."
Kim F. Storm's avatar
Kim F. Storm committed
624 625 626
  :type '(repeat regexp)
  :group 'ido)

627
(defvar ido-unc-hosts-cache t
628
  "Cached value from `ido-unc-hosts' function.")
629

630
(defcustom ido-unc-hosts nil
Lute Kamstra's avatar
Lute Kamstra committed
631
  "List of known UNC host names to complete after initial //.
632 633 634 635 636 637 638 639 640 641 642
If value is a function, that function is called to search network for
hosts on first use of UNC path."
  :type '(choice (repeat :tag "List of UNC host names" string)
		 (function-item :tag "Use `NET VIEW'"
				:value ido-unc-hosts-net-view)
		 (function :tag "Your own function"))
  :set #'(lambda (symbol value)
	   (set symbol value)
	   (setq ido-unc-hosts-cache t))
  :group 'ido)

643
(defcustom ido-downcase-unc-hosts t
Lute Kamstra's avatar
Lute Kamstra committed
644
  "Non-nil if UNC host names should be downcased."
645 646 647
  :type 'boolean
  :group 'ido)

648
(defcustom ido-ignore-unc-host-regexps nil
Lute Kamstra's avatar
Lute Kamstra committed
649
  "List of regexps matching UNC hosts to ignore.
650
Case is ignored if `ido-downcase-unc-hosts' is set."
651
  :type '(repeat regexp)
652 653 654
  :group 'ido)

(defcustom ido-cache-unc-host-shares-time 8.0
Lute Kamstra's avatar
Lute Kamstra committed
655
  "Maximum time to cache shares of an UNC host (in hours).
656
Use C-l in prompt to refresh list.
657
If zero, UNC host shares are not cached."
658 659 660
  :type 'number
  :group 'ido)

Kim F. Storm's avatar
Kim F. Storm committed
661
(defcustom ido-max-work-file-list 10
Lute Kamstra's avatar
Lute Kamstra committed
662
  "Maximum number of names of recently opened files to record.
663
This is the list of the file names (sans directory) which have most recently
664
been opened.  See `ido-work-file-list' and `ido-save-directory-list-file'."
Kim F. Storm's avatar
Kim F. Storm committed
665 666 667 668
  :type 'integer
  :group 'ido)

(defcustom ido-work-directory-match-only t
Lute Kamstra's avatar
Lute Kamstra committed
669
  "Non-nil means to skip non-matching directories in the directory history.
Kim F. Storm's avatar
Kim F. Storm committed
670 671 672 673 674 675 676
When some text is already entered at the `ido-find-file' prompt, using
\\[ido-prev-work-directory] or \\[ido-next-work-directory] will skip directories
without any matching entries."
  :type 'boolean
  :group 'ido)

(defcustom ido-auto-merge-work-directories-length 0
Lute Kamstra's avatar
Lute Kamstra committed
677
  "Automatically switch to merged work directories during file name input.
Kim F. Storm's avatar
Kim F. Storm committed
678 679 680 681 682 683 684
The value is number of characters to type before switching to merged mode.
If zero, the switch happens when no matches are found in the current directory.
Automatic merging is disabled if the value is negative."
  :type 'integer
  :group 'ido)

(defcustom ido-auto-merge-delay-time 0.70
Lute Kamstra's avatar
Lute Kamstra committed
685
  "Delay in seconds to wait for more input before doing auto merge."
Kim F. Storm's avatar
Kim F. Storm committed
686 687 688 689
  :type 'number
  :group 'ido)

(defcustom ido-auto-merge-inhibit-characters-regexp "[][*?~]"
Lute Kamstra's avatar
Lute Kamstra committed
690
  "Regexp matching characters which should inhibit automatic merging.
Kim F. Storm's avatar
Kim F. Storm committed
691 692 693 694 695 696 697 698 699 700
When a (partial) file name matches this regexp, merging is inhibited."
  :type 'regexp
  :group 'ido)

(defcustom ido-merged-indicator "^"
  "The string appended to first choice if it has multiple directory choices."
  :type 'string
  :group 'ido)

(defcustom ido-max-dir-file-cache 100
Lute Kamstra's avatar
Lute Kamstra committed
701
  "Maximum number of working directories to be cached.
702
This is the size of the cache of `file-name-all-completions' results.
Kim F. Storm's avatar
Kim F. Storm committed
703 704 705 706 707 708 709 710 711
Each cache entry is time stamped with the modification time of the
directory.  Some systems, like Windows, have unreliable directory
modification times, so you may choose to disable caching on such
systems, or explicitly refresh the cache contents using the command
`ido-reread-directory' command (C-l) in the minibuffer.
See also `ido-dir-file-cache' and `ido-save-directory-list-file'."
  :type 'integer
  :group 'ido)

712
(defcustom ido-max-directory-size 30000
Lute Kamstra's avatar
Lute Kamstra committed
713
  "Maximum size (in bytes) for directories to use ido completion.
714 715 716 717 718 719
If you enter a directory with a size larger than this size, ido will
not provide the normal completion.  To show the completions, use C-a."
  :type '(choice (const :tag "No limit" nil)
		 (integer :tag "Size in bytes" 30000))
  :group 'ido)

Kim F. Storm's avatar
Kim F. Storm committed
720
(defcustom ido-rotate-file-list-default nil
Lute Kamstra's avatar
Lute Kamstra committed
721
  "Non-nil means that `ido' will always rotate file list to get default in front."
Kim F. Storm's avatar
Kim F. Storm committed
722 723 724
  :type 'boolean
  :group 'ido)

725
(defcustom ido-enter-matching-directory 'only
Lute Kamstra's avatar
Lute Kamstra committed
726
  "Additional methods to enter sub-directory of first/only matching item.
727 728 729 730 731
If value is 'first, enter first matching sub-directory when typing a slash.
If value is 'only, typing a slash only enters the sub-directory if it is
the only matching item.
If value is t, automatically enter a sub-directory when it is the only
matching item, even without typing a slash."
732
  :type '(choice (const :tag "Never" nil)
733 734 735
		 (const :tag "Slash enters first directory" first)
		 (const :tag "Slash enters first and only directory" only)
		 (other :tag "Always enter unique directory" t))
Kim F. Storm's avatar
Kim F. Storm committed
736 737 738
  :group 'ido)

(defcustom ido-create-new-buffer 'prompt
Lute Kamstra's avatar
Lute Kamstra committed
739
  "Specify whether a new buffer is created if no buffer matches substring.
Kim F. Storm's avatar
Kim F. Storm committed
740 741
Choices are 'always to create new buffers unconditionally, 'prompt to
ask user whether to create buffer, or 'never to never create new buffer."
742
  :type '(choice (const always)
Kim F. Storm's avatar
Kim F. Storm committed
743 744 745 746
		 (const prompt)
		 (const never))
  :group 'ido)

Kim F. Storm's avatar
Kim F. Storm committed
747
(defcustom ido-setup-hook  nil
Lute Kamstra's avatar
Lute Kamstra committed
748
  "Hook run after the ido variables and keymap have been setup.
Kim F. Storm's avatar
Kim F. Storm committed
749
The dynamic variable `ido-cur-item' contains the current type of item that
750
is read by ido; possible values are file, dir, buffer, and list.
751
Additional keys can be defined in `ido-completion-map'."
Kim F. Storm's avatar
Kim F. Storm committed
752 753 754 755
  :type 'hook
  :group 'ido)

(defcustom ido-separator nil
Lute Kamstra's avatar
Lute Kamstra committed
756
  "String used by ido to separate the alternatives in the minibuffer.
Kim F. Storm's avatar
Kim F. Storm committed
757
Obsolete.  Set 3rd element of `ido-decorations' instead."
Markus Rost's avatar
Markus Rost committed
758
  :type '(choice string (const nil))
Kim F. Storm's avatar
Kim F. Storm committed
759 760
  :group 'ido)

761
(defcustom ido-decorations '( "{" "}" " | " " | ..." "[" "]" " [No match]" " [Matched]" " [Not readable]" " [Too big]" " [Confirm]")
Lute Kamstra's avatar
Lute Kamstra committed
762
  "List of strings used by ido to display the alternatives in the minibuffer.
Kim F. Storm's avatar
Kim F. Storm committed
763
There are 11 elements in this list:
Kim F. Storm's avatar
Kim F. Storm committed
764
1st and 2nd elements are used as brackets around the prospect list,
765
3rd element is the separator between prospects (ignored if `ido-separator' is set),
Kim F. Storm's avatar
Kim F. Storm committed
766 767 768
4th element is the string inserted at the end of a truncated list of prospects,
5th and 6th elements are used as brackets around the common match string which
can be completed using TAB,
769 770 771
7th element is the string displayed when there are no matches, and
8th element is displayed if there is a single match (and faces are not used),
9th element is displayed when the current directory is non-readable,
772 773
10th element is displayed when directory exceeds `ido-max-directory-size',
11th element is displayed to confirm creating new file or buffer."
Kim F. Storm's avatar
Kim F. Storm committed
774 775 776
  :type '(repeat string)
  :group 'ido)

777 778
(defcustom ido-use-virtual-buffers nil
  "If non-nil, refer to past buffers as well as existing ones.
779 780 781 782 783 784 785 786 787 788 789
Essentially it works as follows: Say you are visiting a file and
the buffer gets cleaned up by mignight.el.  Later, you want to
switch to that buffer, but find it's no longer open.  With
virtual buffers enabled, the buffer name stays in the buffer
list (using the ido-virtual face, and always at the end), and if
you select it, it opens the file back up again.  This allows you
to think less about whether recently opened files are still open
or not.  Most of the time you can quit Emacs, restart, and then
switch to a file buffer that was previously open as if it still
were.
    This feature relies upon the `recentf' package, which will be
790
enabled if this variable is configured to a non-nil value."
791
  :version "24.1"
792 793 794
  :type 'boolean
  :group 'ido)

Kim F. Storm's avatar
Kim F. Storm committed
795
(defcustom ido-use-faces t
Lute Kamstra's avatar
Lute Kamstra committed
796
  "Non-nil means use ido faces to highlighting first match, only match and
Kim F. Storm's avatar
Kim F. Storm committed
797 798 799 800
subdirs in the alternatives."
  :type 'boolean
  :group 'ido)

801
(defface ido-first-match  '((t (:bold t)))
Lute Kamstra's avatar
Lute Kamstra committed
802
  "Face used by ido for highlighting first match."
Kim F. Storm's avatar
Kim F. Storm committed
803 804
  :group 'ido)

805
(defface ido-only-match  '((((class color))
Kim F. Storm's avatar
Kim F. Storm committed
806 807
                                 (:foreground "ForestGreen"))
                                (t (:italic t)))
Lute Kamstra's avatar
Lute Kamstra committed
808
  "Face used by ido for highlighting only match."
Kim F. Storm's avatar
Kim F. Storm committed
809 810
  :group 'ido)

811
(defface ido-subdir  '((((min-colors 88) (class color))
812 813
                             (:foreground "red1"))
			    (((class color))
Kim F. Storm's avatar
Kim F. Storm committed
814 815
                             (:foreground "red"))
                            (t (:underline t)))
Lute Kamstra's avatar
Lute Kamstra committed
816
  "Face used by ido for highlighting subdirs in the alternatives."
Kim F. Storm's avatar
Kim F. Storm committed
817 818
  :group 'ido)

819 820
(defface ido-virtual '((t (:inherit font-lock-builtin-face)))
  "Face used by ido for matching virtual buffer names."
821
  :version "24.1"
822 823
  :group 'ido)

824
(defface ido-indicator  '((((min-colors 88) (class color))
825 826 827 828
				(:foreground "yellow1"
				 :background "red1"
				 :width condensed))
			       (((class color))
Kim F. Storm's avatar
Kim F. Storm committed
829 830 831 832
				(:foreground "yellow"
				 :background "red"
				 :width condensed))
			       (t (:inverse-video t)))
Lute Kamstra's avatar
Lute Kamstra committed
833
  "Face used by ido for highlighting its indicators."
Kim F. Storm's avatar
Kim F. Storm committed
834 835
  :group 'ido)

836 837 838 839 840 841
(defface ido-incomplete-regexp
  '((t
     (:inherit font-lock-warning-face)))
  "Ido face for indicating incomplete regexps."
  :group 'ido)

Kim F. Storm's avatar
Kim F. Storm committed
842
(defcustom ido-make-file-list-hook  nil
Lute Kamstra's avatar
Lute Kamstra committed
843
  "List of functions to run when the list of matching files is created.
Kim F. Storm's avatar
Kim F. Storm committed
844 845 846 847 848 849
Each function on the list may modify the dynamically bound variable
`ido-temp-list' which contains the current list of matching files."
  :type 'hook
  :group 'ido)

(defcustom ido-make-dir-list-hook  nil
Lute Kamstra's avatar
Lute Kamstra committed
850
  "List of functions to run when the list of matching directories is created.
Kim F. Storm's avatar
Kim F. Storm committed
851 852 853 854 855 856
Each function on the list may modify the dynamically bound variable
`ido-temp-list' which contains the current list of matching directories."
  :type 'hook
  :group 'ido)

(defcustom ido-make-buffer-list-hook  nil
Lute Kamstra's avatar
Lute Kamstra committed
857
  "List of functions to run when the list of matching buffers is created.
Kim F. Storm's avatar
Kim F. Storm committed
858 859 860 861 862
Each function on the list may modify the dynamically bound variable
`ido-temp-list' which contains the current list of matching buffer names."
  :type 'hook
  :group 'ido)

863
(defcustom ido-rewrite-file-prompt-functions nil
Lute Kamstra's avatar
Lute Kamstra committed
864
  "List of functions to run when the find-file prompt is created.
Kim F. Storm's avatar
Kim F. Storm committed
865 866
Each function on the list may modify the following dynamically bound
variables:
Richard M. Stallman's avatar
Richard M. Stallman committed
867 868 869 870 871
  dirname   - the (abbreviated) directory name
		 to be modified by the hook functions
  max-width - the max width of the resulting dirname; nil means no limit
  prompt    - the basic prompt (e.g. \"Find File: \")
  literal   - the string shown if doing \"literal\" find; set to nil to omit
872
  vc-off    - the string shown if version control is inhibited; set to nil to omit
Richard M. Stallman's avatar
Richard M. Stallman committed
873 874
  prefix    - either nil or a fixed prefix for the dirname

Kim F. Storm's avatar
Kim F. Storm committed
875
The following variables are available, but should not be changed:
876
  `ido-current-directory' - the unabbreviated directory name
Richard M. Stallman's avatar
Richard M. Stallman committed
877
  item - equals `file' or `dir' depending on the current mode."
Kim F. Storm's avatar
Kim F. Storm committed
878 879 880
  :type 'hook
  :group 'ido)

881 882 883 884 885 886 887 888 889
(defvar ido-rewrite-file-prompt-rules nil
  "*Alist of rewriting rules for directory names in ido prompts.
A list of elements of the form (FROM . TO) or (FROM . FUNC), each
meaning to rewrite the directory name if matched by FROM by either
substituting the matched string by TO or calling the function FUNC
with the current directory name as its only argument and using the
return value as the new directory name.  In addition, each FUNC may
also modify the dynamic variables described for the variable
`ido-rewrite-file-prompt-functions'.")
Kim F. Storm's avatar
Kim F. Storm committed
890 891

(defcustom ido-completion-buffer "*Ido Completions*"
Lute Kamstra's avatar
Lute Kamstra committed
892
  "Name of completion buffer used by ido.
Kim F. Storm's avatar
Kim F. Storm committed
893 894 895 896 897
Set to nil to disable completion buffers popping up."
  :type 'string
  :group 'ido)

(defcustom ido-completion-buffer-all-completions nil
Lute Kamstra's avatar
Lute Kamstra committed
898
  "Non-nil means to show all completions in completion buffer.
Kim F. Storm's avatar
Kim F. Storm committed
899 900 901 902 903 904 905 906 907
Otherwise, only the current list of matches is shown."
  :type 'boolean
  :group 'ido)

(defvar ido-all-frames 'visible
  "*Argument to pass to `walk-windows' when finding visible files.
See documentation of `walk-windows' for useful values.")

(defcustom ido-minibuffer-setup-hook nil
Lute Kamstra's avatar
Lute Kamstra committed
908
  "Ido-specific customization of minibuffer setup.
Kim F. Storm's avatar
Kim F. Storm committed
909

910
This hook is run during minibuffer setup if `ido' is active.
Kim F. Storm's avatar
Kim F. Storm committed
911 912 913
It is intended for use in customizing ido for interoperation
with other packages.  For instance:

914
  \(add-hook 'ido-minibuffer-setup-hook
Kim F. Storm's avatar
Kim F. Storm committed
915 916
	    \(function
	     \(lambda ()
917 918
	       \(make-local-variable 'max-mini-window-height)
	       \(setq max-mini-window-height 3))))
Kim F. Storm's avatar
Kim F. Storm committed
919

920
will constrain Emacs to a maximum minibuffer height of 3 lines when
Kim F. Storm's avatar
Kim F. Storm committed
921 922 923 924
ido is running.  Copied from `icomplete-minibuffer-setup-hook'."
  :type 'hook
  :group 'ido)

925
(defcustom ido-save-directory-list-file (convert-standard-filename "~/.ido.last")
Kim F. Storm's avatar
Kim F. Storm committed
926 927 928 929 930 931 932 933
  "File in which the ido state is saved between invocations.
Variables stored are: `ido-last-directory-list', `ido-work-directory-list',
`ido-work-file-list', and `ido-dir-file-cache'.
Must be set before enabling ido mode."
  :type 'string
  :group 'ido)

(defcustom ido-read-file-name-as-directory-commands '()
934
  "List of commands which uses `read-file-name' to read a directory name.
Kim F. Storm's avatar
Kim F. Storm committed
935
When `ido-everywhere' is non-nil, the commands in this list will read
936
the directory using `ido-read-directory-name'."
Kim F. Storm's avatar
Kim F. Storm committed
937 938 939 940 941 942
  :type '(repeat symbol)
  :group 'ido)

(defcustom ido-read-file-name-non-ido '()
  "List of commands which shall not read file names the ido way.
When `ido-everywhere' is non-nil, the commands in this list will read
943
the file name using normal `read-file-name' style."
Kim F. Storm's avatar
Kim F. Storm committed
944 945 946
  :type '(repeat symbol)
  :group 'ido)

947 948 949 950 951 952
(defcustom ido-before-fallback-functions '()
  "List of functions to call before calling a fallback command.
The fallback command is passed as an argument to the functions."
  :type 'hook
  :group 'ido)

Kim F. Storm's avatar
Kim F. Storm committed
953 954 955 956
;;; Internal Variables

;; Persistent variables

957
(defvar ido-completion-map nil
Kim F. Storm's avatar
Kim F. Storm committed
958 959
  "Currently active keymap for ido commands.")

960
(defvar ido-common-completion-map nil
Kim F. Storm's avatar
Kim F. Storm committed
961 962
  "Keymap for all ido commands.")

963
(defvar ido-file-completion-map nil
Kim F. Storm's avatar
Kim F. Storm committed
964 965
  "Keymap for ido file commands.")

966
(defvar ido-file-dir-completion-map nil
Kim F. Storm's avatar
Kim F. Storm committed
967 968
  "Keymap for ido file and directory commands.")

969
(defvar ido-buffer-completion-map nil
Kim F. Storm's avatar
Kim F. Storm committed
970
  "Keymap for ido buffer commands.")
Kim F. Storm's avatar
Kim F. Storm committed
971 972 973 974 975 976 977 978

(defvar  ido-file-history nil
  "History of files selected using `ido-find-file'.")

(defvar  ido-buffer-history nil
  "History of buffers selected using `ido-switch-buffer'.")

(defvar ido-last-directory-list nil
979
  "List of last selected directory names.
Kim F. Storm's avatar
Kim F. Storm committed
980 981 982
See `ido-enable-last-directory-history' for details.")

(defvar ido-work-directory-list nil
983
  "List of actual working directory names.
Kim F. Storm's avatar
Kim F. Storm committed
984
The current directory is inserted at the front of this list whenever a
985
file is opened with `ido-find-file' and family.")
Kim F. Storm's avatar
Kim F. Storm committed
986 987 988

(defvar ido-work-file-list nil
  "List of actual work file names.
Richard M. Stallman's avatar
Richard M. Stallman committed
989 990 991
Opening a file with `ido-find-file' and similar functions
inserts the current file name (relative to its containing directory)
at the front of this list.")
Kim F. Storm's avatar
Kim F. Storm committed
992 993

(defvar ido-dir-file-cache nil
Richard M. Stallman's avatar
Richard M. Stallman committed
994 995
  "List of `file-name-all-completions' results.
Each element in the list is of the form (DIR (MTIME) FILE...).")
Kim F. Storm's avatar
Kim F. Storm committed
996

997 998
(defvar ido-ignore-item-temp-list nil
  "List of items to ignore in current ido invocation.
999
Intended to be let-bound by functions which call ido repeatedly.
1000 1001
Should never be set permanently.")

Kim F. Storm's avatar
Kim F. Storm committed
1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023
;; Temporary storage

(defvar ido-eoinput 1
  "Point where minibuffer input ends and completion info begins.
Copied from `icomplete-eoinput'.")
(make-variable-buffer-local 'ido-eoinput)

(defvar ido-common-match-string  nil
  "Stores the string that is common to all matching files.")

(defvar ido-rescan nil
  "Non-nil means we need to regenerate the list of matching items.")

(defvar ido-rotate nil
  "Non-nil means we are rotating list of matches.")

(defvar ido-text nil
  "Stores the users string as it is typed in.")

(defvar ido-text-init nil
  "The initial string for the users string it is typed in.")

Kim F. Storm's avatar
Kim F. Storm committed
1024 1025 1026
(defvar ido-input-stack nil
  "Stores the users strings when user hits M-b/M-f.")

Kim F. Storm's avatar
Kim F. Storm committed
1027 1028 1029 1030
(defvar ido-matches nil
  "List of files currently matching `ido-text'.")

(defvar ido-report-no-match t
1031
  "Report [No Match] when no completions matches `ido-text'.")
Kim F. Storm's avatar
Kim F. Storm committed
1032

1033 1034
(defvar ido-exit nil
  "Flag to monitor how `ido-find-file' exits.
Kim F. Storm's avatar
Kim F. Storm committed
1035 1036 1037 1038
If equal to `takeprompt', we use the prompt as the file name to be
selected.")

(defvar ido-current-directory nil
1039
  "Current directory for `ido-find-file'.")
Kim F. Storm's avatar
Kim F. Storm committed
1040 1041 1042 1043 1044

(defvar ido-auto-merge-timer nil
  "Delay timer for auto merge.")

(defvar ido-use-mycompletion-depth 0
1045
  "Non-nil means use `ido' completion feedback.
1046 1047
Is set by ido functions to the current `minibuffer-depth',
so that it doesn't interfere with other minibuffer usage.")
Kim F. Storm's avatar
Kim F. Storm committed
1048

1049 1050
(defvar ido-incomplete-regexp nil
  "Non-nil if an incomplete regexp is entered.")
Kim F. Storm's avatar
Kim F. Storm committed
1051

1052 1053 1054 1055
(defvar ido-initial-position nil
  "Non-nil means to explicitly cursor on entry to minibuffer.
Value is an integer which is number of chars to right of prompt.")

1056 1057 1058 1059 1060
(defvar ido-virtual-buffers nil
  "List of virtual buffers, that is, past visited files.
This is a copy of `recentf-list', pared down and with faces applied.
Only used if `ido-use-virtual-buffers' is non-nil.")

Kim F. Storm's avatar
Kim F. Storm committed
1061 1062 1063
;;; Variables with dynamic bindings.
;;; Declared here to keep the byte compiler quiet.

1064
;; Stores the current ido item type ('file, 'dir, 'buffer, or 'list).
Kim F. Storm's avatar
Kim F. Storm committed
1065 1066
(defvar ido-cur-item)

1067 1068 1069
;;; Stores the current default item
(defvar ido-default-item)

Kim F. Storm's avatar
Kim F. Storm committed
1070 1071 1072
;; Stores the current list of items that will be searched through.
;; The list is ordered, so that the most interesting item comes first,
;; although by default, the files visible in the current frame are put
1073 1074
;; at the end of the list.
(defvar ido-cur-list nil)
Kim F. Storm's avatar
Kim F. Storm committed
1075

1076
;; Stores the choice list for ido-completing-read
1077
(defvar ido-choice-list nil)
1078

Kim F. Storm's avatar
Kim F. Storm committed
1079 1080 1081 1082
;; Stores the list of items which are ignored when building
;; `ido-cur-list'.  It is in no specific order.
(defvar ido-ignored-list)

1083 1084 1085
;; Remember if current directory is non-readable (so we cannot do completion).
(defvar ido-directory-nonreadable)

1086 1087 1088
;; Remember if current directory is 'huge' (so we don't want to do completion).
(defvar ido-directory-too-big)

Kim F. Storm's avatar
Kim F. Storm committed
1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103
;; Keep current item list if non-nil.
(defvar ido-keep-item-list)

;; Process ido-ignore-* lists.
(defvar ido-process-ignore-lists)