Subject: RE: bug#8184: 23.1.90; `menu-bar-non-minibuffer-window-p' error in callsto `kill-this-buffer'

From: "Drew Adams" <[email-masked]>
Date: Sun, 6 Mar 2011 10:59:05 -0800

> Am I right that the time for executing `kill-this-buffer-enabled-p' is
> currently always proportional to the number of live buffers?

Seems so.

> In that case I'd rewrite [t]his function as
> 
> (defun kill-this-buffer-enabled-p ()
>    (or (not (menu-bar-non-minibuffer-window-p))
>        (let (found-1)
> 	(catch 'found-2
> 	  (dolist (buffer (buffer-list))
> 	    (unless (string-match-p "^ " (buffer-name buffer))
> 	      (if (not found-1)
> 		  (setq found-1 t)
> 		(throw 'found-2 t))))))))

`found-1' is useless here (not used).

(defun kill-this-buffer-enabled-p ()
  (or (not (menu-bar-non-minibuffer-window-p))
      (catch 'found
        (dolist (buffer  (buffer-list))
          (unless (string-match-p "^ " (buffer-name buffer))
            (throw 'found t)))
        nil)))