From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "Yan Tang" Newsgroups: gmane.emacs.help Subject: Re: swtching between buffers? Date: Sun, 11 May 2003 08:53:11 +0800 Organization: PKU Sender: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: <000001c31757$ca94aa40$c40a0a0a@rainman> References: <84of2a7mqt.fsf@lucy.is.informatik.uni-duisburg.de> Reply-To: ty@net.cs.pku.edu.cn NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: main.gmane.org 1052620986 5152 80.91.224.249 (11 May 2003 02:43:06 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Sun, 11 May 2003 02:43:06 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Sun May 11 04:43:04 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19Egno-0001KY-00 for ; Sun, 11 May 2003 04:43:04 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 19Egow-0003x4-02 for gnu-help-gnu-emacs@m.gmane.org; Sat, 10 May 2003 22:44:14 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10.13) id 19Egoc-0003tE-00 for help-gnu-emacs@gnu.org; Sat, 10 May 2003 22:43:54 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10.13) id 19Egoa-0003qL-00 for help-gnu-emacs@gnu.org; Sat, 10 May 2003 22:43:53 -0400 Original-Received: from net.cs.pku.edu.cn ([162.105.203.25]) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 19EgoZ-0003Vq-00 for help-gnu-emacs@gnu.org; Sat, 10 May 2003 22:43:51 -0400 Original-Received: from rainman ([162.105.80.90]) by net.cs.pku.edu.cn (8.12.8/8.12.8) with ESMTP id h4B1DNe4028472 for ; Sun, 11 May 2003 09:14:07 +0800 Original-To: X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.2627 In-Reply-To: <84of2a7mqt.fsf@lucy.is.informatik.uni-duisburg.de> Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:9557 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:9557 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- 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 '))) (while (not (equal (car ptr) ')) (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))) )) ------------------------------------------------------------------------ ----