From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?utf-8?Q?=C3=93scar_Fuentes?= Newsgroups: gmane.emacs.devel Subject: Re: PATCH: Fix IDO interaction with uniquify.el Date: Mon, 18 Jan 2010 18:35:30 +0100 Message-ID: <87tyujz57h.fsf@telefonica.net> References: <87k4vf1zdh.fsf@telefonica.net> <87d4171oy1.fsf@telefonica.net> <87636z1nm7.fsf@telefonica.net> <87d417h0z6.fsf@stupidchicken.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1263836234 19884 80.91.229.12 (18 Jan 2010 17:37:14 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 18 Jan 2010 17:37:14 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jan 18 18:37:07 2010 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.50) id 1NWvXE-0007BW-BK for ged-emacs-devel@m.gmane.org; Mon, 18 Jan 2010 18:37:04 +0100 Original-Received: from localhost ([127.0.0.1]:36181 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NWvXF-0002Qg-Af for ged-emacs-devel@m.gmane.org; Mon, 18 Jan 2010 12:37:05 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NWvWF-0001o7-BX for emacs-devel@gnu.org; Mon, 18 Jan 2010 12:36:03 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NWvWA-0001lJ-I7 for emacs-devel@gnu.org; Mon, 18 Jan 2010 12:36:02 -0500 Original-Received: from [199.232.76.173] (port=37508 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NWvWA-0001lF-8j for emacs-devel@gnu.org; Mon, 18 Jan 2010 12:35:58 -0500 Original-Received: from lo.gmane.org ([80.91.229.12]:34937) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NWvW9-0002CJ-LF for emacs-devel@gnu.org; Mon, 18 Jan 2010 12:35:58 -0500 Original-Received: from list by lo.gmane.org with local (Exim 4.50) id 1NWvW3-0006iv-UI for emacs-devel@gnu.org; Mon, 18 Jan 2010 18:35:51 +0100 Original-Received: from 251.red-88-24-228.staticip.rima-tde.net ([88.24.228.251]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 18 Jan 2010 18:35:51 +0100 Original-Received: from ofv by 251.red-88-24-228.staticip.rima-tde.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 18 Jan 2010 18:35:51 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 112 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 251.red-88-24-228.staticip.rima-tde.net User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.91 (gnu/linux) Cancel-Lock: sha1:mHPQphdq3ilK/MVAYpYCnIHYMPA= X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." 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:120210 Archived-At: Chong Yidong writes: > Óscar Fuentes writes: > >> +(defun ido-kill-buffer-internal (buf) >> + "Actually kill the buffer and check if it is needed to rebuild >> +the list of known buffers." > > The docstring does not follow conventions. The first line should be a > single sentence. Something like this should suffice > > "Kill buffer BUF and and rebuild ido's buffer list if needed." Okay. Updated docstring and incorporated a style improvement suggested by Juanma. 2010-01-18 Óscar Fuentes * ido.el (ido-cur-list): Initialize as nil. Remove obsolete information from commentary. (ido-choice-list): Initialize as nil. (ido-get-bufname): Reject minibuffers. (ido-make-buffer-list): If "default" is a nonexistent buffer, ignore it, as per the docstring. (ido-kill-buffer-internal): New function. (ido-kill-buffer-at-head): Use it. (ido-visit-buffer): Likewise. === modified file 'lisp/ido.el' --- lisp/ido.el 2010-01-13 08:35:10 +0000 +++ lisp/ido.el 2010-01-18 17:32:44 +0000 @@ -1042,11 +1042,11 @@ ;; Stores the current list of items that will be searched through. ;; The list is ordered, so that the most interesting item comes first, ;; although by default, the files visible in the current frame are put -;; at the end of the list. Created by `ido-make-item-list'. -(defvar ido-cur-list) +;; at the end of the list. +(defvar ido-cur-list nil) ;; Stores the choice list for ido-completing-read -(defvar ido-choice-list) +(defvar ido-choice-list nil) ;; Stores the list of items which are ignored when building ;; `ido-cur-list'. It is in no specific order. @@ -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)) @@ -3590,6 +3590,7 @@ ;; Used by `ido-get-buffers-in-frames' to walk through all windows (let ((buf (buffer-name (window-buffer win)))) (unless (or (member buf ido-bufs-in-frame) + (minibufferp buf) (member buf ido-ignore-item-temp-list)) ;; Only add buf if it is not already in list. ;; This prevents same buf in two different windows being @@ -3830,6 +3831,29 @@ ;;(add-hook 'completion-setup-hook 'completion-setup-function) (display-completion-list completion-list))))))) +(defun ido-kill-buffer-internal (buf) + "Kill buffer BUF and rebuild ido's buffer list if needed." + (if (not (kill-buffer buf)) + ;; buffer couldn't be killed. + (setq ido-rescan t) + (let ((next-buf (cadr ido-matches)) + (needs-update nil)) + ;; else buffer was killed so remove name from list. + (setq ido-cur-list (delq buf ido-cur-list)) + ;; Some packages, like uniquify.el, may rename buffers when one + ;; is killed, so we need to test this condition to avoid using + ;; an outdated list of buffer names. We don't want to always + ;; rebuild the list of buffers, as this alters the previous + ;; buffer order that the user was seeing on the prompt. However, + ;; when we rebuild the list, we try to keep the previous second + ;; buffer as the first one. + (catch 'update + (dolist (b ido-cur-list) + (unless (get-buffer b) + (setq ido-cur-list (ido-make-buffer-list next-buf)) + (setq ido-rescan t) + (throw 'update nil))))))) + ;;; KILL CURRENT BUFFER (defun ido-kill-buffer-at-head () "Kill the buffer at the head of `ido-matches'. @@ -3840,7 +3864,7 @@ (let ((enable-recursive-minibuffers t) (buf (ido-name (car ido-matches)))) (when buf - (kill-buffer buf) + (ido-kill-buffer-internal buf) ;; Check if buffer still exists. (if (get-buffer buf) ;; buffer couldn't be killed. @@ -3884,7 +3908,7 @@ ((eq method 'kill) (if record (ido-record-command 'kill-buffer buffer)) - (kill-buffer buffer)) + (ido-kill-buffer-internal buffer)) ((eq method 'other-window) (if record