]> code.delx.au - gnu-emacs/blobdiff - lisp/ido.el
(url-http-mark-connection-as-free, url-http-find-free-connection):
[gnu-emacs] / lisp / ido.el
index 1c2617b814dfda97f2290eba906cb06f6d15d376..8e309a27099219ed36442e380ff75ce5caee214c 100644 (file)
@@ -404,13 +404,13 @@ example functions that filter filenames."
   :group 'ido)
 
 (defcustom ido-ignore-extensions t
-  "*Non-nil means ignore files in completion-ignored-extensions list."
+  "*Non-nil means ignore files in `completion-ignored-extensions' list."
   :type 'boolean
   :group 'ido)
 
 (defcustom ido-show-dot-for-dired nil
   "*Non-nil means to always put . as the first item in file name lists.
-This allows the current directory to be opened immediate with `dired'."
+This allows the current directory to be opened immediately with `dired'."
   :type 'boolean
   :group 'ido)
 
@@ -448,35 +448,41 @@ in merged file and directory lists."
 ;;; Examples for setting the value of ido-ignore-files
 ;(setq ido-ignore-files '("^ " "\\.c$" "\\.h$"))
 
-(defcustom ido-default-file-method  'always-frame
-    "*How to switch to new file when using `ido-find-file'.
+(defcustom ido-default-file-method  'raise-frame
+    "*How to visit a new file when using `ido-find-file'.
 Possible values:
-`samewindow'   Show new file in same window
-`otherwindow'  Show new file in another window (same frame)
-`display'      Display file in another window without switching to it
-`otherframe'   Show new file in another frame
-`maybe-frame'  If a file is visible in another frame, prompt to ask if you
-               you want to see the file in the same window of the current
-               frame or in the other frame
-`always-frame'  If a file is visible in another frame, raise that
-               frame; otherwise, visit the file in the same window"
-    :type '(choice (const samewindow)
-                  (const otherwindow)
-                  (const display)
-                  (const otherframe)
-                  (const maybe-frame)
-                  (const always-frame))
+`selected-window' Show new file in selected window
+`other-window'   Show new file in another window (same frame)
+`display'        Display file in another window without selecting to it
+`other-frame'    Show new file in another frame
+`maybe-frame'    If a file is visible in another frame, prompt to ask if you
+                 you want to see the file in the same window of the current
+                 frame or in the other frame
+`raise-frame'     If a file is visible in another frame, raise that
+                 frame; otherwise, visit the file in the same window"
+    :type '(choice (const :tag "Visit in selected window" selected-window)
+                  (const :tag "Visit in other window" other-window)
+                  (const :tag "Display (no select) in other window" display)
+                  (const :tag "Visit in other frame" other-frame)
+                  (const :tag "Ask to visit in other frame" maybe-frame)
+                  (const :tag "Raise frame if already visited" raise-frame))
     :group 'ido)
 
-(defcustom ido-default-buffer-method  'always-frame
+(defcustom ido-default-buffer-method  'raise-frame
     "*How to switch to new buffer when using `ido-switch-buffer'.
 See `ido-default-file-method' for details."
-    :type '(choice (const samewindow)
-                  (const otherwindow)
+    :type '(choice (const :tag "Show in selected window" selected-window)
+                  (const :tag "Show in other window" other-window)
+                  (const :tag "Display (no select) in other window" display)
+                  (const :tag "Show in other frame" other-frame)
+                  (const :tag "Ask to show in other frame" maybe-frame)
+                  (const :tag "Raise frame if already shown" raise-frame))
+    :type '(choice (const selected-window)
+                  (const other-window)
                   (const display)
-                  (const otherframe)
+                  (const other-frame)
                   (const maybe-frame)
-                  (const always-frame))
+                  (const raise-frame))
     :group 'ido)
 
 (defcustom ido-enable-flex-matching nil
@@ -497,7 +503,7 @@ Value can be toggled within `ido' using `ido-toggle-regexp'."
 (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.
-Nil means to match if the entered text is an arbitrary substring.
+nil means to match if the entered text is an arbitrary substring.
 Value can be toggled within `ido' using `ido-toggle-prefix'."
   :type 'boolean
   :group 'ido)
@@ -708,7 +714,7 @@ When a (partial) file name matches this regexp, merging is inhibited."
 
 (defcustom ido-max-dir-file-cache 100
   "*Maximum number of working directories to be cached.
-This is the size of the cache of file-name-all-completions results.
+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
 modification times, so you may choose to disable caching on such
@@ -771,7 +777,7 @@ Obsolete.  Set 3rd element of `ido-decorations' instead."
   "*List of strings used by ido to display the alternatives in the minibuffer.
 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),
+3rd element is the separator between prospects (ignored if `ido-separator' is set),
 4th element is the string inserted at the end of a truncated list of prospects,
 5th and 6th elements are used as brackets around the common match string which
 can be completed using TAB,
@@ -789,13 +795,13 @@ subdirs in the alternatives."
   :group 'ido)
 
 (defface ido-first-match  '((t (:bold t)))
-  "*Font 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 (:italic t)))
-  "*Font 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))
@@ -803,7 +809,7 @@ subdirs in the alternatives."
                            (((class color))
                              (:foreground "red"))
                             (t (:underline t)))
-  "*Font used by ido for highlighting subdirs in the alternatives."
+  "*Face used by ido for highlighting subdirs in the alternatives."
   :group 'ido)
 
 (defface ido-indicator  '((((min-colors 88) (class color))
@@ -815,7 +821,7 @@ subdirs in the alternatives."
                                 :background "red"
                                 :width condensed))
                               (t (:inverse-video t)))
-  "*Font used by ido for highlighting its indicators."
+  "*Face used by ido for highlighting its indicators."
   :group 'ido)
 
 (defface ido-incomplete-regexp
@@ -858,7 +864,7 @@ variables:
   prefix    - either nil or a fixed prefix for the dirname
 
 The following variables are available, but should not be changed:
-  ido-current-directory - the unabbreviated directory name
+  `ido-current-directory' - the unabbreviated directory name
   item - equals `file' or `dir' depending on the current mode."
   :type 'hook
   :group 'ido)
@@ -1028,8 +1034,8 @@ selected.")
 
 (defvar ido-use-mycompletion-depth 0
   "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.")
+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
   "Non-nil if an incomplete regexp is entered.")
@@ -1532,6 +1538,7 @@ With ARG, turn ido speed-up on if arg is positive, off otherwise."
     (define-key map "\C-t" 'ido-toggle-regexp)
     (define-key map "\C-z" 'ido-undo-merge-work-directory)
     (define-key map [(control ?\s)] 'ido-restrict-to-matches)
+    (define-key map [(meta ?\s)] 'ido-take-first-match)
     (define-key map [(control ?@)] 'ido-restrict-to-matches)
     (define-key map [right] 'ido-next-match)
     (define-key map [left] 'ido-prev-match)
@@ -1559,6 +1566,7 @@ With ARG, turn ido speed-up on if arg is positive, off otherwise."
     (define-key map "\C-l" 'ido-reread-directory)
     (define-key map [(meta ?d)] 'ido-wide-find-dir-or-delete-dir)
     (define-key map [(meta ?b)] 'ido-push-dir)
+    (define-key map [(meta ?v)] 'ido-push-dir-first)
     (define-key map [(meta ?f)] 'ido-wide-find-file-or-pop-dir)
     (define-key map [(meta ?k)] 'ido-forget-work-directory)
     (define-key map [(meta ?m)] 'ido-make-directory)
@@ -1832,6 +1840,7 @@ If INITIAL is non-nil, it specifies the initial input string."
                       (and d (cdr d)))))))
        (if (member ido-default-item ido-ignore-item-temp-list)
            (setq ido-default-item nil))
+       (ido-trace "new default" ido-default-item)
        (setq ido-set-default-item nil))
 
       (if ido-process-ignore-lists-inhibit
@@ -2035,7 +2044,7 @@ If INITIAL is non-nil, it specifies the initial input string."
             (not (if ido-directory-too-big
                      (file-exists-p (concat ido-current-directory ido-final-text))
                    (ido-existing-item-p))))
-       (error "must specify valid item"))
+       (error "Must specify valid item"))
 
        (t
        (setq ido-selected
@@ -2086,8 +2095,10 @@ If INITIAL is non-nil, it specifies the initial input string."
                        (cons (cons ido-current-directory ido-selected) ido-last-directory-list)))))
          (ido-set-current-directory ido-current-directory ido-selected)
          (if ido-input-stack
-             (while ido-input-stack
-               (let ((elt (car ido-input-stack)))
+             ; automatically pop stack elements which match existing files or directories
+             (let (elt)
+               (while (and (setq elt (car ido-input-stack))
+                           (file-exists-p (concat ido-current-directory (cdr elt))))
                  (if (setq ido-input-stack (cdr ido-input-stack))
                      (ido-set-current-directory ido-current-directory (cdr elt))
                    (setq ido-text-init (cdr elt)))
@@ -2101,7 +2112,7 @@ If INITIAL is non-nil, it specifies the initial input string."
 (defun ido-edit-input ()
   "Edit absolute file name entered so far with ido; terminate by RET."
   (interactive)
-  (setq ido-text-init (if ido-matches (car ido-matches) ido-text))
+  (setq ido-text-init (if ido-matches (ido-name (car ido-matches)) ido-text))
   (setq ido-exit 'edit)
   (exit-minibuffer))
 
@@ -2152,7 +2163,7 @@ If INITIAL is non-nil, it specifies the initial input string."
 
        ;; buffer doesn't exist
        ((eq ido-create-new-buffer 'never)
-       (message "no buffer matching `%s'" buf))
+       (message "No buffer matching `%s'" buf))
 
        ((and (eq ido-create-new-buffer 'prompt)
             (not (y-or-n-p (format "No buffer matching `%s', create one? " buf))))
@@ -2213,7 +2224,6 @@ If INITIAL is non-nil, it specifies the initial input string."
   (let ((ido-current-directory (ido-expand-directory default))
        (ido-context-switch-command switch-cmd)
        ido-directory-nonreadable ido-directory-too-big
-       (minibuffer-completing-file-name t)
        filename)
 
     (if (or (not ido-mode) (ido-is-slow-ftp-host))
@@ -2257,9 +2267,10 @@ If INITIAL is non-nil, it specifies the initial input string."
 
       (unless filename
        (setq ido-saved-vc-hb vc-handled-backends)
-       (setq filename (ido-read-internal item
-                                         (or prompt "Find file: ")
-                                         'ido-file-history nil nil initial)))
+       (let ((minibuffer-completing-file-name t))
+         (setq filename (ido-read-internal item
+                                           (or prompt "Find file: ")
+                                           'ido-file-history nil nil initial))))
 
       ;; Choose the file name: either the text typed in, or the head
       ;; of the list of matches
@@ -2331,7 +2342,7 @@ If INITIAL is non-nil, it specifies the initial input string."
        (setq default-directory ido-current-directory)
        (ido-record-command 'write-file (concat ido-current-directory filename))
        (ido-record-work-directory)
-       (write-file filename))
+       (write-file (concat ido-current-directory filename)))
 
        ((eq method 'read-only)
        (ido-record-work-file filename)
@@ -2415,13 +2426,13 @@ If INITIAL is non-nil, it specifies the initial input string."
      ((and (= 1 (length ido-matches))
           (not (and ido-enable-tramp-completion
                     (string-equal ido-current-directory "/")
-                    (string-match "..[@:]\\'" (car ido-matches)))))
+                    (string-match "..[@:]\\'" (ido-name (car ido-matches))))))
       ;; only one choice, so select it.
       (if (not ido-confirm-unique-completion)
          (exit-minibuffer)
        (setq ido-rescan (not ido-enable-prefix))
        (delete-region (minibuffer-prompt-end) (point))
-       (insert (car ido-matches))))
+       (insert (ido-name (car ido-matches)))))
 
      (t ;; else there could be some completions
       (setq res ido-common-match-string)
@@ -2510,10 +2521,10 @@ C-x d ... C-f    fallback to non-ido dired."
 (defun ido-magic-backward-char ()
   "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."
+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)
   (cond
    ((> (point) (minibuffer-prompt-end))
@@ -2600,7 +2611,7 @@ C-x C-f ... C-d  enter dired on current directory."
 May be useful if cached version is no longer valid, but directory
 timestamp has not changed (e.g. with ftp or on Windows)."
   (interactive)
-  (if (and ido-mode (eq ido-cur-item 'file))
+  (if (and ido-mode (memq ido-cur-item '(file dir)))
       (progn
        (if (ido-is-unc-root)
            (setq ido-unc-hosts-cache t)
@@ -2647,19 +2658,19 @@ If no buffer or file exactly matching the prompt exists, maybe create a new one.
   (exit-minibuffer))
 
 (defun ido-enter-dired ()
-  "Drop into dired from file switching."
+  "Drop into `dired' from file switching."
   (interactive)
   (setq ido-exit 'dired)
   (exit-minibuffer))
 
 (defun ido-enter-insert-buffer ()
-  "Drop into insert buffer from insert file."
+  "Drop into `insert-buffer' from insert file."
   (interactive)
   (setq ido-exit 'insert-buffer)
   (exit-minibuffer))
 
 (defun ido-enter-insert-file ()
-  "Drop into insert file from insert buffer."
+  "Drop into `insert-file' from insert buffer."
   (interactive)
   (setq ido-exit 'insert-file)
   (exit-minibuffer))
@@ -2799,12 +2810,28 @@ If input stack is non-empty, delete current directory component."
       (ido-delete-backward-word-updir 1)
     (ido-wide-find-dir)))
 
+(defun ido-take-first-match ()
+  "Use first matching item as input text."
+  (interactive)
+  (when ido-matches
+    (setq ido-text-init (ido-name (car ido-matches)))
+    (setq ido-exit 'refresh)
+    (exit-minibuffer)))
+
 (defun ido-push-dir ()
   "Move to previous directory in file name, push current input on stack."
   (interactive)
   (setq ido-exit 'push)
   (exit-minibuffer))
 
+(defun ido-push-dir-first ()
+  "Move to previous directory in file name, push first match on stack."
+  (interactive)
+  (if ido-matches
+      (setq ido-text (ido-name (car ido-matches))))
+  (setq ido-exit 'push)
+  (exit-minibuffer))
+
 (defun ido-pop-dir (arg)
   "Pop directory from input stack back to input.
 With \\[universal-argument], pop all element."
@@ -2869,11 +2896,13 @@ With \\[universal-argument], pop all element."
   "Insert file name of current buffer.
 If repeated, insert text from buffer instead."
   (interactive "P")
-  (let* ((bfname (buffer-file-name ido-entry-buffer))
+  (let* ((bfname (or (buffer-file-name ido-entry-buffer)
+                    (buffer-name ido-entry-buffer)))
         (name (and bfname (file-name-nondirectory bfname))))
     (when name
       (setq ido-text-init
            (if (or all
+                   (eq last-command this-command)
                    (not (equal (file-name-directory bfname) ido-current-directory))
                    (not (string-match "\\.[^.]*\\'" name)))
                name
@@ -3055,12 +3084,14 @@ for first matching file."
   (let ((oa (ido-file-extension-order a n))
        (ob (ido-file-extension-order b n)))
     (cond
-     ((= oa ob)
-      lessp)
      ((and oa ob)
-      (if lessp
-         (> oa ob)
-       (< oa ob)))
+      (cond
+       ((= oa ob)
+       lessp)
+       (lessp
+       (> oa ob))
+       (t
+       (< oa ob))))
      (oa
       (not lessp))
      (ob
@@ -3107,7 +3138,12 @@ for first matching file."
   (let ((filenames
         (split-string
          (shell-command-to-string
-          (concat "find " dir " -name \"" (if prefix "" "*") file "*\" -type " (if finddir "d" "f") " -print"))))
+          (concat "find "
+                  (shell-quote-argument dir)
+                  " -name "
+                  (shell-quote-argument
+                   (concat (if prefix "" "*") file "*"))
+                  " -type " (if finddir "d" "f") " -print"))))
        filename d f
        res)
     (while filenames
@@ -3500,37 +3536,40 @@ for first matching file."
   (let* ((case-fold-search  ido-case-fold)
         (slash (and (not ido-enable-prefix) (ido-final-slash ido-text)))
         (text (if slash (substring ido-text 0 -1) ido-text))
-        (rexq (concat (if ido-enable-regexp text (regexp-quote text)) (if slash ".*/" "")))
+        (rex0 (if ido-enable-regexp text (regexp-quote text)))
+        (rexq (concat rex0 (if slash ".*/" "")))
         (re (if ido-enable-prefix (concat "\\`" rexq) rexq))
-        (full-re (and do-full (not ido-enable-regexp) (not (string-match "\$\\'" re))
-                      (concat "\\`" re "\\'")))
+        (full-re (and do-full (not ido-enable-regexp) (not (string-match "\$\\'" rex0))
+                      (concat "\\`" rex0 (if slash "/" "") "\\'")))
+        (suffix-re (and do-full slash
+                        (not ido-enable-regexp) (not (string-match "\$\\'" rex0))
+                        (concat rex0 "/\\'")))
         (prefix-re (and full-re (not ido-enable-prefix)
                         (concat "\\`" rexq)))
         (non-prefix-dot (or (not ido-enable-dot-prefix)
                             (not ido-process-ignore-lists)
                             ido-enable-prefix
                             (= (length ido-text) 0)))
-
-        full-matches
-        prefix-matches
-        matches)
+        full-matches suffix-matches prefix-matches matches)
     (setq ido-incomplete-regexp nil)
     (condition-case error
         (mapcar
          (lambda (item)
            (let ((name (ido-name item)))
-             (if (and (or non-prefix-dot
-                          (if (= (aref ido-text 0) ?.)
-                              (= (aref name 0) ?.)
-                            (/= (aref name 0) ?.)))
-                      (string-match re name))
-                 (cond
-                  ((and full-re (string-match full-re name))
-                   (setq full-matches (cons item full-matches)))
-                  ((and prefix-re (string-match prefix-re name))
-                   (setq prefix-matches (cons item prefix-matches)))
-                  (t (setq matches (cons item matches))))))
-           t)
+            (if (and (or non-prefix-dot
+                         (if (= (aref ido-text 0) ?.)
+                             (= (aref name 0) ?.)
+                           (/= (aref name 0) ?.)))
+                     (string-match re name))
+                (cond
+                 ((and full-re (string-match full-re name))
+                  (setq full-matches (cons item full-matches)))
+                 ((and suffix-re (string-match suffix-re name))
+                  (setq suffix-matches (cons item suffix-matches)))
+                 ((and prefix-re (string-match prefix-re name))
+                  (setq prefix-matches (cons item prefix-matches)))
+                 (t (setq matches (cons item matches))))))
+          t)
          items)
       (invalid-regexp
        (setq ido-incomplete-regexp t
@@ -3538,10 +3577,15 @@ for first matching file."
              ;; special-case single match, and handle appropriately
              ;; elsewhere.
              matches (cdr error))))
-    (if prefix-matches
-       (setq matches (nconc prefix-matches matches)))
-    (if full-matches
-       (setq matches (nconc full-matches matches)))
+    (when prefix-matches
+      (ido-trace "prefix match" prefix-matches)
+      (setq matches (nconc prefix-matches matches)))
+    (when suffix-matches
+      (ido-trace "suffix match" (list text suffix-re suffix-matches))
+      (setq matches (nconc suffix-matches matches)))
+    (when full-matches
+      (ido-trace "full match" (list text full-re full-matches))
+      (setq matches (nconc full-matches matches)))
     (when (and (null matches)
               ido-enable-flex-matching
               (> (length ido-text) 1)
@@ -3581,7 +3625,7 @@ for first matching file."
                  ((stringp nextstr)
                   (and (>= flen (setq slen (length nextstr)))
                        (string-equal (substring name (- flen slen)) nextstr)))
-                 ((fboundp nextstr) (funcall nextstr name))
+                 ((functionp nextstr) (funcall nextstr name))
                  (t nil))
                 (setq ignorep t
                       ext-list nil
@@ -3591,7 +3635,7 @@ for first matching file."
             (setq nextstr (car re-list))
             (if (cond
                  ((stringp nextstr) (string-match nextstr name))
-                 ((fboundp nextstr) (funcall nextstr name))
+                 ((functionp nextstr) (funcall nextstr name))
                  (t nil))
                 (setq ignorep t
                       re-list nil)
@@ -3698,7 +3742,7 @@ for first matching file."
                  (funcall f completion-list
                           :help-string "ido "
                           :activate-callback
-                          '(lambda (x y z) (message "doesn't work yet, sorry!"))))
+                          '(lambda (x y z) (message "Doesn't work yet, sorry!"))))
              ;; else running Emacs
              ;;(add-hook 'completion-setup-hook 'completion-setup-function)
              (display-completion-list completion-list)))))))
@@ -3708,7 +3752,7 @@ for first matching file."
   "Kill the buffer at the head of `ido-matches'."
   (interactive)
   (let ((enable-recursive-minibuffers t)
-       (buf (car ido-matches)))
+       (buf (ido-name (car ido-matches))))
     (when buf
       (kill-buffer buf)
       ;; Check if buffer still exists.
@@ -3723,7 +3767,7 @@ for first matching file."
   "Delete the file at the head of `ido-matches'."
   (interactive)
   (let ((enable-recursive-minibuffers t)
-       (file (car ido-matches)))
+       (file (ido-name (car ido-matches))))
     (if file
        (setq file (concat ido-current-directory file)))
     (when (and file
@@ -3742,9 +3786,10 @@ for first matching file."
 
 ;;; VISIT CHOSEN BUFFER
 (defun ido-visit-buffer (buffer method &optional record)
-  "Visit file named FILE according to METHOD.
+  "Switch to BUFFER according to METHOD.
 Record command in `command-history' if optional RECORD is non-nil."
-
+  (if (bufferp buffer)
+      (setq buffer (buffer-name buffer)))
   (let (win newframe)
     (cond
      ((eq method 'kill)
@@ -3752,33 +3797,7 @@ Record command in `command-history' if optional RECORD is non-nil."
          (ido-record-command 'kill-buffer buffer))
       (kill-buffer buffer))
 
-     ((eq method 'samewindow)
-      (if record
-         (ido-record-command 'switch-to-buffer buffer))
-      (switch-to-buffer buffer))
-
-     ((memq method '(always-frame maybe-frame))
-      (cond
-       ((and window-system
-            (setq win (ido-window-buffer-p buffer))
-            (or (eq method 'always-frame)
-                (y-or-n-p "Jump to frame? ")))
-       (setq newframe (window-frame win))
-       (if (fboundp 'select-frame-set-input-focus)
-           (select-frame-set-input-focus newframe)
-         (raise-frame newframe)
-         (select-frame newframe)
-         (unless (featurep 'xemacs)
-           (set-mouse-position (selected-frame) (1- (frame-width)) 0)))
-       (select-window win))
-       (t
-       ;;  No buffer in other frames...
-       (if record
-           (ido-record-command 'switch-to-buffer buffer))
-       (switch-to-buffer buffer)
-       )))
-
-     ((eq method 'otherwindow)
+     ((eq method 'other-window)
       (if record
          (ido-record-command 'switch-to-buffer buffer))
       (switch-to-buffer-other-window buffer))
@@ -3786,14 +3805,29 @@ Record command in `command-history' if optional RECORD is non-nil."
      ((eq method 'display)
       (display-buffer buffer))
 
-     ((eq method 'otherframe)
+     ((eq method 'other-frame)
       (switch-to-buffer-other-frame buffer)
-      (unless (featurep 'xemacs)
-       (select-frame-set-input-focus (selected-frame)))
+      (select-frame-set-input-focus (selected-frame)))
+
+     ((and (memq method '(raise-frame maybe-frame))
+          window-system
+          (setq win (ido-buffer-window-other-frame buffer))
+          (or (eq method 'raise-frame)
+              (y-or-n-p "Jump to frame? ")))
+      (setq newframe (window-frame win))
+      (select-frame-set-input-focus newframe)
+      (select-window win))
+
+     ;; (eq method 'selected-window)
+     (t
+      ;;  No buffer in other frames...
+      (if record
+         (ido-record-command 'switch-to-buffer buffer))
+      (switch-to-buffer buffer)
       ))))
 
 
-(defun ido-window-buffer-p  (buffer)
+(defun ido-buffer-window-other-frame  (buffer)
   ;; Return window pointer if BUFFER is visible in another frame.
   ;; If BUFFER is visible in the current frame, return nil.
   (let ((blist (ido-get-buffers-in-frames 'current)))
@@ -3850,7 +3884,7 @@ in a separate window.
 The buffer name is selected interactively by typing a substring.
 For details of keybindings, do `\\[describe-function] ido'."
   (interactive)
-  (ido-buffer-internal 'otherwindow 'switch-to-buffer-other-window))
+  (ido-buffer-internal 'other-window 'switch-to-buffer-other-window))
 
 ;;;###autoload
 (defun ido-display-buffer ()
@@ -3883,7 +3917,7 @@ The buffer name is selected interactively by typing a substring.
 For details of keybindings, do `\\[describe-function] ido'."
   (interactive)
   (if ido-mode
-      (ido-buffer-internal 'otherframe)
+      (ido-buffer-internal 'other-frame)
     (call-interactively 'switch-to-buffer-other-frame)))
 
 ;;;###autoload
@@ -3945,7 +3979,7 @@ in a separate window.
 The file name is selected interactively by typing a substring.
 For details of keybindings, do `\\[describe-function] ido-find-file'."
   (interactive)
-  (ido-file-internal 'otherwindow 'find-file-other-window))
+  (ido-file-internal 'other-window 'find-file-other-window))
 
 ;;;###autoload
 (defun ido-find-alternate-file ()
@@ -3993,7 +4027,7 @@ For details of keybindings, do `\\[describe-function] ido-find-file'."
 The file name is selected interactively by typing a substring.
 For details of keybindings, do `\\[describe-function] ido-find-file'."
   (interactive)
-  (ido-file-internal 'otherframe 'find-file-other-frame))
+  (ido-file-internal 'other-frame 'find-file-other-frame))
 
 ;;;###autoload
 (defun ido-write-file ()
@@ -4019,7 +4053,7 @@ For details of keybindings, do `\\[describe-function] 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, do `\\[describe-function] ido-find-file'."
   (interactive)
@@ -4028,7 +4062,7 @@ For details of keybindings, do `\\[describe-function] 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, do `\\[describe-function] ido-find-file'."
   (interactive)
@@ -4079,12 +4113,13 @@ For details of keybindings, do `\\[describe-function] ido-find-file'."
          try-single-dir-match
          refresh)
 
-      (ido-trace "\nexhibit" this-command)
-      (ido-trace "dir" ido-current-directory)
-      (ido-trace "contents" contents)
-      (ido-trace "list" ido-cur-list)
-      (ido-trace "matches" ido-matches)
-      (ido-trace "rescan" ido-rescan)
+      (when ido-trace-enable
+       (ido-trace "\nexhibit" this-command)
+       (ido-trace "dir" ido-current-directory)
+       (ido-trace "contents" contents)
+       (ido-trace "list" ido-cur-list)
+       (ido-trace "matches" ido-matches)
+       (ido-trace "rescan" ido-rescan))
 
       (save-excursion
        (goto-char (point-max))
@@ -4133,7 +4168,7 @@ For details of keybindings, do `\\[describe-function] ido-find-file'."
            (setq refresh t))
           ((string-equal contents "./")
            (setq refresh t))
-          ((string-match "\\`~[a-zA-Z0-9]+/\\'" contents)
+          ((string-match "\\`~[-_a-zA-Z0-9]+[$]?/\\'" contents)
            (ido-trace "new home" contents)
            (ido-set-current-home contents)
            (setq refresh t))
@@ -4174,7 +4209,7 @@ For details of keybindings, do `\\[describe-function] ido-find-file'."
            ((= (length contents) 2)
             "/")
            (ido-matches
-            (concat ido-current-directory (car ido-matches)))
+            (concat ido-current-directory (ido-name (car ido-matches))))
            (t
             (concat ido-current-directory (substring contents 0 -1)))))
          (setq ido-text-init (substring contents -1))
@@ -4210,12 +4245,12 @@ For details of keybindings, do `\\[describe-function] ido-find-file'."
                   ido-matches
                   (or (eq ido-enter-matching-directory 'first)
                       (null (cdr ido-matches)))
-                  (ido-final-slash (car ido-matches))
+                  (ido-final-slash (ido-name (car ido-matches)))
                   (or try-single-dir-match
                       (eq ido-enter-matching-directory t)))
          (ido-trace "single match" (car ido-matches))
          (ido-set-current-directory
-          (concat ido-current-directory (car ido-matches)))
+          (concat ido-current-directory (ido-name (car ido-matches))))
          (setq ido-exit 'refresh)
          (exit-minibuffer))