;;; ido.el --- interactively do things with buffers and files.
;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
;;; ido.el --- interactively do things with buffers and files.
;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
-;; 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+;; 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
-;; the Free Software Foundation; either version 3, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING. If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
;; 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
;; 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
;;
;; Also, to improve the responsiveness of ido, the maximum number of
;; matching items is limited to 12, but you can increase or removed
;;
;; Also, to improve the responsiveness of ido, the maximum number of
;; matching items is limited to 12, but you can increase or removed
;; To use ido for all buffer and file selections in Emacs, customize the
;; variable `ido-everywhere'.
;; To use ido for all buffer and file selections in Emacs, customize the
;; variable `ido-everywhere'.
;; -----------------------------------------------
;; If you don't want to rely on the `ido-everywhere' functionality,
;; -----------------------------------------------
;; If you don't want to rely on the `ido-everywhere' functionality,
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
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
:type '(repeat (choice regexp function))
:group 'ido)
(defcustom ido-ignore-files
'("\\`CVS/" "\\`#" "\\`.#" "\\`\\.\\./" "\\`\\./")
:type '(repeat (choice regexp function))
:group 'ido)
(defcustom ido-ignore-files
'("\\`CVS/" "\\`#" "\\`.#" "\\`\\.\\./" "\\`\\./")
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."
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."
This allows the current directory to be opened immediately with `dired'."
:type 'boolean
:group 'ido)
(defcustom ido-file-extensions-order nil
This allows the current directory to be opened immediately with `dired'."
:type 'boolean
:group 'ido)
(defcustom ido-file-extensions-order nil
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
for files with an unlisted file extension."
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
for files with an unlisted file extension."
Directory names matched by one of the regexps in this list are not inserted
in merged file and directory lists."
:type '(repeat (choice regexp function))
Directory names matched by one of the regexps in this list are not inserted
in merged file and directory lists."
:type '(repeat (choice regexp function))
;;(setq ido-ignore-files '("^ " "\\.c\\'" "\\.h\\'"))
(defcustom ido-default-file-method 'raise-frame
;;(setq ido-ignore-files '("^ " "\\.c\\'" "\\.h\\'"))
(defcustom ido-default-file-method 'raise-frame
Possible values:
`selected-window' Show new file in selected window
`other-window' Show new file in another window (same frame)
Possible values:
`selected-window' Show new file in selected window
`other-window' Show new file in another window (same frame)
See `ido-default-file-method' for details."
:type '(choice (const :tag "Show in selected window" selected-window)
(const :tag "Show in other window" other-window)
See `ido-default-file-method' for details."
:type '(choice (const :tag "Show in selected window" selected-window)
(const :tag "Show in other window" other-window)
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."
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."
- "*Non-nil means only match if the entered text is a prefix of file name.
-This behavior is like the standard emacs-completion.
+ "Non-nil means only match if the entered text is a prefix of file name.
+This behavior is like the standard Emacs completion.
If nil, match if the entered text is an arbitrary substring.
Value can be toggled within `ido' using `ido-toggle-prefix'."
:type 'boolean
:group 'ido)
(defcustom ido-enable-dot-prefix nil
If nil, match if the entered text is an arbitrary substring.
Value can be toggled within `ido' using `ido-toggle-prefix'."
:type 'boolean
:group 'ido)
(defcustom ido-enable-dot-prefix nil
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)
(defcustom ido-confirm-unique-completion nil
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)
(defcustom ido-confirm-unique-completion nil
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)
(defcustom ido-cannot-complete-command 'ido-completion-help
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)
(defcustom ido-cannot-complete-command 'ido-completion-help
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."
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."
For a long list of prospects, building the full list for the minibuffer can take a
non-negligible amount of time; setting this variable reduces that time."
:type 'integer
:group 'ido)
(defcustom ido-max-file-prompt-width 0.35
For a long list of prospects, building the full list for the minibuffer can take a
non-negligible amount of time; setting this variable reduces that time."
:type 'integer
:group 'ido)
(defcustom ido-max-file-prompt-width 0.35
If value is a floating point number, it specifies a fraction of the frame width."
:type '(choice
(integer :tag "Characters" :value 20)
If value is a floating point number, it specifies a fraction of the frame width."
:type '(choice
(integer :tag "Characters" :value 20)
See `ido-last-directory-list' and `ido-save-directory-list-file'."
:type 'boolean
:group 'ido)
(defcustom ido-max-work-directory-list 50
See `ido-last-directory-list' and `ido-save-directory-list-file'."
:type 'boolean
:group 'ido)
(defcustom ido-max-work-directory-list 50
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
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
Directory names matched by one of the regexps in this list are not inserted in
the `ido-work-directory-list' list."
:type '(repeat regexp)
Directory names matched by one of the regexps in this list are not inserted in
the `ido-work-directory-list' list."
:type '(repeat regexp)
May use `ffap-guesser' to guess whether text at point is a filename.
If found, use that as the starting point for filename selection."
:type '(choice
May use `ffap-guesser' to guess whether text at point is a filename.
If found, use that as the starting point for filename selection."
:type '(choice
If found, call `find-file-at-point' to visit it."
:type 'boolean
:group 'ido)
(defcustom ido-enable-tramp-completion t
If found, call `find-file-at-point' to visit it."
:type 'boolean
:group 'ido)
(defcustom ido-enable-tramp-completion t
A tramp file name uses the following syntax: /method:user@host:filename."
:type 'boolean
:group 'ido)
(defcustom ido-record-ftp-work-directories t
A tramp file name uses the following syntax: /method:user@host:filename."
:type 'boolean
:group 'ido)
(defcustom ido-record-ftp-work-directories t
Use C-l in prompt to refresh list.
If zero, ftp directories are not cached."
:type 'number
:group 'ido)
(defcustom ido-slow-ftp-hosts nil
Use C-l in prompt to refresh list.
If zero, ftp directories are not cached."
:type 'number
:group 'ido)
(defcustom ido-slow-ftp-hosts nil
If an ftp host is on this list, ido automatically switches to the non-ido
equivalent function, e.g. `find-file' rather than `ido-find-file'."
:type '(repeat string)
:group 'ido)
(defcustom ido-slow-ftp-host-regexps nil
If an ftp host is on this list, ido automatically switches to the non-ido
equivalent function, e.g. `find-file' rather than `ido-find-file'."
:type '(repeat string)
:group 'ido)
(defcustom ido-slow-ftp-host-regexps nil
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)
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)
Use C-l in prompt to refresh list.
If zero, UNC host shares are not cached."
:type 'number
:group 'ido)
(defcustom ido-max-work-file-list 10
Use C-l in prompt to refresh list.
If zero, UNC host shares are not cached."
:type 'number
:group 'ido)
(defcustom ido-max-work-file-list 10
- "*Maximum number of names of recently opened files to record.
-This is the list the file names (sans directory) which have most recently
+ "Maximum number of names of recently opened files to record.
+This is the list of the file names (sans directory) which have most recently
been opened. See `ido-work-file-list' and `ido-save-directory-list-file'."
:type 'integer
:group 'ido)
(defcustom ido-work-directory-match-only t
been opened. See `ido-work-file-list' and `ido-save-directory-list-file'."
:type 'integer
:group 'ido)
(defcustom ido-work-directory-match-only t
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."
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."
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."
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."
This is the size of the cache of `file-name-all-completions' results.
Each cache entry is time stamped with the modification time of the
directory. Some systems, like Windows, have unreliable directory
This is the size of the cache of `file-name-all-completions' results.
Each cache entry is time stamped with the modification time of the
directory. Some systems, like Windows, have unreliable directory
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)
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)
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 '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.
Choices are 'always to create new buffers unconditionally, 'prompt to
ask user whether to create buffer, or 'never to never create new buffer."
:type '(choice (const always)
Choices are 'always to create new buffers unconditionally, 'prompt to
ask user whether to create buffer, or 'never to never create new buffer."
:type '(choice (const always)
-is read by ido, possible values are file, dir, buffer, and list.
+is read by ido; possible values are file, dir, buffer, and list.
Obsolete. Set 3rd element of `ido-decorations' instead."
:type '(choice string (const nil))
:group 'ido)
(defcustom ido-decorations '( "{" "}" " | " " | ..." "[" "]" " [No match]" " [Matched]" " [Not readable]" " [Too big]")
Obsolete. Set 3rd element of `ido-decorations' instead."
:type '(choice string (const nil))
:group 'ido)
(defcustom ido-decorations '( "{" "}" " | " " | ..." "[" "]" " [No match]" " [Matched]" " [Not readable]" " [Too big]")
There are 10 elements in this list:
1st and 2nd elements are used as brackets around the prospect list,
3rd element is the separator between prospects (ignored if `ido-separator' is set),
There are 10 elements in this list:
1st and 2nd elements are used as brackets around the prospect list,
3rd element is the separator between prospects (ignored if `ido-separator' is set),
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
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
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
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
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)
(defcustom ido-rewrite-file-prompt-functions nil
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)
(defcustom ido-rewrite-file-prompt-functions nil
Each function on the list may modify the following dynamically bound
variables:
dirname - the (abbreviated) directory name
Each function on the list may modify the following dynamically bound
variables:
dirname - the (abbreviated) directory name
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
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
prefix - either nil or a fixed prefix for the dirname
The following variables are available, but should not be changed:
prefix - either nil or a fixed prefix for the dirname
The following variables are available, but should not be changed:
Set to nil to disable completion buffers popping up."
:type 'string
:group 'ido)
(defcustom ido-completion-buffer-all-completions nil
Set to nil to disable completion buffers popping up."
:type 'string
:group 'ido)
(defcustom ido-completion-buffer-all-completions nil
This hook is run during minibuffer setup if `ido' is active.
It is intended for use in customizing ido for interoperation
This hook is run during minibuffer setup if `ido' is active.
It is intended for use in customizing ido for interoperation
"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'.
"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'.
(if (listp ido-unc-hosts-cache)
(ido-pp 'ido-unc-hosts-cache)
(insert "\n;; ----- ido-unc-hosts-cache -----\nt\n"))
(if (listp ido-unc-hosts-cache)
(ido-pp 'ido-unc-hosts-cache)
(insert "\n;; ----- ido-unc-hosts-cache -----\nt\n"))
(if ido-minor-mode-map-entry
(setcdr ido-minor-mode-map-entry map)
(setq ido-minor-mode-map-entry (cons 'ido-mode map))
(if ido-minor-mode-map-entry
(setcdr ido-minor-mode-map-entry map)
(setq ido-minor-mode-map-entry (cons 'ido-mode map))
DEFAULT if given is the default item to start with.
If REQUIRE-MATCH is non-nil, an existing file must be selected.
If INITIAL is non-nil, it specifies the initial input string."
DEFAULT if given is the default item to start with.
If REQUIRE-MATCH is non-nil, an existing file must be selected.
If INITIAL is non-nil, it specifies the initial input string."
((eq ido-exit 'insert-file)
(ido-file-internal 'insert 'insert-file nil "Insert file: " nil ido-text 'ido-enter-insert-buffer))
((eq ido-exit 'insert-file)
(ido-file-internal 'insert 'insert-file nil "Insert file: " nil ido-text 'ido-enter-insert-buffer))
((eq ido-exit 'insert-buffer)
(ido-buffer-internal 'insert 'insert-buffer "Insert buffer: " nil ido-text 'ido-enter-insert-file))
((eq ido-exit 'insert-buffer)
(ido-buffer-internal 'insert 'insert-buffer "Insert buffer: " nil ido-text 'ido-enter-insert-file))
(ido-record-command method dirname)
(ido-record-work-directory)
(funcall method dirname))
(ido-record-command method dirname)
(ido-record-work-directory)
(funcall method dirname))
(ido-record-command method dirname)
(ido-record-work-directory dirname)
(make-directory-internal dirname)
(ido-record-command method dirname)
(ido-record-work-directory dirname)
(make-directory-internal dirname)
"Move forward in user input or perform magic action.
If no user input is present, or at end of input, perform magic actions:
"Move forward in user input or perform magic action.
If no user input is present, or at end of input, perform magic actions:
-C-x C-b ... C-f switch to ido-find-file.
-C-x C-f ... C-f fallback to non-ido find-file.
-C-x C-d ... C-f fallback to non-ido brief dired.
-C-x d ... C-f fallback to non-ido dired."
- (interactive)
+C-x C-b ... C-f switch to `ido-find-file'.
+C-x C-f ... C-f fallback to non-ido `find-file'.
+C-x C-d ... C-f fallback to non-ido brief `dired'.
+C-x d ... C-f fallback to non-ido `dired'."
+ (interactive "P")
"Move backward in user input or perform magic action.
If no user input is present, or at start of input, perform magic actions:
C-x C-f C-b switch to `ido-switch-buffer'.
C-x C-d C-b switch to `ido-switch-buffer'.
C-x d C-b switch to `ido-switch-buffer'.
C-x C-b C-b fallback to non-ido `switch-to-buffer'."
"Move backward in user input or perform magic action.
If no user input is present, or at start of input, perform magic actions:
C-x C-f C-b switch to `ido-switch-buffer'.
C-x C-d C-b switch to `ido-switch-buffer'.
C-x d C-b switch to `ido-switch-buffer'.
C-x C-b C-b fallback to non-ido `switch-to-buffer'."
"Delete following char in user input or perform magic action.
If at end of user input, perform magic actions:
"Delete following char in user input or perform magic action.
If at end of user input, perform magic actions: