emacs-devel
[Top][All Lists]
Advanced

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

Re: Buffer listing in multiple frames/ttys


From: Juri Linkov
Subject: Re: Buffer listing in multiple frames/ttys
Date: Thu, 08 Dec 2005 09:48:42 +0200
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux)

Thanks for your patch.  Generally it works correctly, with few exceptions:

1. The function `buffer-list' returns a list of buried buffers in reverse
order.  In the frame parameter `buried_buffer_list' the most recently
buried buffer is first, so `buffer-list' misses a Fnreverse on `prevlist'.

2. Since `last-buffer' is a general function, I suggest to move it to
simple.el.

3. Could you create a separate function from lambda which is now let-bound
in `last-buffer'?  It could be named, for example, as `get-next-valid-buffer'.
Beside of the advantage of not messing with funcalls, it will be
useful outside `last-buffer'.  In .emacs I have a function defadviced
on `next-buffer' and `prev-buffer' that displays a list of two previous,
current and two next buffer names in the echo area after calling
`next-buffer' or `prev-buffer'.  The message looks like:

-2:*Messages* -1:*Help*    0:.emacs      1:*info*  2:*scratch*

It is useful to see what buffers will be visited on subsequent
invocation of `next-buffer' or `prev-buffer'.  This is like what
some window managers display during switching of windows.

If you create a new function from lambda then the code to put in .emacs
to display this message could be simplified to:

(defadvice previous-buffer (after my-previous-buffer activate)
  (my-display-prev-next-buffers))

(defadvice next-buffer (after my-next-buffer activate)
  (my-display-prev-next-buffers))

(defun my-display-prev-next-buffers ()
  "Show two previous, current and two next buffer names in the echo area."
  (interactive)
  (let ((i -3) b (bl (buffer-list (selected-frame))) (message-log-max nil))
    (message "%s"
             (mapconcat
              (lambda (x)
                (setq i (+ i 1))
                (format "%d:%-12s"
                        i (substring
                           (buffer-name x) 0 (min (length (buffer-name x)) 
11))))
              (append
               (nreverse
                (list
                 (setq b (get-next-valid-buffer (reverse bl) t))
                 (get-next-valid-buffer (cdr (memq b (reverse bl))) t)))
               (list (current-buffer))
               (list
                (setq b (get-next-valid-buffer (cdr bl) t))
                (get-next-valid-buffer (cdr (memq b bl)) t)))
              " "))))

-- 
Juri Linkov
http://www.jurta.org/emacs/





reply via email to

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