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

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

other-window-or-buffer


From: John Sturdy
Subject: other-window-or-buffer
Date: 5 May 2006 09:42:14 -0700
User-agent: G2/0.2

Here's one of those "commands I wouldn't be without", to avoid all that
typing of buffer names (and all that hurried mistyping of buffer
names).

(defun other-window-or-buffer ()
  (interactive)
  "Switch to the next window, or, if there is only one window, the next
buffer.
If done repeatedly when there is only one window, keeps getting
different
buffers from the buffer list"
  (setq other-window-or-buffer-consecutive-count
        (if (eq last-command 'other-window-or-buffer)
            (1+ other-window-or-buffer-consecutive-count)
          1))
  (if (one-window-p)
       (if (<= other-window-or-buffer-consecutive-count 2)
           (switch-to-buffer (other-buffer))
         (switch-to-buffer (nth other-window-or-buffer-consecutive-count
                                (buffer-list)))
         (message "Next one will be %s"
                  (buffer-name (nth (1+ 
other-window-or-buffer-consecutive-count)
                                    (buffer-list)))))

    (if (<= other-window-or-buffer-consecutive-count 2)
      (other-window 1)
      (delete-other-windows))))



reply via email to

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