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: PJ Weisberg
Subject: Re: Clever way to do this?
Date: Thu, 28 Jul 2011 08:51:23 -0700

On Thursday, July 28, 2011, 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.
>
> Thanks,
> Deniz

You could have it pass in nil interactively, and do the completing-read if rating is nil after you check ftip-movie-id.  Or have it pass in some other value if you want to distinguish between an interactive call and a lisp call that actually passed in nil.

--

-PJ

reply via email to

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