[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

list buffers

From: Matthias Meulien
Subject: list buffers
Date: 14 Nov 2004 13:56:56 +0530
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3

In GNU Emacs 21.3.1 (i386-pc-linux-gnu, X toolkit, Xaw3d scroll bars)
 of 2004-04-07 on raven, modified by Debian
configured using `configure '--build=i386-linux' '--host=i386-linux' 
'--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib' 
'--localstatedir=/var/lib' '--infodir=/usr/share/info' 
'--mandir=/usr/share/man' '--with-pop=yes' '--with-x=yes' 
'--with-x-toolkit=athena' 'CFLAGS=-DDEBIAN -g -O2' 'build_alias=i386-linux' 

Please describe exactly what actions triggered the bug
and the precise symptoms of the bug:

I describe a missing feature rather than a bug. I hope it's the right
place to do so (there is no maintener email in the file

One wants to be able to browse, delete, etc buffers that will be saved
by the library `desktop.el' (for example such a function could be in
the `kill-emacs-query-functions' variable).

The following function (written by Kevin Rodgers) return the right
list of buffers:

(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)
                 (setq buffer-list (cons buffer buffer-list)))))
     (nreverse buffer-list)))

But the browsing, deleting, etc facilities are missing.

To fix this, one needs a light improvment of `list-buffers-noselect'.
It should be possible to pass a second optional argument to this
function, namely a list of buffers; in case this argument is non-nil,
the displayed list of buffers in the buffer *Buffer List* is the one
passed as argument so that the user can browse, etc this list of

For clarity, I insert the (trivial) code to implement this:

(defun list-buffers-noselect (&optional files-only arg)
  "Create and return a buffer with a list of names of existing buffers.
The buffer is named `*Buffer List*'.
Note that buffers with names starting with spaces are omitted.
Non-null optional arg FILES-ONLY means mention only file buffers.
If the optional arg ARG is non-null, then it is interpreted as the list
of buffers to be listed.

The M column contains a * for buffers that are modified.
The R column contains a % for buffers that are read-only."
  (let ((old-buffer (current-buffer))
        (standard-output standard-output)
      (set-buffer (get-buffer-create "*Buffer List*"))
      (setq buffer-read-only nil)
      (setq standard-output (current-buffer))
      (princ "\
 MR Buffer           Size  Mode         File
 -- ------           ----  ----         ----
      ;; Record the column where buffer names start.
      (setq Buffer-menu-buffer-column 4)
      (dolist (buffer (or arg (buffer-list)))
        (let ((name (buffer-name buffer))

Here is the wanted example:

(defun list-desktop-buffers (&optional files-only)
  "Display a list of names of buffers that will be saved by
`desktop-save. The list is displayed in a buffer named `*Buffer List*'
(see `list-buffers')."
  (interactive "P")
  (display-buffer (list-buffers-noselect 
                   files-only (desktop-save-buffer-list))))

Matthias Meulien

reply via email to

[Prev in Thread] Current Thread [Next in Thread]