Howdy all.
I don't have newsgroup access from work (where this would probably be more
appropriate), and I didn't see anything in my quick search through emacswiki,
so I thought I'd ask this here on the beta list (where everyone has been
rather helpful to in the past but I'll understand if I'm told it's a bit TOO
off topic for the beta list).
Here's my dilemma...I've been using these two functions for a long time to
loop through buffers in the current window easily:
(defun buffer-ring ()
"Works around a ring of buffers.
Steps to the next buffer in list, putting the current buffer
at the end of the selection list."
(interactive)
(bury-buffer (current-buffer))
(switch-to-buffer (other-buffer)))
;; borrowed code from mouse-unbury-buffer to create the reverse function:
(defun buffer-ring-backwards ()
"Works backwards throught a ring of buffers"
(interactive)
(let* ((bufs (buffer-list))
(entry (1- (length bufs)))
val)
(while (not (setq val (nth entry bufs)
val (and (/= (aref (buffer-name val) 0)
? )
val)))
(setq entry (1- entry)))
(switch-to-buffer val)))
I have those bound to (meta prior) and (meta next) respectively, and they have
one very annoying habit of any new files opened in other windows (or frames
for that matter) end up being insterted into the list such that they are
selected next for buffer-ring-backwards.
The behavior is understandable, but very annoying, and apparently today it's
pushed me to try and come up with a more acceptable solution.
So, I was thinking about writting some elisp that will explicitly add a buffer
to a special ring (I've got some ideas already, using funcs from ring.el
and maybe ring+.el that I found on emacswiki) and changing the above functions
to use these rings instead of the builtin buffer list manipulation functions.
I would like to be able to have multiple rings (and have another func to
prompt for the ring to add the current buffer to) but not sure how I would
handle the same buffer being in multiple rings (which shouldn't happen very
often anyways, but could I suppose, I may ignore that possibility for now for
simplicity).
In the simple case (buffer in only one ring) the next-buffer-in-ring and
prev-buffer-in-ring functions would look through the global list of known
rings to find which one the current buffer is in to determine which ring to
use.
I guess I'm asking for any hints/advice on implementing this (particularily
how to "nicely" handle same buffer in multiple rings since it should be fairly
easy to implement the simpler version) or perhaps more importantly if there is
already a package out there that anyone knows about that does something along
these lines so I don't duplicate any effort...
Thanks,
Chuck
--
Charles K. Hines <ckh(a)requesttech.com> <chuck.hines(a)baesystems.com>
Principal Scientist at ReQuest Technologies Inc (
http://www.ReQuestTech.com/)
"Behold my tongue of doom and tremble...TREMBLE!" - Sheen (Jimmy Neutron,
"My Son, the Hamster")