help-gnu-emacs
[Top][All Lists]
Advanced

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

C-tab for next-buffer


From: fourfold_slimy
Subject: C-tab for next-buffer
Date: Sun, 02 May 2004 00:36:43 -0500
User-agent: Pan/0.14.2 (This is not a psychotic episode. It's a cleansing moment of clarity.)

I've wanted the ability to cycle linearly through a useful subset of
the buffer list for some time.  I've written the following functions to do
that.  Comments?  My lisp skills are pretty basic.

(defun next-buffer ()
  (interactive)
  (setq l (buffer-list))
  (bury-buffer (car (buffer-list)))
  (get-buffer-create "*scratch*")
  (while (cool-buffer (car (buffer-list))) 
    (bury-buffer (car (buffer-list))))
  (switch-to-buffer (car (buffer-list))))
(global-set-key [(control tab)] 'next-buffer)
(global-set-key [(meta \\)] 'next-buffer)

(defun previous-buffer ()
  (interactive)
  (setq r (nreverse (buffer-list)))
  (while (cool-buffer (car r)) (setq r (cdr r)))
  (switch-to-buffer (buffer-name (car r))))
(global-set-key [(control shift iso-lefttab)] 'previous-buffer)
(global-set-key [(control shift tab)] 'previous-buffer)
(global-set-key [(meta |)] 'previous-buffer)

(defun cool-buffer (x) 
  (and (not (string= "*scratch*" (buffer-name x))) 
       (or
        (string= (buffer-name (current-buffer)) (buffer-name x))
        (string= "*" (substring (buffer-name x) 0 1))
        (string= "*" (substring (buffer-name x) 0 1))
        (string= " " (substring (buffer-name x) 0 1)))))

The ideal thing would be for emacs to display buffers in tabs, just like
mozilla or gedit.  Until then, I'll just make do with the one true editor.

I would also like a buffer-list like function which returns a list of
buffers _in the order they were created_, which seems like the more
natural order for the buffers to be cycled through.



reply via email to

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