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: Fri, 28 May 2010 14:29:01 +0200 Message-ID: <201005281429.03104.tassilo@member.fsf.org> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_Oc7/LEX7c1udRtd" X-Trace: dough.gmane.org 1275049760 16692 80.91.229.12 (28 May 2010 12:29:20 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 28 May 2010 12:29:20 +0000 (UTC) Cc: Juanma Barranquero , emacs-devel@gnu.org To: Leo Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri May 28 14:29:18 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 1OHygg-00053N-7E for ged-emacs-devel@m.gmane.org; Fri, 28 May 2010 14:29:18 +0200 Original-Received: from localhost ([127.0.0.1]:34648 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OHygf-0007Lr-3X for ged-emacs-devel@m.gmane.org; Fri, 28 May 2010 08:29:17 -0400 Original-Received: from [140.186.70.92] (port=42810 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OHygW-0007KY-28 for emacs-devel@gnu.org; Fri, 28 May 2010 08:29:10 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OHygU-0006f8-Lw for emacs-devel@gnu.org; Fri, 28 May 2010 08:29:07 -0400 Original-Received: from deliver.uni-koblenz.de ([141.26.64.15]:26129) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OHygU-0006el-9T for emacs-devel@gnu.org; Fri, 28 May 2010 08:29:06 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by deliver.uni-koblenz.de (Postfix) with ESMTP id E67DB78A47EA; Fri, 28 May 2010 14:29:04 +0200 (CEST) Original-Received: from deliver.uni-koblenz.de ([127.0.0.1]) by localhost (deliver.uni-koblenz.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 06251-03; Fri, 28 May 2010 14:29:03 +0200 (CEST) X-CHKRCPT: Envelopesender noch tassilo@member.fsf.org Original-Received: from thinkpad.localnet (tsdh.uni-koblenz.de [141.26.67.142]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by deliver.uni-koblenz.de (Postfix) with ESMTP id 836E278A47EF; Fri, 28 May 2010 14:29:03 +0200 (CEST) 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:125327 Archived-At: --Boundary-00=_Oc7/LEX7c1udRtd Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit On Friday 28 May 2010 14:15:23 Leo wrote: Hi Leo! > Thanks for this. I have incorporated your fix and the updated patch > against trunk is available here: > http://paste.lisp.org/display/105717#1. I've applied it, and it seems to work like a charm. For the record, I attach it to this mail as well. So let's wait for your papers to arrive and then apply it. Bye, Tassilo --Boundary-00=_Oc7/LEX7c1udRtd Content-Type: text/x-patch; charset="UTF-8"; name="ido-vbuffers-modified-by-leo.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="ido-vbuffers-modified-by-leo.patch" === modified file 'lisp/ido.el' --- lisp/ido.el 2010-05-25 02:11:08 +0000 +++ lisp/ido.el 2010-05-28 12:26:03 +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. @@ -1095,6 +1098,15 @@ ;; Don't process ido-ignore- lists once. (defvar ido-process-ignore-lists-inhibit) +;; existing buffers including ignored ones when switching buffers in ido +(defvar ido-existing-buffers) + +;; ido virtual buffers are currently enabled +(defvar ido-virtual-buffers-enabled) + +;; stop ido virtual buffers from being added +(defvar ido-virtual-buffers-inhibit) + ;; Buffer from which ido was entered. (defvar ido-entry-buffer) @@ -1841,6 +1853,7 @@ (icomplete-mode nil) ;; prevent icomplete starting up ;; Exported dynamic variables: ido-cur-list + ido-existing-buffers ido-ignored-list (ido-rotate-temp nil) (ido-keep-item-list nil) @@ -1859,6 +1872,12 @@ (run-hooks 'ido-setup-hook) + (when (eq ido-cur-item 'buffer) + (setq ido-existing-buffers + ;; ido-process-ignore-lists nil means not to ignore + (let (ido-process-ignore-lists ido-virtual-buffers-enabled) + (ido-make-buffer-list nil)))) + (while (not done) (ido-trace "\n_LOOP_" ido-text-init) (setq ido-exit nil) @@ -2181,9 +2200,11 @@ (ido-current-directory nil) (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 - ido-use-virtual-buffers)) + ;; when method is 'kill don't enable virtual buffers; this + ;; is the case when calling `idl-kill-buffer'. + (ido-virtual-buffers-enabled (and (eq ido-use-virtual-buffers 'always) + (not (eq method 'kill)))) + (ido-virtual-buffers-inhibit (not ido-virtual-buffers-enabled)) (require-match (confirm-nonexistent-file-or-buffer)) (buf (ido-read-internal 'buffer (or prompt "Buffer: ") 'ido-buffer-history default require-match initial)) @@ -2224,7 +2245,8 @@ (ido-visit-buffer buf method t))) ;; check for a virtual buffer reference - ((and ido-use-virtual-buffers ido-virtual-buffers + ((and ido-virtual-buffers-enabled + ido-virtual-buffers (setq filename (assoc buf ido-virtual-buffers))) (ido-visit-buffer (find-file-noselect (cdr filename)) method t)) @@ -2712,7 +2734,8 @@ 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-virtual-buffers-enabled + (not ido-virtual-buffers-enabled)) (setq ido-text-init ido-text) (setq ido-exit 'refresh) (exit-minibuffer))) @@ -3403,7 +3426,7 @@ (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 (and (boundp ido-virtual-buffers-enabled) ido-virtual-buffers-enabled) (ido-add-virtual-buffers-to-list)) (run-hooks 'ido-make-buffer-list-hook) ido-temp-list)) @@ -4465,6 +4488,33 @@ (setq ido-exit 'refresh) (exit-minibuffer))) + (when (and (eq ido-use-virtual-buffers 'auto) + (eq ido-cur-item 'buffer) + (not ido-matches) + ido-virtual-buffers-inhibit) + (setq ido-text-init ido-text) + (setq ido-virtual-buffers-enabled t) + (setq ido-virtual-buffers-inhibit nil) + (setq ido-exit 'refresh) + (exit-minibuffer)) + + (when (and (eq ido-use-virtual-buffers 'auto) + (eq ido-cur-item 'buffer) + ido-matches + ido-virtual-buffers-enabled + (not ido-virtual-buffers-inhibit)) + ;; protect ido-matches from being modified by ido-set-matches + (let ((ido-matches ido-matches)) + (let ((ido-cur-list ido-existing-buffers) + (ido-rotate ido-rotate)) + (ido-set-matches)) + (when ido-matches + (setq ido-virtual-buffers-enabled nil) + (setq ido-virtual-buffers-inhibit t) + (setq ido-text-init ido-text) + (setq ido-exit 'refresh) + (exit-minibuffer)))) + (when (and ido-rescan (not ido-matches) --Boundary-00=_Oc7/LEX7c1udRtd--