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

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

Re: swtching between buffers?


From: John Paul Wallington
Subject: Re: swtching between buffers?
Date: Sat, 10 May 2003 19:22:48 +0100
User-agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/21.3.50 (powerpc-unknown-linux-gnu)

Miguel Ulloa <address@hidden> wrote:

> I would like to know if there is a command to circularly navigate all
> opened buffers in emacs, thanks in advance.

There are `prev-buffer' and `next-buffer', bound to C-x <left> and
C-x <right> respectively, in the development sources:

(define-key global-map [?\C-x right] 'next-buffer)
(define-key global-map [?\C-x left] 'prev-buffer)
(defun next-buffer ()
  "Switch to the next buffer in cyclic order."
  (interactive)
  (let ((buffer (current-buffer)))
    (switch-to-buffer (other-buffer buffer))
    (bury-buffer buffer)))

(defun prev-buffer ()
  "Switch to the previous buffer in cyclic order."
  (interactive)
  (let ((list (nreverse (buffer-list)))
        found)
    (while (and (not found) list)
      (let ((buffer (car list)))
        (if (and (not (get-buffer-window buffer))
                 (not (string-match "\\` " (buffer-name buffer))))
            (setq found buffer)))
      (setq list (cdr list)))
    (switch-to-buffer found)))


reply via email to

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