From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: David Kastrup Newsgroups: gmane.emacs.help Subject: Re: buffer-list and desktop Date: Wed, 10 Nov 2004 23:18:27 +0100 Organization: Organization?!? Message-ID: References: <2vf8jiF2krb46U1@uni-berlin.de> <2vfhn9F2kl6jmU1@uni-berlin.de> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1100174302 1661 80.91.229.6 (11 Nov 2004 11:58:22 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 11 Nov 2004 11:58:22 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Nov 10 23:22:04 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 1CS0qp-0007AQ-00 for ; Wed, 10 Nov 2004 23:22:04 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CS0zJ-0002Ha-15 for geh-help-gnu-emacs@m.gmane.org; Wed, 10 Nov 2004 17:30:49 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!headwall.stanford.edu!fu-berlin.de!uni-berlin.de!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 39 Original-X-Trace: news.uni-berlin.de WC1aFqQd3rMoA1U0AiReVAgj0fYGIwvPJ0QqIqfCINe2Ho42AE X-Face: 2FEFf>]>q>2iw=B6, xrUubRI>pR&Ml9=ao@P@i)L:\urd*t9M~y1^:+Y]'C0~{mAl`oQuAl \!3KEIp?*w`|bL5qr,H)LFO6Q=qx~iH4DN; i"; /yuIsqbLLCh/!U#X[S~(5eZ41to5f%E@'ELIi$t^ Vc\LWP@J5p^rst0+('>Er0=^1{]M9!p?&:\z]|;&=NP3AhB!B_bi^]Pfkw User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/21.3.50 (gnu/linux) Cancel-Lock: sha1:K2xeTNhyywbLQFDAu4hBBCg5DqI= Original-Xref: shelby.stanford.edu gnu.emacs.help:126490 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:21886 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:21886 Kevin Rodgers writes: > Kevin Rodgers wrote: > > Here's a start: > > Gotta get used to using with-current-buffer: > > (defun desktop-list-buffers () > "Return the list of buffers that `desktop-save' would save." > (nreverse > (apply 'nconc > (mapcar (lambda (buffer) > (with-current-buffer buffer > (if (desktop-save-buffer-p (buffer-file-name) > (buffer-name) > major-mode) > (list buffer)))) > (buffer-list))))) Actually, you are trying too hard to be smart: the code is rather inefficient. You'll get by better with (defun desktop-list-buffers () "..." (let ((lst)) (dolist (buffer (buffer-list) lst) (with-current-buffer buffer (when (desktop-save-buffer-p ...) (push buffer lst)))))) This only has two variable bindings (lst and the list for dolist), and none in the loop. In contrast, your version binds and unbinds buffer fresh for every iteration, and it needs a (slow) call to apply/nconc with a large number of arguments. -- David Kastrup, Kriemhildstr. 15, 44793 Bochum