]> code.delx.au - gnu-emacs/blobdiff - lisp/ido.el
international/characters.el: Add category '|' (word breakable) to fullwidth characters.
[gnu-emacs] / lisp / ido.el
index 60b874dcd4900904f0ce2e95a389b7fce4a76045..a4409775a86ca4b53a409d3ae8519a2d5a47282a 100644 (file)
@@ -2272,7 +2272,8 @@ If cursor is not at the end of the user input, move to end of input."
           (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 behavior 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
@@ -2288,7 +2289,10 @@ If cursor is not at the end of the user input, move to end of input."
                              (ffap-guesser)
                            (ffap-string-at-point))))
               (not (string-match "^http:/" fn))
-              (setq d (file-name-directory (expand-file-name fn)))
+              (let ((absolute-fn (expand-file-name fn)))
+                (setq d (if (file-directory-p absolute-fn)
+                            (file-name-as-directory absolute-fn)
+                          (file-name-directory absolute-fn))))
               (file-directory-p d))
          (setq ido-current-directory d)
          (setq initial (file-name-nondirectory fn))))))
@@ -3345,11 +3349,8 @@ for first matching file."
        (nconc ido-temp-list ido-current-buffers)
       (setq ido-temp-list ido-current-buffers))
     (if default
-       (progn
-         (setq ido-temp-list
-               (delete default ido-temp-list))
-         (setq ido-temp-list
-               (cons default ido-temp-list))))
+        (setq ido-temp-list
+              (cons default (delete default ido-temp-list))))
     (run-hooks 'ido-make-buffer-list-hook)
     ido-temp-list))
 
@@ -3838,15 +3839,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
-       (kill-buffer 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 ()