;;; ido.el --- interactively do things with buffers and files.
;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
-;; 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+;; 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
;; Author: Kim F. Storm <storm@cua.dk>
;; Based on: iswitchb by Stephen Eglen <stephen@cns.ed.ac.uk>
;; This file is part of GNU Emacs.
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
-;; 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 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/>.
;;; Commentary:
;; 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 behaviour, set the variable `ido-max-window-height'.
+;; 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
;; To use ido for all buffer and file selections in Emacs, customize the
;; variable `ido-everywhere'.
-;; Using ido-like behaviour in other lisp packages
+;; Using ido-like behavior in other lisp packages
;; -----------------------------------------------
;; If you don't want to rely on the `ido-everywhere' functionality,
;;; Code:
-(provide 'ido)
-
(defvar cua-inhibit-cua-keys)
;;; User Variables
use either \\[customize] or the function `ido-mode'."
:set #'(lambda (symbol value)
(ido-mode value))
- :initialize 'custom-initialize-set
+ :initialize 'custom-initialize-default
:require 'ido
:link '(emacs-commentary-link "ido.el")
:set-after '(ido-save-directory-list-file
"*List of regexps or functions matching buffer names to ignore.
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
-example functions that filter buffernames."
+example functions that filter buffer names."
:type '(repeat (choice regexp function))
:group 'ido)
:type '(repeat (choice regexp function))
:group 'ido)
-;;; Examples for setting the value of ido-ignore-buffers
-;(defun ido-ignore-c-mode (name)
-; "Ignore all c mode buffers -- example function for ido."
-; (save-excursion
-; (set-buffer name)
-; (string-match "^C$" mode-name)))
-;
-;(setq ido-ignore-buffers '("^ " ido-ignore-c-mode))
+;; 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))
-;;; Examples for setting the value of ido-ignore-files
-;(setq ido-ignore-files '("^ " "\\.c$" "\\.h$"))
+;; Examples for setting the value of ido-ignore-files
+;;(setq ido-ignore-files '("^ " "\\.c\\'" "\\.h\\'"))
(defcustom ido-default-file-method 'raise-frame
- "*How to visit a new file when using `ido-find-file'.
+ "*How to visit a new file when using `ido-find-file'.
Possible values:
`selected-window' Show new file in selected window
`other-window' Show new file in another window (same frame)
:group 'ido)
(defcustom ido-default-buffer-method 'raise-frame
- "*How to switch to new buffer when using `ido-switch-buffer'.
+ "*How to switch to new buffer when using `ido-switch-buffer'.
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)
(defcustom ido-enable-prefix nil
"*Non-nil means only match if the entered text is a prefix of file name.
-This behavior is like the standard emacs-completion.
+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-max-prospects 12
- "*Non-zero means that the prospect list will be limited to than number of items.
+ "*Non-zero means that the prospect list will be limited to that number of items.
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
- "*Non-zero means that the prompt string be limited to than number of characters.
+ "*Non-zero means that the prompt string be limited to that number of characters.
If value is a floating point number, it specifies a fraction of the frame width."
:type '(choice
(integer :tag "Characters" :value 20)
:group 'ido)
(defcustom ido-merge-ftp-work-directories nil
- "*If nil means merging ignores ftp file names in the work directory list."
+ "*If nil, merging ignores ftp file names in the work directory list."
:type 'boolean
: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
+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-setup-hook nil
"*Hook run after the ido variables and keymap have been setup.
The dynamic variable `ido-cur-item' contains the current type of item that
-is read by ido, possible values are file, dir, buffer, and list.
+is read by ido; possible values are file, dir, buffer, and list.
Additional keys can be defined in `ido-completion-map'."
:type 'hook
:group 'ido)
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
- vc-off - the string shown if version control is inhibited; set to nit to omit
+ vc-off - the string shown if version control is inhibited; 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:
(unwind-protect
(with-current-buffer buf
(erase-buffer)
+ (insert ";;; -*- coding: utf-8 -*-\n")
+ (setq buffer-file-coding-system 'utf-8)
(ido-pp 'ido-last-directory-list)
(ido-pp 'ido-work-directory-list)
(ido-pp 'ido-work-file-list)
(if (listp ido-unc-hosts-cache)
(ido-pp 'ido-unc-hosts-cache)
(insert "\n;; ----- ido-unc-hosts-cache -----\nt\n"))
- (insert "\n")
(write-file ido-save-directory-list-file nil))
(kill-buffer buf)))))
(if ido-minor-mode-map-entry
(setcdr ido-minor-mode-map-entry map)
(setq ido-minor-mode-map-entry (cons 'ido-mode map))
- (add-to-list 'minor-mode-map-alist ido-minor-mode-map-entry)))))
+ (add-to-list 'minor-mode-map-alist ido-minor-mode-map-entry))))
+
+ (message "Ido mode %s" (if ido-mode "enabled" "disabled")))
(defun ido-everywhere (arg)
(cond
((eq ido-exit 'find-file)
- (ido-file-internal ido-default-file-method nil nil nil nil ido-text))
+ (ido-file-internal
+ (if (memq method '(other-window other-frame)) method ido-default-file-method)
+ nil nil nil nil ido-text))
((eq ido-exit 'insert-file)
(ido-file-internal 'insert 'insert-file nil "Insert file: " nil ido-text 'ido-enter-insert-buffer))
(or ido-use-url-at-point ido-use-filename-at-point))
(let (fn d)
(require 'ffap)
- ;; Duplicate code from ffap-guesser as we want different behaviour for files and URLs.
+ ;; Duplicate code from ffap-guesser as we want different behavior for files and URLs.
(cond
((with-no-warnings
(and ido-use-url-at-point
filename t))
((and ido-use-filename-at-point
- (setq fn (if (eq ido-use-filename-at-point 'guess)
- (with-no-warnings (ffap-guesser))
- (ffap-string-at-point)))
+ (setq fn (with-no-warnings
+ (if (eq ido-use-filename-at-point 'guess)
+ (ffap-guesser)
+ (ffap-string-at-point))))
(not (string-match "^http:/" fn))
(setq d (file-name-directory fn))
(file-directory-p d))
(call-interactively this-command)))
((eq ido-exit 'switch-to-buffer)
- (ido-buffer-internal ido-default-buffer-method nil nil nil ido-text))
+ (ido-buffer-internal
+ (if (memq method '(other-window other-frame)) method ido-default-buffer-method)
+ nil nil nil ido-text))
((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))
- ((y-or-n-p (format "Directory %s does not exist. Create it? " filename))
+ ((y-or-n-p (format "Directory %s does not exist. Create it? " filename))
(ido-record-command method dirname)
(ido-record-work-directory dirname)
(make-directory-internal dirname)
;;; Magic C-f
-(defun ido-magic-forward-char ()
+(defun ido-magic-forward-char (arg)
"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")
(cond
- ((not (eobp))
- (forward-char 1))
+ ((or arg (not (eobp)))
+ (forward-char (min (prefix-numeric-value arg)
+ (- (point-max) (point)))))
((memq ido-cur-item '(file dir))
(ido-fallback-command))
(ido-context-switch-command
;;; Magic C-b
-(defun ido-magic-backward-char ()
+(defun ido-magic-backward-char (arg)
"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'."
- (interactive)
+ (interactive "P")
(cond
- ((> (point) (minibuffer-prompt-end))
- (forward-char -1))
+ ((or arg (> (point) (minibuffer-prompt-end)))
+ (forward-char
+ (- (min (prefix-numeric-value arg)
+ (- (point) (minibuffer-prompt-end))))))
((eq last-command this-command)
(when (and (memq ido-cur-item '(file dir))
(not (bobp)))
;;; Magic C-d
-(defun ido-magic-delete-char ()
+(defun ido-magic-delete-char (arg)
"Delete following char in user input or perform magic action.
If at end of user input, perform magic actions:
-C-x C-f ... C-d enter dired on current directory."
- (interactive)
+C-x C-f ... C-d enter `dired' on current directory."
+ (interactive "P")
(cond
- ((not (eobp))
- (delete-char 1))
+ ((or arg (not (eobp)))
+ (delete-char (min (prefix-numeric-value arg)
+ (- (point-max) (point)))))
(ido-context-switch-command
nil)
((memq ido-cur-item '(file dir))
(defun ido-pop-dir (arg)
"Pop directory from input stack back to input.
-With \\[universal-argument], pop all element."
+With \\[universal-argument], pop all elements."
(interactive "P")
(when ido-input-stack
(setq ido-exit (if arg 'pop-all 'pop))
(nconc ido-temp-list items)
(setq ido-temp-list items)))
+(declare-function tramp-tramp-file-p "tramp" (name))
+
(defun ido-file-name-all-completions-1 (dir)
(cond
((ido-nonreadable-directory-p dir) '())
;; Caller must have done that if necessary.
((and ido-enable-tramp-completion
- (or (fboundp 'tramp-completion-mode)
+ (or (fboundp 'tramp-completion-mode-p)
(require 'tramp nil t))
(string-match "\\`/[^/]+[:@]\\'" dir))
;; Strip method:user@host: part of tramp completions.
;; Tramp completions do not include leading slash.
- (let ((len (1- (length dir)))
- (compl
- (or (file-name-all-completions "" dir)
- ;; work around bug in ange-ftp.
- ;; /ftp:user@host: => nil
- ;; /ftp:user@host:./ => ok
- (and
- (not (string= "/ftp:" dir))
- (tramp-tramp-file-p dir)
- (fboundp 'tramp-ftp-file-name-p)
- (funcall 'tramp-ftp-file-name-p dir)
- (string-match ":\\'" dir)
- (file-name-all-completions "" (concat dir "./"))))))
+ (let* ((len (1- (length dir)))
+ (tramp-completion-mode t)
+ (compl
+ (or (file-name-all-completions "" dir)
+ ;; work around bug in ange-ftp.
+ ;; /ftp:user@host: => nil
+ ;; /ftp:user@host:./ => ok
+ (and
+ (not (string= "/ftp:" dir))
+ (tramp-tramp-file-p dir)
+ (fboundp 'tramp-ftp-file-name-p)
+ (funcall 'tramp-ftp-file-name-p dir)
+ (string-match ":\\'" dir)
+ (file-name-all-completions "" (concat dir "./"))))))
(if (and compl
(> (length (car compl)) len)
(string= (substring (car compl) 0 len) (substring dir 1)))
(ido-choice-list choices))
(ido-read-internal 'list prompt hist def require-match initial-input)))
+(defun ido-unload-function ()
+ "Unload the Ido library."
+ (ido-mode -1)
+ (setq minor-mode-map-alist (assq-delete-all 'ido-mode minor-mode-map-alist))
+ ;; continue standard unloading
+ nil)
+
+(provide 'ido)
-;;; arch-tag: b63a3500-1735-41bd-8a01-05373f0864da
+;; arch-tag: b63a3500-1735-41bd-8a01-05373f0864da
;;; ido.el ends here