From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Kastrup Newsgroups: gmane.emacs.help Subject: Re: This code won't match buffer names. Why not? Date: Mon, 31 Aug 2009 14:03:59 +0200 Organization: Organization?!? Message-ID: <87pracyyts.fsf@lola.goethe.zz> References: <30670a65-7226-4950-b43a-adb2890eec1c@i18g2000pro.googlegroups.com> <87hbw0odr7.fsf@in-ulm.de> <87y6p24vnc.fsf@lola.goethe.zz> <7cbplwqrb0.fsf@pbourguignon.anevia.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1251723145 13641 80.91.229.12 (31 Aug 2009 12:52:25 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 31 Aug 2009 12:52:25 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Aug 31 14:52:18 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Mi6Mp-00018n-F3 for geh-help-gnu-emacs@m.gmane.org; Mon, 31 Aug 2009 14:52:17 +0200 Original-Received: from localhost ([127.0.0.1]:55504 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mi6Mo-0000Er-EA for geh-help-gnu-emacs@m.gmane.org; Mon, 31 Aug 2009 08:52:14 -0400 Original-Path: news.stanford.edu!headwall.stanford.edu!news.glorb.com!news2.glorb.com!news2.arglkargh.de!news.n-ix.net!news.belwue.de!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help X-Face: 2FEFf>]>q>2iw=B6, xrUubRI>pR&Ml9=ao@P@i)L:\urd*t9M~y1^:+Y]'C0~{mAl`oQuAl \!3KEIp?*w`|bL5qr,H)LFO6Q=qx~iH4DN; i"; /yuIsqbLLCh/!U#X[S~(5eZ41to5f%E@'ELIi$t^ Vc\LWP@J5p^rst0+('>Er0=^1{]M9!p?&:\z]|;&=NP3AhB!B_bi^]Pfkw User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) Cancel-Lock: sha1:gRXX9aSeea+Fncx7WT0vsTOWTUI= Original-Lines: 46 Original-NNTP-Posting-Date: 31 Aug 2009 14:04:00 CEST Original-NNTP-Posting-Host: 6e989719.newsspool3.arcor-online.net Original-X-Trace: DXC=ikTb>:Qai; CV`H8_`hhQ4^9QSCVg3dO6gcO2@_RHd:42VlH9gV^WA6?ma2E^mo5E8 Original-X-Complaints-To: usenet-abuse@arcor.de Original-Xref: news.stanford.edu gnu.emacs.help:172542 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:67683 Archived-At: pjb@informatimago.com (Pascal J. Bourguignon) writes: > David Kastrup writes: > >> Benjamin Andresen writes: >> >>> The rewritten code would be better written like this: >>> >>> (global-set-key (kbd "") >>> '(lambda () >>> (interactive) >>> (next-buffer) >>> (while (member (buffer-name (current-buffer)) >>> '("*scratch*" "*Messages*" "*Whitespace Errors*")) >>> (next-buffer)))) >> >> What if only *scratch* is left? > > (defvar *bad-buffers* '("*scratch*" "*Messages*" "*Whitespace Errors*")) > > (defun next-good-buffer () > (interactive) > (unless (= 1 (length (buffer-list))) > (next-buffer) > (while (member (buffer-name (current-buffer)) *bad-buffers*) > (next-buffer)))) > > (global-set-key (kbd "") 'next-good-buffer) What if both *scratch* and *Messages* are left? I mean, think before you post. Something like (defun next-good-buffer () (interactive) (let ((old-buffer (current-buffer))) (while (and (not (eq old-buffer (progn (next-buffer) (current-buffer)))) (member (buffer-name (current-buffer)) *bad-buffers*))))) I am not sure whether next-buffer is supposed to revisit a hidden buffer when starting out from it, so this is not completely fool-proof. But I am short of time right now... -- David Kastrup