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

3
;; Copyright (C) 1996-2012 Free Software Foundation, Inc.
Kim F. Storm's avatar
Kim F. Storm committed
4 5 6 7 8 9 10

;; 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.

11
;; GNU Emacs is free software: you can redistribute it and/or modify
Kim F. Storm's avatar
Kim F. Storm committed
12
;; it under the terms of the GNU General Public License as published by
13 14
;; 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
15 16 17 18 19 20 21

;; 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
22
;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
Kim F. Storm's avatar
Kim F. Storm committed
23 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


;;; 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
;;
55
;;       Buffer: {123456 | 123}
Kim F. Storm's avatar
Kim F. Storm committed
56 57
;;
;; If I then press 2:
58
;;       Buffer: 2[3]{123456 | 123}
Kim F. Storm's avatar
Kim F. Storm committed
59 60 61 62
;;
;; 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
63 64 65
;; 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
66 67 68 69 70
;;
;; 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:
71
;;	 Buffer: 23{123456 | 123}
Kim F. Storm's avatar
Kim F. Storm committed
72 73 74 75 76 77 78
;;
;; 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:
79 80 81 82 83
;;       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
84
;;
85 86
;; 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
87
;;
88
;; If instead, I type "a":
Kim F. Storm's avatar
Kim F. Storm committed
89 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
;;       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
122
;; to inhibit the ido substring matching for ftp access.
Kim F. Storm's avatar
Kim F. Storm committed
123 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
;;
;; 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
175
;; not match because "2" is not a PREFIX in any of the buffer-names.
Kim F. Storm's avatar
Kim F. Storm committed
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199

;; 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
200 201 202 203
;; 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
204 205 206 207 208 209 210


;; Customization
;; -------------
;;
;; Customize the `ido' group to change the `ido' functionality.
;;
Kim F. Storm's avatar
Kim F. Storm committed
211 212
;; 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
213 214 215
;;
;;(defun ido-my-keys ()
;;  "Add my keybindings for ido."
216
;;  (define-key ido-completion-map " " 'ido-next-match)
Kim F. Storm's avatar
Kim F. Storm committed
217 218 219 220 221 222 223 224 225 226
;;  )

;; 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
227
;; resizing behavior, set the variable `ido-max-window-height'.
Kim F. Storm's avatar
Kim F. Storm committed
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250
;;
;; 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
251
;; end of the list (these are created by AUCTeX when compiling.)
Kim F. Storm's avatar
Kim F. Storm committed
252 253 254 255 256 257 258
;; 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.
259 260
;; The faces used are ido-first-match, ido-only-match and
;; ido-subdir.
Paul Eggert's avatar
Paul Eggert committed
261
;; Coloring of the matching item was suggested by
Kim F. Storm's avatar
Kim F. Storm committed
262 263 264 265 266 267 268 269 270 271 272 273
;; 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
274
;; Using ido-like behavior in other lisp packages
Kim F. Storm's avatar
Kim F. Storm committed
275 276 277 278 279 280 281
;; -----------------------------------------------

;; 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.

282 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
;;; 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
Paul Eggert's avatar
Paul Eggert committed
311
;; found it awkward to merge my changes into the "iswitchb-" namespace,
312 313 314 315 316 317 318 319 320
;; 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
321 322 323

;;; Code:

324
(defvar recentf-list)
325

Kim F. Storm's avatar
Kim F. Storm committed
326 327 328 329 330 331 332 333 334 335 336
;;; 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
337
  :version "22.1"
Kim F. Storm's avatar
Kim F. Storm committed
338 339 340 341 342 343
  :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
344
should be enabled.  The following values are possible:
Richard M. Stallman's avatar
Richard M. Stallman committed
345
- `buffer': Turn only on ido buffer behavior \(switching, killing,
346
  displaying...)
Richard M. Stallman's avatar
Richard M. Stallman committed
347 348 349
- `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
350 351 352

Setting this variable directly does not take effect;
use either \\[customize] or the function `ido-mode'."
353
  :set #'(lambda (_symbol value)
