avoid recursive `require' when loading semantic
[bpt/emacs.git] / lisp / ido.el
index 6c12894..b16ab1f 100644 (file)
 ;;
 ;; 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
+;; 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.
 ;; Customization
 ;; -------------
 ;;
-;; Customize the `ido' group to change the `ido' functionality.
+;; Customize the Ido group to change the Ido functionality.
 ;;
 ;; To modify the keybindings, use the ido-setup-hook.  For example:
 ;;(add-hook 'ido-setup-hook 'ido-my-keys)
 ;; 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.
+;; or a directory name in the Ido way.
 
 ;;; Acknowledgments
 
 (defcustom ido-mode nil
   "Determines for which buffer/file Ido should be enabled.
 The following values are possible:
-- `buffer': Turn only on ido buffer behavior (switching, killing,
+- `buffer': Turn only on Ido buffer behavior (switching, killing,
   displaying...)
-- `file': Turn only on ido file behavior (finding, writing, inserting...)
-- `both': Turn on ido buffer and file behavior.
--  nil: Turn off any ido switching.
+- `file': Turn only on Ido file behavior (finding, writing, inserting...)
+- `both': Turn on Ido buffer and file behavior.
+-  nil: Turn off any Ido switching.
 
 Setting this variable directly does not take effect;
 use either \\[customize] or the function `ido-mode'."
@@ -430,10 +430,10 @@ in merged file and directory lists."
 ;;  (with-current-buffer name
 ;;    (derived-mode-p 'c-mode)))
 ;;
-;;(setq ido-ignore-buffers '("^ " ido-ignore-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\\'"))
+;;(setq ido-ignore-files '("\\` " "\\.c\\'" "\\.h\\'"))
 
 (defcustom ido-default-file-method  'raise-frame
   "How to visit a new file when using `ido-find-file'.
@@ -467,7 +467,7 @@ See `ido-default-file-method' for details."
     :group 'ido)
 
 (defcustom ido-enable-flex-matching nil
-  "Non-nil means that `ido' will do flexible string matching.
+  "Non-nil means that Ido will do flexible string matching.
 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."
@@ -476,8 +476,8 @@ in the given sequence will match."
 
 
 (defcustom ido-enable-regexp nil
-  "Non-nil means that `ido' will do regexp matching.
-Value can be toggled within `ido' using `ido-toggle-regexp'."
+  "Non-nil means that Ido will do regexp matching.
+Value can be toggled within Ido using `ido-toggle-regexp'."
   :type 'boolean
   :group 'ido)
 
@@ -485,7 +485,7 @@ Value can be toggled within `ido' using `ido-toggle-regexp'."
   "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'."
+Value can be toggled within Ido using `ido-toggle-prefix'."
   :type 'boolean
   :group 'ido)
 
@@ -499,7 +499,7 @@ as first char even if `ido-enable-prefix' is nil."
 ;; See http://debbugs.gnu.org/2042 for more info.
 (defcustom ido-buffer-disable-smart-matches t
   "Non-nil means not to re-order matches for buffer switching.
-By default, ido arranges matches in the following order:
+By default, Ido arranges matches in the following order:
 
   full-matches > suffix matches > prefix matches > remaining matches
 
@@ -564,7 +564,7 @@ the frame width."
   :group 'ido)
 
 (defcustom ido-enable-last-directory-history t
-  "Non-nil means that `ido' will remember latest selected directory names.
+  "Non-nil means that Ido will remember latest selected directory names.
 See `ido-last-directory-list' and `ido-save-directory-list-file'."
   :type 'boolean
   :group 'ido)
@@ -585,7 +585,7 @@ the `ido-work-directory-list' list."
 
 
 (defcustom ido-use-filename-at-point nil
-  "Non-nil means that ido shall look for a filename at point.
+  "Non-nil means that Ido shall look for a filename at point.
 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
@@ -603,38 +603,38 @@ If found, call `find-file-at-point' to visit it."
 
 
 (defcustom ido-enable-tramp-completion t
-  "Non-nil means that ido shall perform tramp method and server name completion.
+  "Non-nil means that Ido shall perform tramp method and server name completion.
 A tramp file name uses the following syntax: /method:user@host:filename."
   :type 'boolean
   :group 'ido)
 
 (defcustom ido-record-ftp-work-directories t
-  "Non-nil means record ftp file names in the work directory list."
+  "Non-nil means record FTP file names in the work directory list."
   :type 'boolean
   :group 'ido)
 
 (defcustom ido-merge-ftp-work-directories nil
-  "If nil, 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-cache-ftp-work-directory-time 1.0
-  "Maximum time to cache contents of an ftp directory (in hours).
+  "Maximum time to cache contents of an FTP directory (in hours).
 \\<ido-file-completion-map>
 Use \\[ido-reread-directory] in prompt to refresh list.
-If zero, ftp directories are not cached."
+If zero, FTP directories are not cached."
   :type 'number
   :group 'ido)
 
 (defcustom ido-slow-ftp-hosts nil
-  "List of slow ftp hosts where ido prompting should not be used.
-If an ftp host is on this list, ido automatically switches to the non-ido
+  "List of slow FTP hosts where Ido prompting should not be used.
+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
-  "List of regexps matching slow ftp hosts (see `ido-slow-ftp-hosts')."
+  "List of regexps matching slow FTP hosts (see `ido-slow-ftp-hosts')."
   :type '(repeat regexp)
   :group 'ido)
 
@@ -726,16 +726,16 @@ See also `ido-dir-file-cache' and `ido-save-directory-list-file'."
   :group 'ido)
 
 (defcustom ido-max-directory-size nil
-  "Maximum size (in bytes) for directories to use ido completion.
+  "Maximum size (in bytes) for directories to use Ido completion.
 \\<ido-completion-map>
-If you enter a directory with a size larger than this size, ido will
+If you enter a directory with a size larger than this size, Ido will
 not provide the normal completion.  To show the completions, use \\[ido-toggle-ignore]."
   :type '(choice (const :tag "No limit" nil)
                 (integer :tag "Size in bytes" 30000))
   :group 'ido)
 
 (defcustom ido-rotate-file-list-default nil
-  "Non-nil means that `ido' will always rotate file list to get default in front."
+  "Non-nil means that Ido will always rotate file list to get default in front."
   :type 'boolean
   :group 'ido)
 
@@ -762,21 +762,23 @@ ask user whether to create buffer, or 'never to never create new buffer."
   :group 'ido)
 
 (defcustom ido-setup-hook  nil
-  "Hook run after the ido variables and keymap have been setup.
+  "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)
 
 (defcustom ido-separator nil
-  "String used by ido to separate the alternatives in the minibuffer.
-Obsolete.  Set 3rd element of `ido-decorations' instead."
+  "String used by Ido to separate the alternatives in the minibuffer."
   :type '(choice string (const nil))
   :group 'ido)
+(make-obsolete-variable 'ido-separator
+                       "set 3rd element of `ido-decorations' instead." nil)
 
-(defcustom ido-decorations '( "{" "}" " | " " | ..." "[" "]" " [No match]" " [Matched]" " [Not readable]" " [Too big]" " [Confirm]")
-  "List of strings used by ido to display the alternatives in the minibuffer.
+(defcustom ido-decorations '("{" "}" " | " " | ..." "[" "]" " [No match]"
+                            " [Matched]" " [Not readable]" " [Too big]" " [Confirm]")
+  "List of strings used by Ido to display the alternatives in the minibuffer.
 There are between 11 and 13 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
@@ -820,19 +822,19 @@ enabled if this variable is configured to a non-nil value."
   :group 'ido)
 
 (defcustom ido-use-faces t
-  "Non-nil means use ido faces to highlighting first match, only match and
+  "Non-nil means use Ido faces to highlighting first match, only match and
 subdirs in the alternatives."
   :type 'boolean
   :group 'ido)
 
 (defface ido-first-match  '((t :weight bold))
-  "Face used by ido for highlighting first match."
+  "Face used by Ido for highlighting first match."
   :group 'ido)
 
 (defface ido-only-match  '((((class color))
                            :foreground "ForestGreen")
                           (t :slant italic))
-  "Face used by ido for highlighting only match."
+  "Face used by Ido for highlighting only match."
   :group 'ido)
 
 (defface ido-subdir  '((((min-colors 88) (class color))
@@ -840,11 +842,11 @@ subdirs in the alternatives."
                       (((class color))
                        :foreground "red")
                       (t :underline t))
-  "Face used by ido for highlighting subdirs in the alternatives."
+  "Face used by Ido for highlighting subdirs in the alternatives."
   :group 'ido)
 
 (defface ido-virtual '((t :inherit font-lock-builtin-face))
-  "Face used by ido for matching virtual buffer names."
+  "Face used by Ido for matching virtual buffer names."
   :version "24.1"
   :group 'ido)
 
@@ -853,7 +855,7 @@ subdirs in the alternatives."
                         (((class color))
                          :foreground "yellow" :background "red" :width condensed)
                         (t :inverse-video t))
-  "Face used by ido for highlighting its indicators."
+  "Face used by Ido for highlighting its indicators."
   :group 'ido)
 
 (defface ido-incomplete-regexp
@@ -901,7 +903,7 @@ The following variables are available, but should not be changed:
   :group 'ido)
 
 (defvar ido-rewrite-file-prompt-rules nil
-  "Alist of rewriting rules for directory names in ido prompts.
+  "Alist of rewriting rules for directory names in Ido prompts.
 A list of elements of the form (FROM . TO) or (FROM . FUNC), each
 meaning to rewrite the directory name if matched by FROM by either
 substituting the matched string by TO or calling the function FUNC
@@ -911,7 +913,7 @@ also modify the dynamic variables described for the variable
 `ido-rewrite-file-prompt-functions'.")
 
 (defcustom ido-completion-buffer "*Ido Completions*"
-  "Name of completion buffer used by ido.
+  "Name of completion buffer used by Ido.
 Set to nil to disable completion buffers popping up."
   :type 'string
   :group 'ido)
@@ -934,40 +936,37 @@ See documentation of `walk-windows' for useful values."
 (defcustom ido-minibuffer-setup-hook nil
   "Ido-specific customization of minibuffer setup.
 
-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
 with other packages.  For instance:
 
-  \(add-hook 'ido-minibuffer-setup-hook
-           \(function
-            \(lambda ()
-              \(make-local-variable 'max-mini-window-height)
-              \(setq max-mini-window-height 3))))
+  (add-hook 'ido-minibuffer-setup-hook
+           (lambda () (setq-local max-mini-window-height 3)))
 
 will constrain Emacs to a maximum minibuffer height of 3 lines when
-ido is running.  Copied from `icomplete-minibuffer-setup-hook'."
+Ido is running.  Copied from `icomplete-minibuffer-setup-hook'."
   :type 'hook
   :group 'ido)
 
 (defcustom ido-save-directory-list-file
   (locate-user-emacs-file "ido.last" ".ido.last")
-  "File in which the ido state is saved between invocations.
+  "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."
+Must be set before enabling Ido mode."
   :version "24.4"                       ; added locate-user-emacs-file
   :type 'string
   :group 'ido)
 
 (defcustom ido-read-file-name-as-directory-commands '()
-  "List of commands which uses `read-file-name' to read a directory name.
+  "List of commands which use `read-file-name' to read a directory name.
 When `ido-everywhere' is non-nil, the commands in this list will read
 the directory using `ido-read-directory-name'."
   :type '(repeat symbol)
   :group 'ido)
 
 (defcustom ido-read-file-name-non-ido '()
-  "List of commands which shall not read file names the ido way.
+  "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
 the file name using normal `read-file-name' style."
   :type '(repeat symbol)
@@ -984,19 +983,19 @@ The fallback command is passed as an argument to the functions."
 ;; Persistent variables
 
 (defvar ido-completion-map nil
-  "Currently active keymap for ido commands.")
+  "Currently active keymap for Ido commands.")
 
 (defvar ido-common-completion-map nil
-  "Keymap for all ido commands.")
+  "Keymap for all Ido commands.")
 
 (defvar ido-file-completion-map nil
-  "Keymap for ido file commands.")
+  "Keymap for Ido file commands.")
 
 (defvar ido-file-dir-completion-map nil
-  "Keymap for ido file and directory commands.")
+  "Keymap for Ido file and directory commands.")
 
 (defvar ido-buffer-completion-map nil
-  "Keymap for ido buffer commands.")
+  "Keymap for Ido buffer commands.")
 
 (defvar  ido-file-history nil
   "History of files selected using `ido-find-file'.")
@@ -1024,8 +1023,8 @@ at the front of this list.")
 Each element in the list is of the form (DIR (MTIME) FILE...).")
 
 (defvar ido-ignore-item-temp-list nil
-  "List of items to ignore in current ido invocation.
-Intended to be let-bound by functions which call ido repeatedly.
+  "List of items to ignore in current Ido invocation.
+Intended to be let-bound by functions which call Ido repeatedly.
 Should never be set permanently.")
 
 ;; Temporary storage
@@ -1045,19 +1044,19 @@ Copied from `icomplete-eoinput'.")
   "Non-nil means we are rotating list of matches.")
 
 (defvar ido-text nil
-  "Stores the users string as it is typed in.")
+  "Stores the user's string as it is typed in.")
 
 (defvar ido-text-init nil
-  "The initial string for the users string it is typed in.")
+  "The initial string for the user's string it is typed in.")
 
 (defvar ido-input-stack nil
-  "Stores the users strings when user hits M-b/M-f.")
+  "Stores the user's strings when user hits M-b/M-f.")
 
 (defvar ido-matches nil
   "List of files currently matching `ido-text'.")
 
 (defvar ido-report-no-match t
-  "Report [No Match] when no completions matches `ido-text'.")
+  "Report \"[No Match]\" when no completions matches `ido-text'.")
 
 (defvar ido-exit nil
   "Flag to monitor how `ido-find-file' exits.
@@ -1071,8 +1070,8 @@ selected.")
   "Delay timer for auto merge.")
 
 (defvar ido-use-mycompletion-depth 0
-  "Non-nil means use `ido' completion feedback.
-Is set by ido functions to the current `minibuffer-depth',
+  "Non-nil means use Ido completion feedback.
+Is set by Ido functions to the current `minibuffer-depth',
 so that it doesn't interfere with other minibuffer usage.")
 
 (defvar ido-incomplete-regexp nil
@@ -1283,7 +1282,8 @@ Only used if `ido-use-virtual-buffers' is non-nil.")
 (defun ido-is-ftp-directory (&optional dir)
   (string-match
    (if ido-enable-tramp-completion
-       "\\`/[^/:][^/:]+:"  ;; like tramp-file-name-regexp-unified, but doesn't match single drive letters
+       ;; like tramp-file-name-regexp-unified, but doesn't match single drive letters
+       "\\`/[^/:][^/:]+:"
      "\\`/[^/:][^/:]+:/")
    (or dir ido-current-directory)))
 
@@ -1353,7 +1353,7 @@ Only used if `ido-use-virtual-buffers' is non-nil.")
     (insert "\n)\n")))
 
 (defun ido-save-history ()
-  "Save ido history and cache information between sessions."
+  "Save Ido history and cache information between sessions."
   (interactive)
   (when (and ido-last-directory-list ido-save-directory-list-file)
     (let ((buf (get-buffer-create " *ido session*"))
@@ -1374,7 +1374,7 @@ Only used if `ido-use-virtual-buffers' is non-nil.")
        (kill-buffer buf)))))
 
 (defun ido-load-history (&optional arg)
-  "Load ido history and cache information from previous session.
+  "Load Ido history and cache information from previous session.
 With prefix argument, reload history unconditionally."
   (interactive "P")
   (if (or arg (and ido-save-directory-list-file (not ido-last-directory-list)))
@@ -1397,7 +1397,7 @@ With prefix argument, reload history unconditionally."
   (ido-wash-history))
 
 (defun ido-wash-history ()
-  "Clean-up ido history and cache information.
+  "Clean-up Ido history and cache information.
 Removes badly formatted data and ignored directories."
   (interactive)
   ;; Check format of each of our lists, discard bogus elements
@@ -1510,8 +1510,8 @@ Removes badly formatted data and ignored directories."
 (define-minor-mode ido-everywhere
   "Toggle use of Ido for all buffer/file reading.
 With a prefix argument ARG, enable this feature if ARG is
-positive, and disable it otherwise.  If called from Lisp, enable
-the mode if ARG is omitted or nil."
+positive, and disable it otherwise.  If called from Lisp,
+enable the mode if ARG is omitted or nil."
   :global t
   :group 'ido
   (when (get 'ido-everywhere 'file)
@@ -1532,11 +1532,11 @@ the mode if ARG is omitted or nil."
 
 ;;;###autoload
 (defun ido-mode (&optional arg)
-  "Toggle ido mode on or off.
-With ARG, turn ido-mode on if arg is positive, off otherwise.
-Turning on ido-mode will remap (via a minor-mode keymap) the default
+  "Toggle Ido mode on or off.
+With ARG, turn Ido mode on if arg is positive, off otherwise.
+Turning on Ido mode will remap (via a minor-mode keymap) the default
 keybindings for the `find-file' and `switch-to-buffer' families of
-commands to the ido versions of these functions.
+commands to the Ido versions of these functions.
 However, if ARG arg equals 'files, remap only commands for files, or
 if it equals 'buffers, remap only commands for buffer switching.
 This function also adds a hook to the minibuffer."
@@ -1598,7 +1598,7 @@ This function also adds a hook to the minibuffer."
 
 ;;; IDO KEYMAP
 (defun ido-init-completion-maps ()
-  "Set up the completion keymaps used by `ido'."
+  "Set up the completion keymaps used by Ido."
 
   ;; Common map
   (let ((map (make-sparse-keymap)))
@@ -1679,7 +1679,7 @@ This function also adds a hook to the minibuffer."
 
 
 (defun ido-setup-completion-map ()
-  "Set up the keymap for `ido'."
+  "Set up the keymap for Ido."
 
   ;; generated every time so that it can inherit new functions.
   (let ((map (make-sparse-keymap))
@@ -2205,7 +2205,7 @@ If INITIAL is non-nil, it specifies the initial input string."
     ido-selected))
 
 (defun ido-edit-input ()
-  "Edit absolute file name entered so far with ido; terminate by RET.
+  "Edit absolute file name entered so far with Ido; terminate by RET.
 If cursor is not at the end of the user input, move to end of input."
   (interactive)
   (if (not (eobp))
@@ -2356,8 +2356,8 @@ If cursor is not at the end of the user input, move to end of input."
                 (ido-directory-too-big-p ido-current-directory))))
 
     (when (and (eq item 'file)
-          (or ido-use-url-at-point ido-use-filename-at-point))
-      (let (fn d)
+               (or ido-use-url-at-point ido-use-filename-at-point))
+      (let (fn)
        (require 'ffap)
        ;; Duplicate code from ffap-guesser as we want different
        ;; behavior for files and URLs.
@@ -2375,17 +2375,19 @@ If cursor is not at the end of the user input, move to end of input."
                          (if (eq ido-use-filename-at-point 'guess)
                              (ffap-guesser)
                            (ffap-string-at-point))))
-              (not (string-match "^http:/" fn)))
+              (not (string-match "\\`http:/" fn)))
           (let ((absolute-fn (expand-file-name fn)))
             (cond
              ((file-directory-p absolute-fn)
-              (setq ido-current-directory (file-name-as-directory absolute-fn)))
+              (setq ido-current-directory
+                    (file-name-as-directory absolute-fn)))
              ((file-directory-p (file-name-directory absolute-fn))
               (setq ido-current-directory (file-name-directory absolute-fn))
               (setq initial (file-name-nondirectory absolute-fn)))))))))
 
     (let (ido-saved-vc-hb
-         (vc-handled-backends (and (boundp 'vc-handled-backends) vc-handled-backends))
+         (vc-handled-backends (and (boundp 'vc-handled-backends)
+                                    vc-handled-backends))
          (ido-work-directory-index -1)
          (ido-work-file-index -1)
                  (ido-find-literal nil))
@@ -2393,11 +2395,13 @@ If cursor is not at the end of the user input, move to end of input."
       (unless filename
        (setq ido-saved-vc-hb vc-handled-backends)
        (let ((minibuffer-completing-file-name t))
-         (setq filename (ido-read-internal item
-                                           (or prompt "Find file: ")
-                                           'ido-file-history
-                                           (and (eq method 'alt-file) buffer-file-name)
-                                           (confirm-nonexistent-file-or-buffer) initial))))
+         (setq filename
+                (ido-read-internal item
+                                   (or prompt "Find file: ")
+                                   'ido-file-history
+                                   (and (eq method 'alt-file) buffer-file-name)
+                                   (confirm-nonexistent-file-or-buffer)
+                                   initial))))
 
       ;; Choose the file name: either the text typed in, or the head
       ;; of the list of matches
@@ -2414,11 +2418,13 @@ If cursor is not at the end of the user input, move to end of input."
 
        ((eq ido-exit 'switch-to-buffer)
        (ido-buffer-internal
-        (if (memq method '(other-window other-frame)) method ido-default-buffer-method)
+        (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-buffer-internal 'insert 'insert-buffer "Insert buffer: "
+                             nil ido-text 'ido-enter-insert-file))
 
        ((eq ido-exit 'dired)
         (funcall (cond ((eq method 'other-window) 'dired-other-window)
@@ -2438,7 +2444,8 @@ If cursor is not at the end of the user input, move to end of input."
        ((memq method '(dired list-directory))
        (if (equal filename ".")
            (setq filename ""))
-       (let* ((dirname (ido-final-slash (concat ido-current-directory filename) t))
+       (let* ((dirname (ido-final-slash
+                         (concat ido-current-directory filename) t))
               (file (substring dirname 0 -1)))
          (cond
           ((file-directory-p dirname)
@@ -2459,7 +2466,8 @@ If cursor is not at the end of the user input, move to end of input."
              (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)
@@ -2505,7 +2513,8 @@ If cursor is not at the end of the user input, move to end of input."
        (ido-record-command 'find-file filename)
        (add-to-history 'file-name-history filename)
        (ido-record-work-directory)
-       (ido-visit-buffer (find-file-noselect filename nil ido-find-literal) method))))))
+       (ido-visit-buffer (find-file-noselect filename nil ido-find-literal)
+                          method))))))
 
 (defun ido-existing-item-p ()
   ;; Return non-nil if there is a matching item
@@ -2607,7 +2616,7 @@ If cursor is not at the end of the user input, move to end of input."
     (ido-complete)))
 
 (defun ido-undo-merge-work-directory (&optional text try refresh)
-  "Undo or redo last ido directory merge operation.
+  "Undo or redo last Ido directory merge operation.
 If no merge has yet taken place, toggle automatic merging option."
   (interactive)
   (cond
@@ -2639,9 +2648,9 @@ If no merge has yet taken place, toggle automatic merging option."
   "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'."
+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
    ((or arg (not (eobp)))
@@ -2662,7 +2671,7 @@ 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'."
+C-x C-b C-b  fallback to non-Ido `switch-to-buffer'."
   (interactive "P")
   (cond
    ((or arg (> (point) (minibuffer-prompt-end)))
@@ -2735,7 +2744,7 @@ C-x C-f ... C-d  enter `dired' on current directory."
     (exit-minibuffer)))
 
 (defun ido-toggle-vc ()
-  "Disable version control for this file."
+  "Toggle version control for this file."
   (interactive)
   (if (and ido-mode (eq ido-cur-item 'file))
       (progn
@@ -2772,7 +2781,7 @@ See `ido-use-virtual-buffers' for explanation of virtual buffer."
 (defun ido-reread-directory ()
   "Read current directory again.
 May be useful if cached version is no longer valid, but directory
-timestamp has not changed (e.g. with ftp or on Windows)."
+timestamp has not changed (e.g. with FTP or on Windows)."
   (interactive)
   (if (and ido-mode (memq ido-cur-item '(file dir)))
       (progn
@@ -2806,7 +2815,7 @@ If no buffer or file exactly matching the prompt exists, maybe create a new one.
   (exit-minibuffer))
 
 (defun ido-fallback-command ()
-  "Fallback to non-ido version of current command."
+  "Fallback to non-Ido version of current command."
   (interactive)
   (let ((i (length ido-text)))
     (while (> i 0)
@@ -2940,7 +2949,7 @@ If no buffer or file exactly matching the prompt exists, maybe create a new one.
   (exit-minibuffer))
 
 (defun ido-wide-find-file (&optional file)
-  "Prompt for FILE to search for using find, starting from current directory."
+  "Prompt for FILE to search for using `find', starting from current directory."
   (interactive)
   (unless file
     (let ((enable-recursive-minibuffers t))
@@ -2956,7 +2965,7 @@ If no buffer or file exactly matching the prompt exists, maybe create a new one.
     (exit-minibuffer)))
 
 (defun ido-wide-find-dir (&optional dir)
-  "Prompt for DIR to search for using find, starting from current directory."
+  "Prompt for DIR to search for using `find', starting from current directory."
   (interactive)
   (unless dir
     (let ((enable-recursive-minibuffers t))
@@ -2972,7 +2981,7 @@ If no buffer or file exactly matching the prompt exists, maybe create a new one.
     (exit-minibuffer)))
 
 (defun ido-wide-find-dir-or-delete-dir (&optional _dir)
-  "Prompt for DIR to search for using find, starting from current directory.
+  "Prompt for DIR to search for using `find', starting from current directory.
 If input stack is non-empty, delete current directory component."
   (interactive)
   (if ido-input-stack
@@ -3929,7 +3938,7 @@ If `ido-change-word-sub' cannot be found in WORD, return nil."
     t))
 
 (defun ido-completion-help ()
-  "Show possible completions in a *File Completions* buffer."
+  "Show possible completions in a \"*File Completions*\" buffer."
   (interactive)
   (setq ido-rescan nil)
   (let ((temp-buf (and ido-completion-buffer
@@ -4110,31 +4119,31 @@ default is to show it in the same window, unless it is already visible
 in another frame.
 
 As you type in a string, all of the buffers matching the string are
-displayed if substring-matching is used \(default).  Look at
+displayed if substring-matching is used (default).  Look at
 `ido-enable-prefix' and `ido-toggle-prefix'.  When you have found the
 buffer you want, it can then be selected.  As you type, most keys have
 their normal keybindings, except for the following: \\<ido-buffer-completion-map>
 
-RET Select the buffer at the front of the list of matches.  If the
-list is empty, possibly prompt to create new buffer.
-
-\\[ido-select-text] Use the current input string verbatim.
-
-\\[ido-next-match] Put the first element at the end of the list.
-\\[ido-prev-match] Put the last element at the start of the list.
-\\[ido-complete] Complete a common suffix to the current string that
-matches all buffers.  If there is only one match, select that buffer.
-If there is no common suffix, show a list of all matching buffers
-in a separate window.
-\\[ido-edit-input] Edit input string.
-\\[ido-fallback-command] Fallback to non-ido version of current command.
-\\[ido-toggle-regexp] Toggle regexp searching.
-\\[ido-toggle-prefix] Toggle between substring and prefix matching.
-\\[ido-toggle-case] Toggle case-sensitive searching of buffer names.
-\\[ido-completion-help] Show list of matching buffers in separate window.
-\\[ido-enter-find-file] Drop into `ido-find-file'.
-\\[ido-kill-buffer-at-head] Kill buffer at head of buffer list.
-\\[ido-toggle-ignore] Toggle ignoring buffers listed in `ido-ignore-buffers'."
+RET\tSelect the buffer at the front of the list of matches.
+\tIf the list is empty, possibly prompt to create new buffer.
+
+\\[ido-select-text]\tUse the current input string verbatim.
+
+\\[ido-next-match]\tPut the first element at the end of the list.
+\\[ido-prev-match]\tPut the last element at the start of the list.
+\\[ido-complete]\tComplete a common suffix to the current string that matches
+\tall buffers.  If there is only one match, select that buffer.
+\tIf there is no common suffix, show a list of all matching buffers
+\tin a separate window.
+\\[ido-edit-input]\tEdit input string.
+\\[ido-fallback-command]\tFallback to non-ido version of current command.
+\\[ido-toggle-regexp]\tToggle regexp searching.
+\\[ido-toggle-prefix]\tToggle between substring and prefix matching.
+\\[ido-toggle-case]\tToggle case-sensitive searching of buffer names.
+\\[ido-completion-help]\tShow list of matching buffers in separate window.
+\\[ido-enter-find-file]\tDrop into `ido-find-file'.
+\\[ido-kill-buffer-at-head]\tKill buffer at head of buffer list.
+\\[ido-toggle-ignore]\tToggle ignoring buffers listed in `ido-ignore-buffers'."
   (interactive)
   (ido-buffer-internal ido-default-buffer-method))
 
@@ -4160,7 +4169,8 @@ For details of keybindings, see `ido-switch-buffer'."
 The buffer name is selected interactively by typing a substring.
 For details of keybindings, see `ido-switch-buffer'."
   (interactive)
-  (ido-buffer-internal 'kill 'kill-buffer "Kill buffer: " (buffer-name (current-buffer)) nil 'ignore))
+  (ido-buffer-internal 'kill 'kill-buffer "Kill buffer: "
+                      (buffer-name (current-buffer)) nil 'ignore))
 
 ;;;###autoload
 (defun ido-insert-buffer ()
@@ -4168,7 +4178,8 @@ For details of keybindings, see `ido-switch-buffer'."
 The buffer name is selected interactively by typing a substring.
 For details of keybindings, see `ido-switch-buffer'."
   (interactive)
-  (ido-buffer-internal 'insert 'insert-buffer "Insert buffer: " nil nil 'ido-enter-insert-file))
+  (ido-buffer-internal 'insert 'insert-buffer "Insert buffer: "
+                      nil nil 'ido-enter-insert-file))
 
 ;;;###autoload
 (defun ido-switch-buffer-other-frame ()
@@ -4191,42 +4202,45 @@ For details of keybindings, see `ido-switch-buffer'."
 (defun ido-find-file ()
   "Edit file with name obtained via minibuffer.
 The file is displayed according to `ido-default-file-method' -- the
-default is to show it in the same window, unless it is already
-visible in another frame.
+default is to show it in the same window, unless it is already visible
+in another frame.
 
 The file name is selected interactively by typing a substring.  As you
 type in a string, all of the filenames matching the string are displayed
-if substring-matching is used \(default).  Look at `ido-enable-prefix' and
+if substring-matching is used (default).  Look at `ido-enable-prefix' and
 `ido-toggle-prefix'.  When you have found the filename you want, it can
 then be selected.  As you type, most keys have their normal keybindings,
 except for the following: \\<ido-file-completion-map>
 
-RET Select the file at the front of the list of matches.  If the
-list is empty, possibly prompt to create new file.
-
-\\[ido-select-text] Use the current input string verbatim.
-
-\\[ido-next-match] Put the first element at the end of the list.
-\\[ido-prev-match] Put the last element at the start of the list.
-\\[ido-complete] Complete a common suffix to the current string that
-matches all files.  If there is only one match, select that file.
-If there is no common suffix, show a list of all matching files
-in a separate window.
-\\[ido-magic-delete-char] Open the specified directory in Dired mode.
-\\[ido-edit-input] Edit input string (including directory).
-\\[ido-prev-work-directory] or \\[ido-next-work-directory] go to previous/next directory in work directory history.
-\\[ido-merge-work-directories] search for file in the work directory history.
-\\[ido-forget-work-directory] removes current directory from the work directory history.
-\\[ido-prev-work-file] or \\[ido-next-work-file] cycle through the work file history.
-\\[ido-wide-find-file-or-pop-dir] and \\[ido-wide-find-dir-or-delete-dir] prompts and uses find to locate files or directories.
-\\[ido-make-directory] prompts for a directory to create in current directory.
-\\[ido-fallback-command] Fallback to non-ido version of current command.
-\\[ido-toggle-regexp] Toggle regexp searching.
-\\[ido-toggle-prefix] Toggle between substring and prefix matching.
-\\[ido-toggle-case] Toggle case-sensitive searching of file names.
-\\[ido-toggle-literal] Toggle literal reading of this file.
-\\[ido-completion-help] Show list of matching files in separate window.
-\\[ido-toggle-ignore] Toggle ignoring files listed in `ido-ignore-files'."
+RET\tSelect the file at the front of the list of matches.
+\tIf the list is empty, possibly prompt to create new file.
+
+\\[ido-select-text]\tUse the current input string verbatim.
+
+\\[ido-next-match]\tPut the first element at the end of the list.
+\\[ido-prev-match]\tPut the last element at the start of the list.
+\\[ido-complete]\tComplete a common suffix to the current string that matches
+\tall files.  If there is only one match, select that file.
+\tIf there is no common suffix, show a list of all matching files
+\tin a separate window.
+\\[ido-magic-delete-char]\tOpen the specified directory in Dired mode.
+\\[ido-edit-input]\tEdit input string (including directory).
+\\[ido-prev-work-directory]\tGo to previous directory in work directory history.
+\\[ido-next-work-directory]\tGo to next directory in work directory history.
+\\[ido-merge-work-directories]\tSearch for file in the work directory history.
+\\[ido-forget-work-directory]\tRemove current directory from the work directory history.
+\\[ido-prev-work-file]\tCycle to previous file in work file history.
+\\[ido-next-work-file]\tCycle to next file in work file history.
+\\[ido-wide-find-file-or-pop-dir]\tPrompt for a file and use find to locate it.
+\\[ido-wide-find-dir-or-delete-dir]\tPrompt for a directory and use find to locate it.
+\\[ido-make-directory]\tPrompt for a directory to create in current directory.
+\\[ido-fallback-command]\tFallback to non-Ido version of current command.
+\\[ido-toggle-regexp]\tToggle regexp searching.
+\\[ido-toggle-prefix]\tToggle between substring and prefix matching.
+\\[ido-toggle-case]\tToggle case-sensitive searching of file names.
+\\[ido-toggle-literal]\tToggle literal reading of this file.
+\\[ido-completion-help]\tShow list of matching files in separate window.
+\\[ido-toggle-ignore]\tToggle ignoring files listed in `ido-ignore-files'."
 
   (interactive)
   (ido-file-internal ido-default-file-method))
@@ -4261,7 +4275,8 @@ For details of keybindings, see `ido-find-file'."
 The file name is selected interactively by typing a substring.
 For details of keybindings, see `ido-find-file'."
   (interactive)
-  (ido-file-internal 'read-only 'find-file-read-only-other-window nil "Find file read-only other window: "))
+  (ido-file-internal 'read-only 'find-file-read-only-other-window nil
+                    "Find file read-only other window: "))
 
 ;;;###autoload
 (defun ido-find-file-read-only-other-frame ()
@@ -4269,7 +4284,8 @@ For details of keybindings, see `ido-find-file'."
 The file name is selected interactively by typing a substring.
 For details of keybindings, see `ido-find-file'."
   (interactive)
-  (ido-file-internal 'read-only 'find-file-read-only-other-frame nil "Find file read-only other frame: "))
+  (ido-file-internal 'read-only 'find-file-read-only-other-frame nil
+                    "Find file read-only other frame: "))
 
 ;;;###autoload
 (defun ido-display-file ()
@@ -4311,7 +4327,7 @@ For details of keybindings, see `ido-find-file'."
 
 ;;;###autoload
 (defun ido-dired ()
-  "Call `dired' the ido way.
+  "Call `dired' the Ido way.
 The directory is selected interactively by typing a substring.
 For details of keybindings, see `ido-find-file'."
   (interactive)
@@ -4320,7 +4336,7 @@ For details of keybindings, see `ido-find-file'."
     (ido-file-internal 'dired 'dired nil "Dired: " 'dir)))
 
 (defun ido-list-directory ()
-  "Call `list-directory' the ido way.
+  "Call `list-directory' the Ido way.
 The directory is selected interactively by typing a substring.
 For details of keybindings, see `ido-find-file'."
   (interactive)
@@ -4358,7 +4374,7 @@ For details of keybindings, see `ido-find-file'."
       (throw 'ido contents))))
 
 (defun ido-exhibit ()
-  "Post command hook for `ido'."
+  "Post command hook for Ido."
   ;; Find matching files and display a list in the minibuffer.
   ;; Copied from `icomplete-exhibit' with two changes:
   ;; 1. It prints a default file name when there is no text yet entered.
@@ -4686,7 +4702,7 @@ Modified from `icomplete-completions'."
              (nth 1 ido-decorations)))))))
 
 (defun ido-minibuffer-setup ()
-  "Minibuffer setup hook for `ido'."
+  "Minibuffer setup hook for Ido."
   ;; Copied from `icomplete-minibuffer-setup-hook'.
   (when (ido-active)
     (add-hook 'pre-command-hook 'ido-tidy nil t)
@@ -4700,7 +4716,7 @@ Modified from `icomplete-completions'."
       (setq ido-initial-position nil))))
 
 (defun ido-tidy ()
-  "Pre command hook for `ido'."
+  "Pre command hook for Ido."
   ;; Remove completions display, if any, prior to new user input.
   ;; Copied from `icomplete-tidy'."
 
@@ -4859,10 +4875,10 @@ See `read-directory-name' for additional parameters."
 (defun ido-completing-read (prompt choices &optional _predicate require-match
                             initial-input hist def _inherit-input-method)
   "Ido replacement for the built-in `completing-read'.
-Read a string in the minibuffer with ido-style completion.
+Read a string in the minibuffer with Ido-style completion.
 PROMPT is a string to prompt with; normally it ends in a colon and a space.
 CHOICES is a list of strings which are the possible completions.
-PREDICATE and INHERIT-INPUT-METHOD is currently ignored; it is included
+PREDICATE and INHERIT-INPUT-METHOD are currently ignored; they are included
  to be compatible with `completing-read'.
 If REQUIRE-MATCH is non-nil, the user is not allowed to exit unless
  the input is (or completes to) an element of CHOICES or is null.