all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* list buffers
@ 2004-11-14  8:26 Matthias Meulien
  0 siblings, 0 replies; only message in thread
From: Matthias Meulien @ 2004-11-14  8:26 UTC (permalink / raw)


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' 'host_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
`buff-menu.el').

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)
                                            (buffer-name)
                                            major-mode)
                 (setq buffer-list (cons buffer buffer-list)))))
           (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
buffers.

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)
	desired-point)
    (save-excursion
      (set-buffer (get-buffer-create "*Buffer List*"))
      (setq buffer-read-only nil)
      (erase-buffer)
      (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))))

Regards,
-- 
Matthias Meulien

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2004-11-14  8:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-11-14  8:26 list buffers Matthias Meulien

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.