[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: buffer-list and desktop
From: |
David Kastrup |
Subject: |
Re: buffer-list and desktop |
Date: |
Wed, 10 Nov 2004 23:18:27 +0100 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/21.3.50 (gnu/linux) |
Kevin Rodgers <ihs_4664@yahoo.com> 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