* interactive?
@ 2010-01-18 13:32 alin.s
2010-01-18 13:44 ` interactive? Andreas Schwab
2010-01-18 14:00 ` interactive? tomas
0 siblings, 2 replies; 5+ messages in thread
From: alin.s @ 2010-01-18 13:32 UTC (permalink / raw)
To: Emacs-devel
I do not understand the use of (interactive )
(defun x (n)
(interactive "P")
n)
(symbol-function 'x)
(lambda (n) (interactive "P") n)
I see that it is added to lambda-expression, but what is the effect of
evaluation from minibuffer or from inside some code?
Where in the evaluator one makes the diff between interactive and
non-interactive?
Please, can somebody explain me what is the implementation of interactive,
from the moment where it is read up to evaluating ?
--
View this message in context: http://old.nabble.com/interactive--tp27210523p27210523.html
Sent from the Emacs - Dev mailing list archive at Nabble.com.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: interactive?
2010-01-18 13:32 interactive? alin.s
@ 2010-01-18 13:44 ` Andreas Schwab
2010-01-18 14:03 ` interactive? alin.s
2010-01-18 14:00 ` interactive? tomas
1 sibling, 1 reply; 5+ messages in thread
From: Andreas Schwab @ 2010-01-18 13:44 UTC (permalink / raw)
To: alin.s; +Cc: Emacs-devel
"alin.s" <alinsoar@voila.fr> writes:
> Where in the evaluator one makes the diff between interactive and
> non-interactive?
commandp is a built-in function in `C source code'.
(commandp function &optional for-call-interactively)
Non-nil if function makes provisions for interactive calling.
This means it contains a description for how to read arguments to give it.
The value is nil for an invalid function or a symbol with no function
definition.
Interactively callable functions include strings and vectors (treated
as keyboard macros), lambda-expressions that contain a top-level call
to `interactive', autoload definitions made by `autoload' with non-nil
fourth argument, and some of the built-in functions of Lisp.
Also, a symbol satisfies `commandp' if its function definition does so.
If the optional argument for-call-interactively is non-nil,
then strings and vectors are not accepted.
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: interactive?
2010-01-18 13:44 ` interactive? Andreas Schwab
@ 2010-01-18 14:03 ` alin.s
0 siblings, 0 replies; 5+ messages in thread
From: alin.s @ 2010-01-18 14:03 UTC (permalink / raw)
To: Emacs-devel
I see now. one can check whether an object is interactive using commandp.
For example, to check whether a lambda-expression is interactive, it does
exactly as we know: it checks the cadr after the argument list, and compare
with the symbol 'interactive, etc.
/* Lists may represent commands. */
if (!CONSP (fun))
return Qnil;
funcar = XCAR (fun);
if (EQ (funcar, Qlambda))
return !NILP (Fassq (Qinteractive, Fcdr (XCDR (fun)))) ? Qt : if_prop;
And DEFUN(interactive) is Qnil means that if an object is defined
interactive, that means nothing unless checked using commandp.
This is what I did understand, thank you.
Andreas Schwab-2 wrote:
>
> "alin.s" <alinsoar@voila.fr> writes:
>
>> Where in the evaluator one makes the diff between interactive and
>> non-interactive?
>
> commandp is a built-in function in `C source code'.
>
> (commandp function &optional for-call-interactively)
>
> Non-nil if function makes provisions for interactive calling.
> This means it contains a description for how to read arguments to give it.
> The value is nil for an invalid function or a symbol with no function
> definition.
>
> Interactively callable functions include strings and vectors (treated
> as keyboard macros), lambda-expressions that contain a top-level call
> to `interactive', autoload definitions made by `autoload' with non-nil
> fourth argument, and some of the built-in functions of Lisp.
>
> Also, a symbol satisfies `commandp' if its function definition does so.
>
> If the optional argument for-call-interactively is non-nil,
> then strings and vectors are not accepted.
>
> Andreas.
>
> --
> Andreas Schwab, schwab@linux-m68k.org
> GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
> "And now for something completely different."
>
>
>
>
--
View this message in context: http://old.nabble.com/interactive--tp27210523p27210930.html
Sent from the Emacs - Dev mailing list archive at Nabble.com.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: interactive?
2010-01-18 13:32 interactive? alin.s
2010-01-18 13:44 ` interactive? Andreas Schwab
@ 2010-01-18 14:00 ` tomas
2010-01-18 14:10 ` interactive? alin.s
1 sibling, 1 reply; 5+ messages in thread
From: tomas @ 2010-01-18 14:00 UTC (permalink / raw)
To: alin.s; +Cc: Emacs-devel
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Mon, Jan 18, 2010 at 05:32:02AM -0800, alin.s wrote:
>
> I do not understand the use of (interactive )
>
> (defun x (n)
> (interactive "P")
> n)
(See also Andreas' reply)
One way to look at it is that an interactive function is also a
"command": you, as a user get help to call such a function. For example,
you can call "query-replace-regexp" with M-x query-replace-regexp and
get help with tab-expansion and with parameters (just try), because it
was declared "interactive" (note that the call for interactive has
specifications about how to prompt for the different arguments).
You need to declare a function interactive if you want to bind it to a
menu or key.
Besides that, it will still behave as a normal function.
Regards
- -- tomás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
iD8DBQFLVGmQBcgs9XrR2kYRAlk+AJ9NNhXMuycxz0jWYsSK7gP84TzJOwCffbkU
IT9VC9snV+nJGoTD53d3Ibo=
=8z9j
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: interactive?
2010-01-18 14:00 ` interactive? tomas
@ 2010-01-18 14:10 ` alin.s
0 siblings, 0 replies; 5+ messages in thread
From: alin.s @ 2010-01-18 14:10 UTC (permalink / raw)
To: Emacs-devel
Tomas Zerolo wrote:
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On Mon, Jan 18, 2010 at 05:32:02AM -0800, alin.s wrote:
>>
>> I do not understand the use of (interactive )
>>
>> (defun x (n)
>> (interactive "P")
>> n)
>
> (See also Andreas' reply)
>
> One way to look at it is that an interactive function is also a
> "command": you, as a user get help to call such a function. For example,
> you can call "query-replace-regexp" with M-x query-replace-regexp and
> get help with tab-expansion and with parameters (just try), because it
> was declared "interactive" (note that the call for interactive has
> specifications about how to prompt for the different arguments).
>
>
>
This happens because execute-extended-command calls Fcompleting_read with
the predicate Qcommandp, in order to limit the results. Only interactive
forms are returned:
function = Fcompleting_read (build_string (buf),
Vobarray, Qcommandp,
Qt, Qnil, Qextended_command_history, Qnil,
Qnil);
You need to declare a function interactive if you want to bind it to a
menu or key.
Yes, due to the call of commandp inside Fcompleting_read.
Besides that, it will still behave as a normal function.
Yes, because (interactive) returns null all the time.
Now I understand, thank you all.
Alin
--
View this message in context: http://old.nabble.com/interactive--tp27210523p27210996.html
Sent from the Emacs - Dev mailing list archive at Nabble.com.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-01-18 14:10 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-18 13:32 interactive? alin.s
2010-01-18 13:44 ` interactive? Andreas Schwab
2010-01-18 14:03 ` interactive? alin.s
2010-01-18 14:00 ` interactive? tomas
2010-01-18 14:10 ` interactive? alin.s
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).