all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Yan Tang" <ty@net.cs.pku.edu.cn>
Subject: Re: swtching between buffers?
Date: Sun, 11 May 2003 08:53:11 +0800	[thread overview]
Message-ID: <000001c31757$ca94aa40$c40a0a0a@rainman> (raw)
In-Reply-To: <84of2a7mqt.fsf@lucy.is.informatik.uni-duisburg.de>

I have another trick for cycle buffer, stolen from the famous cycle
buffer and modified by myself.

The following are my codes.
When you press C-o to cycle buffer, buffer list will be appeared in
mini-buffer, and cycle right, just like alt-tab in M$ windows.
The first one in mini-buffer will be the next main buffer.
------------------------------------------------------------------------
----
;; C-<TAB> only work in XWindow, so I have to define C-o, but why?
(global-set-key "\C-o" 'next-buffer)
;(global-set-key [\C-tab] 'next-buffer) ;forward reference
;(global-set-key [\C-\S-tab] 'prev-buffer) ;forward reference

;; Dired mode has its own ctrl-o, I have to do local key rebinding.
(add-hook 'dired-mode-hook
          '(lambda ()
             (define-key dired-mode-map "\C-o" 'next-buffer)))

(defun next-buffer ()
  "Switch to the other buffer (2nd in list-buffer) in current window."
  (interactive)
  (bury-buffer (current-buffer))
  (cycle-buffer (buffer-list)))

(defun prev-buffer ()
  "Switch to previous buffer in current window."
  (interactive)
  (cycle-buffer (reverse (buffer-list))))

(defun cycle-buffer (ls)
  (let* ((ptr ls) bf bn)
    (setq ptr (append ptr (list '<BUFFER-FLAG>)))
    (while (not (equal (car ptr) '<BUFFER-FLAG>))
      (setq bf (car ptr)
            bn (buffer-name bf))
      (if (null (ignore-buffer bn))
          (setq ptr (append (cdr ptr) (list (car ptr))))
        (setq ptr (cdr ptr))))
    (setq ptr (cdr ptr))
    (setq bf (car ptr))
    (setq ptr (append (cdr ptr) (list (car ptr))))
    (message "%s" ptr)
    (if bf
        (switch-to-buffer bf))))

(defun ignore-buffer (str)
  (or
    ;;buffers I don't want to switch to 
   (string-match "\\*Buffer List\\*" str)
   (string-match "\\*Compilation\\*" str)
   (string-match "^TAGS" str)
   (string-match "^\\*Messages\\*$" str)
   (string-match "^\\*Completions\\*$" str)
   (string-match "output\\*$" str)
   (string-match "^ " str)
   
   ;(memq str (mapcar 
   ;   (lambda (x) (buffer-name (window-buffer (frame-selected-window
x))))
   ;   (visible-frame-list)))
   ))
------------------------------------------------------------------------
----

  reply	other threads:[~2003-05-11  0:53 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-10 16:09 swtching between buffers? Miguel Ulloa
2003-05-10 16:49 ` Marco Parrone
2003-05-10 17:08 ` Kai Großjohann
2003-05-11  0:53   ` Yan Tang [this message]
2003-05-10 18:22 ` John Paul Wallington
2003-05-10 19:52   ` Miguel Ulloa
2003-05-10 19:04 ` Jiri Pejchal
2003-05-12  8:19 ` Stefan Kamphausen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='000001c31757$ca94aa40$c40a0a0a@rainman' \
    --to=ty@net.cs.pku.edu.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.