From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Benjamin Andresen Newsgroups: gmane.emacs.help Subject: Re: This code won't match buffer names. Why not? Date: Sat, 22 Aug 2009 03:09:48 +0200 Organization: [ posted via ] IN-Ulm Message-ID: <87hbw0odr7.fsf@in-ulm.de> References: <30670a65-7226-4950-b43a-adb2890eec1c@i18g2000pro.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1250926668 27890 80.91.229.12 (22 Aug 2009 07:37:48 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 22 Aug 2009 07:37:48 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Aug 22 09:37:41 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 1MelAS-0005wa-Hz for geh-help-gnu-emacs@m.gmane.org; Sat, 22 Aug 2009 09:37:40 +0200 Original-Received: from localhost ([127.0.0.1]:39486 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MelAS-0007FB-0r for geh-help-gnu-emacs@m.gmane.org; Sat, 22 Aug 2009 03:37:40 -0400 Original-Path: news.stanford.edu!headwall.stanford.edu!news.glorb.com!news2.glorb.com!de-l.enfer-du-nord.net!newsfeed.straub-nv.de!news-2.dfn.de!news.dfn.de!news.uni-stuttgart.de!newsfeed.in-ulm.de!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 49 Original-X-Trace: news.in-ulm.de 00A15726C856A6D66F47F24B244A909F User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) Cancel-Lock: sha1:CrtHZISAsqrLrpl3ph9XqJzxUV0= Original-Xref: news.stanford.edu gnu.emacs.help:172216 X-Mailman-Approved-At: Sat, 22 Aug 2009 03:27:08 -0400 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:67385 Archived-At: Chris Seberino writes: > 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? (current-buffer) returns an buffer and not the buffer-name. You can check that with M-: (current-buffer) Use (buffer-name (current-buffer)) and string-match. Or see below. > (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?) `if' also need an else part. Check C-h f if > ; 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)))) 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)))) HTH, benny