From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tassilo Horn Newsgroups: gmane.emacs.devel Subject: Re: Concerning the new `ido-use-virtual-buffers' feature Date: Thu, 27 May 2010 21:05:44 +0200 Message-ID: <201005272105.45102.tassilo@member.fsf.org> References: <201005271257.02056.tassilo@member.fsf.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_IKs/LPezX6i4z5f" X-Trace: dough.gmane.org 1274987182 18424 80.91.229.12 (27 May 2010 19:06:22 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 27 May 2010 19:06:22 +0000 (UTC) Cc: John Wiegley , "Kim F. Storm" , emacs-devel@gnu.org To: Leo Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu May 27 21:06:20 2010 connect(): No such file or directory Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OHiPK-0007GY-50 for ged-emacs-devel@m.gmane.org; Thu, 27 May 2010 21:06:18 +0200 Original-Received: from localhost ([127.0.0.1]:42490 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OHiPJ-00029z-8g for ged-emacs-devel@m.gmane.org; Thu, 27 May 2010 15:06:17 -0400 Original-Received: from [140.186.70.92] (port=58237 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OHiP7-00026x-AS for emacs-devel@gnu.org; Thu, 27 May 2010 15:06:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OHiP5-0005ur-Fy for emacs-devel@gnu.org; Thu, 27 May 2010 15:06:04 -0400 Original-Received: from out2.smtp.messagingengine.com ([66.111.4.26]:34963) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OHiP5-0005uk-BK for emacs-devel@gnu.org; Thu, 27 May 2010 15:06:03 -0400 Original-Received: from compute1.internal (compute1.internal [10.202.2.41]) by gateway1.messagingengine.com (Postfix) with ESMTP id AD697F84D2; Thu, 27 May 2010 15:05:50 -0400 (EDT) Original-Received: from heartbeat1.messagingengine.com ([10.202.2.160]) by compute1.internal (MEProxy); Thu, 27 May 2010 15:05:50 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=messagingengine.com; h=from:to:subject:date:cc:references:in-reply-to:mime-version:content-type:message-id; s=smtpout; bh=WIZX7JaVNhGytgnrrH/xH64XBnQ=; b=f/ZdxVazfLZOb453shWrKOeZp1sthXj+3xdNBoqxSdFPbtrppghDxB0tcrk2a/y7f3LCvJxktndKEakULZtNRzuxpaUdqmCln61ffsSatHS/sCo0zV4AgKuDCUU123Z3pMpzcqhF/XPJjD7HbSFjugqnXKstwNRy6uXFl7f05+o= X-Sasl-enc: fbLeGmnZJdr5RlWqKtF3mViDiIBJ7UseGuRczyUXf5bA 1274987149 Original-Received: from thinkpad.localnet (p54AF145F.dip0.t-ipconnect.de [84.175.20.95]) by mail.messagingengine.com (Postfix) with ESMTPSA id B167F4C27C3; Thu, 27 May 2010 15:05:49 -0400 (EDT) User-Agent: KMail/1.13.3 (Linux/2.6.34-gentoo; KDE/4.4.3; x86_64; ; ) In-Reply-To: X-Face: `TY6r/ws=N5uqO1E`M=Sups<}n%T[E^o_?MJj< =?iso-8859-1?q?O4j=265ljV6lU=7DcXU7oftH=26/x=5F=7EK=7B=26zv9=7D=0A=09sB?= =?iso-8859-1?q?=7D5/Ea=5BhU=7BCS=23=3F=3F0=3F=3Fn?=@sX+ft]?{(l?, mp"a`u List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:125310 Archived-At: --Boundary-00=_IKs/LPezX6i4z5f Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit On Thursday 27 May 2010 20:01:04 Leo wrote: Hi Leo, > > The resulting patch is attached. Basically, it works, but there's > > one bug I cannot figure out how to solve. When > > ido-use-virtual-buffers is 'auto and the current input doesn't even > > match any closed buffer (recentf file), then it's stuck instead of > > displaying [no match]. > > > > I don't know ido very well and cannot figure out how to get that > > right. Kim, maybe you could check what's wrong? > > I think it is in the added code in ido-exhibit which is run in > post-command-hook if I remember correctly. > > When your input doesn't match any (including virtual ones), the code > in ido-exhibit tells ido (the big LOOP in ido-read-internal) to > rebuild the buffer list and there isn't any match so it rebuild again > and again. Go into a infinite loop. > > You could try creating a new let-bound variable to detect such a > situation and avoid the infinite loop. Thanks for that. Here's a new patch which uses a new dynamic variable. It seems to work as far as I can tell, but it would be great if you could give it a test drive. One other wishlist item would be to remove virtual buffers from the completion list as soon as the input string matches a normal buffer again, because the user deleted some chars from the input... Bye, Tassilo --Boundary-00=_IKs/LPezX6i4z5f Content-Type: text/x-patch; charset="UTF-8"; name="ido-virtual-buffers.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="ido-virtual-buffers.patch" === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2010-05-27 07:08:37 +0000 +++ lisp/ChangeLog 2010-05-27 18:59:30 +0000 @@ -1,3 +1,14 @@ +2010-05-27 Tassilo Horn + + * ido.el (ido-exhibit, ido-buffer-internal) + (ido-toggle-virtual-buffers, ido-make-buffer-list) + (ido-buffer-internal, ido-exhibit, ido-read-internal): + ido-use-virtual-buffers now is a choice option with values 'never + (default), 'always, and 'auto. The latter means, show virtual + buffers if the current input doesn't match any existing buffer. + + Based on a patch by Leo . + 2010-05-27 Kenichi Handa * language/hebrew.el (hebrew-shape-gstring): Check if a glyph === modified file 'lisp/ido.el' --- lisp/ido.el 2010-05-25 02:11:08 +0000 +++ lisp/ido.el 2010-05-27 18:58:16 +0000 @@ -774,8 +774,10 @@ :type '(repeat string) :group 'ido) -(defcustom ido-use-virtual-buffers nil - "If non-nil, refer to past buffers as well as existing ones. +(defcustom ido-use-virtual-buffers 'never + "If `always', refer to past buffers as well as existing ones. +If `auto', refer to past buffers only when the current input +doesn't match an existing buffer. Essentially it works as follows: Say you are visiting a file and the buffer gets cleaned up by mignight.el. Later, you want to switch to that buffer, but find it's no longer open. With @@ -785,11 +787,12 @@ to think less about whether recently opened files are still open or not. Most of the time you can quit Emacs, restart, and then switch to a file buffer that was previously open as if it still -were. - This feature relies upon the `recentf' package, which will be -enabled if this variable is configured to a non-nil value." +were. This feature relies upon the `recentf' package, which will +be enabled if this variable is configured to a non-nil value." :version "24.1" - :type 'boolean + :type '(choice (const always) + (const auto) + (const never)) :group 'ido) (defcustom ido-use-faces t @@ -1056,7 +1059,7 @@ (defvar ido-virtual-buffers nil "List of virtual buffers, that is, past visited files. This is a copy of `recentf-list', pared down and with faces applied. -Only used if `ido-use-virtual-buffers' is non-nil.") +Only used if `ido-use-virtual-buffers' is not `never'.") ;;; Variables with dynamic bindings. ;;; Declared here to keep the byte compiler quiet. @@ -1837,6 +1840,7 @@ ido-default-item ido-selected ido-final-text + ido-using-virtual-buffers (done nil) (icomplete-mode nil) ;; prevent icomplete starting up ;; Exported dynamic variables: @@ -2182,7 +2186,7 @@ (ido-directory-nonreadable nil) (ido-directory-too-big nil) (ido-use-virtual-buffers (if (eq method 'kill) - nil ;; Don't consider virtual buffers for killing + 'never ;; Don't consider virtual buffers for killing ido-use-virtual-buffers)) (require-match (confirm-nonexistent-file-or-buffer)) (buf (ido-read-internal 'buffer (or prompt "Buffer: ") 'ido-buffer-history default @@ -2224,7 +2228,9 @@ (ido-visit-buffer buf method t))) ;; check for a virtual buffer reference - ((and ido-use-virtual-buffers ido-virtual-buffers + ((and (or (eq ido-use-virtual-buffers 'always) + (eq ido-use-virtual-buffers 'auto)) + ido-virtual-buffers (setq filename (assoc buf ido-virtual-buffers))) (ido-visit-buffer (find-file-noselect (cdr filename)) method t)) @@ -2712,7 +2718,9 @@ See `ido-use-virtual-buffers' for explanation of virtual buffer." (interactive) (when (and ido-mode (eq ido-cur-item 'buffer)) - (setq ido-use-virtual-buffers (not ido-use-virtual-buffers)) + (setq ido-use-virtual-buffers (if (eq ido-use-virtual-buffers 'never) + 'always + 'never)) (setq ido-text-init ido-text) (setq ido-exit 'refresh) (exit-minibuffer))) @@ -3403,7 +3411,9 @@ (when (and default (buffer-live-p (get-buffer default))) (setq ido-temp-list (cons default (delete default ido-temp-list)))) - (if ido-use-virtual-buffers + (if (or (eq ido-use-virtual-buffers 'always) + (and (eq ido-use-virtual-buffers 'auto) + (not ido-matches))) (ido-add-virtual-buffers-to-list)) (run-hooks 'ido-make-buffer-list-hook) ido-temp-list)) @@ -4465,6 +4475,15 @@ (setq ido-exit 'refresh) (exit-minibuffer))) + (when (and (eq ido-use-virtual-buffers 'auto) + (eq ido-cur-item 'buffer) + (not ido-matches) + (not ido-using-virtual-buffers)) + (setq ido-text-init ido-text) + (setq ido-using-virtual-buffers t) + (setq ido-exit 'refresh) + (exit-minibuffer)) + (when (and ido-rescan (not ido-matches) --Boundary-00=_IKs/LPezX6i4z5f--