diff options
| author | Leo Liu | 2010-08-21 15:35:27 +0200 |
|---|---|---|
| committer | Stefan Monnier | 2010-08-21 15:35:27 +0200 |
| commit | e0143335522bda205591cab09407e3bec41c9a40 (patch) | |
| tree | fc6d02c7d81d730ecbfa398659c5e63c2c3ec722 | |
| parent | 8f081e96dec8821ecf3452237b74cfc7ee6a315b (diff) | |
| download | emacs-e0143335522bda205591cab09407e3bec41c9a40.tar.gz emacs-e0143335522bda205591cab09407e3bec41c9a40.zip | |
Fix buffer-list rename&refresh after after killing a buffer in ido.
* lisp/ido.el: Revert Óscar's.
(ido-kill-buffer-at-head): Exit the minibuffer with ido-exit=refresh.
Remember the buffers at head, rather than their name.
* lisp/iswitchb.el (iswitchb-kill-buffer): Re-make the list.
| -rw-r--r-- | lisp/ChangeLog | 8 | ||||
| -rw-r--r-- | lisp/ido.el | 66 | ||||
| -rw-r--r-- | lisp/iswitchb.el | 10 |
3 files changed, 40 insertions, 44 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index f6aa59c2db5..2318ce84600 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,11 @@ | |||
| 1 | 2010-08-21 Leo <sdl.web@gmail.com> | ||
| 2 | |||
| 3 | Fix buffer-list rename&refresh after after killing a buffer in ido. | ||
| 4 | * lisp/ido.el: Revert Óscar's. | ||
| 5 | (ido-kill-buffer-at-head): Exit the minibuffer with ido-exit=refresh. | ||
| 6 | Remember the buffers at head, rather than their name. | ||
| 7 | * lisp/iswitchb.el (iswitchb-kill-buffer): Re-make the list. | ||
| 8 | |||
| 1 | 2010-08-21 Kirk Kelsey <kirk.kelsey@0x4b.net> (tiny change) | 9 | 2010-08-21 Kirk Kelsey <kirk.kelsey@0x4b.net> (tiny change) |
| 2 | Stefan Monnier <monnier@iro.umontreal.ca> | 10 | Stefan Monnier <monnier@iro.umontreal.ca> |
| 3 | 11 | ||
diff --git a/lisp/ido.el b/lisp/ido.el index 6cedccb3787..a4409775a86 100644 --- a/lisp/ido.el +++ b/lisp/ido.el | |||
| @@ -1042,11 +1042,11 @@ Value is an integer which is number of chars to right of prompt.") | |||
| 1042 | ;; Stores the current list of items that will be searched through. | 1042 | ;; Stores the current list of items that will be searched through. |
| 1043 | ;; The list is ordered, so that the most interesting item comes first, | 1043 | ;; The list is ordered, so that the most interesting item comes first, |
| 1044 | ;; although by default, the files visible in the current frame are put | 1044 | ;; although by default, the files visible in the current frame are put |
| 1045 | ;; at the end of the list. | 1045 | ;; at the end of the list. Created by `ido-make-item-list'. |
| 1046 | (defvar ido-cur-list nil) | 1046 | (defvar ido-cur-list) |
| 1047 | 1047 | ||
| 1048 | ;; Stores the choice list for ido-completing-read | 1048 | ;; Stores the choice list for ido-completing-read |
| 1049 | (defvar ido-choice-list nil) | 1049 | (defvar ido-choice-list) |
| 1050 | 1050 | ||
| 1051 | ;; Stores the list of items which are ignored when building | 1051 | ;; Stores the list of items which are ignored when building |
| 1052 | ;; `ido-cur-list'. It is in no specific order. | 1052 | ;; `ido-cur-list'. It is in no specific order. |
| @@ -3348,12 +3348,9 @@ for first matching file." | |||
| 3348 | (if ido-temp-list | 3348 | (if ido-temp-list |
| 3349 | (nconc ido-temp-list ido-current-buffers) | 3349 | (nconc ido-temp-list ido-current-buffers) |
| 3350 | (setq ido-temp-list ido-current-buffers)) | 3350 | (setq ido-temp-list ido-current-buffers)) |
| 3351 | (if (and default (buffer-live-p (get-buffer default))) | 3351 | (if default |
| 3352 | (progn | 3352 | (setq ido-temp-list |
| 3353 | (setq ido-temp-list | 3353 | (cons default (delete default ido-temp-list)))) |
| 3354 | (delete default ido-temp-list)) | ||
| 3355 | (setq ido-temp-list | ||
| 3356 | (cons default ido-temp-list)))) | ||
| 3357 | (run-hooks 'ido-make-buffer-list-hook) | 3354 | (run-hooks 'ido-make-buffer-list-hook) |
| 3358 | ido-temp-list)) | 3355 | ido-temp-list)) |
| 3359 | 3356 | ||
| @@ -3594,7 +3591,6 @@ for first matching file." | |||
| 3594 | ;; Used by `ido-get-buffers-in-frames' to walk through all windows | 3591 | ;; Used by `ido-get-buffers-in-frames' to walk through all windows |
| 3595 | (let ((buf (buffer-name (window-buffer win)))) | 3592 | (let ((buf (buffer-name (window-buffer win)))) |
| 3596 | (unless (or (member buf ido-bufs-in-frame) | 3593 | (unless (or (member buf ido-bufs-in-frame) |
| 3597 | (minibufferp buf) | ||
| 3598 | (member buf ido-ignore-item-temp-list)) | 3594 | (member buf ido-ignore-item-temp-list)) |
| 3599 | ;; Only add buf if it is not already in list. | 3595 | ;; Only add buf if it is not already in list. |
| 3600 | ;; This prevents same buf in two different windows being | 3596 | ;; This prevents same buf in two different windows being |
| @@ -3835,27 +3831,6 @@ for first matching file." | |||
| 3835 | ;;(add-hook 'completion-setup-hook 'completion-setup-function) | 3831 | ;;(add-hook 'completion-setup-hook 'completion-setup-function) |
| 3836 | (display-completion-list completion-list))))))) | 3832 | (display-completion-list completion-list))))))) |
| 3837 | 3833 | ||
| 3838 | (defun ido-kill-buffer-internal (buf) | ||
| 3839 | "Kill buffer BUF and rebuild ido's buffer list if needed." | ||
| 3840 | (if (not (kill-buffer buf)) | ||
| 3841 | ;; buffer couldn't be killed. | ||
| 3842 | (setq ido-rescan t) | ||
| 3843 | ;; else buffer was killed so remove name from list. | ||
| 3844 | (setq ido-cur-list (delq buf ido-cur-list)) | ||
| 3845 | ;; Some packages, like uniquify.el, may rename buffers when one | ||
| 3846 | ;; is killed, so we need to test this condition to avoid using | ||
| 3847 | ;; an outdated list of buffer names. We don't want to always | ||
| 3848 | ;; rebuild the list of buffers, as this alters the previous | ||
| 3849 | ;; buffer order that the user was seeing on the prompt. However, | ||
| 3850 | ;; when we rebuild the list, we try to keep the previous second | ||
| 3851 | ;; buffer as the first one. | ||
| 3852 | (catch 'update | ||
| 3853 | (dolist (b ido-cur-list) | ||
| 3854 | (unless (get-buffer b) | ||
| 3855 | (setq ido-cur-list (ido-make-buffer-list (cadr ido-matches))) | ||
| 3856 | (setq ido-rescan t) | ||
| 3857 | (throw 'update nil)))))) | ||
| 3858 | |||
| 3859 | ;;; KILL CURRENT BUFFER | 3834 | ;;; KILL CURRENT BUFFER |
| 3860 | (defun ido-kill-buffer-at-head () | 3835 | (defun ido-kill-buffer-at-head () |
| 3861 | "Kill the buffer at the head of `ido-matches'. | 3836 | "Kill the buffer at the head of `ido-matches'. |
| @@ -3864,15 +3839,26 @@ If cursor is not at the end of the user input, delete to end of input." | |||
| 3864 | (if (not (eobp)) | 3839 | (if (not (eobp)) |
| 3865 | (delete-region (point) (line-end-position)) | 3840 | (delete-region (point) (line-end-position)) |
| 3866 | (let ((enable-recursive-minibuffers t) | 3841 | (let ((enable-recursive-minibuffers t) |
| 3867 | (buf (ido-name (car ido-matches)))) | 3842 | (buf (ido-name (car ido-matches))) |
| 3868 | (when buf | 3843 | (nextbuf (cadr ido-matches))) |
| 3869 | (ido-kill-buffer-internal buf) | 3844 | (when (get-buffer buf) |
| 3870 | ;; Check if buffer still exists. | 3845 | ;; If next match names a buffer use the buffer object; buffer |
| 3871 | (if (get-buffer buf) | 3846 | ;; name may be changed by packages such as uniquify; mindful |
| 3872 | ;; buffer couldn't be killed. | 3847 | ;; of virtual buffers. |
| 3848 | (when (and nextbuf (get-buffer nextbuf)) | ||
| 3849 | (setq nextbuf (get-buffer nextbuf))) | ||
| 3850 | (if (null (kill-buffer buf)) | ||
| 3851 | ;; Buffer couldn't be killed. | ||
| 3873 | (setq ido-rescan t) | 3852 | (setq ido-rescan t) |
| 3874 | ;; else buffer was killed so remove name from list. | 3853 | ;; Else `kill-buffer' succeeds so re-make the buffer list |
| 3875 | (setq ido-cur-list (delq buf ido-cur-list))))))) | 3854 | ;; taking into account packages like uniquify may rename |
| 3855 | ;; buffers. | ||
| 3856 | (if (bufferp nextbuf) | ||
| 3857 | (setq nextbuf (buffer-name nextbuf))) | ||
| 3858 | (setq ido-default-item nextbuf | ||
| 3859 | ido-text-init ido-text | ||
| 3860 | ido-exit 'refresh) | ||
| 3861 | (exit-minibuffer)))))) | ||
| 3876 | 3862 | ||
| 3877 | ;;; DELETE CURRENT FILE | 3863 | ;;; DELETE CURRENT FILE |
| 3878 | (defun ido-delete-file-at-head () | 3864 | (defun ido-delete-file-at-head () |
| @@ -3910,7 +3896,7 @@ Record command in `command-history' if optional RECORD is non-nil." | |||
| 3910 | ((eq method 'kill) | 3896 | ((eq method 'kill) |
| 3911 | (if record | 3897 | (if record |
| 3912 | (ido-record-command 'kill-buffer buffer)) | 3898 | (ido-record-command 'kill-buffer buffer)) |
| 3913 | (ido-kill-buffer-internal buffer)) | 3899 | (kill-buffer buffer)) |
| 3914 | 3900 | ||
| 3915 | ((eq method 'other-window) | 3901 | ((eq method 'other-window) |
| 3916 | (if record | 3902 | (if record |
diff --git a/lisp/iswitchb.el b/lisp/iswitchb.el index ea4b00dc90d..081897a89b3 100644 --- a/lisp/iswitchb.el +++ b/lisp/iswitchb.el | |||
| @@ -1027,8 +1027,8 @@ Return the modified list with the last element prepended to it." | |||
| 1027 | (defun iswitchb-kill-buffer () | 1027 | (defun iswitchb-kill-buffer () |
| 1028 | "Kill the buffer at the head of `iswitchb-matches'." | 1028 | "Kill the buffer at the head of `iswitchb-matches'." |
| 1029 | (interactive) | 1029 | (interactive) |
| 1030 | (let ( (enable-recursive-minibuffers t) | 1030 | (let ((enable-recursive-minibuffers t) |
| 1031 | buf) | 1031 | buf) |
| 1032 | 1032 | ||
| 1033 | (setq buf (car iswitchb-matches)) | 1033 | (setq buf (car iswitchb-matches)) |
| 1034 | ;; check to see if buf is non-nil. | 1034 | ;; check to see if buf is non-nil. |
| @@ -1042,8 +1042,10 @@ Return the modified list with the last element prepended to it." | |||
| 1042 | (if (get-buffer buf) | 1042 | (if (get-buffer buf) |
| 1043 | ;; buffer couldn't be killed. | 1043 | ;; buffer couldn't be killed. |
| 1044 | (setq iswitchb-rescan t) | 1044 | (setq iswitchb-rescan t) |
| 1045 | ;; else buffer was killed so remove name from list. | 1045 | ;; Else `kill-buffer' succeeds so re-make the buffer list |
| 1046 | (setq iswitchb-buflist (delq buf iswitchb-buflist))))))) | 1046 | ;; taking into account packages like uniquify may rename |
| 1047 | ;; buffers | ||
| 1048 | (iswitchb-make-buflist iswitchb-default)))))) | ||
| 1047 | 1049 | ||
| 1048 | ;;; VISIT CHOSEN BUFFER | 1050 | ;;; VISIT CHOSEN BUFFER |
| 1049 | (defun iswitchb-visit-buffer (buffer) | 1051 | (defun iswitchb-visit-buffer (buffer) |