Subject: bug#6147: 23.2; ido-read-buffer regression

From: Juanma Barranquero <[email-masked]>
Date: Mon, 10 May 2010 01:02:30 +0200

On Sun, May 9, 2010 at 22:06, Kyle Hargraves <[email-masked]> wrote:

> This can be reproduced by evaluating:
> (ido-read-buffer "Buffer: " "nonexistent-buffer")
> In 23.2, you will see only a list of your current buffers. In 23.1,
> nonexistent-buffer is the default value.

Yes, it has changed.

> I believe the related commit may be:
> http://github.com/emacsmirror/emacs/commit/e2300713fd5a941bfe1dad338b88f4caf77cc945

Why do you believe that? AFAICS, that commit is related to virtual
buffers, and so it's not on Emacs 23.2.

The "culprit" is this change:

  ------------------------------------------------------------
  revno: 99373
  author: Óscar Fuentes <[email-masked]>
  committer: Juanma Barranquero <[email-masked]>
  branch nick: trunk
  timestamp: Mon 2010-01-18 20:34:55 +0100
  message:
    ido.el: Consider the possibility of buffer names changing after kill-buffer.

which includes this:

        (ido-make-buffer-list): If "default" is a nonexistent
        buffer, ignore it, as per the docstring.

=== modified file 'lisp/ido.el'
--- lisp/ido.el	2010-01-13 08:35:10 +0000
+++ lisp/ido.el	2010-01-18 19:34:55 +0000
@@ -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))

Now, though `ido-make-buffer-list' has not exactly a docstring, but a
comment, it really says:

  ;; [...]  If DEFAULT is non-nil, and corresponds to an existing buffer,
  ;; it is put to the start of the list.

so the use you did of it was relying on undocumented behaviour.

Whether it should work as you prefer or not, I have no comment; but
there has been some recent discussion on emacs-devel about reverting
this patch and replacing it with another fix, by Leo (see thread
titled "PATCH: Fix IDO  interaction with uniquify.el"); so perhaps you
can chime in with your thoughts.

   Juanma