emacs-devel
[Top][All Lists]
Advanced

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

Re: The minibuffer vs. Dialog Boxes (Re: Making XEmacs be more up-to-dat


From: Sean MacLennan
Subject: Re: The minibuffer vs. Dialog Boxes (Re: Making XEmacs be more up-to-date)
Date: Tue, 23 Apr 2002 23:45:49 -0400

Terje Bless writes:

 > But the switch to buffer bit is simply that me and Hrvoje are speaking of
 > slightly different things. Switch to buffer by name is there, but I'd like
 > to cycle through buffers sequentially; analogous to switching between
 > applications using Alt-TAB on Windows or Cmd-TAB on Mac OS.
 > 
 > A simple repetetive action instead of a single complicated one.

I have attached some sample code that does just what you want
;-) You probably want to attach it to a key though. Email me privately
if you want help with that. I have only tested it in XEmacs.

I wrote this for a new emacs user who wanted just what you said, an
Alt-TAB for buffers. However, most people tend to keep the number of
windows on their desktop to a relatively low number. Too many windows
and the desktop gets so cluttered that you cannot deal with the
windows. Plus, you will tend to run out of memory :-)

On the other hand, the number of buffers in an active emacs session
can get huge. I have had my current emacs session running for about 2
hours and have not been doing any majour development, just email and
this and that. I am up to 30 buffers. At work I can easily have
sessions running for days with hundreds of open buffers.

The above user quickly gave up on the command, so it is not heavily
tested :-) It also probably needs a previous-buffer command since if
you overshoot the buffer you have to go through the entire list again.

Now, both the user and I are developers. Maybe in a different
environment the command would be useful. If so, maybe something like
this should go in emacs.

Cheers,
   Sean MacLennan

(require 'iswitchb)

(defvar next-buffer-depth 0)

(defun next-buffer ()
  (interactive)
  (let (buflist len buf)
    ;; This is a stripped down version of `iswitchb-make-buflist'.
    ;; I want to use `iswitchb-ignore-buffername-p' instead of
    ;; duplicating the work.
    (setq buflist
          (delq nil
                (mapcar
                 (lambda (x)
                   (let ((b-name (buffer-name x)))
                     (unless (iswitchb-ignore-buffername-p b-name)
                       b-name)))
                 (buffer-list))))
    ;; However, I do not want the current buffer in the list
    (setq buflist (delq (buffer-name) buflist))

    (if (eq last-command 'next-buffer)
        (progn
          (setq len (1- (list-length buflist)))
          (if (eq next-buffer-depth len)
              ;; Just keep taking the tail of the list
              (setq buf (nth next-buffer-depth buflist))
            (progn
              (setq next-buffer-depth (1+ next-buffer-depth))
              (setq buf (nth next-buffer-depth buflist)))))
      ;; This is the first next-buffer
      (setq next-buffer-depth 0)
      (setq buf (car buflist)))
    (if (not buf) (error "No other buffers"))
    (switch-to-buffer buf)))

(global-set-key [f11] 'next-buffer)

reply via email to

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