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

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

Re: Clever way to do this?


From: Barry Margolin
Subject: Re: Clever way to do this?
Date: Wed, 28 Mar 2012 19:20:07 -0000
User-agent: MT-NewsWatcher/3.5.3b3 (Intel Mac OS X)

In article <mailman.429.1311864988.939.help-gnu-emacs@gnu.org>,
 Deniz Dogan <deniz@dogan.se> wrote:

> I have a command like this:
> 
> (defun ftip-rate-movie (rating)
>    (interactive
>     (list
>      (if (not ftip-movie-id)
>          (error "Not viewing movie")
>        (completing-read "Rating: " '("1" "2" "3" "4" "5" "Remove 
> rating") nil t))))
>    (unless ftip-movie-id
>      (error "Not viewing movie"))
> 
>    ;; ...code here
>    )
> 
> Is there any more intelligent way to do this?  I'm not too keen on the 
> code duplication.

I wouldn't bother checking during argument reading.  Let the user enter 
a rating, and then report an error afterward.

-- 
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***


reply via email to

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