Kim F. Storm's avatar
Kim F. Storm committed
354
	   (ido-mode value))
355
  :initialize 'custom-initialize-default
Kim F. Storm's avatar
Kim F. Storm committed
356 357
  :require 'ido
  :link '(emacs-commentary-link "ido.el")
358
  :set-after '(ido-save-directory-list-file
359
	       ;; This will clear ido-unc-hosts-cache, so set it
360
	       ;; before loading history file.
361
	       ido-unc-hosts)
362
  :type '(choice (const :tag "Turn on only buffer" buffer)
Kim F. Storm's avatar
Kim F. Storm committed
363 364 365 366 367 368
                 (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
369
  "Non-nil if searching of buffer and file names should ignore case."
Kim F. Storm's avatar
Kim F. Storm committed
370 371 372 373 374
  :type 'boolean
  :group 'ido)

(defcustom ido-ignore-buffers
  '("\\` ")
Lute Kamstra's avatar
Lute Kamstra committed
375
  "List of regexps or functions matching buffer names to ignore.
Kim F. Storm's avatar
Kim F. Storm committed
376 377
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
378
example functions that filter buffer names."
Kim F. Storm's avatar
Kim F. Storm committed
379 380 381 382 383
  :type '(repeat (choice regexp function))
  :group 'ido)

(defcustom ido-ignore-files
  '("\\`CVS/" "\\`#" "\\`.#" "\\`\\.\\./" "\\`\\./")
Lute Kamstra's avatar
Lute Kamstra committed
384
  "List of regexps or functions matching file names to ignore.
Kim F. Storm's avatar
Kim F. Storm committed
385 386 387 388 389 390 391
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
392
  "Non-nil means ignore files in `completion-ignored-extensions' list."
Kim F. Storm's avatar
Kim F. Storm committed
393 394 395 396
  :type 'boolean
  :group 'ido)

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

402
(defcustom ido-file-extensions-order nil
Lute Kamstra's avatar
Lute Kamstra committed
403
  "List of file extensions specifying preferred order of file selections.
404 405
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
406
for files with an unlisted file extension."
407 408 409 410
  :type '(repeat (choice string
			 (const :tag "Default order" t)))
  :group 'ido)

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

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

424 425 426 427 428 429 430
;; 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
431

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

435
(defcustom ido-default-file-method  'raise-frame
Lute Kamstra's avatar
Lute Kamstra committed
436
  "How to visit a new file when using `ido-find-file'.
Kim F. Storm's avatar
Kim F. Storm committed
437
Possible values:
438 439 440 441 442 443 444 445 446 447 448 449 450 451 452
`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
453 454
    :group 'ido)

455
(defcustom ido-default-buffer-method  'raise-frame
Lute Kamstra's avatar
Lute Kamstra committed
456
  "How to switch to new buffer when using `ido-switch-buffer'.
457
See `ido-default-file-method' for details."
458 459 460 461 462 463
    :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))
Kim F. Storm's avatar
Kim F. Storm committed
464 465 466
    :group 'ido)

(defcustom ido-enable-flex-matching nil
Lute Kamstra's avatar
Lute Kamstra committed
467
  "Non-nil means that `ido' will do flexible string matching.
Kim F. Storm's avatar
Kim F. Storm committed
468 469 470 471 472 473 474 475
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
476
  "Non-nil means that `ido' will do regexp matching.
Kim F. Storm's avatar
Kim F. Storm committed
477 478 479 480 481
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
482
  "Non-nil means only match if the entered text is a prefix of file name.
483
This behavior is like the standard Emacs completion.
484
If nil, match if the entered text is an arbitrary substring.
Kim F. Storm's avatar
Kim F. Storm committed
485 486 487 488
Value can be toggled within `ido' using `ido-toggle-prefix'."
  :type 'boolean
  :group 'ido)

489
(defcustom ido-enable-dot-prefix nil
Lute Kamstra's avatar
Lute Kamstra committed
490
  "Non-nil means to match leading dot as prefix.
491 492 493 494 495
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)

496
(defcustom ido-confirm-unique-completion nil
Lute Kamstra's avatar
Lute Kamstra committed
497
  "Non-nil means that even a unique completion must be confirmed.
498 499 500 501 502
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)

503
(defcustom ido-cannot-complete-command 'ido-completion-help
Lute Kamstra's avatar
Lute Kamstra committed
504
  "Command run when `ido-complete' can't complete any more.
505 506 507 508 509 510 511
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
512
(defcustom ido-record-commands t
Lute Kamstra's avatar
Lute Kamstra committed
513
  "Non-nil means that `ido' will record commands in command history.
Kim F. Storm's avatar
Kim F. Storm committed
514 515 516 517 518
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
519
  "Non-zero means that the prospect list will be limited to that number of items.
Kim F. Storm's avatar
Kim F. Storm committed
520
For a long list of prospects, building the full list for the minibuffer can take a
521
non-negligible amount of time; setting this variable reduces that time."
Kim F. Storm's avatar
Kim F. Storm committed
522 523 524
  :type 'integer
  :group 'ido)

525
(defcustom ido-max-file-prompt-width 0.35
Lute Kamstra's avatar
Lute Kamstra committed
526
  "Non-zero means that the prompt string be limited to that number of characters.
Kim F. Storm's avatar
Kim F. Storm committed
527 528 529 530 531 532 533 534 535
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
536
  "Non-nil specifies a value to override `max-mini-window-height'."
Kim F. Storm's avatar
Kim F. Storm committed
537 538 539 540 541 542 543 544 545 546
  :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
547
  "Non-nil means that `ido' will remember latest selected directory names.
Kim F. Storm's avatar
Kim F. Storm committed
548 549 550 551 552
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
553
  "Maximum number of working directories to record.
Kim F. Storm's avatar
Kim F. Storm committed
554 555 556 557 558 559
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
560
  "List of regexps matching directories which should not be recorded.
561
Directory names matched by one of the regexps in this list are not inserted in
Kim F. Storm's avatar
Kim F. Storm committed
562 563 564 565
the `ido-work-directory-list' list."
  :type '(repeat regexp)
  :group 'ido)

566

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


(defcustom ido-use-url-at-point nil
Lute Kamstra's avatar
Lute Kamstra committed
579
  "Non-nil means that ido shall look for a URL at point.
580 581 582 583 584
If found, call `find-file-at-point' to visit it."
  :type 'boolean
  :group 'ido)


585
(defcustom ido-enable-tramp-completion t
Lute Kamstra's avatar
Lute Kamstra committed
586
  "Non-nil means that ido shall perform tramp method and server name completion.
587
A tramp file name uses the following syntax: /method:user@host:filename."
588 589 590
  :type 'boolean
  :group 'ido)

Kim F. Storm's avatar
Kim F. Storm committed
591
(defcustom ido-record-ftp-work-directories t
Lute Kamstra's avatar
Lute Kamstra committed
592
  "Non-nil means record ftp file names in the work directory list."
Kim F. Storm's avatar
Kim F. Storm committed
593 594 595 596
  :type 'boolean
  :group 'ido)

(defcustom ido-merge-ftp-work-directories nil
Lute Kamstra's avatar
Lute Kamstra committed
597
  "If nil, merging ignores ftp file names in the work directory list."
Kim F. Storm's avatar
Kim F. Storm committed
598 599 600 601
  :type 'boolean
  :group 'ido)

(defcustom ido-cache-ftp-work-directory-time 1.0
Lute Kamstra's avatar
Lute Kamstra committed
602
  "Maximum time to cache contents of an ftp directory (in hours).
603
Use C-l in prompt to refresh list.
Kim F. Storm's avatar
Kim F. Storm committed
604 605 606 607 608
If zero, ftp directories are not cached."
  :type 'number
  :group 'ido)

(defcustom ido-slow-ftp-hosts nil
Lute Kamstra's avatar
Lute Kamstra committed
609
  "List of slow ftp hosts where ido prompting should not be used.
Kim F. Storm's avatar
Kim F. Storm committed
610
If an ftp host is on this list, ido automatically switches to the non-ido
611
equivalent function, e.g. `find-file' rather than `ido-find-file'."
Kim F. Storm's avatar
Kim F. Storm committed
612 613 614 615
  :type '(repeat string)
  :group 'ido)

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

620
(defvar ido-unc-hosts-cache t
621
  "Cached value from `ido-unc-hosts' function.")
622

623
(defcustom ido-unc-hosts nil
Lute Kamstra's avatar
Lute Kamstra committed
624
  "List of known UNC host names to complete after initial //.
625 626 627 628 629 630 631 632 633 634 635
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)

636
(defcustom ido-downcase-unc-hosts t
Lute Kamstra's avatar
Lute Kamstra committed
637
  "Non-nil if UNC host names should be downcased."
638 639 640
  :type 'boolean
  :group 'ido)

641
(defcustom ido-ignore-unc-host-regexps nil
Lute Kamstra's avatar
Lute Kamstra committed
642
  "List of regexps matching UNC hosts to ignore.
643
Case is ignored if `ido-downcase-unc-hosts' is set."
644
  :type '(repeat regexp)
645 646 647
  :group 'ido)

(defcustom ido-cache-unc-host-shares-time 8.0
Lute Kamstra's avatar
Lute Kamstra committed
648
  "Maximum time to cache shares of an UNC host (in hours).
649
Use C-l in prompt to refresh list.
650
If zero, UNC host shares are not cached."
651 652 653
  :type 'number
  :group 'ido)

Kim F. Storm's avatar
Kim F. Storm committed
654
(defcustom ido-max-work-file-list 10
Lute Kamstra's avatar
Lute Kamstra committed
655
  "Maximum number of names of recently opened files to record.
656
This is the list of the file names (sans directory) which have most recently
657
been opened.  See `ido-work-file-list' and `ido-save-directory-list-file'."
Kim F. Storm's avatar
Kim F. Storm committed
658 659 660 661
  :type 'integer
  :group 'ido)

(defcustom ido-work-directory-match-only t
Lute Kamstra's avatar
Lute Kamstra committed
662
  "Non-nil means to skip non-matching directories in the directory history.
Kim F. Storm's avatar
Kim F. Storm committed
663 664 665 666 667 668 669
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
670
  "Automatically switch to merged work directories during file name input.
Kim F. Storm's avatar
Kim F. Storm committed
671 672 673 674 675 676 677
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
678
  "Delay in seconds to wait for more input before doing auto merge."
Kim F. Storm's avatar
Kim F. Storm committed
679 680 681 682
  :type 'number
  :group 'ido)

(defcustom ido-auto-merge-inhibit-characters-regexp "[][*?~]"
Lute Kamstra's avatar
Lute Kamstra committed
683
  "Regexp matching characters which should inhibit automatic merging.
Kim F. Storm's avatar
Kim F. Storm committed
684 685 686 687 688 689 690 691 692 693
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
694
  "Maximum number of working directories to be cached.
695
This is the size of the cache of `file-name-all-completions' results.
Kim F. Storm's avatar
Kim F. Storm committed
696 697 698 699 700 701 702 703 704
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)

705
(defcustom ido-max-directory-size 30000
Lute Kamstra's avatar
Lute Kamstra committed
706
  "Maximum size (in bytes) for directories to use ido completion.
707 708 709 710 711 712
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
713
(defcustom ido-rotate-file-list-default nil
Lute Kamstra's avatar
Lute Kamstra committed
714
  "Non-nil means that `ido' will always rotate file list to get default in front."
Kim F. Storm's avatar
Kim F. Storm committed
715 716 717
  :type 'boolean
  :group 'ido)

718
(defcustom ido-enter-matching-directory 'only
Lute Kamstra's avatar
Lute Kamstra committed
719
  "Additional methods to enter sub-directory of first/only matching item.
720 721 722 723 724
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."
725
  :type '(choice (const :tag "Never" nil)
726 727 728
		 (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
729 730 731
  :group 'ido)

(defcustom ido-create-new-buffer 'prompt
Lute Kamstra's avatar
Lute Kamstra committed
732
  "Specify whether a new buffer is created if no buffer matches substring.
Kim F. Storm's avatar
Kim F. Storm committed
733 734
Choices are 'always to create new buffers unconditionally, 'prompt to
ask user whether to create buffer, or 'never to never create new buffer."
735
  :type '(choice (const always)
Kim F. Storm's avatar
Kim F. Storm committed
736 737 738 739
		 (const prompt)
		 (const never))
  :group 'ido)

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

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

754
(defcustom ido-decorations '( "{" "}" " | " " | ..." "[" "]" " [No match]" " [Matched]" " [Not readable]" " [Too big]" " [Confirm]")
Lute Kamstra's avatar
Lute Kamstra committed
755
  "List of strings used by ido to display the alternatives in the minibuffer.
Kim F. Storm's avatar
Kim F. Storm committed
756
There are 11 elements in this list:
Kim F. Storm's avatar
Kim F. Storm committed
757
1st and 2nd elements are used as brackets around the prospect list,
758
3rd element is the separator between prospects (ignored if `ido-separator' is set),
Kim F. Storm's avatar
Kim F. Storm committed
759 760 761
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,
762 763 764
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,
765 766
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
767 768 769
  :type '(repeat string)
  :group 'ido)

770 771
(defcustom ido-use-virtual-buffers nil
  "If non-nil, refer to past buffers as well as existing ones.
772
Essentially it works as follows: Say you are visiting a file and
Paul Eggert's avatar
Paul Eggert committed
773
the buffer gets cleaned up by midnight.el.  Later, you want to
774 775
switch to that buffer, but find it's no longer open.  With
virtual buffers enabled, the buffer name stays in the buffer
776
list (using the `ido-virtual' face, and always at the end), and if
777 778 779 780 781 782
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
783
enabled if this variable is configured to a non-nil value."
784
  :version "24.1"
785 786 787
  :type 'boolean
  :group 'ido)

Kim F. Storm's avatar
Kim F. Storm committed
788
(defcustom ido-use-faces t
Lute Kamstra's avatar
Lute Kamstra committed
789
  "Non-nil means use ido faces to highlighting first match, only match and
Kim F. Storm's avatar
Kim F. Storm committed
790 791 792 793
subdirs in the alternatives."
  :type 'boolean
  :group 'ido)

794
(defface ido-first-match  '((t :weight bold))
Lute Kamstra's avatar
Lute Kamstra committed
795
  "Face used by ido for highlighting first match."
Kim F. Storm's avatar
Kim F. Storm committed
796 797
  :group 'ido)

798
(defface ido-only-match  '((((class color))
799 800
			    :foreground "ForestGreen")
			   (t :slant italic))
Lute Kamstra's avatar
Lute Kamstra committed
801
  "Face used by ido for highlighting only match."
Kim F. Storm's avatar
Kim F. Storm committed
802 803
  :group 'ido)

804
(defface ido-subdir  '((((min-colors 88) (class color))
805 806 807 808
			:foreground "red1")
		       (((class color))
			:foreground "red")
		       (t :underline t))
Lute Kamstra's avatar
Lute Kamstra committed
809
  "Face used by ido for highlighting subdirs in the alternatives."
Kim F. Storm's avatar
Kim F. Storm committed
810 811
  :group 'ido)

812
(defface ido-virtual '((t :inherit font-lock-builtin-face))
813
  "Face used by ido for matching virtual buffer names."
814
  :version "24.1"
815 816
  :group 'ido)

817 818 819 820 821
(defface ido-indicator '((((min-colors 88) (class color))
			  :foreground "yellow1" :background "red1" :width condensed)
			 (((class color))
			  :foreground "yellow" :background "red" :width condensed)
			 (t :inverse-video t))
Lute Kamstra's avatar
Lute Kamstra committed
822
  "Face used by ido for highlighting its indicators."
Kim F. Storm's avatar
Kim F. Storm committed
823 824
  :group 'ido)

825
(defface ido-incomplete-regexp
826
  '((t :inherit font-lock-warning-face))
827 828 829
  "Ido face for indicating incomplete regexps."
  :group 'ido)

Kim F. Storm's avatar
Kim F. Storm committed
830
(defcustom ido-make-file-list-hook  nil
Lute Kamstra's avatar
Lute Kamstra committed
831
  "List of functions to run when the list of matching files is created.
Kim F. Storm's avatar
Kim F. Storm committed
832 833 834 835 836 837
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
838
  "List of functions to run when the list of matching directories is created.
Kim F. Storm's avatar
Kim F. Storm committed
839 840 841 842 843 844
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
845
  "List of functions to run when the list of matching buffers is created.
Kim F. Storm's avatar
Kim F. Storm committed
846 847 848 849 850
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)

851
(defcustom ido-rewrite-file-prompt-functions nil
Lute Kamstra's avatar
Lute Kamstra committed
852
  "List of functions to run when the find-file prompt is created.
Kim F. Storm's avatar
Kim F. Storm committed
853 854
Each function on the list may modify the following dynamically bound
variables:
Richard M. Stallman's avatar
Richard M. Stallman committed
855 856 857 858 859
  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
860
  vc-off    - the string shown if version control is inhibited; set to nil to omit
Richard M. Stallman's avatar
Richard M. Stallman committed
861 862
  prefix    - either nil or a fixed prefix for the dirname

Kim F. Storm's avatar
Kim F. Storm committed
863
The following variables are available, but should not be changed:
864
  `ido-current-directory' - the unabbreviated directory name
Richard M. Stallman's avatar
Richard M. Stallman committed
865
  item - equals `file' or `dir' depending on the current mode."
Kim F. Storm's avatar
Kim F. Storm committed
866 867 868
  :type 'hook
  :group 'ido)

869
(defvar ido-rewrite-file-prompt-rules nil
870
  "Alist of rewriting rules for directory names in ido prompts.
871 872 873 874 875 876 877
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
878 879

(defcustom ido-completion-buffer "*Ido Completions*"
Lute Kamstra's avatar
Lute Kamstra committed
880
  "Name of completion buffer used by ido.
Kim F. Storm's avatar
Kim F. Storm committed
881 882 883 884 885
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
886
  "Non-nil means to show all completions in completion buffer.
Kim F. Storm's avatar
Kim F. Storm committed
887 888 889 890
Otherwise, only the current list of matches is shown."
  :type 'boolean
  :group 'ido)

891 892 893 894 895 896 897 898
(defcustom ido-all-frames 'visible
  "Argument to pass to `walk-windows' when Ido is finding buffers.
See documentation of `walk-windows' for useful values."
  :type '(choice (const :tag "Selected frame only" nil)
		 (const :tag "All existing frames" t)
		 (const :tag "All visible frames" visible)
		 (const :tag "All frames on this terminal" 0))
  :group 'ido)
Kim F. Storm's avatar
Kim F. Storm committed
899 900

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

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

907
  \(add-hook 'ido-minibuffer-setup-hook
Kim F. Storm's avatar
Kim F. Storm committed
908 909
	    \(function
	     \(lambda ()
910 911
	       \(make-local-variable 'max-mini-window-height)
	       \(setq max-mini-window-height 3))))
Kim F. Storm's avatar
Kim F. Storm committed
912

913
will constrain Emacs to a maximum minibuffer height of 3 lines when
Kim F. Storm's avatar
Kim F. Storm committed
914 915 916 917
ido is running.  Copied from `icomplete-minibuffer-setup-hook'."
  :type 'hook
  :group 'ido)

918
(defcustom ido-save-directory-list-file (convert-standard-filename "~/.ido.last")
Kim F. Storm's avatar
Kim F. Storm committed
919 920 921 922 923 924 925 926
  "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 '()
927
  "List of commands which uses `read-file-name' to read a directory name.
Kim F. Storm's avatar
Kim F. Storm committed
928
When `ido-everywhere' is non-nil, the commands in this list will read
929
the directory using `ido-read-directory-name'."
Kim F. Storm's avatar
Kim F. Storm committed
930 931 932 933 934 935
  :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
936
the file name using normal `read-file-name' style."
Kim F. Storm's avatar
Kim F. Storm committed
937 938 939
  :type '(repeat symbol)
  :group 'ido)

940 941 942 943 944 945
(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
946 947 948 949
;;; Internal Variables

;; Persistent variables

950
(defvar ido-completion-map nil
Kim F. Storm's avatar
Kim F. Storm committed
951 952
  "Currently active keymap for ido commands.")

953
(defvar ido-common-completion-map nil
Kim F. Storm's avatar
Kim F. Storm committed
954 955
  "Keymap for all ido commands.")

956
(defvar ido-file-completion-map nil
Kim F. Storm's avatar
Kim F. Storm committed
957 958
  "Keymap for ido file commands.")

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

962
(defvar ido-buffer-completion-map nil
Kim F. Storm's avatar
Kim F. Storm committed
963
  "Keymap for ido buffer commands.")
Kim F. Storm's avatar
Kim F. Storm committed
964 965 966 967 968 969 970 971

(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
972
  "List of last selected directory names.
Kim F. Storm's avatar
Kim F. Storm committed
973 974 975
See `ido-enable-last-directory-history' for details.")

(defvar ido-work-directory-list nil
976
  "List of actual working directory names.
Kim F. Storm's avatar
Kim F. Storm committed
977
The current directory is inserted at the front of this list whenever a
978
file is opened with `ido-find-file' and family.")
Kim F. Storm's avatar
Kim F. Storm committed
979 980 981

(defvar ido-work-file-list nil
  "List of actual work file names.
Richard M. Stallman's avatar
Richard M. Stallman committed
982 983 984
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
985 986

(defvar ido-dir-file-cache nil
Richard M. Stallman's avatar
Richard M. Stallman committed
987 988
  "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
989

990 991
(defvar ido-ignore-item-temp-list nil
  "List of items to ignore in current ido invocation.
992
Intended to be let-bound by functions which call ido repeatedly.
993 994
Should never be set permanently.")

Kim F. Storm's avatar
Kim F. Storm committed
995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016
;; 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
1017 1018 1019
(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
1020 1021 1022 1023
(defvar ido-matches nil
  "List of files currently matching `ido-text'.")

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

1026 1027
(defvar ido-exit nil
  "Flag to monitor how `ido-find-file' exits.
Kim F. Storm's avatar
Kim F. Storm committed
1028 1029 1030 1031
If equal to `takeprompt', we use the prompt as the file name to be
selected.")

(defvar ido-current-directory nil
1032
  "Current directory for `ido-find-file'.")
Kim F. Storm's avatar
Kim F. Storm committed
1033 1034 1035 1036 1037

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

(defvar ido-use-mycompletion-depth 0
1038
  "Non-nil means use `ido' completion feedback.
1039 1040
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
1041

1042 1043
(defvar ido-incomplete-regexp nil
  "Non-nil if an incomplete regexp is entered.")
Kim F. Storm's avatar
Kim F. Storm committed
1044

1045 1046 1047 1048
(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.")

1049 1050 1051 1052 1053
(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
1054 1055 1056
;;; Variables with dynamic bindings.
;;; Declared here to keep the byte compiler quiet.

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

1060 1061 1062
;;; Stores the current default item
(defvar ido-default-item)

Kim F. Storm's avatar
Kim F. Storm committed
1063 1064 1065
;; 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
1066 1067
;; at the end of the list.  Created by `ido-make-item-list'.
(defvar ido-cur-list)
Kim F. Storm's avatar
Kim F. Storm committed
1068

1069
;; Stores the choice list for ido-completing-read
1070
(defvar ido-choice-list)
1071

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

1076 1077 1078
;; Remember if current directory is non-readable (so we cannot do completion).
(defvar ido-directory-nonreadable)

Kim F. Storm's avatar