help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to structure looking-at with error conditions


From: Barry Margolin
Subject: Re: How to structure looking-at with error conditions
Date: Wed, 24 Nov 2010 08:33:24 -0500
User-agent: MT-NewsWatcher/3.5.3b3 (Intel Mac OS X)

In article 
<fe88468f-9fac-423b-baac-d39d1bd46f75@z9g2000yqz.googlegroups.com>,
 Fren Zeee <frenzeee@gmail.com> wrote:

> hello emacs users
> 
> generally, i use looking-at as follows
> 
> (when (looking-at "desired_pattern")
>         ( do_this_and_that
> 
>        (do some more things)
> 
> (when (looking-at "anther_ desired_pattern")
>         ( do_this_and_that)
> )
> 
> )
> 
> whats your expert advice on how to modify if the cursor is not at the
> desired pattern in either case so that an error message is reported ?
> 
> should I wrap the looking-at in cond or can I add some kind of default
> ie else like functioning clause to when ?
> 
> Franz Xe

Use the more general cond:

(cond ((looking-at "pattern1")
       (do-first-stuff))
      ((looking-at "pattern2")
       (do-other-stuff))
      (t (error ...)))

-- 
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***


reply via email to

[Prev in Thread] Current Thread [Next in Thread]