emacs-devel
[Top][All Lists]
Advanced

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

Re: Shift selection using interactive spec


From: Stefan Monnier
Subject: Re: Shift selection using interactive spec
Date: Sun, 30 Mar 2008 00:12:43 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

>> As I understand the purpose of this feature is practically to move
>> the last expression of the command's body that usually is written as
>> 
>> (if (interactive-p)
>> (message "Result of this command is %.0f" return-value)
>> (format "%.0f" return-value))
>> 
>> You have the right idea in mind for what the code would be trying to
>> do.  But code like that would be a strange way to write it, and in
>> practice does seem to occur much if at all.  The way I would envision
>> this is more like
>> 
>> (if interactive-call
>> (message "Result of this command is %.0f" return-value))
>> return-value)
>> 
>> where `interactive-call' is an argument initialized to non-nil
>> for an interactive call.
>> 
>> The job of the second arg to `interactive', that I've proposed, would
>> be to control how to generate the message in the interactive case.

> Then the second arg to `interactive' could be just a lambda
> with one argument with the value this function returns, e.g.

Yes, and if the use of `lambda' turns out to be a bit heavy, we can
provide a handy alternative: if the return-spec is a list but not
a function, then take the list as a function call with a missing argument:

   (defun command ()
     (interactive
       nil
       (lambda (ret-val)
         (message "Result of this command is %.0f" ret-val)))
     ...
     (let ((return-value ...))
       ...
       return-value))

=>

   (defun command ()
     (interactive
       nil
       (message "Result of this command is %.0f"))
     ...
     (let ((return-value ...))
       ...
       return-value))


-- Stefan




reply via email to

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