File: ido.el.html

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

      Buffer: {123456 | 123}

If I then press 2:
      Buffer: 2[3]{123456 | 123}

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

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:
 Buffer: 23{123456 | 123}

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

If I want to create a new buffer named "234", I press C-j instead of TAB or RET.

If instead, I type "a":
      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
to inhibit the ido substring matching for ftp access.

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 not match because "2" is not a PREFIX in any of the buffer-names.

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

Customization
-------------

Customize the Ido group to change the Ido functionality.

To modify the keybindings, use define-key on ido-common-completion-map or one of the specialized keymaps: ido-file-dir-completion-map, ido-file-completion-map or ido-buffer-completion-map.

(with-eval-after-load 'ido
  (keymap-set ido-common-completion-map "SPC" 'ido-next-match))

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 resizing behavior, set the variable ido-max-window-height.

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
end of the list (these are created by AUCTeX when compiling.) 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. The faces used are ido-first-match, ido-only-match and ido-subdir. Coloring 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(var)/ido-everywhere(fun).

Using ido-like behavior in other Lisp packages
-----------------------------------------------

If you don't want to rely on the ido-everywhere(var)/ido-everywhere(fun) 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.

; Acknowledgments

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

Defined variables (99)

ido-all-framesArgument to pass to ‘walk-windows’ when Ido is finding buffers.
ido-auto-merge-delay-timeDelay in seconds to wait for more input before doing auto merge.
ido-auto-merge-inhibit-characters-regexpRegexp matching characters which should inhibit automatic merging.
ido-auto-merge-timerDelay timer for auto merge.
ido-auto-merge-work-directories-lengthAutomatically switch to merged work directories during file name input.
ido-before-fallback-functionsList of functions to call before calling a fallback command.
ido-big-directoriesList of directory pattern strings that should be considered big.
ido-buffer-completion-mapKeymap for Ido buffer commands.
ido-buffer-disable-smart-matchesNon-nil means not to re-order matches for buffer switching.
ido-buffer-historyHistory of buffers selected using ‘ido-switch-buffer’.
ido-cache-ftp-work-directory-timeMaximum time to cache contents of an FTP directory (in hours).
ido-cache-unc-host-shares-timeMaximum time to cache shares of an UNC host (in hours).
ido-cannot-complete-commandCommand run when ‘ido-complete’ can’t complete any more.
ido-case-foldNon-nil if searching of buffer and file names should ignore case.
ido-common-completion-mapKeymap for all Ido commands.
ido-common-match-stringStores the string that is common to all matching files.
ido-completion-bufferName of completion buffer used by Ido.
ido-completion-buffer-all-completionsNon-nil means to show all completions in completion buffer.
ido-completion-mapCurrently active keymap for Ido commands.
ido-confirm-unique-completionNon-nil means that even a unique completion must be confirmed.
ido-create-new-bufferSpecify whether a new buffer is created if no buffer matches substring.
ido-current-directoryCurrent directory for ‘ido-find-file’.
ido-decorationsList of strings used by Ido to display the alternatives in the minibuffer.
ido-default-buffer-methodHow to switch to new buffer when using ‘ido-switch-buffer’.
ido-default-file-methodHow to visit a new file when using ‘ido-find-file’.
ido-dir-file-cacheList of ‘file-name-all-completions’ results.
ido-downcase-unc-hostsNon-nil if UNC host names should be downcased.
ido-enable-dot-prefixNon-nil means to match leading dot as prefix.
ido-enable-flex-matchingNon-nil means that Ido will do flexible string matching.
ido-enable-last-directory-historyNon-nil means that Ido will remember latest selected directory names.
ido-enable-prefixNon-nil means only match if the entered text is a prefix of file name.
ido-enable-regexpNon-nil means that Ido will do regexp matching.
ido-enable-tramp-completionNon-nil means that Ido shall perform tramp method and server name completion.
ido-enter-matching-directoryAdditional methods to enter sub-directory of first/only matching item.
ido-eoinputPoint where minibuffer input ends and completion info begins.
ido-everywhereNon-nil if Ido-Everywhere mode is enabled.
ido-everywhere-hookHook run after entering or leaving ‘ido-everywhere’.
ido-exitFlag to monitor how ‘ido-find-file’ exits.
ido-file-completion-mapKeymap for Ido file commands.
ido-file-dir-completion-mapKeymap for Ido file and directory commands.
ido-file-extensions-orderList of file extensions specifying preferred order of file selections.
ido-file-historyHistory of files selected using ‘ido-find-file’.
ido-ignore-buffersList of regexps or functions matching buffer names to ignore.
ido-ignore-directoriesList of regexps or functions matching sub-directory names to ignore.
ido-ignore-directories-mergeList of regexps or functions matching directory names to ignore during merge.
ido-ignore-extensionsNon-nil means ignore files in ‘completion-ignored-extensions’ list.
ido-ignore-filesList of regexps or functions matching file names to ignore.
ido-ignore-item-temp-listList of items to ignore in current Ido invocation.
ido-ignore-unc-host-regexpsList of regexps matching UNC hosts to ignore.
ido-incomplete-regexpNon-nil if an incomplete regexp is entered.
ido-initial-positionNon-nil means to explicitly cursor on entry to minibuffer.
ido-input-stackStores the user’s strings when user hits M-b/M-f.
ido-last-directory-listList of last selected directory names.
ido-make-buffer-list-hookList of functions to run when the list of matching buffers is created.
ido-make-dir-list-hookList of functions to run when the list of matching directories is created.
ido-make-file-list-hookList of functions to run when the list of matching files is created.
ido-matchesList of files currently matching ‘ido-text’.
ido-max-dir-file-cacheMaximum number of working directories to be cached.
ido-max-directory-sizeMaximum size (in bytes) for directories to use Ido completion.
ido-max-file-prompt-widthUpper limit of the prompt string.
ido-max-prospectsUpper limit of the prospect list if non-zero.
ido-max-window-heightNon-nil specifies a value to override ‘max-mini-window-height’.
ido-max-work-directory-listMaximum number of working directories to record.
ido-max-work-file-listMaximum number of names of recently opened files to record.
ido-merge-ftp-work-directoriesIf nil, merging ignores FTP file names in the work directory list.
ido-merged-indicatorThe string appended to first choice if it has multiple directory choices.
ido-minibuffer-setup-hookIdo-specific customization of minibuffer setup.
ido-modeDetermines for which buffer/file Ido should be enabled.
ido-predicateCurrent completion predicate.
ido-read-file-name-as-directory-commandsList of commands which use ‘read-file-name’ to read a directory name.
ido-read-file-name-non-idoList of commands which shall not read file names the Ido way.
ido-record-commandsNon-nil means that Ido will record commands in command history.
ido-record-ftp-work-directoriesNon-nil means record FTP file names in the work directory list.
ido-report-no-matchReport "[No Match]" when no completions matches ‘ido-text’.
ido-rescanNon-nil means we need to regenerate the list of matching items.
ido-rewrite-file-prompt-functionsList of functions to run when the ‘find-file’ prompt is created.
ido-rewrite-file-prompt-rulesAlist of rewriting rules for directory names in Ido prompts.
ido-rotateNon-nil means we are rotating list of matches.
ido-rotate-file-list-defaultNon-nil means that Ido will always rotate file list to get default in front.
ido-save-directory-list-fileFile in which the Ido state is saved between invocations.
ido-separatorString used by Ido to separate the alternatives in the minibuffer.
ido-setup-hookHook run after the Ido variables and keymap have been setup.
ido-show-dot-for-diredNon-nil means to always put . as the first item in file name lists.
ido-slow-ftp-host-regexpsList of regexps matching slow FTP hosts (see ‘ido-slow-ftp-hosts’).
ido-slow-ftp-hostsList of slow FTP hosts where Ido prompting should not be used.
ido-textStores the user’s string as it is typed in.
ido-text-initThe initial string for the user’s string it is typed in.
ido-unc-hostsList of known UNC host names to complete after initial //.
ido-unc-hosts-cacheCached value from the function ‘ido-unc-hosts’.
ido-use-facesNon-nil means use Ido faces to highlighting first match, only match and
ido-use-filename-at-pointNon-nil means that Ido shall look for a filename at point.
ido-use-mycompletion-depthNon-nil means use Ido completion feedback.
ido-use-url-at-pointNon-nil means that ido shall look for a URL at point.
ido-use-virtual-buffersIf non-nil, refer to past ("virtual") buffers as well as existing ones.
ido-virtual-buffersList of virtual buffers, that is, past visited files.
ido-work-directory-listList of actual working directory names.
ido-work-directory-list-ignore-regexpsList of regexps matching directories which should not be recorded.
ido-work-directory-match-onlyNon-nil means to skip non-matching directories in the directory history.
ido-work-file-listList of actual work file names.

Defined functions (162)

ido--ffap-find-file(FILE &optional WILDCARD)
ido-active(&optional MERGE)
ido-add-virtual-buffers-to-list()
ido-buffer-internal(METHOD &optional FALLBACK PROMPT DEFAULT INITIAL SWITCH-CMD)
ido-buffer-window-other-frame(BUFFER)
ido-bury-buffer-at-head()
ido-cache-ftp-valid(&optional TIME)
ido-cache-unc-valid(&optional TIME)
ido-choose-completion-string(CHOICE &rest IGNORED)
ido-chop(ITEMS ELEM)
ido-complete()
ido-complete-space()
ido-completing-read(PROMPT CHOICES &optional PREDICATE REQUIRE-MATCH INITIAL-INPUT HIST DEF INHERIT-INPUT-METHOD)
ido-completion-auto-help()
ido-completion-help()
ido-completions(NAME)
ido-copy-current-file-name(ALL)
ido-copy-current-word(ALL)
ido-delete-backward-updir(COUNT)
ido-delete-backward-word-updir(COUNT)
ido-delete-file-at-head()
ido-directory-too-big-p(DIR)
ido-dired()
ido-dired-other-frame()
ido-dired-other-window()
ido-display-buffer(&optional ACTION)
ido-display-buffer-other-frame()
ido-display-file()
ido-edit-input()
ido-enter-dired()
ido-enter-find-file()
ido-enter-insert-buffer()
ido-enter-insert-file()
ido-enter-switch-buffer()
ido-everywhere(&optional ARG)
ido-exhibit()
ido-exit-minibuffer()
ido-expand-directory(DIR)
ido-fallback-command(&optional FALLBACK-COMMAND)
ido-file-extension-aux(A B N LESSP)
ido-file-extension-lessp(A B)
ido-file-extension-order(S N)
ido-file-internal(METHOD &optional FALLBACK DEFAULT PROMPT ITEM INITIAL SWITCH-CMD)
ido-file-lessp(A B)
ido-file-name-all-completions(DIR)
ido-file-name-all-completions-1(DIR)
ido-final-slash(DIR &optional FIX-IT)
ido-find-alternate-file()
ido-find-alternate-file-other-window()
ido-find-common-substring(ITEMS SUBS)
ido-find-file()
ido-find-file-in-dir(DIR)
ido-find-file-other-frame()
ido-find-file-other-window()
ido-find-file-read-only()
ido-find-file-read-only-other-frame()
ido-find-file-read-only-other-window()
ido-flatten-merged-list(ITEMS)
ido-fractionp(N)
ido-get-buffers-in-frames(&optional CURRENT)
ido-get-bufname(WIN)
ido-get-work-directory(&optional INCR MUST-MATCH)
ido-get-work-file(INCR)
ido-ignore-item-p(NAME RE-LIST &optional IGNORE-EXT)
ido-init-completion-maps(&rest REST)
ido-initiate-auto-merge(BUFFER)
ido-insert-buffer()
ido-insert-file()
ido-is-ftp-directory(&optional DIR)
ido-is-root-directory(&optional DIR)
ido-is-slow-ftp-host(&optional DIR)
ido-is-tramp-root(&optional DIR)
ido-is-unc-host(&optional DIR)
ido-is-unc-root(&optional DIR)
ido-kill-buffer()
ido-kill-buffer-at-head()
ido-list-directory()
ido-load-history(&optional ARG)
ido-local-file-exists-p(FILE)
ido-magic-backward-char(ARG)
ido-magic-delete-char(ARG)
ido-magic-forward-char(ARG)
ido-make-buffer-list(DEFAULT)
ido-make-buffer-list-1(&optional FRAME VISIBLE)
ido-make-choice-list(DEFAULT)
ido-make-dir-list(DEFAULT)
ido-make-dir-list-1(DIR &optional MERGED)
ido-make-directory(&optional DIR)
ido-make-file-list(DEFAULT)
ido-make-file-list-1(DIR &optional MERGED)
ido-make-merged-file-list(TEXT AUTO WIDE)
ido-make-merged-file-list-1(TEXT AUTO WIDE)
ido-make-prompt(ITEM PROMPT)
ido-makealist(RES)
ido-may-cache-directory(&optional DIR)
ido-merge-work-directories()
ido-minibuffer-setup()
ido-mode(&optional ARG)
ido-name(ITEM)
ido-next-match()
ido-next-match-dir()
ido-next-work-directory()
ido-next-work-file()
ido-no-final-slash(S)
ido-nonreadable-directory-p(DIR)
ido-pop-dir(ARG)
ido-pp(LIST &optional SEP)
ido-prev-match()
ido-prev-match-dir()
ido-prev-work-directory()
ido-prev-work-file()
ido-push-dir()
ido-push-dir-first()
ido-read-buffer(PROMPT &optional DEFAULT REQUIRE-MATCH PREDICATE)
ido-read-directory-name(PROMPT &optional DIR DEFAULT-DIRNAME MUSTMATCH INITIAL)
ido-read-file-name(PROMPT &optional DIR DEFAULT-FILENAME MUSTMATCH INITIAL PREDICATE)
ido-read-internal(ITEM PROMPT HIST &optional DEFAULT REQUIRE-MATCH INITIAL)
ido-record-command(COMMAND ARG)
ido-record-work-directory(&optional DIR)
ido-record-work-file(NAME)
ido-remove-cached-dir(DIR)
ido-reread-directory()
ido-restrict-to-matches(&optional REMOVEP)
ido-save-history()
ido-select-text()
ido-set-current-directory(DIR &optional SUBDIR NO-MERGE)
ido-set-current-home(&optional DIR)
ido-set-matches()
ido-set-matches-1(ITEMS &optional DO-FULL)
ido-setup-completion-map()
ido-sort-merged-list(ITEMS PROMOTE)
ido-switch-buffer()
ido-switch-buffer-other-frame()
ido-switch-buffer-other-window()
ido-switch-to-completions()
ido-take-first-match()
ido-tidy()
ido-time-stamp(&optional TIME)
ido-to-end(ITEMS)
ido-toggle-case()
ido-toggle-ignore()
ido-toggle-literal()
ido-toggle-prefix()
ido-toggle-regexp()
ido-toggle-trace(ARG)
ido-toggle-vc()
ido-toggle-virtual-buffers()
ido-trace(P &optional S RETVAL)
ido-unc-hosts(&optional QUERY)
ido-unc-hosts-net-view()
ido-undo-merge-work-directory(&optional TEXT TRY REFRESH)
ido-unload-function()
ido-up-directory(&optional CLEAR)
ido-visit-buffer(BUFFER METHOD &optional RECORD)
ido-wash-history()
ido-wide-find-dir(&optional DIR)
ido-wide-find-dir-or-delete-dir(&optional DIR)
ido-wide-find-dirs-or-files(DIR FILE &optional PREFIX FINDDIR)
ido-wide-find-file(&optional FILE)
ido-wide-find-file-or-pop-dir(ARG)
ido-word-matching-substring(WORD)
ido-write-file()

Defined faces (6)

ido-first-matchFace used by Ido for highlighting first match.
ido-incomplete-regexpIdo face for indicating incomplete regexps.
ido-indicatorFace used by Ido for highlighting its indicators.
ido-only-matchFace used by Ido for highlighting only match.
ido-subdirFace used by Ido for highlighting subdirs in the alternatives.
ido-virtualFace used by Ido for matching virtual buffer names.