From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Kevin Rodgers Newsgroups: gmane.emacs.help Subject: Re: buffer-list and desktop Date: Thu, 11 Nov 2004 11:14:01 -0700 Message-ID: <2vhofgF2m0kl3U1@uni-berlin.de> References: <2vf8jiF2krb46U1@uni-berlin.de> <2vfhn9F2kl6jmU1@uni-berlin.de> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1100197070 12813 80.91.229.6 (11 Nov 2004 18:17:50 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 11 Nov 2004 18:17:50 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Nov 11 19:17:41 2004 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1CSJVt-0006G0-00 for ; Thu, 11 Nov 2004 19:17:41 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CSJeO-0006ed-KD for geh-help-gnu-emacs@m.gmane.org; Thu, 11 Nov 2004 13:26:28 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!fu-berlin.de!uni-berlin.de!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 52 Original-X-Trace: news.uni-berlin.de l4HvclzwfE4LpPd34r3KQgRDor6H+fZlzNzHQtqy7mzxL8PCM= User-Agent: Mozilla Thunderbird 0.9 (X11/20041105) X-Accept-Language: en-us, en In-Reply-To: Original-Xref: shelby.stanford.edu gnu.emacs.help:126509 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:21901 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:21901 David Kastrup wrote: > Jesper Harder writes: >>Or if you don't mind requiring cl: I do mind. :-) >>(delete-if-not >> (lambda (buf) >> (desktop-save-buffer-p (buffer-file-name buf) (buffer-name buf) >> (buffer-local-value 'major-mode buf))) >> (buffer-list)) buffer-local-value is not defined in Emacs 21.3. Too bad, because passing the buffer as an argument should be faster than using with-current-buffer. > Still slow because of one bind/unbind per iteration. If you want to > do it that way, anyway, you could avoid cl by using > > (delq nil > (mapcar > (lambda (buf) > (and (desktop-save-buffer-p ...) > buf)) > (buffer-list))) > > with hardly more effort. Your first idea to just push each buffer that satisifies the predicate on to a result list is better. And I don't share your aversion to variable bindings. :-) So here's what I've come up with. The real problem I see is that the buffer browsing commands (list-buffers and electric-buffer-list) don't take the list of buffers as an argument, so you can't write new desktop-save- versions of those commands that use the result of this function. (defun desktop-save-buffer-list () "Return the list of buffers that `desktop-save' would save." (let ((buffer-list '())) (mapc (lambda (buffer) (with-current-buffer buffer (when (desktop-save-buffer-p (buffer-file-name) (buffer-name) major-mode) (setq buffer-list (cons buffer buffer-list))))) (buffer-list)) (nreverse buffer-list))) -- Kevin Rodgers