From: "Óscar Fuentes" <ofv@wanadoo.es>
To: emacs-devel@gnu.org
Subject: Re: PATCH: Fix IDO interaction with uniquify.el
Date: Mon, 18 Jan 2010 18:52:41 +0100 [thread overview]
Message-ID: <87ockrz4eu.fsf@telefonica.net> (raw)
In-Reply-To: 87tyujz57h.fsf@telefonica.net
Óscar Fuentes <ofv@wanadoo.es> writes:
This is the definitive one.
... or so I hope.
Removed a `let' that was unnecessary after the style improvement.
2010-01-18 Óscar Fuentes <ofv@wanadoo.es>
* ido.el (ido-cur-list): Initialize as nil. Remove obsolete
information from commentary.
(ido-choice-list): Initialize as nil.
(ido-get-bufname): Reject minibuffers.
(ido-make-buffer-list): If "default" is a nonexistent
buffer, ignore it, as per the docstring.
(ido-kill-buffer-internal): New function.
(ido-kill-buffer-at-head): Use it.
(ido-visit-buffer): Likewise.
=== modified file 'lisp/ido.el'
--- lisp/ido.el 2010-01-13 08:35:10 +0000
+++ lisp/ido.el 2010-01-18 17:45:50 +0000
@@ -1042,11 +1042,11 @@
;; 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. Created by `ido-make-item-list'.
-(defvar ido-cur-list)
+;; at the end of the list.
+(defvar ido-cur-list nil)
;; Stores the choice list for ido-completing-read
-(defvar ido-choice-list)
+(defvar ido-choice-list nil)
;; Stores the list of items which are ignored when building
;; `ido-cur-list'. It is in no specific order.
@@ -3344,7 +3344,7 @@
(if ido-temp-list
(nconc ido-temp-list ido-current-buffers)
(setq ido-temp-list ido-current-buffers))
- (if default
+ (if (and default (buffer-live-p (get-buffer default)))
(progn
(setq ido-temp-list
(delete default ido-temp-list))
@@ -3590,6 +3590,7 @@
;; 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
@@ -3830,6 +3831,28 @@
;;(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)
+ (progn
+ ;; 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'.
@@ -3840,7 +3863,7 @@
(let ((enable-recursive-minibuffers t)
(buf (ido-name (car ido-matches))))
(when buf
- (kill-buffer buf)
+ (ido-kill-buffer-internal buf)
;; Check if buffer still exists.
(if (get-buffer buf)
;; buffer couldn't be killed.
@@ -3884,7 +3907,7 @@
((eq method 'kill)
(if record
(ido-record-command 'kill-buffer buffer))
- (kill-buffer buffer))
+ (ido-kill-buffer-internal buffer))
((eq method 'other-window)
(if record
next prev parent reply other threads:[~2010-01-18 17:52 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-18 10:27 PATCH: Fix IDO interaction with uniquify.el Óscar Fuentes
2010-01-18 10:59 ` Juanma Barranquero
2010-01-18 11:12 ` Juanma Barranquero
2010-01-18 14:13 ` Óscar Fuentes
2010-01-18 14:32 ` Juanma Barranquero
2010-01-18 14:41 ` Óscar Fuentes
2010-01-18 15:44 ` Chong Yidong
2010-01-18 17:35 ` Óscar Fuentes
2010-01-18 17:52 ` Óscar Fuentes [this message]
2010-01-18 18:06 ` Chong Yidong
2010-01-18 19:17 ` Juanma Barranquero
2010-05-05 8:27 ` Leo
2010-05-05 9:56 ` Juanma Barranquero
2010-05-05 12:40 ` Leo
2010-05-05 16:47 ` Juanma Barranquero
2010-05-05 17:35 ` Leo
2010-05-05 19:12 ` Leo
2010-05-05 19:48 ` Juanma Barranquero
2010-05-06 12:54 ` Stefan Monnier
2010-05-05 17:56 ` Leo
2010-05-05 19:25 ` Juanma Barranquero
2010-05-05 18:14 ` Stefan Monnier
2010-05-05 19:09 ` Óscar Fuentes
2010-05-05 19:50 ` Leo
2010-05-05 19:59 ` Leo
2010-05-05 20:36 ` Óscar Fuentes
2010-05-06 20:43 ` Juri Linkov
2010-05-05 20:27 ` Stefan Monnier
2010-05-05 20:38 ` Óscar Fuentes
2010-05-06 16:56 ` Kim F. Storm
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ockrz4eu.fsf@telefonica.net \
--to=ofv@wanadoo.es \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.