From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Leo Newsgroups: gmane.emacs.bugs Subject: bug#5952: 23.1.95; Some new ido features on top of virtual buffers Date: Thu, 15 Apr 2010 11:54:37 +0100 Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: dough.gmane.org 1271329160 24212 80.91.229.12 (15 Apr 2010 10:59:20 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 15 Apr 2010 10:59:20 +0000 (UTC) Cc: John Wiegley To: 5952@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Apr 15 12:59:18 2010 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1O2Mmw-0002hy-Je for geb-bug-gnu-emacs@m.gmane.org; Thu, 15 Apr 2010 12:59:15 +0200 Original-Received: from localhost ([127.0.0.1]:38178 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O2Mmr-0007D0-OS for geb-bug-gnu-emacs@m.gmane.org; Thu, 15 Apr 2010 06:59:09 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O2Mmk-0007Cr-BV for bug-gnu-emacs@gnu.org; Thu, 15 Apr 2010 06:59:02 -0400 Original-Received: from [140.186.70.92] (port=45008 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O2Mmh-0007Ci-US for bug-gnu-emacs@gnu.org; Thu, 15 Apr 2010 06:59:01 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O2Mmg-0001bD-9y for bug-gnu-emacs@gnu.org; Thu, 15 Apr 2010 06:58:59 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:41782) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O2Mmg-0001b9-7J for bug-gnu-emacs@gnu.org; Thu, 15 Apr 2010 06:58:58 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1O2Mir-0001to-S2; Thu, 15 Apr 2010 06:55:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Leo Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 15 Apr 2010 10:55:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 5952 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.12713288927292 (code B ref -1); Thu, 15 Apr 2010 10:55:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 15 Apr 2010 10:54:52 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O2Mih-0001tZ-Rq for submit@debbugs.gnu.org; Thu, 15 Apr 2010 06:54:52 -0400 Original-Received: from mx10.gnu.org ([199.232.76.166]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O2Mig-0001tU-5c for submit@debbugs.gnu.org; Thu, 15 Apr 2010 06:54:50 -0400 Original-Received: from lists.gnu.org ([199.232.76.165]:37964) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1O2Mia-0003FD-OH for submit@debbugs.gnu.org; Thu, 15 Apr 2010 06:54:44 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O2Mia-0004o9-AM for bug-gnu-emacs@gnu.org; Thu, 15 Apr 2010 06:54:44 -0400 Original-Received: from [140.186.70.92] (port=37462 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O2MiS-0004km-8X for bug-gnu-emacs@gnu.org; Thu, 15 Apr 2010 06:54:43 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O2MiN-0000ve-Mw for bug-gnu-emacs@gnu.org; Thu, 15 Apr 2010 06:54:34 -0400 Original-Received: from ppsw-52.csi.cam.ac.uk ([131.111.8.152]:35939) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O2MiN-0000v1-D0 for bug-gnu-emacs@gnu.org; Thu, 15 Apr 2010 06:54:31 -0400 X-Cam-AntiVirus: no malware found X-Cam-SpamDetails: not scanned X-Cam-ScannerInfo: http://www.cam.ac.uk/cs/email/scanner/ Original-Received: from lapwing-gw-1.csx.cam.ac.uk ([131.111.1.66]:53618 helo=Victoria.local) by ppsw-52.csi.cam.ac.uk (smtp.hermes.cam.ac.uk [131.111.8.157]:587) with esmtpsa (PLAIN:sl392) (TLSv1:DHE-RSA-AES128-SHA:128) id 1O2MiL-0005HF-HM (Exim 4.70) (return-path ); Thu, 15 Apr 2010 11:54:29 +0100 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Thu, 15 Apr 2010 06:55:01 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:36259 Archived-At: --=-=-= Hello John, Thank you for the new feature 'virtual buffers' to ido.el in the devel repo. I have been using a similar feature locally but since discovered your patch, I switched to it. Here are three patches that add three features: 1. make it possible to toggle the use of virtual buffers. Bind the command to C-o when switching buffer (o for 'old' buffers). 2. handle files with same base names by appending one level of parent directory. Some files may still be ignored but the chance is much slimmer. 3. automatically bring in virtual buffers when user input doesn't match existing ones. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-New-function-ido-toggle-virtual-buffers-and-bind-to-.patch >From 9577b975915066f95ea744b54d25f594d7ceeeac Mon Sep 17 00:00:00 2001 From: Leo Date: Thu, 15 Apr 2010 08:39:13 +0100 Subject: [PATCH 1/3] New function ido-toggle-virtual-buffers and bind to C-o --- lisp/ido.el | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-) diff --git a/lisp/ido.el b/lisp/ido.el index ac97aed..704bf22 100644 --- a/lisp/ido.el +++ b/lisp/ido.el @@ -1633,6 +1633,7 @@ This function also adds a hook to the minibuffer." (define-key map "\C-x\C-f" 'ido-enter-find-file) (define-key map "\C-x\C-b" 'ido-fallback-command) (define-key map "\C-k" 'ido-kill-buffer-at-head) + (define-key map "\C-o" 'ido-toggle-virtual-buffers) (set-keymap-parent map ido-common-completion-map) (setq ido-buffer-completion-map map))) @@ -2182,6 +2183,7 @@ If cursor is not at the end of the user input, move to end of input." (ido-current-directory nil) (ido-directory-nonreadable nil) (ido-directory-too-big nil) + (ido-use-virtual-buffers ido-use-virtual-buffers) (require-match (confirm-nonexistent-file-or-buffer)) (buf (ido-read-internal 'buffer (or prompt "Buffer: ") 'ido-buffer-history default require-match initial)) @@ -2707,6 +2709,16 @@ C-x C-f ... C-d enter `dired' on current directory." (setq ido-exit 'keep) (exit-minibuffer)))) +(defun ido-toggle-virtual-buffers () + "Toggle the use of virtual buffers. +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-text-init ido-text) + (setq ido-exit 'refresh) + (exit-minibuffer))) + (defun ido-reread-directory () "Read current directory again. May be useful if cached version is no longer valid, but directory -- 1.7.0.4 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0002-Use-parent-directory-for-files-with-same-base-name.patch >From 8ed6d4f903efcab1d915ec67bb907bd9bb4f2c09 Mon Sep 17 00:00:00 2001 From: Leo Date: Wed, 14 Apr 2010 18:58:18 +0100 Subject: [PATCH 2/3] Use parent directory for files with same base name --- lisp/ido.el | 24 +++++++++++++++++++++++- 1 files changed, 23 insertions(+), 1 deletions(-) diff --git a/lisp/ido.el b/lisp/ido.el index 704bf22..92d2a09 100644 --- a/lisp/ido.el +++ b/lisp/ido.el @@ -3410,6 +3410,21 @@ for first matching file." (run-hooks 'ido-make-buffer-list-hook) ido-temp-list)) +(defun ido-find-duplicate-basenames (files) + "Find all the duplicate base names in FILES." + (let ((names (mapcar 'file-name-nondirectory files)) + dups head dup-p) + (setq names (sort names 'string<)) + (while names + (setq head (pop names)) + (while (string= head (car names)) + (pop names) + (setq dup-p t)) + (when dup-p + (push head dups) + (setq dup-p nil))) + dups)) + (defun ido-add-virtual-buffers-to-list () "Add recently visited files, and bookmark files, to the buffer list. This is to make them appear as if they were \"virtual buffers\"." @@ -3418,10 +3433,17 @@ This is to make them appear as if they were \"virtual buffers\"." ;; the file which the user might thought was still open. (unless recentf-mode (recentf-mode 1)) (setq ido-virtual-buffers nil) - (let (name) + (let ((dups (ido-find-duplicate-basenames recentf-list)) + name dir) (dolist (head recentf-list) (and (setq name (file-name-nondirectory head)) (null (get-file-buffer head)) + (if (not (member name dups)) + t + (setq dir head) + (dotimes (__ 2) + (setq dir (directory-file-name (file-name-directory dir)))) + (setq name (file-relative-name head dir))) (not (assoc name ido-virtual-buffers)) (not (member name ido-temp-list)) (not (ido-ignore-item-p name ido-ignore-buffers)) -- 1.7.0.4 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0003-Turn-on-virtual-buffers-automatically-when-no-matche.patch >From ed1321a6ea51ece2a90bb63842081a5ccee495a9 Mon Sep 17 00:00:00 2001 From: Leo Date: Thu, 15 Apr 2010 08:27:59 +0100 Subject: [PATCH 3/3] Turn on virtual buffers automatically when no matches --- lisp/ido.el | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) diff --git a/lisp/ido.el b/lisp/ido.el index 92d2a09..671e8a8 100644 --- a/lisp/ido.el +++ b/lisp/ido.el @@ -4491,7 +4491,14 @@ For details of keybindings, see `ido-find-file'." (setq ido-exit 'refresh) (exit-minibuffer))) + (when (and (eq ido-cur-item 'buffer) + (not ido-matches) + (not ido-use-virtual-buffers)) + (setq ido-text-init ido-text) + (setq ido-use-virtual-buffers t) + (setq ido-exit 'refresh) + (exit-minibuffer)) + (when (and ido-rescan (not ido-matches) -- 1.7.0.4 --=-=-= Leo --=-=-=--