nnimap.el (nnimap-open-connection): Look for the "imaps" entry in the .authinfo if...
[bpt/emacs.git] / lisp / ido.el
index f75f029..858ee3e 100644 (file)
@@ -780,7 +780,7 @@ Essentially it works as follows: Say you are visiting a file and
 the buffer gets cleaned up by mignight.el.  Later, you want to
 switch to that buffer, but find it's no longer open.  With
 virtual buffers enabled, the buffer name stays in the buffer
-list (using the ido-virtual face, and always at the end), and if
+list (using the `ido-virtual' face, and always at the end), and if
 you select it, it opens the file back up again.  This allows you
 to think less about whether recently opened files are still open
 or not.  Most of the time you can quit Emacs, restart, and then
@@ -1070,11 +1070,11 @@ Only used if `ido-use-virtual-buffers' is non-nil.")
 ;; Stores the current list of items that will be searched through.
 ;; The list is ordered, so that the most interesting item comes first,
 ;; although by default, the files visible in the current frame are put
-;; at the end of the list.
-(defvar ido-cur-list nil)
+;; at the end of the list.  Created by `ido-make-item-list'.
+(defvar ido-cur-list)
 
 ;; Stores the choice list for ido-completing-read
-(defvar ido-choice-list nil)
+(defvar ido-choice-list)
 
 ;; Stores the list of items which are ignored when building
 ;; `ido-cur-list'.  It is in no specific order.
@@ -2815,7 +2815,7 @@ If no buffer or file exactly matching the prompt exists, maybe create a new one.
    ((eq this-original-command 'viper-del-backward-char-in-insert)
     (funcall this-original-command))
    (t
-    (delete-backward-char (prefix-numeric-value count)))))
+    (delete-char (- (prefix-numeric-value count))))))
 
 (defun ido-delete-backward-word-updir (count)
   "Delete all chars backwards, or at beginning of buffer, go up one level."
@@ -3400,11 +3400,9 @@ for first matching file."
     (if ido-temp-list
        (nconc ido-temp-list ido-current-buffers)
       (setq ido-temp-list ido-current-buffers))
-    (when (and default (buffer-live-p (get-buffer default)))
-      (setq ido-temp-list
-           (cons default (delete default ido-temp-list))))
-    (if ido-use-virtual-buffers
-       (ido-add-virtual-buffers-to-list))
+    (if default
+        (setq ido-temp-list
+              (cons default (delete default ido-temp-list))))
     (run-hooks 'ido-make-buffer-list-hook)
     ido-temp-list))
 
@@ -3672,7 +3670,6 @@ This is to make them appear as if they were \"virtual buffers\"."
   ;; Used by `ido-get-buffers-in-frames' to walk through all windows
   (let ((buf (buffer-name (window-buffer win))))
        (unless (or (member buf ido-bufs-in-frame)
-                   (minibufferp buf)
                    (member buf ido-ignore-item-temp-list))
          ;; Only add buf if it is not already in list.
          ;; This prevents same buf in two different windows being
@@ -3913,27 +3910,6 @@ This is to make them appear as if they were \"virtual buffers\"."
              ;;(add-hook 'completion-setup-hook 'completion-setup-function)
              (display-completion-list completion-list)))))))
 
-(defun ido-kill-buffer-internal (buf)
-  "Kill buffer BUF and rebuild ido's buffer list if needed."
-  (if (not (kill-buffer buf))
-      ;; buffer couldn't be killed.
-      (setq ido-rescan t)
-    ;; else buffer was killed so remove name from list.
-    (setq ido-cur-list (delq buf ido-cur-list))
-    ;; Some packages, like uniquify.el, may rename buffers when one
-    ;; is killed, so we need to test this condition to avoid using
-    ;; an outdated list of buffer names. We don't want to always
-    ;; rebuild the list of buffers, as this alters the previous
-    ;; buffer order that the user was seeing on the prompt. However,
-    ;; when we rebuild the list, we try to keep the previous second
-    ;; buffer as the first one.
-    (catch 'update
-      (dolist (b ido-cur-list)
-       (unless (get-buffer b)
-         (setq ido-cur-list (ido-make-buffer-list (cadr ido-matches)))
-         (setq ido-rescan t)
-         (throw 'update nil))))))
-
 ;;; KILL CURRENT BUFFER
 (defun ido-kill-buffer-at-head ()
   "Kill the buffer at the head of `ido-matches'.
@@ -3942,15 +3918,26 @@ If cursor is not at the end of the user input, delete to end of input."
   (if (not (eobp))
       (delete-region (point) (line-end-position))
     (let ((enable-recursive-minibuffers t)
-         (buf (ido-name (car ido-matches))))
-      (when buf
-       (ido-kill-buffer-internal buf)
-       ;; Check if buffer still exists.
-       (if (get-buffer buf)
-           ;; buffer couldn't be killed.
+         (buf (ido-name (car ido-matches)))
+         (nextbuf (cadr ido-matches)))
+      (when (get-buffer buf)
+       ;; If next match names a buffer use the buffer object; buffer
+       ;; name may be changed by packages such as uniquify; mindful
+       ;; of virtual buffers.
+       (when (and nextbuf (get-buffer nextbuf))
+         (setq nextbuf (get-buffer nextbuf)))
+       (if (null (kill-buffer buf))
+           ;; Buffer couldn't be killed.
            (setq ido-rescan t)
-         ;; else buffer was killed so remove name from list.
-         (setq ido-cur-list (delq buf ido-cur-list)))))))
+         ;; Else `kill-buffer' succeeds so re-make the buffer list
+         ;; taking into account packages like uniquify may rename
+         ;; buffers.
+         (if (bufferp nextbuf)
+             (setq nextbuf (buffer-name nextbuf)))
+         (setq ido-default-item nextbuf
+               ido-text-init ido-text
+               ido-exit 'refresh)
+         (exit-minibuffer))))))
 
 ;;; DELETE CURRENT FILE
 (defun ido-delete-file-at-head ()
@@ -3988,7 +3975,7 @@ Record command in `command-history' if optional RECORD is non-nil."
      ((eq method 'kill)
       (if record
          (ido-record-command 'kill-buffer buffer))
-      (ido-kill-buffer-internal buffer))
+      (kill-buffer buffer))
 
      ((eq method 'other-window)
       (if record