90 |
these hooks, it terminates execution of the hook, and clears the hook |
these hooks, it terminates execution of the hook, and clears the hook |
91 |
variable to @code{nil} so as to prevent an infinite loop of errors. |
variable to @code{nil} so as to prevent an infinite loop of errors. |
92 |
|
|
93 |
|
A request coming into the Emacs server (@pxref{Emacs Server,,, |
94 |
|
emacs, The GNU Emacs Manual}) runs these two hooks just as a keyboard |
95 |
|
command does. |
96 |
|
|
97 |
@node Defining Commands |
@node Defining Commands |
98 |
@section Defining Commands |
@section Defining Commands |
99 |
@cindex defining commands |
@cindex defining commands |
503 |
@code{call-interactively}, which reads the arguments and calls the |
@code{call-interactively}, which reads the arguments and calls the |
504 |
command. You can also call these functions yourself. |
command. You can also call these functions yourself. |
505 |
|
|
506 |
@defun commandp object |
@defun commandp object &optional for-call-interactively |
507 |
Returns @code{t} if @var{object} is suitable for calling interactively; |
Returns @code{t} if @var{object} is suitable for calling interactively; |
508 |
that is, if @var{object} is a command. Otherwise, returns @code{nil}. |
that is, if @var{object} is a command. Otherwise, returns @code{nil}. |
509 |
|
|
514 |
(non-@code{nil} fourth argument to @code{autoload}), and some of the |
(non-@code{nil} fourth argument to @code{autoload}), and some of the |
515 |
primitive functions. |
primitive functions. |
516 |
|
|
517 |
A symbol satisfies @code{commandp} if its function definition satisfies |
A symbol satisfies @code{commandp} if its function definition |
518 |
@code{commandp}. |
satisfies @code{commandp}. Keys and keymaps are not commands. |
519 |
|
Rather, they are used to look up commands (@pxref{Keymaps}). |
520 |
Keys and keymaps are not commands. Rather, they are used to look up |
|
521 |
commands (@pxref{Keymaps}). |
If @var{for-call-interactively} is non-@code{nil}, then |
522 |
|
@code{commandp} returns @code{t} only for objects that |
523 |
|
@code{call-interactively} could call---thus, not for keyboard macros. |
524 |
|
|
525 |
See @code{documentation} in @ref{Accessing Documentation}, for a |
See @code{documentation} in @ref{Accessing Documentation}, for a |
526 |
realistic example of using @code{commandp}. |
realistic example of using @code{commandp}. |
663 |
(message "foo"))) |
(message "foo"))) |
664 |
@end example |
@end example |
665 |
|
|
666 |
|
@noindent |
667 |
|
Defined in this way, the function does display the message when |
668 |
|
called from a keyboard macro. |
669 |
|
|
670 |
The numeric prefix argument, provided by @samp{p}, is never @code{nil}. |
The numeric prefix argument, provided by @samp{p}, is never @code{nil}. |
671 |
|
|
672 |
@node Command Loop Info |
@node Command Loop Info |
733 |
restore the old value in case of error---a feature of @code{let} which |
restore the old value in case of error---a feature of @code{let} which |
734 |
in this case does precisely what we want to avoid. |
in this case does precisely what we want to avoid. |
735 |
|
|
736 |
|
@defvar this-original-command |
737 |
|
This has the same value as @code{this-command} except when command |
738 |
|
remapping occurs (@pxref{Remapping Commands}). In that case, |
739 |
|
@code{this-command} gives the command actually run (the result of |
740 |
|
remapping), and @code{this-original-command} gives the command that |
741 |
|
was specified to run but remapped into another command. |
742 |
|
@end defvar |
743 |
|
|
744 |
@defun this-command-keys |
@defun this-command-keys |
745 |
This function returns a string or vector containing the key sequence |
This function returns a string or vector containing the key sequence |
746 |
that invoked the present command, plus any previous commands that |
that invoked the present command, plus any previous commands that |
2055 |
If this is non-@code{nil}, its value specifies the current input method |
If this is non-@code{nil}, its value specifies the current input method |
2056 |
function. |
function. |
2057 |
|
|
2058 |
@strong{Note:} Don't bind this variable with @code{let}. It is often |
@strong{Warning:} don't bind this variable with @code{let}. It is often |
2059 |
buffer-local, and if you bind it around reading input (which is exactly |
buffer-local, and if you bind it around reading input (which is exactly |
2060 |
when you @emph{would} bind it), switching buffers asynchronously while |
when you @emph{would} bind it), switching buffers asynchronously while |
2061 |
Emacs is waiting will cause the value to be restored in the wrong |
Emacs is waiting will cause the value to be restored in the wrong |
2265 |
input comes in, while @code{sleep-for} pauses without updating the |
input comes in, while @code{sleep-for} pauses without updating the |
2266 |
screen. |
screen. |
2267 |
|
|
2268 |
@defun sit-for seconds &optional millisec nodisp |
@defun sit-for seconds &optional nodisp |
2269 |
This function performs redisplay (provided there is no pending input |
This function performs redisplay (provided there is no pending input |
2270 |
from the user), then waits @var{seconds} seconds, or until input is |
from the user), then waits @var{seconds} seconds, or until input is |
2271 |
available. The value is @code{t} if @code{sit-for} waited the full |
available. The value is @code{t} if @code{sit-for} waited the full |
2277 |
Some systems support only a whole number of seconds; on these systems, |
Some systems support only a whole number of seconds; on these systems, |
2278 |
@var{seconds} is rounded down. |
@var{seconds} is rounded down. |
2279 |
|
|
|
The optional argument @var{millisec} specifies an additional waiting |
|
|
period measured in milliseconds. This adds to the period specified by |
|
|
@var{seconds}. If the system doesn't support waiting fractions of a |
|
|
second, you get an error if you specify nonzero @var{millisec}. |
|
|
|
|
2280 |
The expression @code{(sit-for 0)} is a convenient way to request a |
The expression @code{(sit-for 0)} is a convenient way to request a |
2281 |
redisplay, without any delay. @xref{Forcing Redisplay}. |
redisplay, without any delay. @xref{Forcing Redisplay}. |
2282 |
|
|
2289 |
|
|
2290 |
The usual purpose of @code{sit-for} is to give the user time to read |
The usual purpose of @code{sit-for} is to give the user time to read |
2291 |
text that you display. |
text that you display. |
2292 |
|
|
2293 |
|
It is also possible to call @code{sit-for} with three arguments, |
2294 |
|
as @code{(sit-for @var{seconds} @var{millisec} @var{nodisp})}, |
2295 |
|
but that is considered obsolete. |
2296 |
@end defun |
@end defun |
2297 |
|
|
2298 |
@defun sleep-for seconds &optional millisec |
@defun sleep-for seconds &optional millisec |
2833 |
macro terminates, regardless of what caused it to terminate (reaching |
macro terminates, regardless of what caused it to terminate (reaching |
2834 |
the macro end or an error which ended the macro prematurely). |
the macro end or an error which ended the macro prematurely). |
2835 |
@end defvar |
@end defvar |
2836 |
|
|
2837 |
|
@ignore |
2838 |
|
arch-tag: e34944ad-7d5c-4980-be00-36a5fe54d4b1 |
2839 |
|
@end ignore |