emacs: code to cycle buffer & skip emacs internal ones

On Aug 21, 5:31 pm, Chris Seberino wrote:
> When I cycle through buffers, I'd like to skip *scratch*, *Messages*
> and *Whitespace Errors* buffers.
> I wrote following code to skip one more buffer if I'm sitting in
> either of those 3.
> However, it never matches those buffers. Why not?
> (BTW, the (end-kbd-macro) is just a dummy function since "if" needs an
> "else" command.
> Is there a better dummy command I can add there?)
> ; Sets F10 to execute a function that moves to another buffer.
> (global-set-key [f10] (lambda () (interactive)
> (next-buffer)
> (if (equal (current-buffer)
> "*scratch*")
> (next-buffer)
> (end-kbd-macro))
> (if (equal (current-buffer)
> "*Messages*")
> (next-buffer)
> (end-kbd-macro))
> (if (equal (current-buffer)
> "*Whitespace Errors*")
> (next-buffer)
> (end-kbd-macro))))

Wee, the code to skip emacs buffers is in ergoemacs here:

by default it's Ctrl + Page up/down is the shortcut, similar to Firefox et al for switching tabs.
With shift key down, it cycle among emacs's buffers.

here's the relevant code:

(defun next-user-buffer ()
"Switch to the next user buffer.
User buffers are those whose name does not start with *."
(let ((i 0))
(while (and (string-match "^*" (buffer-name)) (< i 50))
(setq i (1+ i)) (next-buffer) )))

∑ http://xahlee.org/

No comments:

Post a Comment