diff options
| author | Richard M. Stallman | 1994-03-28 20:02:03 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1994-03-28 20:02:03 +0000 |
| commit | f142f62a0ac4d515265edc4fcdda31f0b63a7311 (patch) | |
| tree | 4b5ea2b63ea491d1831bee49dc6f35a474dd7a48 | |
| parent | 4d4cd289b45ae706b4f723c3a11955447020d43e (diff) | |
| download | emacs-f142f62a0ac4d515265edc4fcdda31f0b63a7311.tar.gz emacs-f142f62a0ac4d515265edc4fcdda31f0b63a7311.zip | |
*** empty log message ***
| -rw-r--r-- | lispref/commands.texi | 690 |
1 files changed, 356 insertions, 334 deletions
diff --git a/lispref/commands.texi b/lispref/commands.texi index 19eb0340df7..e2878eee00d 100644 --- a/lispref/commands.texi +++ b/lispref/commands.texi | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | @c -*-texinfo-*- | 1 | @c -*-texinfo-*- |
| 2 | @c This is part of the GNU Emacs Lisp Reference Manual. | 2 | @c This is part of the GNU Emacs Lisp Reference Manual. |
| 3 | @c Copyright (C) 1990, 1991, 1992, 1993 Free Software Foundation, Inc. | 3 | @c Copyright (C) 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc. |
| 4 | @c See the file elisp.texi for copying conditions. | 4 | @c See the file elisp.texi for copying conditions. |
| 5 | @setfilename ../info/commands | 5 | @setfilename ../info/commands |
| 6 | @node Command Loop, Keymaps, Minibuffers, Top | 6 | @node Command Loop, Keymaps, Minibuffers, Top |
| @@ -39,42 +39,46 @@ calling the function @code{read-key-sequence}. Your Lisp code can also | |||
| 39 | call this function (@pxref{Key Sequence Input}). Lisp programs can also | 39 | call this function (@pxref{Key Sequence Input}). Lisp programs can also |
| 40 | do input at a lower level with @code{read-event} (@pxref{Reading One | 40 | do input at a lower level with @code{read-event} (@pxref{Reading One |
| 41 | Event}) or discard pending input with @code{discard-input} | 41 | Event}) or discard pending input with @code{discard-input} |
| 42 | (@pxref{Peeking and Discarding}). | 42 | (@pxref{Event Input Misc}). |
| 43 | 43 | ||
| 44 | The key sequence is translated into a command through the currently | 44 | The key sequence is translated into a command through the currently |
| 45 | active keymaps. @xref{Key Lookup}, for information on how this is done. | 45 | active keymaps. @xref{Key Lookup}, for information on how this is done. |
| 46 | The result should be a keyboard macro or an interactively callable | 46 | The result should be a keyboard macro or an interactively callable |
| 47 | function. If the key is @kbd{M-x}, then it reads the name of another | 47 | function. If the key is @kbd{M-x}, then it reads the name of another |
| 48 | command, which is used instead. This is done by the command | 48 | command, which it then calls. This is done by the command |
| 49 | @code{execute-extended-command} (@pxref{Interactive Call}). | 49 | @code{execute-extended-command} (@pxref{Interactive Call}). |
| 50 | 50 | ||
| 51 | Once the command is chosen, it must be executed, which includes | 51 | To execute a command requires first reading the arguments for it. |
| 52 | reading arguments to be given to it. This is done by calling | 52 | This is done by calling @code{command-execute} (@pxref{Interactive |
| 53 | @code{command-execute} (@pxref{Interactive Call}). For commands written | 53 | Call}). For commands written in Lisp, the @code{interactive} |
| 54 | in Lisp, the @code{interactive} specification says how to read the | 54 | specification says how to read the arguments. This may use the prefix |
| 55 | arguments. This may use the prefix argument (@pxref{Prefix Command | 55 | argument (@pxref{Prefix Command Arguments}) or may read with prompting |
| 56 | Arguments}) or may read with prompting in the minibuffer | 56 | in the minibuffer (@pxref{Minibuffers}). For example, the command |
| 57 | (@pxref{Minibuffers}). For example, the command @code{find-file} has an | 57 | @code{find-file} has an @code{interactive} specification which says to |
| 58 | @code{interactive} specification which says to read a file name using | 58 | read a file name using the minibuffer. The command's function body does |
| 59 | the minibuffer. The command's function body does not use the | 59 | not use the minibuffer; if you call this command from Lisp code as a |
| 60 | minibuffer; if you call this command from Lisp code as a function, you | 60 | function, you must supply the file name string as an ordinary Lisp |
| 61 | must supply the file name string as an ordinary Lisp function argument. | 61 | function argument. |
| 62 | 62 | ||
| 63 | If the command is a string or vector (i.e., a keyboard macro) then | 63 | If the command is a string or vector (i.e., a keyboard macro) then |
| 64 | @code{execute-kbd-macro} is used to execute it. You can call this | 64 | @code{execute-kbd-macro} is used to execute it. You can call this |
| 65 | function yourself (@pxref{Keyboard Macros}). | 65 | function yourself (@pxref{Keyboard Macros}). |
| 66 | 66 | ||
| 67 | If a command runs away, typing @kbd{C-g} terminates its execution | 67 | To terminate the execution of a running command, type @kbd{C-g}. This |
| 68 | immediately. This is called @dfn{quitting} (@pxref{Quitting}). | 68 | character causes @dfn{quitting} (@pxref{Quitting}). |
| 69 | 69 | ||
| 70 | @defvar pre-command-hook | 70 | @defvar pre-command-hook |
| 71 | The editor command loop runs this normal hook before each command. | 71 | The editor command loop runs this normal hook before each command. At |
| 72 | that time, @code{this-command} contains the command that is about to | ||
| 73 | run, and @code{last-command} describes the previous command. | ||
| 72 | @end defvar | 74 | @end defvar |
| 73 | 75 | ||
| 74 | @defvar post-command-hook | 76 | @defvar post-command-hook |
| 75 | The editor command loop runs this normal hook after each command, | 77 | The editor command loop runs this normal hook after each command |
| 76 | and also when the command loop is entered, or reentered after | 78 | (including commands terminated prematurely by quitting or by errors), |
| 77 | an error or quit. | 79 | and also when the command loop is first entered. At that time, |
| 80 | @code{this-command} describes the command that just ran, and | ||
| 81 | @code{last-command} describes the command before that. | ||
| 78 | @end defvar | 82 | @end defvar |
| 79 | 83 | ||
| 80 | @node Defining Commands | 84 | @node Defining Commands |
| @@ -108,12 +112,12 @@ makes a Lisp function an interactively-callable command. | |||
| 108 | This special form declares that the function in which it appears is a | 112 | This special form declares that the function in which it appears is a |
| 109 | command, and that it may therefore be called interactively (via | 113 | command, and that it may therefore be called interactively (via |
| 110 | @kbd{M-x} or by entering a key sequence bound to it). The argument | 114 | @kbd{M-x} or by entering a key sequence bound to it). The argument |
| 111 | @var{arg-descriptor} declares the way the arguments to the command are | 115 | @var{arg-descriptor} declares how to compute the arguments to the |
| 112 | to be computed when the command is called interactively. | 116 | command when the command is called interactively. |
| 113 | 117 | ||
| 114 | A command may be called from Lisp programs like any other function, but | 118 | A command may be called from Lisp programs like any other function, but |
| 115 | then the arguments are supplied by the caller and @var{arg-descriptor} | 119 | then the caller supplies the arguments and @var{arg-descriptor} has no |
| 116 | has no effect. | 120 | effect. |
| 117 | 121 | ||
| 118 | The @code{interactive} form has its effect because the command loop | 122 | The @code{interactive} form has its effect because the command loop |
| 119 | (actually, its subroutine @code{call-interactively}) scans through the | 123 | (actually, its subroutine @code{call-interactively}) scans through the |
| @@ -172,7 +176,7 @@ existing buffer followed by a new name to give to that buffer: | |||
| 172 | @end smallexample | 176 | @end smallexample |
| 173 | 177 | ||
| 174 | @cindex @samp{*} in interactive | 178 | @cindex @samp{*} in interactive |
| 175 | @kindex buffer-read-only | 179 | @cindex read-only buffers in interactive |
| 176 | If the first character in the string is @samp{*}, then an error is | 180 | If the first character in the string is @samp{*}, then an error is |
| 177 | signaled if the buffer is read-only. | 181 | signaled if the buffer is read-only. |
| 178 | 182 | ||
| @@ -222,6 +226,9 @@ This code letter computes an argument without reading any input. | |||
| 222 | Therefore, it does not use a prompt string, and any prompt string you | 226 | Therefore, it does not use a prompt string, and any prompt string you |
| 223 | supply is ignored. | 227 | supply is ignored. |
| 224 | 228 | ||
| 229 | Even though the code letter doesn't use a prompt string, you must follow | ||
| 230 | it with a newline if it is not the last code character in the string. | ||
| 231 | |||
| 225 | @item Prompt | 232 | @item Prompt |
| 226 | A prompt immediately follows the code character. The prompt ends either | 233 | A prompt immediately follows the code character. The prompt ends either |
| 227 | with the end of the string or with a newline. | 234 | with the end of the string or with a newline. |
| @@ -266,7 +273,7 @@ Completion, Prompt. | |||
| 266 | 273 | ||
| 267 | @item d | 274 | @item d |
| 268 | @cindex position argument | 275 | @cindex position argument |
| 269 | The position of point as a number (@pxref{Point}). No I/O. | 276 | The position of point, as an integer (@pxref{Point}). No I/O. |
| 270 | 277 | ||
| 271 | @item D | 278 | @item D |
| 272 | A directory name. The default is the current default directory of the | 279 | A directory name. The default is the current default directory of the |
| @@ -280,13 +287,10 @@ the data in the lists. @xref{Input Events}. No I/O. | |||
| 280 | 287 | ||
| 281 | You can use @samp{e} more than once in a single command's interactive | 288 | You can use @samp{e} more than once in a single command's interactive |
| 282 | specification. If the key sequence which invoked the command has | 289 | specification. If the key sequence which invoked the command has |
| 283 | @var{n} events with parameters, the @var{n}th @samp{e} provides the | 290 | @var{n} events that are lists, the @var{n}th @samp{e} provides the |
| 284 | @var{n}th list event. Events which are not lists, such as function keys | 291 | @var{n}th such event. Events which are not lists, such as function keys |
| 285 | and @sc{ASCII} characters, do not count where @samp{e} is concerned. | 292 | and @sc{ASCII} characters, do not count where @samp{e} is concerned. |
| 286 | 293 | ||
| 287 | Even though @samp{e} does not use a prompt string, you must follow | ||
| 288 | it with a newline if it is not the last code character. | ||
| 289 | |||
| 290 | @item f | 294 | @item f |
| 291 | A file name of an existing file (@pxref{File Names}). The default | 295 | A file name of an existing file (@pxref{File Names}). The default |
| 292 | directory is @code{default-directory}. Existing, Completion, Default, | 296 | directory is @code{default-directory}. Existing, Completion, Default, |
| @@ -306,7 +310,7 @@ This kind of input is used by commands such as @code{describe-key} and | |||
| 306 | 310 | ||
| 307 | @item m | 311 | @item m |
| 308 | @cindex marker argument | 312 | @cindex marker argument |
| 309 | The position of the mark as a number. No I/O. | 313 | The position of the mark, as an integer. No I/O. |
| 310 | 314 | ||
| 311 | @item n | 315 | @item n |
| 312 | A number read with the minibuffer. If the input is not a number, the | 316 | A number read with the minibuffer. If the input is not a number, the |
| @@ -315,8 +319,8 @@ Prompt. | |||
| 315 | 319 | ||
| 316 | @item N | 320 | @item N |
| 317 | @cindex raw prefix argument usage | 321 | @cindex raw prefix argument usage |
| 318 | The raw prefix argument. If the prefix argument is @code{nil}, then a | 322 | The raw prefix argument. If the prefix argument is @code{nil}, then |
| 319 | number is read as with @kbd{n}. Requires a number. Prompt. | 323 | read a number as with @kbd{n}. Requires a number. Prompt. |
| 320 | 324 | ||
| 321 | @item p | 325 | @item p |
| 322 | @cindex numeric prefix argument usage | 326 | @cindex numeric prefix argument usage |
| @@ -429,9 +433,10 @@ that is, if @var{object} is a command. Otherwise, returns @code{nil}. | |||
| 429 | 433 | ||
| 430 | The interactively callable objects include strings and vectors (treated | 434 | The interactively callable objects include strings and vectors (treated |
| 431 | as keyboard macros), lambda expressions that contain a top-level call to | 435 | as keyboard macros), lambda expressions that contain a top-level call to |
| 432 | @code{interactive}, byte-code function objects, autoload objects that | 436 | @code{interactive}, compiled function objects made from such lambda |
| 433 | are declared as interactive (non-@code{nil} fourth argument to | 437 | expressions, autoload objects that are declared as interactive |
| 434 | @code{autoload}), and some of the primitive functions. | 438 | (non-@code{nil} fourth argument to @code{autoload}), and some of the |
| 439 | primitive functions. | ||
| 435 | 440 | ||
| 436 | A symbol is @code{commandp} if its function definition is | 441 | A symbol is @code{commandp} if its function definition is |
| 437 | @code{commandp}. | 442 | @code{commandp}. |
| @@ -461,7 +466,7 @@ an argument. @xref{Command History}. | |||
| 461 | @cindex keyboard macro execution | 466 | @cindex keyboard macro execution |
| 462 | This function executes @var{command} as an editing command. The | 467 | This function executes @var{command} as an editing command. The |
| 463 | argument @var{command} must satisfy the @code{commandp} predicate; i.e., | 468 | argument @var{command} must satisfy the @code{commandp} predicate; i.e., |
| 464 | it must be an interactively callable function or a string. | 469 | it must be an interactively callable function or a keyboard macro. |
| 465 | 470 | ||
| 466 | A string or vector as @var{command} is executed with | 471 | A string or vector as @var{command} is executed with |
| 467 | @code{execute-kbd-macro}. A function is passed to | 472 | @code{execute-kbd-macro}. A function is passed to |
| @@ -482,9 +487,9 @@ This function reads a command name from the minibuffer using | |||
| 482 | command returns becomes the value of @code{execute-extended-command}. | 487 | command returns becomes the value of @code{execute-extended-command}. |
| 483 | 488 | ||
| 484 | @cindex execute with prefix argument | 489 | @cindex execute with prefix argument |
| 485 | If the command asks for a prefix argument, the value | 490 | If the command asks for a prefix argument, it receives the value |
| 486 | @var{prefix-argument} is supplied. If @code{execute-extended-command} | 491 | @var{prefix-argument}. If @code{execute-extended-command} is called |
| 487 | is called interactively, the current raw prefix argument is used for | 492 | interactively, the current raw prefix argument is used for |
| 488 | @var{prefix-argument}, and thus passed on to whatever command is run. | 493 | @var{prefix-argument}, and thus passed on to whatever command is run. |
| 489 | 494 | ||
| 490 | @c !!! Should this be @kindex? | 495 | @c !!! Should this be @kindex? |
| @@ -512,11 +517,11 @@ This function returns @code{t} if the containing function (the one that | |||
| 512 | called @code{interactive-p}) was called interactively, with the function | 517 | called @code{interactive-p}) was called interactively, with the function |
| 513 | @code{call-interactively}. (It makes no difference whether | 518 | @code{call-interactively}. (It makes no difference whether |
| 514 | @code{call-interactively} was called from Lisp or directly from the | 519 | @code{call-interactively} was called from Lisp or directly from the |
| 515 | editor command loop.) Note that if the containing function was called | 520 | editor command loop.) If the containing function was called by Lisp |
| 516 | by Lisp evaluation (or with @code{apply} or @code{funcall}), then it was | 521 | evaluation (or with @code{apply} or @code{funcall}), then it was not |
| 517 | not called interactively. | 522 | called interactively. |
| 518 | 523 | ||
| 519 | The usual application of @code{interactive-p} is for deciding whether to | 524 | The most common use of @code{interactive-p} is for deciding whether to |
| 520 | print an informative message. As a special exception, | 525 | print an informative message. As a special exception, |
| 521 | @code{interactive-p} returns @code{nil} whenever a keyboard macro is | 526 | @code{interactive-p} returns @code{nil} whenever a keyboard macro is |
| 522 | being run. This is to suppress the informative messages and speed | 527 | being run. This is to suppress the informative messages and speed |
| @@ -569,9 +574,9 @@ This variable records the name of the previous command executed by the | |||
| 569 | command loop (the one before the current command). Normally the value | 574 | command loop (the one before the current command). Normally the value |
| 570 | is a symbol with a function definition, but this is not guaranteed. | 575 | is a symbol with a function definition, but this is not guaranteed. |
| 571 | 576 | ||
| 572 | The value is set by copying the value of @code{this-command} when a | 577 | The value is copied from @code{this-command} when a command returns to |
| 573 | command returns to the command loop, except when the command specifies a | 578 | the command loop, except when the command specifies a prefix argument |
| 574 | prefix argument for the following command. | 579 | for the following command. |
| 575 | @end defvar | 580 | @end defvar |
| 576 | 581 | ||
| 577 | @defvar this-command | 582 | @defvar this-command |
| @@ -580,17 +585,17 @@ This variable records the name of the command now being executed by | |||
| 580 | the editor command loop. Like @code{last-command}, it is normally a symbol | 585 | the editor command loop. Like @code{last-command}, it is normally a symbol |
| 581 | with a function definition. | 586 | with a function definition. |
| 582 | 587 | ||
| 583 | This variable is set by the command loop just before the command is run, | 588 | The command loop sets this variable just before running a command, and |
| 584 | and its value is copied into @code{last-command} when the command | 589 | copies its value into @code{last-command} when the command finishes |
| 585 | finishes (unless the command specifies a prefix argument for the | 590 | (unless the command specifies a prefix argument for the following |
| 586 | following command). | 591 | command). |
| 587 | 592 | ||
| 588 | @cindex kill command repetition | 593 | @cindex kill command repetition |
| 589 | Some commands change the value of this variable during their execution, | 594 | Some commands set this variable during their execution, as a flag for |
| 590 | simply as a flag for whatever command runs next. In particular, the | 595 | whatever command runs next. In particular, the functions that kill text |
| 591 | functions that kill text set @code{this-command} to @code{kill-region} | 596 | set @code{this-command} to @code{kill-region} so that any kill commands |
| 592 | so that any kill commands immediately following will know to append the | 597 | immediately following will know to append the killed text to the |
| 593 | killed text to the previous kill. | 598 | previous kill. |
| 594 | @end defvar | 599 | @end defvar |
| 595 | 600 | ||
| 596 | If you do not want a particular command to be recognized as the previous | 601 | If you do not want a particular command to be recognized as the previous |
| @@ -625,7 +630,7 @@ if all those events were characters. @xref{Input Events}. | |||
| 625 | 630 | ||
| 626 | @defvar last-nonmenu-event | 631 | @defvar last-nonmenu-event |
| 627 | This variable holds the last input event read as part of a key | 632 | This variable holds the last input event read as part of a key |
| 628 | sequence, aside from events resulting from mouse menus. | 633 | sequence, not counting events resulting from mouse menus. |
| 629 | 634 | ||
| 630 | One use of this variable is to figure out a good default location to | 635 | One use of this variable is to figure out a good default location to |
| 631 | pop up another menu. | 636 | pop up another menu. |
| @@ -640,7 +645,7 @@ character to insert. | |||
| 640 | 645 | ||
| 641 | @example | 646 | @example |
| 642 | @group | 647 | @group |
| 643 | last-command-char | 648 | last-command-event |
| 644 | ;; @r{Now type @kbd{C-u C-x C-e}.} | 649 | ;; @r{Now type @kbd{C-u C-x C-e}.} |
| 645 | @result{} 5 | 650 | @result{} 5 |
| 646 | @end group | 651 | @end group |
| @@ -666,9 +671,9 @@ frame, the value is the frame to which the event was redirected. | |||
| 666 | This variable determines how much time should elapse before command | 671 | This variable determines how much time should elapse before command |
| 667 | characters echo. Its value must be an integer, which specifies the | 672 | characters echo. Its value must be an integer, which specifies the |
| 668 | number of seconds to wait before echoing. If the user types a prefix | 673 | number of seconds to wait before echoing. If the user types a prefix |
| 669 | key (say @kbd{C-x}) and then delays this many seconds before continuing, | 674 | key (such as @kbd{C-x}) and then delays this many seconds before |
| 670 | the key @kbd{C-x} is echoed in the echo area. Any subsequent characters | 675 | continuing, the prefix key is echoed in the echo area. Any subsequent |
| 671 | in the same command will be echoed as well. | 676 | characters in the same command will be echoed as well. |
| 672 | 677 | ||
| 673 | If the value is zero, then command input is not echoed. | 678 | If the value is zero, then command input is not echoed. |
| 674 | @end defvar | 679 | @end defvar |
| @@ -683,16 +688,6 @@ represent keyboard or mouse activity. The events for keyboard activity | |||
| 683 | are characters or symbols; mouse events are always lists. This section | 688 | are characters or symbols; mouse events are always lists. This section |
| 684 | describes the representation and meaning of input events in detail. | 689 | describes the representation and meaning of input events in detail. |
| 685 | 690 | ||
| 686 | A command invoked using events that are lists can get the full values of | ||
| 687 | these events using the @samp{e} interactive code. @xref{Interactive | ||
| 688 | Codes}. | ||
| 689 | |||
| 690 | A key sequence that starts with a mouse event is read using the keymaps | ||
| 691 | of the buffer in the window that the mouse was in, not the current | ||
| 692 | buffer. This does not imply that clicking in a window selects that | ||
| 693 | window or its buffer---that is entirely under the control of the command | ||
| 694 | binding of the key sequence. | ||
| 695 | |||
| 696 | @defun eventp object | 691 | @defun eventp object |
| 697 | This function returns non-@code{nil} if @var{event} is an input event. | 692 | This function returns non-@code{nil} if @var{event} is an input event. |
| 698 | @end defun | 693 | @end defun |
| @@ -700,6 +695,7 @@ This function returns non-@code{nil} if @var{event} is an input event. | |||
| 700 | @menu | 695 | @menu |
| 701 | * Keyboard Events:: Ordinary characters--keys with symbols on them. | 696 | * Keyboard Events:: Ordinary characters--keys with symbols on them. |
| 702 | * Function Keys:: Function keys--keys with names, not symbols. | 697 | * Function Keys:: Function keys--keys with names, not symbols. |
| 698 | * Mouse Events:: Overview of mouse events. | ||
| 703 | * Click Events:: Pushing and releasing a mouse button. | 699 | * Click Events:: Pushing and releasing a mouse button. |
| 704 | * Drag Events:: Moving the mouse before releasing the button. | 700 | * Drag Events:: Moving the mouse before releasing the button. |
| 705 | * Button-Down Events:: A button was pushed and not yet released. | 701 | * Button-Down Events:: A button was pushed and not yet released. |
| @@ -720,7 +716,9 @@ This function returns non-@code{nil} if @var{event} is an input event. | |||
| 720 | There are two kinds of input you can get from the keyboard: ordinary | 716 | There are two kinds of input you can get from the keyboard: ordinary |
| 721 | keys, and function keys. Ordinary keys correspond to characters; the | 717 | keys, and function keys. Ordinary keys correspond to characters; the |
| 722 | events they generate are represented in Lisp as characters. In Emacs | 718 | events they generate are represented in Lisp as characters. In Emacs |
| 723 | versions 18 and earlier, characters were the only events. | 719 | versions 18 and earlier, characters were the only events. The event |
| 720 | type of a character event is the character itself (an integer); | ||
| 721 | see @ref{Classifying Events}. | ||
| 724 | 722 | ||
| 725 | @cindex modifier bits (of input character) | 723 | @cindex modifier bits (of input character) |
| 726 | @cindex basic code (of input character) | 724 | @cindex basic code (of input character) |
| @@ -756,7 +754,7 @@ the @sc{ASCII} character set whenever possible, Emacs avoids using | |||
| 756 | the 2**21 bit for those characters. | 754 | the 2**21 bit for those characters. |
| 757 | 755 | ||
| 758 | However, @sc{ASCII} provides no way to distinguish @kbd{C-A} from | 756 | However, @sc{ASCII} provides no way to distinguish @kbd{C-A} from |
| 759 | @kbd{C-A}, so Emacs uses the 2**21 bit in @kbd{C-A} and not in | 757 | @kbd{C-a}, so Emacs uses the 2**21 bit in @kbd{C-A} and not in |
| 760 | @kbd{C-a}. | 758 | @kbd{C-a}. |
| 761 | 759 | ||
| 762 | @item hyper | 760 | @item hyper |
| @@ -785,13 +783,12 @@ function @code{event-modifiers} (@pxref{Classifying Events}). | |||
| 785 | @cindex function keys | 783 | @cindex function keys |
| 786 | Most keyboards also have @dfn{function keys}---keys which have names or | 784 | Most keyboards also have @dfn{function keys}---keys which have names or |
| 787 | symbols that are not characters. Function keys are represented in Lisp | 785 | symbols that are not characters. Function keys are represented in Lisp |
| 788 | as symbols; the symbol's name is the function key's label. For example, | 786 | as symbols; the symbol's name is the function key's label, in lower |
| 789 | pressing a key labeled @key{F1} places the symbol @code{f1} in the input | 787 | case. For example, pressing a key labeled @key{F1} places the symbol |
| 790 | stream. | 788 | @code{f1} in the input stream. |
| 791 | 789 | ||
| 792 | For all keyboard events, the event type (which classifies the event for | 790 | The event type of a function key event is the event symbol itself. |
| 793 | key lookup purposes) is identical to the event---it is the character or | 791 | @xref{Classifying Events}. |
| 794 | the symbol. @xref{Classifying Events}. | ||
| 795 | 792 | ||
| 796 | Here are a few special cases in the symbol naming convention for | 793 | Here are a few special cases in the symbol naming convention for |
| 797 | function keys: | 794 | function keys: |
| @@ -801,15 +798,16 @@ function keys: | |||
| 801 | These keys correspond to common @sc{ASCII} control characters that have | 798 | These keys correspond to common @sc{ASCII} control characters that have |
| 802 | special keys on most keyboards. | 799 | special keys on most keyboards. |
| 803 | 800 | ||
| 804 | In @sc{ASCII}, @kbd{C-i} and @key{TAB} are the same character. Emacs | 801 | In @sc{ASCII}, @kbd{C-i} and @key{TAB} are the same character. If the |
| 805 | lets you distinguish them if you wish, by returning the former as the | 802 | terminal can distinguish between them, Emacs conveys the distinction to |
| 806 | integer 9, and the latter as the symbol @code{tab}. | 803 | Lisp programs by representing the former as the integer 9, and the |
| 804 | latter as the symbol @code{tab}. | ||
| 807 | 805 | ||
| 808 | Most of the time, it's not useful to distinguish the two. So normally | 806 | Most of the time, it's not useful to distinguish the two. So normally |
| 809 | @code{function-key-map} is set up to map @code{tab} into 9. Thus, a | 807 | @code{function-key-map} is set up to map @code{tab} into 9. Thus, a key |
| 810 | key binding for character code 9 also applies to @code{tab}. Likewise | 808 | binding for character code 9 (the character @kbd{C-i}) also applies to |
| 811 | for the other symbols in this group. The function @code{read-char} | 809 | @code{tab}. Likewise for the other symbols in this group. The function |
| 812 | also converts these events into characters. | 810 | @code{read-char} likewise converts these events into characters. |
| 813 | 811 | ||
| 814 | In @sc{ASCII}, @key{BS} is really @kbd{C-h}. But @code{backspace} | 812 | In @sc{ASCII}, @key{BS} is really @kbd{C-h}. But @code{backspace} |
| 815 | converts into the character code 127 (@key{DEL}), not into code 8 | 813 | converts into the character code 127 (@key{DEL}), not into code 8 |
| @@ -845,9 +843,31 @@ The super modifier. | |||
| 845 | @end table | 843 | @end table |
| 846 | 844 | ||
| 847 | Thus, the symbol for the key @key{F3} with @key{META} held down is | 845 | Thus, the symbol for the key @key{F3} with @key{META} held down is |
| 848 | @kbd{M-@key{F3}}. When you use more than one prefix, we recommend you | 846 | @kbd{M-@key{f3}}. When you use more than one prefix, we recommend you |
| 849 | write them in alphabetical order (though the order does not matter in | 847 | write them in alphabetical order; but the order does not matter in |
| 850 | arguments to the key-binding lookup and modification functions). | 848 | arguments to the key-binding lookup and modification functions. |
| 849 | |||
| 850 | @node Mouse Events | ||
| 851 | @subsection Mouse Events | ||
| 852 | |||
| 853 | Emacs supports four kinds of mouse events: click events, drag events, | ||
| 854 | button-down events, and motion events. All mouse events are represented | ||
| 855 | as lists. The @sc{car} of the list is the event type; this says which | ||
| 856 | mouse button was involved, and which modifier keys were used with it. | ||
| 857 | The event type can also distinguish double or triple button presses | ||
| 858 | (@pxref{Repeat Events}). The rest of the list elements give position | ||
| 859 | and time information. | ||
| 860 | |||
| 861 | For key lookup, only the event type matters: two events of the same type | ||
| 862 | necessarily run the same command. The command can access the full | ||
| 863 | values of these events using the @samp{e} interactive code. | ||
| 864 | @xref{Interactive Codes}. | ||
| 865 | |||
| 866 | A key sequence that starts with a mouse event is read using the keymaps | ||
| 867 | of the buffer in the window that the mouse was in, not the current | ||
| 868 | buffer. This does not imply that clicking in a window selects that | ||
| 869 | window or its buffer---that is entirely under the control of the command | ||
| 870 | binding of the key sequence. | ||
| 851 | 871 | ||
| 852 | @node Click Events | 872 | @node Click Events |
| 853 | @subsection Click Events | 873 | @subsection Click Events |
| @@ -860,18 +880,17 @@ this form: | |||
| 860 | 880 | ||
| 861 | @example | 881 | @example |
| 862 | (@var{event-type} | 882 | (@var{event-type} |
| 863 | (@var{window} @var{buffer-pos} | 883 | (@var{window} @var{buffer-pos} (@var{x} . @var{y}) @var{timestamp}) |
| 864 | (@var{x} . @var{y}) @var{timestamp}) | ||
| 865 | @var{click-count}) | 884 | @var{click-count}) |
| 866 | @end example | 885 | @end example |
| 867 | 886 | ||
| 868 | Here is what the elements normally mean: | 887 | Here is what the elements normally mean: |
| 869 | 888 | ||
| 870 | @table @var | 889 | @table @asis |
| 871 | @item event-type | 890 | @item @var{event-type} |
| 872 | This is a symbol that indicates which mouse button was used. It is | 891 | This is a symbol that indicates which mouse button was used. It is |
| 873 | one of the symbols @code{mouse-1}, @code{mouse-2}, @dots{}, where the | 892 | one of the symbols @code{mouse-1}, @code{mouse-2}, @dots{}, where the |
| 874 | buttons are numbered numbered left to right. | 893 | buttons are numbered left to right. |
| 875 | 894 | ||
| 876 | You can also use prefixes @samp{A-}, @samp{C-}, @samp{H-}, @samp{M-}, | 895 | You can also use prefixes @samp{A-}, @samp{C-}, @samp{H-}, @samp{M-}, |
| 877 | @samp{S-} and @samp{s-} for modifiers alt, control, hyper, meta, shift | 896 | @samp{S-} and @samp{s-} for modifiers alt, control, hyper, meta, shift |
| @@ -882,30 +901,29 @@ describe events by their types; thus, if there is a key binding for | |||
| 882 | @code{mouse-1}, that binding would apply to all events whose | 901 | @code{mouse-1}, that binding would apply to all events whose |
| 883 | @var{event-type} is @code{mouse-1}. | 902 | @var{event-type} is @code{mouse-1}. |
| 884 | 903 | ||
| 885 | @item window | 904 | @item @var{window} |
| 886 | This is the window in which the click occurred. | 905 | This is the window in which the click occurred. |
| 887 | 906 | ||
| 888 | @item x | 907 | @item @var{x}, @var{y} |
| 889 | @itemx y | ||
| 890 | These are the pixel-based coordinates of the click, relative to the top | 908 | These are the pixel-based coordinates of the click, relative to the top |
| 891 | left corner of @var{window}, which is @code{(0 . 0)}. | 909 | left corner of @var{window}, which is @code{(0 . 0)}. |
| 892 | 910 | ||
| 893 | @item buffer-pos | 911 | @item @var{buffer-pos} |
| 894 | This is the buffer position of the character clicked on. | 912 | This is the buffer position of the character clicked on. |
| 895 | 913 | ||
| 896 | @item timestamp | 914 | @item @var{timestamp} |
| 897 | This is the time at which the event occurred, in milliseconds. (Since | 915 | This is the time at which the event occurred, in milliseconds. (Since |
| 898 | this value wraps around the entire range of Emacs Lisp integers in about | 916 | this value wraps around the entire range of Emacs Lisp integers in about |
| 899 | five hours, it is useful only for relating the times of nearby events.) | 917 | five hours, it is useful only for relating the times of nearby events.) |
| 900 | 918 | ||
| 901 | @item click-count | 919 | @item @var{click-count} |
| 902 | This is the number of rapid repeated presses so far of the same mouse | 920 | This is the number of rapid repeated presses so far of the same mouse |
| 903 | button. @xref{Repeat Events}. | 921 | button. @xref{Repeat Events}. |
| 904 | @end table | 922 | @end table |
| 905 | 923 | ||
| 906 | The meanings of @var{buffer-pos}, @var{row} and @var{column} are | 924 | The meanings of @var{buffer-pos}, @var{x} and @var{y} are somewhat |
| 907 | somewhat different when the event location is in a special part of the | 925 | different when the event location is in a special part of the screen, |
| 908 | screen, such as the mode line or a scroll bar. | 926 | such as the mode line or a scroll bar. |
| 909 | 927 | ||
| 910 | If the location is in a scroll bar, then @var{buffer-pos} is the symbol | 928 | If the location is in a scroll bar, then @var{buffer-pos} is the symbol |
| 911 | @code{vertical-scroll-bar} or @code{horizontal-scroll-bar}, and the pair | 929 | @code{vertical-scroll-bar} or @code{horizontal-scroll-bar}, and the pair |
| @@ -917,8 +935,8 @@ the entire scroll bar. | |||
| 917 | If the position is on a mode line or the vertical line separating | 935 | If the position is on a mode line or the vertical line separating |
| 918 | @var{window} from its neighbor to the right, then @var{buffer-pos} is | 936 | @var{window} from its neighbor to the right, then @var{buffer-pos} is |
| 919 | the symbol @code{mode-line} or @code{vertical-line}. For the mode line, | 937 | the symbol @code{mode-line} or @code{vertical-line}. For the mode line, |
| 920 | @var{row} does not have meaningful data. For the vertical line, | 938 | @var{y} does not have meaningful data. For the vertical line, @var{x} |
| 921 | @var{column} does not have meaningful data. | 939 | does not have meaningful data. |
| 922 | 940 | ||
| 923 | @var{buffer-pos} may be a list containing a symbol (one of the symbols | 941 | @var{buffer-pos} may be a list containing a symbol (one of the symbols |
| 924 | listed above) instead of just the symbol. This is what happens after | 942 | listed above) instead of just the symbol. This is what happens after |
| @@ -939,10 +957,8 @@ position and the final position, like this: | |||
| 939 | 957 | ||
| 940 | @example | 958 | @example |
| 941 | (@var{event-type} | 959 | (@var{event-type} |
| 942 | (@var{window1} @var{buffer-pos1} | 960 | (@var{window1} @var{buffer-pos1} (@var{x1} . @var{y1}) @var{timestamp1}) |
| 943 | (@var{x1} . @var{y1}) @var{timestamp1}) | 961 | (@var{window2} @var{buffer-pos2} (@var{x2} . @var{y2}) @var{timestamp2}) |
| 944 | (@var{window2} @var{buffer-pos2} | ||
| 945 | (@var{x2} . @var{y2}) @var{timestamp2}) | ||
| 946 | @var{click-count}) | 962 | @var{click-count}) |
| 947 | @end example | 963 | @end example |
| 948 | 964 | ||
| @@ -972,10 +988,10 @@ click from a drag until the button is released. | |||
| 972 | 988 | ||
| 973 | If you want to take action as soon as a button is pressed, you need to | 989 | If you want to take action as soon as a button is pressed, you need to |
| 974 | handle @dfn{button-down} events.@footnote{Button-down is the | 990 | handle @dfn{button-down} events.@footnote{Button-down is the |
| 975 | conservative antithesis of drag.}. These occur as soon as a button is | 991 | conservative antithesis of drag.} These occur as soon as a button is |
| 976 | pressed. They are represented by lists which look exactly like click | 992 | pressed. They are represented by lists which look exactly like click |
| 977 | events (@pxref{Click Events}), except that the name of @var{event-type} | 993 | events (@pxref{Click Events}), except that the @var{event-type} symbol |
| 978 | contains the prefix @samp{down-}. The @samp{down-} prefix follows the | 994 | name contains the prefix @samp{down-}. The @samp{down-} prefix follows |
| 979 | modifier key prefixes such as @samp{C-} and @samp{M-}. | 995 | modifier key prefixes such as @samp{C-} and @samp{M-}. |
| 980 | 996 | ||
| 981 | The function @code{read-key-sequence}, and the Emacs command loop, | 997 | The function @code{read-key-sequence}, and the Emacs command loop, |
| @@ -983,10 +999,7 @@ ignore any button-down events that don't have command bindings. This | |||
| 983 | means that you need not worry about defining button-down events unless | 999 | means that you need not worry about defining button-down events unless |
| 984 | you want them to do something. The usual reason to define a button-down | 1000 | you want them to do something. The usual reason to define a button-down |
| 985 | event is so that you can track mouse motion (by reading motion events) | 1001 | event is so that you can track mouse motion (by reading motion events) |
| 986 | until the button is released. | 1002 | until the button is released. @xref{Motion Events}. |
| 987 | @ifinfo | ||
| 988 | @xref{Motion Events}. | ||
| 989 | @end ifinfo | ||
| 990 | 1003 | ||
| 991 | @node Repeat Events | 1004 | @node Repeat Events |
| 992 | @subsection Repeat Events | 1005 | @subsection Repeat Events |
| @@ -995,8 +1008,8 @@ until the button is released. | |||
| 995 | @cindex triple-click events | 1008 | @cindex triple-click events |
| 996 | 1009 | ||
| 997 | If you press the same mouse button more than once in quick succession | 1010 | If you press the same mouse button more than once in quick succession |
| 998 | without moving the mouse, Emacs uses special @dfn{repeat} mouse events | 1011 | without moving the mouse, Emacs generates special @dfn{repeat} mouse |
| 999 | for the second and subsequent presses. | 1012 | events for the second and subsequent presses. |
| 1000 | 1013 | ||
| 1001 | The most common repeat events are @dfn{double-click} events. Emacs | 1014 | The most common repeat events are @dfn{double-click} events. Emacs |
| 1002 | generates a double-click event when you click a button twice; the event | 1015 | generates a double-click event when you click a button twice; the event |
| @@ -1004,7 +1017,7 @@ happens when you release the button (as is normal for all click | |||
| 1004 | events). | 1017 | events). |
| 1005 | 1018 | ||
| 1006 | The event type of a double-click event contains the prefix | 1019 | The event type of a double-click event contains the prefix |
| 1007 | @code{double}. Thus, a double click on the second mouse button with | 1020 | @samp{double-}. Thus, a double click on the second mouse button with |
| 1008 | @key{meta} held down comes to the Lisp program as | 1021 | @key{meta} held down comes to the Lisp program as |
| 1009 | @code{M-double-mouse-2}. If a double-click event has no binding, the | 1022 | @code{M-double-mouse-2}. If a double-click event has no binding, the |
| 1010 | binding of the corresponding ordinary click event is used to execute | 1023 | binding of the corresponding ordinary click event is used to execute |
| @@ -1012,14 +1025,14 @@ it. Thus, you need not pay attention to the double click feature | |||
| 1012 | unless you really want to. | 1025 | unless you really want to. |
| 1013 | 1026 | ||
| 1014 | When the user performs a double click, Emacs generates first an ordinary | 1027 | When the user performs a double click, Emacs generates first an ordinary |
| 1015 | click event, and then a double-click event. Therefore, the command | 1028 | click event, and then a double-click event. Therefore, you must design |
| 1016 | binding of the double click event must be written to assume that the | 1029 | the command binding of the double click event to assume that the |
| 1017 | single-click command has already run. It must produce the desired | 1030 | single-click command has already run. It must produce the desired |
| 1018 | results of a double click, starting from the results of a single click. | 1031 | results of a double click, starting from the results of a single click. |
| 1019 | 1032 | ||
| 1020 | This means that it is most convenient to give double clicks a meaning | 1033 | This is convenient, if the meaning of a double click somehow ``builds |
| 1021 | that somehow ``builds on'' the meaning of a single click. This is what | 1034 | on'' the meaning of a single click---which is recommended user interface |
| 1022 | user interface experts recommend that double clicks should do. | 1035 | design practice for double clicks. |
| 1023 | 1036 | ||
| 1024 | If you click a button, then press it down again and start moving the | 1037 | If you click a button, then press it down again and start moving the |
| 1025 | mouse with the button held down, then you get a @dfn{double-drag} event | 1038 | mouse with the button held down, then you get a @dfn{double-drag} event |
| @@ -1029,11 +1042,12 @@ has no binding, Emacs looks for an alternate binding as if the event | |||
| 1029 | were an ordinary click. | 1042 | were an ordinary click. |
| 1030 | 1043 | ||
| 1031 | Before the double-click or double-drag event, Emacs generates a | 1044 | Before the double-click or double-drag event, Emacs generates a |
| 1032 | @dfn{double-down} event when the button is pressed down for the second | 1045 | @dfn{double-down} event when the user presses the button down for the |
| 1033 | time. Its event type contains @samp{double-down} instead of just | 1046 | second time. Its event type contains @samp{double-down} instead of just |
| 1034 | @samp{down}. If a double-down event has no binding, Emacs looks for an | 1047 | @samp{down}. If a double-down event has no binding, Emacs looks for an |
| 1035 | alternate binding as if the event were an ordinary button-down event. | 1048 | alternate binding as if the event were an ordinary button-down event. |
| 1036 | If it finds no binding that way either, the double-down event is ignored. | 1049 | If it finds no binding that way either, the double-down event is |
| 1050 | ignored. | ||
| 1037 | 1051 | ||
| 1038 | To summarize, when you click a button and then press it again right | 1052 | To summarize, when you click a button and then press it again right |
| 1039 | away, Emacs generates a double-down event, followed by either a | 1053 | away, Emacs generates a double-down event, followed by either a |
| @@ -1046,11 +1060,11 @@ these events contain @samp{triple} instead of @samp{double}. If any | |||
| 1046 | triple event has no binding, Emacs uses the binding that it would use | 1060 | triple event has no binding, Emacs uses the binding that it would use |
| 1047 | for the corresponding double event. | 1061 | for the corresponding double event. |
| 1048 | 1062 | ||
| 1049 | If you click a button three or more times and then press it again, | 1063 | If you click a button three or more times and then press it again, the |
| 1050 | the events for the presses beyond the third are all triple events. | 1064 | events for the presses beyond the third are all triple events. Emacs |
| 1051 | Emacs does not have quadruple, quintuple, etc. events as separate | 1065 | does not have separate event types for quadruple, quintuple, etc.@: |
| 1052 | event types. However, you can look at the event list to find out | 1066 | events. However, you can look at the event list to find out precisely |
| 1053 | precisely how many times the button was pressed. | 1067 | how many times the button was pressed. |
| 1054 | 1068 | ||
| 1055 | @defun event-click-count event | 1069 | @defun event-click-count event |
| 1056 | This function returns the number of consecutive button presses that led | 1070 | This function returns the number of consecutive button presses that led |
| @@ -1061,9 +1075,9 @@ the value is 3 or greater. If @var{event} is an ordinary mouse event | |||
| 1061 | @end defun | 1075 | @end defun |
| 1062 | 1076 | ||
| 1063 | @defvar double-click-time | 1077 | @defvar double-click-time |
| 1064 | To count as double- and triple-clicks, mouse clicks must be at the same | 1078 | To generate repeat events, successive mouse button presses must be at |
| 1065 | location as the first click, and the number of milliseconds between the | 1079 | the same screen position, and the number of milliseconds between |
| 1066 | first release and the second must be less than the value of | 1080 | successive button presses must be less than the value of |
| 1067 | @code{double-click-time}. Setting @code{double-click-time} to | 1081 | @code{double-click-time}. Setting @code{double-click-time} to |
| 1068 | @code{nil} disables multi-click detection entirely. Setting it to | 1082 | @code{nil} disables multi-click detection entirely. Setting it to |
| 1069 | @code{t} removes the time limit; Emacs then detects multi-clicks by | 1083 | @code{t} removes the time limit; Emacs then detects multi-clicks by |
| @@ -1081,8 +1095,7 @@ represented by lists that look like this: | |||
| 1081 | 1095 | ||
| 1082 | @example | 1096 | @example |
| 1083 | (mouse-movement | 1097 | (mouse-movement |
| 1084 | (@var{window} @var{buffer-pos} | 1098 | (@var{window} @var{buffer-pos} (@var{x} . @var{y}) @var{timestamp})) |
| 1085 | (@var{x} . @var{y}) @var{timestamp})) | ||
| 1086 | @end example | 1099 | @end example |
| 1087 | 1100 | ||
| 1088 | The second element of the list describes the current position of the | 1101 | The second element of the list describes the current position of the |
| @@ -1099,8 +1112,8 @@ events enabled. Typically @var{body} would use @code{read-event} | |||
| 1099 | to read the motion events and modify the display accordingly. | 1112 | to read the motion events and modify the display accordingly. |
| 1100 | 1113 | ||
| 1101 | When the user releases the button, that generates a click event. | 1114 | When the user releases the button, that generates a click event. |
| 1102 | Normally @var{body} should return when it sees the click event, and | 1115 | Typically, @var{body} should return when it sees the click event, and |
| 1103 | discard the event. | 1116 | discard that event. |
| 1104 | @end defspec | 1117 | @end defspec |
| 1105 | 1118 | ||
| 1106 | @node Focus Events | 1119 | @node Focus Events |
| @@ -1123,14 +1136,14 @@ Focus events are represented in Lisp as lists that look like this: | |||
| 1123 | @noindent | 1136 | @noindent |
| 1124 | where @var{new-frame} is the frame switched to. | 1137 | where @var{new-frame} is the frame switched to. |
| 1125 | 1138 | ||
| 1126 | In X windows, most window managers are set up so that just moving the | 1139 | Most X window window managers are set up so that just moving the mouse |
| 1127 | mouse into a window is enough to set the focus there. Emacs appears to | 1140 | into a window is enough to set the focus there. Emacs appears to do |
| 1128 | do this, because it changes the cursor to solid in the new frame. | 1141 | this, because it changes the cursor to solid in the new frame. However, |
| 1129 | However, there is no need for the Lisp program to know about the focus | 1142 | there is no need for the Lisp program to know about the focus change |
| 1130 | change until some other kind of input arrives. So Emacs generates the | 1143 | until some other kind of input arrives. So Emacs generates a focus |
| 1131 | focus event only when the user actually types a keyboard key or presses | 1144 | event only when the user actually types a keyboard key or presses a |
| 1132 | a mouse button in the new frame; just moving the mouse between frames | 1145 | mouse button in the new frame; just moving the mouse between frames does |
| 1133 | does not generate a focus event. | 1146 | not generate a focus event. |
| 1134 | 1147 | ||
| 1135 | A focus event in the middle of a key sequence would garble the | 1148 | A focus event in the middle of a key sequence would garble the |
| 1136 | sequence. So Emacs never generates a focus event in the middle of a key | 1149 | sequence. So Emacs never generates a focus event in the middle of a key |
| @@ -1150,7 +1163,7 @@ location, that generates a sequence of events like this: | |||
| 1150 | (mouse-1 (#<window 18 on NEWS> 2613 (0 . 38) -864180)) | 1163 | (mouse-1 (#<window 18 on NEWS> 2613 (0 . 38) -864180)) |
| 1151 | @end smallexample | 1164 | @end smallexample |
| 1152 | 1165 | ||
| 1153 | Or, while holding the control key down, the user might hold down the | 1166 | While holding the control key down, the user might hold down the |
| 1154 | second mouse button, and drag the mouse from one line to the next. | 1167 | second mouse button, and drag the mouse from one line to the next. |
| 1155 | That produces two events, as shown here: | 1168 | That produces two events, as shown here: |
| 1156 | 1169 | ||
| @@ -1160,9 +1173,9 @@ That produces two events, as shown here: | |||
| 1160 | (#<window 18 on NEWS> 3510 (0 . 28) -729648)) | 1173 | (#<window 18 on NEWS> 3510 (0 . 28) -729648)) |
| 1161 | @end smallexample | 1174 | @end smallexample |
| 1162 | 1175 | ||
| 1163 | Or, while holding down the meta and shift keys, the user might press the | 1176 | While holding down the meta and shift keys, the user might press the |
| 1164 | second mouse button on the window's mode line, and then drag the mouse | 1177 | second mouse button on the window's mode line, and then drag the mouse |
| 1165 | into another window. That produces the following pair of events: | 1178 | into another window. That produces a pair of events like these: |
| 1166 | 1179 | ||
| 1167 | @smallexample | 1180 | @smallexample |
| 1168 | (M-S-down-mouse-2 (#<window 18 on NEWS> mode-line (33 . 31) -457844)) | 1181 | (M-S-down-mouse-2 (#<window 18 on NEWS> mode-line (33 . 31) -457844)) |
| @@ -1186,7 +1199,7 @@ list. Thus, the event type is always a symbol or a character. | |||
| 1186 | concerned; thus, they always run the same command. That does not | 1199 | concerned; thus, they always run the same command. That does not |
| 1187 | necessarily mean they do the same things, however, as some commands look | 1200 | necessarily mean they do the same things, however, as some commands look |
| 1188 | at the whole event to decide what to do. For example, some commands use | 1201 | at the whole event to decide what to do. For example, some commands use |
| 1189 | the location of a mouse event to decide what text to act on. | 1202 | the location of a mouse event to decide where in the buffer to act. |
| 1190 | 1203 | ||
| 1191 | Sometimes broader classifications of events are useful. For example, | 1204 | Sometimes broader classifications of events are useful. For example, |
| 1192 | you might want to ask whether an event involved the @key{META} key, | 1205 | you might want to ask whether an event involved the @key{META} key, |
| @@ -1196,11 +1209,16 @@ regardless of which other key or mouse button was used. | |||
| 1196 | provided to get such information conveniently. | 1209 | provided to get such information conveniently. |
| 1197 | 1210 | ||
| 1198 | @defun event-modifiers event | 1211 | @defun event-modifiers event |
| 1199 | This function returns a list of the modifiers that @var{event} has. | 1212 | This function returns a list of the modifiers that @var{event} has. The |
| 1200 | The modifiers are symbols; they include @code{shift}, @code{control}, | 1213 | modifiers are symbols; they include @code{shift}, @code{control}, |
| 1201 | @code{meta}, @code{alt}, @code{hyper} and @code{super}. In addition, | 1214 | @code{meta}, @code{alt}, @code{hyper} and @code{super}. In addition, |
| 1202 | the property of a mouse event symbol always has one of @code{click}, | 1215 | the modifiers list of a mouse event symbol always contains one of |
| 1203 | @code{drag}, and @code{down} among the modifiers. For example: | 1216 | @code{click}, @code{drag}, and @code{down}. |
| 1217 | |||
| 1218 | The argument @var{event} may be an entire event object, or just an event | ||
| 1219 | type. | ||
| 1220 | |||
| 1221 | Here are some examples: | ||
| 1204 | 1222 | ||
| 1205 | @example | 1223 | @example |
| 1206 | (event-modifiers ?a) | 1224 | (event-modifiers ?a) |
| @@ -1260,14 +1278,14 @@ event. | |||
| 1260 | @subsection Accessing Events | 1278 | @subsection Accessing Events |
| 1261 | 1279 | ||
| 1262 | This section describes convenient functions for accessing the data in | 1280 | This section describes convenient functions for accessing the data in |
| 1263 | an event which is a list. | 1281 | a mouse button or motion event. |
| 1264 | 1282 | ||
| 1265 | The following functions return the starting or ending position of a | 1283 | These two functions return the starting or ending position of a |
| 1266 | mouse-button event. The position is a list of this form: | 1284 | mouse-button event. The position is a list of this form: |
| 1267 | 1285 | ||
| 1268 | @smallexample | 1286 | @example |
| 1269 | (@var{window} @var{buffer-position} (@var{col} . @var{row}) @var{timestamp}) | 1287 | (@var{window} @var{buffer-position} (@var{col} . @var{row}) @var{timestamp}) |
| 1270 | @end smallexample | 1288 | @end example |
| 1271 | 1289 | ||
| 1272 | @defun event-start event | 1290 | @defun event-start event |
| 1273 | This returns the starting position of @var{event}. | 1291 | This returns the starting position of @var{event}. |
| @@ -1294,7 +1312,7 @@ Return the window that @var{position} is in. | |||
| 1294 | @end defun | 1312 | @end defun |
| 1295 | 1313 | ||
| 1296 | @defun posn-point position | 1314 | @defun posn-point position |
| 1297 | Return the buffer location in @var{position}. | 1315 | Return the buffer position in @var{position}. This is an integer. |
| 1298 | @end defun | 1316 | @end defun |
| 1299 | 1317 | ||
| 1300 | @defun posn-x-y position | 1318 | @defun posn-x-y position |
| @@ -1303,22 +1321,22 @@ a cons cell @code{(@var{x} . @var{y})}. | |||
| 1303 | @end defun | 1321 | @end defun |
| 1304 | 1322 | ||
| 1305 | @defun posn-col-row position | 1323 | @defun posn-col-row position |
| 1306 | Return the row and column (in units of characters) in @var{position}, as | 1324 | Return the row and column (in units of characters) of @var{position}, as |
| 1307 | a cons cell @code{(@var{col} . @var{row})}. These are computed from the | 1325 | a cons cell @code{(@var{col} . @var{row})}. These are computed from the |
| 1308 | @var{x} and @var{y} values actually found in @var{position}. | 1326 | @var{x} and @var{y} values actually found in @var{position}. |
| 1309 | @end defun | 1327 | @end defun |
| 1310 | 1328 | ||
| 1311 | @defun posn-timestamp position | 1329 | @defun posn-timestamp position |
| 1312 | Return the timestamp of @var{position}. | 1330 | Return the timestamp in @var{position}. |
| 1313 | @end defun | 1331 | @end defun |
| 1314 | 1332 | ||
| 1315 | @defun scroll-bar-scale ratio total | 1333 | @defun scroll-bar-scale ratio total |
| 1316 | This function multiples (in effect) @var{ratio} by @var{total}, | 1334 | This function multiples (in effect) @var{ratio} by @var{total}, rounding |
| 1317 | rounding the result to an integer. @var{ratio} is not a number, | 1335 | the result to an integer. The argument @var{ratio} is not a number, but |
| 1318 | but rather a pair @code{(@var{num} . @var{denom})}. | 1336 | rather a pair @code{(@var{num} . @var{denom})}. |
| 1319 | 1337 | ||
| 1320 | This is handy for scaling a position on a scroll bar into a buffer | 1338 | This function is handy for scaling a position on a scroll bar into a |
| 1321 | position. Here's how to do that: | 1339 | buffer position. Here's how to do that: |
| 1322 | 1340 | ||
| 1323 | @example | 1341 | @example |
| 1324 | (+ (point-min) | 1342 | (+ (point-min) |
| @@ -1348,20 +1366,20 @@ fit in a string, and many Lisp programs contain string constants that | |||
| 1348 | use @samp{\M-} to express meta characters, especially as the argument to | 1366 | use @samp{\M-} to express meta characters, especially as the argument to |
| 1349 | @code{define-key} and similar functions. | 1367 | @code{define-key} and similar functions. |
| 1350 | 1368 | ||
| 1351 | We provide backward compatibility to run those programs with special | 1369 | We provide backward compatibility to run those programs using special |
| 1352 | rules for how to put a keyboard character event in a string. Here are | 1370 | rules for how to put a keyboard character event in a string. Here are |
| 1353 | the rules: | 1371 | the rules: |
| 1354 | 1372 | ||
| 1355 | @itemize @bullet | 1373 | @itemize @bullet |
| 1356 | @item | 1374 | @item |
| 1357 | If the keyboard event value is in the range of 0 to 127, it can go in the | 1375 | If the keyboard character value is in the range of 0 to 127, it can go |
| 1358 | string unchanged. | 1376 | in the string unchanged. |
| 1359 | 1377 | ||
| 1360 | @item | 1378 | @item |
| 1361 | The meta variants of those events, with codes in the range of 2**23 to | 1379 | The meta variants of those characters, with codes in the range of 2**23 |
| 1362 | 2**23+127, can also go in the string, but you must change their numeric | 1380 | to 2**23+127, can also go in the string, but you must change their |
| 1363 | values. You must set the 2**7 bit instead of the 2**23 bit, resulting | 1381 | numeric values. You must set the 2**7 bit instead of the 2**23 bit, |
| 1364 | in a value between 128 and 255. | 1382 | resulting in a value between 128 and 255. |
| 1365 | 1383 | ||
| 1366 | @item | 1384 | @item |
| 1367 | Other keyboard character events cannot fit in a string. This includes | 1385 | Other keyboard character events cannot fit in a string. This includes |
| @@ -1369,7 +1387,8 @@ keyboard events in the range of 128 to 255. | |||
| 1369 | @end itemize | 1387 | @end itemize |
| 1370 | 1388 | ||
| 1371 | Functions such as @code{read-key-sequence} that can construct strings | 1389 | Functions such as @code{read-key-sequence} that can construct strings |
| 1372 | containing events follow these rules. | 1390 | of keyboard input characters follow these rules. They construct vectors |
| 1391 | instead of strings, when the events won't fit in a string. | ||
| 1373 | 1392 | ||
| 1374 | When you use the read syntax @samp{\M-} in a string, it produces a | 1393 | When you use the read syntax @samp{\M-} in a string, it produces a |
| 1375 | code in the range of 128 to 255---the same code that you get if you | 1394 | code in the range of 128 to 255---the same code that you get if you |
| @@ -1377,14 +1396,22 @@ modify the corresponding keyboard event to put it in the string. Thus, | |||
| 1377 | meta events in strings work consistently regardless of how they get into | 1396 | meta events in strings work consistently regardless of how they get into |
| 1378 | the strings. | 1397 | the strings. |
| 1379 | 1398 | ||
| 1380 | New programs can avoid dealing with these rules by using vectors | ||
| 1381 | instead of strings for key sequences when there is any possibility that | ||
| 1382 | these issues might arise. | ||
| 1383 | |||
| 1384 | The reason we changed the representation of meta characters as | 1399 | The reason we changed the representation of meta characters as |
| 1385 | keyboard events is to make room for basic character codes beyond 127, | 1400 | keyboard events is to make room for basic character codes beyond 127, |
| 1386 | and support meta variants of such larger character codes. | 1401 | and support meta variants of such larger character codes. |
| 1387 | 1402 | ||
| 1403 | New programs can avoid dealing with these special compatibility rules | ||
| 1404 | by using vectors instead of strings for key sequences when there is any | ||
| 1405 | possibility that they might contain meta characters, and by using | ||
| 1406 | @code{listify-key-sequence} to access a string of events. | ||
| 1407 | |||
| 1408 | @defun listify-key-sequence key | ||
| 1409 | This function converts the string or vector @var{key} to a list of | ||
| 1410 | events which you can put in @code{unread-command-events}. Converting a | ||
| 1411 | vector is simple, but converting a string is tricky because of the | ||
| 1412 | special representation used for meta characters in a string. | ||
| 1413 | @end defun | ||
| 1414 | |||
| 1388 | @node Reading Input | 1415 | @node Reading Input |
| 1389 | @section Reading Input | 1416 | @section Reading Input |
| 1390 | 1417 | ||
| @@ -1402,7 +1429,7 @@ debugging terminal input. | |||
| 1402 | * Key Sequence Input:: How to read one key sequence. | 1429 | * Key Sequence Input:: How to read one key sequence. |
| 1403 | * Reading One Event:: How to read just one event. | 1430 | * Reading One Event:: How to read just one event. |
| 1404 | * Quoted Character Input:: Asking the user to specify a character. | 1431 | * Quoted Character Input:: Asking the user to specify a character. |
| 1405 | * Peeking and Discarding:: How to reread or throw away input events. | 1432 | * Event Input Misc:: How to reread or throw away input events. |
| 1406 | @end menu | 1433 | @end menu |
| 1407 | 1434 | ||
| 1408 | @node Key Sequence Input | 1435 | @node Key Sequence Input |
| @@ -1426,9 +1453,9 @@ Otherwise, it returns a vector, since a vector can hold all kinds of | |||
| 1426 | events---characters, symbols, and lists. The elements of the string or | 1453 | events---characters, symbols, and lists. The elements of the string or |
| 1427 | vector are the events in the key sequence. | 1454 | vector are the events in the key sequence. |
| 1428 | 1455 | ||
| 1429 | Quitting is suppressed inside @code{read-key-sequence}. In other words, | 1456 | The function @code{read-key-sequence} suppresses quitting: @kbd{C-g} |
| 1430 | a @kbd{C-g} typed while reading with this function is treated like any | 1457 | typed while reading with this function works like any other character, |
| 1431 | other character, and does not set @code{quit-flag}. @xref{Quitting}. | 1458 | and does not set @code{quit-flag}. @xref{Quitting}. |
| 1432 | 1459 | ||
| 1433 | The argument @var{prompt} is either a string to be displayed in the echo | 1460 | The argument @var{prompt} is either a string to be displayed in the echo |
| 1434 | area as a prompt, or @code{nil}, meaning not to display a prompt. | 1461 | area as a prompt, or @code{nil}, meaning not to display a prompt. |
| @@ -1459,7 +1486,7 @@ and key sequences read from keyboard macros being executed. | |||
| 1459 | @cindex upper case key sequence | 1486 | @cindex upper case key sequence |
| 1460 | @cindex downcasing in @code{lookup-key} | 1487 | @cindex downcasing in @code{lookup-key} |
| 1461 | If an input character is an upper case letter and has no key binding, | 1488 | If an input character is an upper case letter and has no key binding, |
| 1462 | but the lower case equivalent has one, then @code{read-key-sequence} | 1489 | but its lower case equivalent has one, then @code{read-key-sequence} |
| 1463 | converts the character to lower case. Note that @code{lookup-key} does | 1490 | converts the character to lower case. Note that @code{lookup-key} does |
| 1464 | not perform case conversion in this way. | 1491 | not perform case conversion in this way. |
| 1465 | 1492 | ||
| @@ -1469,27 +1496,28 @@ button-down events entirely. It also reshuffles focus events so that they | |||
| 1469 | never appear in a key sequence with any other events. | 1496 | never appear in a key sequence with any other events. |
| 1470 | 1497 | ||
| 1471 | When mouse events occur in special parts of a window, such as a mode | 1498 | When mouse events occur in special parts of a window, such as a mode |
| 1472 | line or a scroll bar, the event itself shows nothing special---only the | 1499 | line or a scroll bar, the event type shows nothing special---it is the |
| 1473 | symbol that would normally represent that mouse button and modifier | 1500 | same symbol that would normally represent that combination of mouse |
| 1474 | keys. The information about the screen region is kept elsewhere in the | 1501 | button and modifier keys. The information about the window part is |
| 1475 | event---in the coordinates. But @code{read-key-sequence} translates | 1502 | kept elsewhere in the event---in the coordinates. But |
| 1476 | this information into imaginary prefix keys, all of which are symbols: | 1503 | @code{read-key-sequence} translates this information into imaginary |
| 1477 | @code{mode-line}, @code{vertical-line}, @code{horizontal-scroll-bar} and | 1504 | prefix keys, all of which are symbols: @code{mode-line}, |
| 1505 | @code{vertical-line}, @code{horizontal-scroll-bar} and | ||
| 1478 | @code{vertical-scroll-bar}. | 1506 | @code{vertical-scroll-bar}. |
| 1479 | 1507 | ||
| 1508 | You can define meanings for mouse clicks in special window parts by | ||
| 1509 | defining key sequences using these imaginary prefix keys. | ||
| 1510 | |||
| 1480 | For example, if you call @code{read-key-sequence} and then click the | 1511 | For example, if you call @code{read-key-sequence} and then click the |
| 1481 | mouse on the window's mode line, this is what happens: | 1512 | mouse on the window's mode line, you get an event like this: |
| 1482 | 1513 | ||
| 1483 | @smallexample | 1514 | @example |
| 1484 | (read-key-sequence "Click on the mode line: ") | 1515 | (read-key-sequence "Click on the mode line: ") |
| 1485 | @result{} [mode-line | 1516 | @result{} [mode-line |
| 1486 | (mouse-1 | 1517 | (mouse-1 |
| 1487 | (#<window 6 on NEWS> mode-line | 1518 | (#<window 6 on NEWS> mode-line |
| 1488 | (40 . 63) 5959987))] | 1519 | (40 . 63) 5959987))] |
| 1489 | @end smallexample | 1520 | @end example |
| 1490 | |||
| 1491 | You can define meanings for mouse clicks in special window regions by | ||
| 1492 | defining key sequences using these imaginary prefix keys. | ||
| 1493 | 1521 | ||
| 1494 | @node Reading One Event | 1522 | @node Reading One Event |
| 1495 | @subsection Reading One Event | 1523 | @subsection Reading One Event |
| @@ -1505,13 +1533,12 @@ the user or from a keyboard macro. | |||
| 1505 | The function @code{read-event} does not display any message to indicate | 1533 | The function @code{read-event} does not display any message to indicate |
| 1506 | it is waiting for input; use @code{message} first, if you wish to | 1534 | it is waiting for input; use @code{message} first, if you wish to |
| 1507 | display one. If you have not displayed a message, @code{read-event} | 1535 | display one. If you have not displayed a message, @code{read-event} |
| 1508 | does @dfn{prompting}: it displays descriptions of the events that led to | 1536 | prompts by echoing: it displays descriptions of the events that led to |
| 1509 | or were read by the current command. @xref{The Echo Area}. | 1537 | or were read by the current command. @xref{The Echo Area}. |
| 1510 | 1538 | ||
| 1511 | If @code{cursor-in-echo-area} is non-@code{nil}, then @code{read-event} | 1539 | If @code{cursor-in-echo-area} is non-@code{nil}, then @code{read-event} |
| 1512 | moves the cursor temporarily to the echo area, to the end of any message | 1540 | moves the cursor temporarily to the echo area, to the end of any message |
| 1513 | displayed there. Otherwise @code{read-event} does not move the cursor. | 1541 | displayed there. Otherwise @code{read-event} does not move the cursor. |
| 1514 | @end defun | ||
| 1515 | 1542 | ||
| 1516 | Here is what happens if you call @code{read-event} and then press the | 1543 | Here is what happens if you call @code{read-event} and then press the |
| 1517 | right-arrow function key: | 1544 | right-arrow function key: |
| @@ -1522,17 +1549,18 @@ right-arrow function key: | |||
| 1522 | @result{} right | 1549 | @result{} right |
| 1523 | @end group | 1550 | @end group |
| 1524 | @end example | 1551 | @end example |
| 1552 | @end defun | ||
| 1525 | 1553 | ||
| 1526 | @defun read-char | 1554 | @defun read-char |
| 1527 | This function reads and returns a character of command input. It | 1555 | This function reads and returns a character of command input. It |
| 1528 | discards any events that are not characters until it gets a character. | 1556 | discards any events that are not characters, until it gets a character. |
| 1529 | 1557 | ||
| 1530 | In the first example, the user types @kbd{1} (which is @sc{ASCII} code | 1558 | In the first example, the user types the character @kbd{1} (@sc{ASCII} |
| 1531 | 49). The second example shows a keyboard macro definition that calls | 1559 | code 49). The second example shows a keyboard macro definition that |
| 1532 | @code{read-char} from the minibuffer. @code{read-char} reads the | 1560 | calls @code{read-char} from the minibuffer using @code{eval-expression}. |
| 1533 | keyboard macro's very next character, which is @kbd{1}. The value of | 1561 | @code{read-char} reads the keyboard macro's very next character, which |
| 1534 | this function is displayed in the echo area by the command | 1562 | is @kbd{1}. Then @code{eval-expression} displays its return value in |
| 1535 | @code{eval-expression}. | 1563 | the echo area. |
| 1536 | 1564 | ||
| 1537 | @example | 1565 | @example |
| 1538 | @group | 1566 | @group |
| @@ -1545,7 +1573,7 @@ this function is displayed in the echo area by the command | |||
| 1545 | @result{} "^[^[(read-char)^M1" | 1573 | @result{} "^[^[(read-char)^M1" |
| 1546 | @end group | 1574 | @end group |
| 1547 | @group | 1575 | @group |
| 1548 | (execute-kbd-macro foo) | 1576 | (execute-kbd-macro 'foo) |
| 1549 | @print{} 49 | 1577 | @print{} 49 |
| 1550 | @result{} nil | 1578 | @result{} nil |
| 1551 | @end group | 1579 | @end group |
| @@ -1556,10 +1584,10 @@ this function is displayed in the echo area by the command | |||
| 1556 | @subsection Quoted Character Input | 1584 | @subsection Quoted Character Input |
| 1557 | @cindex quoted character input | 1585 | @cindex quoted character input |
| 1558 | 1586 | ||
| 1559 | You can use the function @code{read-quoted-char} when you want the user | 1587 | You can use the function @code{read-quoted-char} when to ask the user |
| 1560 | to specify a character, and allow the user to specify a control or meta | 1588 | to specify a character, and allow the user to specify a control or meta |
| 1561 | character conveniently with quoting or as an octal character code. The | 1589 | character conveniently with quoting or as an octal character code. The |
| 1562 | command @code{quoted-insert} calls this function. | 1590 | command @code{quoted-insert} uses this function. |
| 1563 | 1591 | ||
| 1564 | @defun read-quoted-char &optional prompt | 1592 | @defun read-quoted-char &optional prompt |
| 1565 | @cindex octal character input | 1593 | @cindex octal character input |
| @@ -1568,13 +1596,13 @@ command @code{quoted-insert} calls this function. | |||
| 1568 | This function is like @code{read-char}, except that if the first | 1596 | This function is like @code{read-char}, except that if the first |
| 1569 | character read is an octal digit (0-7), it reads up to two more octal digits | 1597 | character read is an octal digit (0-7), it reads up to two more octal digits |
| 1570 | (but stopping if a non-octal digit is found) and returns the | 1598 | (but stopping if a non-octal digit is found) and returns the |
| 1571 | character represented by those digits as an octal number. | 1599 | character represented by those digits in octal. |
| 1572 | 1600 | ||
| 1573 | Quitting is suppressed when the first character is read, so that the | 1601 | Quitting is suppressed when the first character is read, so that the |
| 1574 | user can enter a @kbd{C-g}. @xref{Quitting}. | 1602 | user can enter a @kbd{C-g}. @xref{Quitting}. |
| 1575 | 1603 | ||
| 1576 | If @var{prompt} is supplied, it specifies a string for prompting the | 1604 | If @var{prompt} is supplied, it specifies a string for prompting the |
| 1577 | user. The prompt string is always printed in the echo area and followed | 1605 | user. The prompt string is always displayed in the echo area, followed |
| 1578 | by a single @samp{-}. | 1606 | by a single @samp{-}. |
| 1579 | 1607 | ||
| 1580 | In the following example, the user types in the octal number 177 (which | 1608 | In the following example, the user types in the octal number 177 (which |
| @@ -1595,74 +1623,76 @@ What character-@kbd{177} | |||
| 1595 | 1623 | ||
| 1596 | @need 3000 | 1624 | @need 3000 |
| 1597 | 1625 | ||
| 1598 | @node Peeking and Discarding | 1626 | @node Event Input Misc |
| 1599 | @subsection Peeking and Discarding | 1627 | @subsection Miscellaneous Event Input Features |
| 1628 | |||
| 1629 | This section describes how to ``peek ahead'' at events without using | ||
| 1630 | them up, how to check for pending input, and how to discard pending | ||
| 1631 | input. | ||
| 1600 | 1632 | ||
| 1601 | @defvar unread-command-events | 1633 | @defvar unread-command-events |
| 1602 | @cindex next input | 1634 | @cindex next input |
| 1603 | @cindex peeking at input | 1635 | @cindex peeking at input |
| 1604 | This variable holds a list of events waiting to be read as command | 1636 | This variable holds a list of events waiting to be read as command |
| 1605 | input. The events are used in the order they appear in the list. | 1637 | input. The events are used in the order they appear in the list, and |
| 1638 | removed one by one as they are used. | ||
| 1606 | 1639 | ||
| 1607 | The variable is used because in some cases a function reads a event and | 1640 | The variable is needed because in some cases a function reads a event |
| 1608 | then decides not to use it. Storing the event in this variable causes | 1641 | and then decides not to use it. Storing the event in this variable |
| 1609 | it to be processed normally by the command loop or when the functions to | 1642 | causes it to be processed normally, by the command loop or by the |
| 1610 | read command input are called. | 1643 | functions to read command input. |
| 1611 | 1644 | ||
| 1612 | @cindex prefix argument unreading | 1645 | @cindex prefix argument unreading |
| 1613 | For example, the function that implements numeric prefix arguments reads | 1646 | For example, the function that implements numeric prefix arguments reads |
| 1614 | any number of digits. When it finds a non-digit event, it must unread | 1647 | any number of digits. When it finds a non-digit event, it must unread |
| 1615 | the event so that it can be read normally by the command loop. | 1648 | the event so that it can be read normally by the command loop. |
| 1616 | Likewise, incremental search uses this feature to unread events it does | 1649 | Likewise, incremental search uses this feature to unread events with no |
| 1617 | not recognize. | 1650 | special meaning in a search, because these events should exit the search |
| 1651 | and then execute normally. | ||
| 1652 | |||
| 1653 | The reliable and easy way to extract events from a key sequence to put | ||
| 1654 | them in @code{unread-command-events} is to use | ||
| 1655 | @code{listify-key-sequence} (@pxref{Strings of Events}). | ||
| 1618 | @end defvar | 1656 | @end defvar |
| 1619 | 1657 | ||
| 1620 | @defvar unread-command-char | 1658 | @defvar unread-command-char |
| 1621 | This variable holds a character to be read as command input. | 1659 | This variable holds a character to be read as command input. |
| 1622 | A value of -1 means ``empty''. | 1660 | A value of -1 means ``empty''. |
| 1623 | 1661 | ||
| 1624 | This variable is pretty much obsolete now that you can use | 1662 | This variable is mostly obsolete now that you can use |
| 1625 | @code{unread-command-events} instead; it exists only to support programs | 1663 | @code{unread-command-events} instead; it exists only to support programs |
| 1626 | written for Emacs versions 18 and earlier. | 1664 | written for Emacs versions 18 and earlier. |
| 1627 | @end defvar | 1665 | @end defvar |
| 1628 | 1666 | ||
| 1629 | @defun listify-key-sequence key | ||
| 1630 | This function converts the string or vector @var{key} to a list of | ||
| 1631 | events which you can put in @code{unread-command-events}. Converting a | ||
| 1632 | vector is simple, but converting a string is tricky because of the | ||
| 1633 | special representation used for meta characters in a string | ||
| 1634 | (@pxref{Strings of Events}). | ||
| 1635 | @end defun | ||
| 1636 | |||
| 1637 | @defun input-pending-p | 1667 | @defun input-pending-p |
| 1638 | @cindex waiting for command key input | 1668 | @cindex waiting for command key input |
| 1639 | This function determines whether any command input is currently | 1669 | This function determines whether any command input is currently |
| 1640 | available to be read. It returns immediately, with value @code{t} if | 1670 | available to be read. It returns immediately, with value @code{t} if |
| 1641 | there is input, @code{nil} otherwise. On rare occasions it may return | 1671 | there is available input, @code{nil} otherwise. On rare occasions it |
| 1642 | @code{t} when no input is available. | 1672 | may return @code{t} when no input is available. |
| 1643 | @end defun | 1673 | @end defun |
| 1644 | 1674 | ||
| 1645 | @defvar last-input-event | 1675 | @defvar last-input-event |
| 1646 | @defvarx last-input-char | 1676 | This variable records the last terminal input event read, whether |
| 1647 | This variable records the last terminal input event read, whether | ||
| 1648 | as part of a command or explicitly by a Lisp program. | 1677 | as part of a command or explicitly by a Lisp program. |
| 1649 | 1678 | ||
| 1650 | In the example below, a character is read (the character @kbd{1}, | 1679 | In the example below, the Lisp program reads the character @kbd{1}, |
| 1651 | @sc{ASCII} code 49). It becomes the value of @code{last-input-char}, | 1680 | @sc{ASCII} code 49. It becomes the value of @code{last-input-event}, |
| 1652 | while @kbd{C-e} (from the @kbd{C-x C-e} command used to evaluate this | 1681 | while @kbd{C-e} (from the @kbd{C-x C-e} command used to evaluate this |
| 1653 | expression) remains the value of @code{last-command-char}. | 1682 | expression) remains the value of @code{last-command-event}. |
| 1654 | 1683 | ||
| 1655 | @example | 1684 | @example |
| 1656 | @group | 1685 | @group |
| 1657 | (progn (print (read-char)) | 1686 | (progn (print (read-char)) |
| 1658 | (print last-command-char) | 1687 | (print last-command-event) |
| 1659 | last-input-char) | 1688 | last-input-event) |
| 1660 | @print{} 49 | 1689 | @print{} 49 |
| 1661 | @print{} 5 | 1690 | @print{} 5 |
| 1662 | @result{} 49 | 1691 | @result{} 49 |
| 1663 | @end group | 1692 | @end group |
| 1664 | @end example | 1693 | @end example |
| 1665 | 1694 | ||
| 1695 | @vindex last-input-char | ||
| 1666 | The alias @code{last-input-char} exists for compatibility with | 1696 | The alias @code{last-input-char} exists for compatibility with |
| 1667 | Emacs version 18. | 1697 | Emacs version 18. |
| 1668 | @end defvar | 1698 | @end defvar |
| @@ -1677,11 +1707,12 @@ It returns @code{nil}. | |||
| 1677 | 1707 | ||
| 1678 | In the following example, the user may type a number of characters right | 1708 | In the following example, the user may type a number of characters right |
| 1679 | after starting the evaluation of the form. After the @code{sleep-for} | 1709 | after starting the evaluation of the form. After the @code{sleep-for} |
| 1680 | finishes sleeping, any characters that have been typed are discarded. | 1710 | finishes sleeping, @code{discard-input} discards any characters typed |
| 1711 | during the sleep. | ||
| 1681 | 1712 | ||
| 1682 | @example | 1713 | @example |
| 1683 | (progn (sleep-for 2) | 1714 | (progn (sleep-for 2) |
| 1684 | (discard-input)) | 1715 | (discard-input)) |
| 1685 | @result{} nil | 1716 | @result{} nil |
| 1686 | @end example | 1717 | @end example |
| 1687 | @end defun | 1718 | @end defun |
| @@ -1691,19 +1722,19 @@ finishes sleeping, any characters that have been typed are discarded. | |||
| 1691 | @cindex pausing | 1722 | @cindex pausing |
| 1692 | @cindex waiting | 1723 | @cindex waiting |
| 1693 | 1724 | ||
| 1694 | The waiting commands are designed to make Emacs wait for a certain | 1725 | The wait functions are designed to wait for a certain amount of time |
| 1695 | amount of time to pass or until there is input. For example, you may | 1726 | to pass or until there is input. For example, you may wish to pause in |
| 1696 | wish to pause in the middle of a computation to allow the user time to | 1727 | the middle of a computation to allow the user time to view the display. |
| 1697 | view the display. @code{sit-for} pauses and updates the screen, and | 1728 | @code{sit-for} pauses and updates the screen, and returns immediately if |
| 1698 | returns immediately if input comes in, while @code{sleep-for} pauses | 1729 | input comes in, while @code{sleep-for} pauses without updating the |
| 1699 | without updating the screen. | 1730 | screen. |
| 1700 | 1731 | ||
| 1701 | @defun sit-for seconds &optional millisec nodisp | 1732 | @defun sit-for seconds &optional millisec nodisp |
| 1702 | This function performs redisplay (provided there is no pending input | 1733 | This function performs redisplay (provided there is no pending input |
| 1703 | from the user), then waits @var{seconds} seconds, or until input is | 1734 | from the user), then waits @var{seconds} seconds, or until input is |
| 1704 | available. The result is @code{t} if @code{sit-for} waited the full | 1735 | available. The value is @code{t} if @code{sit-for} waited the full |
| 1705 | time with no input arriving (see @code{input-pending-p} in @ref{Peeking | 1736 | time with no input arriving (see @code{input-pending-p} in @ref{Event |
| 1706 | and Discarding}). Otherwise, the value is @code{nil}. | 1737 | Input Misc}). Otherwise, the value is @code{nil}. |
| 1707 | 1738 | ||
| 1708 | @c Emacs 19 feature ??? maybe not working yet | 1739 | @c Emacs 19 feature ??? maybe not working yet |
| 1709 | The optional argument @var{millisec} specifies an additional waiting | 1740 | The optional argument @var{millisec} specifies an additional waiting |
| @@ -1769,14 +1800,14 @@ directly when the command reader is reading input is so that its meaning | |||
| 1769 | can be redefined in the minibuffer in this way. @kbd{C-g} following a | 1800 | can be redefined in the minibuffer in this way. @kbd{C-g} following a |
| 1770 | prefix key is not redefined in the minibuffer, and it has its normal | 1801 | prefix key is not redefined in the minibuffer, and it has its normal |
| 1771 | effect of canceling the prefix key and prefix argument. This too | 1802 | effect of canceling the prefix key and prefix argument. This too |
| 1772 | would not be possible if @kbd{C-g} quit directly. | 1803 | would not be possible if @kbd{C-g} always quit directly. |
| 1773 | 1804 | ||
| 1774 | @kbd{C-g} causes a quit by setting the variable @code{quit-flag} to a | 1805 | When @kbd{C-g} does directly quit, it does so by the variable |
| 1775 | non-@code{nil} value. Emacs checks this variable at appropriate times | 1806 | @code{quit-flag} to @code{t}. Emacs checks this variable at appropriate |
| 1776 | and quits if it is not @code{nil}. Setting @code{quit-flag} | 1807 | times and quits if it is not @code{nil}. Setting @code{quit-flag} |
| 1777 | non-@code{nil} in any way thus causes a quit. | 1808 | non-@code{nil} in any way thus causes a quit. |
| 1778 | 1809 | ||
| 1779 | At the level of C code, quits cannot happen just anywhere; only at the | 1810 | At the level of C code, quitting cannot happen just anywhere; only at the |
| 1780 | special places which check @code{quit-flag}. The reason for this is | 1811 | special places which check @code{quit-flag}. The reason for this is |
| 1781 | that quitting at other places might leave an inconsistency in Emacs's | 1812 | that quitting at other places might leave an inconsistency in Emacs's |
| 1782 | internal state. Because quitting is delayed until a safe place, quitting | 1813 | internal state. Because quitting is delayed until a safe place, quitting |
| @@ -1804,7 +1835,7 @@ the program. | |||
| 1804 | @cindex @code{read-quoted-char} quitting | 1835 | @cindex @code{read-quoted-char} quitting |
| 1805 | In some functions (such as @code{read-quoted-char}), @kbd{C-g} is | 1836 | In some functions (such as @code{read-quoted-char}), @kbd{C-g} is |
| 1806 | handled in a special way which does not involve quitting. This is done | 1837 | handled in a special way which does not involve quitting. This is done |
| 1807 | by reading the input with @code{inhibit-quit} bound to @code{t} and | 1838 | by reading the input with @code{inhibit-quit} bound to @code{t}, and |
| 1808 | setting @code{quit-flag} to @code{nil} before @code{inhibit-quit} | 1839 | setting @code{quit-flag} to @code{nil} before @code{inhibit-quit} |
| 1809 | becomes @code{nil} again. This excerpt from the definition of | 1840 | becomes @code{nil} again. This excerpt from the definition of |
| 1810 | @code{read-quoted-char} shows how this is done; it also shows that | 1841 | @code{read-quoted-char} shows how this is done; it also shows that |
| @@ -1825,8 +1856,8 @@ normal quitting is permitted after the first character of input. | |||
| 1825 | @end example | 1856 | @end example |
| 1826 | 1857 | ||
| 1827 | @defvar quit-flag | 1858 | @defvar quit-flag |
| 1828 | If this variable is non-@code{nil}, then Emacs quits immediately, | 1859 | If this variable is non-@code{nil}, then Emacs quits immediately, unless |
| 1829 | unless @code{inhibit-quit} is non-@code{nil}. Typing @kbd{C-g} sets | 1860 | @code{inhibit-quit} is non-@code{nil}. Typing @kbd{C-g} ordinarily sets |
| 1830 | @code{quit-flag} non-@code{nil}, regardless of @code{inhibit-quit}. | 1861 | @code{quit-flag} non-@code{nil}, regardless of @code{inhibit-quit}. |
| 1831 | @end defvar | 1862 | @end defvar |
| 1832 | 1863 | ||
| @@ -1887,8 +1918,8 @@ typed, without following digits. The equivalent numeric value is | |||
| 1887 | @minus{}1 and the symbol @code{-}. | 1918 | @minus{}1 and the symbol @code{-}. |
| 1888 | @end itemize | 1919 | @end itemize |
| 1889 | 1920 | ||
| 1890 | The various possibilities may be illustrated by calling the following | 1921 | We illustrate these possibilities by calling the following function with |
| 1891 | function with various prefixes: | 1922 | various prefixes: |
| 1892 | 1923 | ||
| 1893 | @example | 1924 | @example |
| 1894 | @group | 1925 | @group |
| @@ -1916,11 +1947,11 @@ M-3 M-x display-prefix @print{} 3 ; @r{(Same as @code{C-u 3}.)} | |||
| 1916 | 1947 | ||
| 1917 | C-u - M-x display-prefix @print{} - | 1948 | C-u - M-x display-prefix @print{} - |
| 1918 | 1949 | ||
| 1919 | M- - M-x display-prefix @print{} - ; @r{(Same as @code{C-u -}.)} | 1950 | M-- M-x display-prefix @print{} - ; @r{(Same as @code{C-u -}.)} |
| 1920 | 1951 | ||
| 1921 | C-u -7 M-x display-prefix @print{} -7 | 1952 | C-u - 7 M-x display-prefix @print{} -7 |
| 1922 | 1953 | ||
| 1923 | M- -7 M-x display-prefix @print{} -7 ; @r{(Same as @code{C-u -7}.)} | 1954 | M-- 7 M-x display-prefix @print{} -7 ; @r{(Same as @code{C-u -7}.)} |
| 1924 | @end example | 1955 | @end example |
| 1925 | 1956 | ||
| 1926 | Emacs uses two variables to store the prefix argument: | 1957 | Emacs uses two variables to store the prefix argument: |
| @@ -1937,6 +1968,27 @@ argument, either numeric or raw, in the @code{interactive} declaration. | |||
| 1937 | value of the prefix argument directly in the variable | 1968 | value of the prefix argument directly in the variable |
| 1938 | @code{current-prefix-arg}, but this is less clean. | 1969 | @code{current-prefix-arg}, but this is less clean. |
| 1939 | 1970 | ||
| 1971 | @defun prefix-numeric-value arg | ||
| 1972 | This function returns the numeric meaning of a valid raw prefix argument | ||
| 1973 | value, @var{arg}. The argument may be a symbol, a number, or a list. | ||
| 1974 | If it is @code{nil}, the value 1 is returned; if it is any other symbol, | ||
| 1975 | the value @minus{}1 is returned. If it is a number, that number is | ||
| 1976 | returned; if it is a list, the @sc{car} of that list (which should be a | ||
| 1977 | number) is returned. | ||
| 1978 | @end defun | ||
| 1979 | |||
| 1980 | @defvar current-prefix-arg | ||
| 1981 | This variable holds the raw prefix argument for the @emph{current} | ||
| 1982 | command. Commands may examine it directly, but the usual way to access | ||
| 1983 | it is with @code{(interactive "P")}. | ||
| 1984 | @end defvar | ||
| 1985 | |||
| 1986 | @defvar prefix-arg | ||
| 1987 | The value of this variable is the raw prefix argument for the | ||
| 1988 | @emph{next} editing command. Commands that specify prefix arguments for | ||
| 1989 | the following command work by setting this variable. | ||
| 1990 | @end defvar | ||
| 1991 | |||
| 1940 | Do not call the functions @code{universal-argument}, | 1992 | Do not call the functions @code{universal-argument}, |
| 1941 | @code{digit-argument}, or @code{negative-argument} unless you intend to | 1993 | @code{digit-argument}, or @code{negative-argument} unless you intend to |
| 1942 | let the user enter the prefix argument for the @emph{next} command. | 1994 | let the user enter the prefix argument for the @emph{next} command. |
| @@ -1961,47 +2013,26 @@ command; its value is negated to form the new prefix argument. Don't | |||
| 1961 | call this command yourself unless you know what you are doing. | 2013 | call this command yourself unless you know what you are doing. |
| 1962 | @end deffn | 2014 | @end deffn |
| 1963 | 2015 | ||
| 1964 | @defun prefix-numeric-value arg | ||
| 1965 | This function returns the numeric meaning of a valid raw prefix argument | ||
| 1966 | value, @var{arg}. The argument may be a symbol, a number, or a list. | ||
| 1967 | If it is @code{nil}, the value 1 is returned; if it is any other symbol, | ||
| 1968 | the value @minus{}1 is returned. If it is a number, that number is | ||
| 1969 | returned; if it is a list, the @sc{car} of that list (which should be a | ||
| 1970 | number) is returned. | ||
| 1971 | @end defun | ||
| 1972 | |||
| 1973 | @defvar current-prefix-arg | ||
| 1974 | This variable is the value of the raw prefix argument for the | ||
| 1975 | @emph{current} command. Commands may examine it directly, but the usual | ||
| 1976 | way to access it is with @code{(interactive "P")}. | ||
| 1977 | @end defvar | ||
| 1978 | |||
| 1979 | @defvar prefix-arg | ||
| 1980 | The value of this variable is the raw prefix argument for the | ||
| 1981 | @emph{next} editing command. Commands that specify prefix arguments for | ||
| 1982 | the following command work by setting this variable. | ||
| 1983 | @end defvar | ||
| 1984 | |||
| 1985 | @node Recursive Editing | 2016 | @node Recursive Editing |
| 1986 | @section Recursive Editing | 2017 | @section Recursive Editing |
| 1987 | @cindex recursive command loop | 2018 | @cindex recursive command loop |
| 1988 | @cindex recursive editing level | 2019 | @cindex recursive editing level |
| 1989 | @cindex command loop, recursive | 2020 | @cindex command loop, recursive |
| 1990 | 2021 | ||
| 1991 | The Emacs command loop is entered automatically when Emacs starts up. | 2022 | The Emacs command loop is entered automatically when Emacs starts up. |
| 1992 | This top-level invocation of the command loop is never exited until the | 2023 | This top-level invocation of the command loop never exits; it keeps |
| 1993 | Emacs is killed. Lisp programs can also invoke the command loop. Since | 2024 | running as long as Emacs does. Lisp programs can also invoke the |
| 1994 | this makes more than one activation of the command loop, we call it | 2025 | command loop. Since this makes more than one activation of the command |
| 1995 | @dfn{recursive editing}. A recursive editing level has the effect of | 2026 | loop, we call it @dfn{recursive editing}. A recursive editing level has |
| 1996 | suspending whatever command invoked it and permitting the user to do | 2027 | the effect of suspending whatever command invoked it and permitting the |
| 1997 | arbitrary editing before resuming that command. | 2028 | user to do arbitrary editing before resuming that command. |
| 1998 | 2029 | ||
| 1999 | The commands available during recursive editing are the same ones | 2030 | The commands available during recursive editing are the same ones |
| 2000 | available in the top-level editing loop and defined in the keymaps. | 2031 | available in the top-level editing loop and defined in the keymaps. |
| 2001 | Only a few special commands exit the recursive editing level; the others | 2032 | Only a few special commands exit the recursive editing level; the others |
| 2002 | return to the recursive editing level when finished. (The special | 2033 | return to the recursive editing level when they finish. (The special |
| 2003 | commands for exiting are always available, but do nothing when recursive | 2034 | commands for exiting are always available, but they do nothing when |
| 2004 | editing is not in progress.) | 2035 | recursive editing is not in progress.) |
| 2005 | 2036 | ||
| 2006 | All command loops, including recursive ones, set up all-purpose error | 2037 | All command loops, including recursive ones, set up all-purpose error |
| 2007 | handlers so that an error in a command run from the command loop will | 2038 | handlers so that an error in a command run from the command loop will |
| @@ -2033,12 +2064,12 @@ control returns to the command loop one level up. This is called | |||
| 2033 | Most applications should not use recursive editing, except as part of | 2064 | Most applications should not use recursive editing, except as part of |
| 2034 | using the minibuffer. Usually it is more convenient for the user if you | 2065 | using the minibuffer. Usually it is more convenient for the user if you |
| 2035 | change the major mode of the current buffer temporarily to a special | 2066 | change the major mode of the current buffer temporarily to a special |
| 2036 | major mode, which has a command to go back to the previous mode. (This | 2067 | major mode, which has a command to go back to the previous mode. (The |
| 2037 | technique is used by the @kbd{w} command in Rmail.) Or, if you wish to | 2068 | @kbd{e} command in Rmail uses this technique.) Or, if you wish to give |
| 2038 | give the user different text to edit ``recursively'', create and select | 2069 | the user different text to edit ``recursively'', create and select a new |
| 2039 | a new buffer in a special mode. In this mode, define a command to | 2070 | buffer in a special mode. In this mode, define a command to complete |
| 2040 | complete the processing and go back to the previous buffer. (The | 2071 | the processing and go back to the previous buffer. (The @kbd{m} command |
| 2041 | @kbd{m} command in Rmail does this.) | 2072 | in Rmail does this.) |
| 2042 | 2073 | ||
| 2043 | Recursive edits are useful in debugging. You can insert a call to | 2074 | Recursive edits are useful in debugging. You can insert a call to |
| 2044 | @code{debug} into a function definition as a sort of breakpoint, so that | 2075 | @code{debug} into a function definition as a sort of breakpoint, so that |
| @@ -2063,7 +2094,7 @@ then type @kbd{C-M-c} to exit and continue executing @code{simple-rec}. | |||
| 2063 | @example | 2094 | @example |
| 2064 | (defun simple-rec () | 2095 | (defun simple-rec () |
| 2065 | (forward-word 1) | 2096 | (forward-word 1) |
| 2066 | (message "Recursive edit in progress.") | 2097 | (message "Recursive edit in progress") |
| 2067 | (recursive-edit) | 2098 | (recursive-edit) |
| 2068 | (forward-word 1)) | 2099 | (forward-word 1)) |
| 2069 | @result{} simple-rec | 2100 | @result{} simple-rec |
| @@ -2119,8 +2150,8 @@ command. These properties are normally set up by the user's | |||
| 2119 | For a few commands, these properties are present by default and may be | 2150 | For a few commands, these properties are present by default and may be |
| 2120 | removed by the @file{.emacs} file. | 2151 | removed by the @file{.emacs} file. |
| 2121 | 2152 | ||
| 2122 | If the value of the @code{disabled} property is a string, that string | 2153 | If the value of the @code{disabled} property is a string, the message |
| 2123 | is included in the message printed when the command is used: | 2154 | saying the command is disabled includes that string. For example: |
| 2124 | 2155 | ||
| 2125 | @example | 2156 | @example |
| 2126 | (put 'delete-region 'disabled | 2157 | (put 'delete-region 'disabled |
| @@ -2134,21 +2165,21 @@ programs. | |||
| 2134 | 2165 | ||
| 2135 | @deffn Command enable-command command | 2166 | @deffn Command enable-command command |
| 2136 | Allow @var{command} to be executed without special confirmation from now | 2167 | Allow @var{command} to be executed without special confirmation from now |
| 2137 | on. The user's @file{.emacs} file is optionally altered so that this | 2168 | on, and optionally alter the user's @file{.emacs} file so that this will |
| 2138 | will apply to future sessions. | 2169 | apply to future sessions. |
| 2139 | @end deffn | 2170 | @end deffn |
| 2140 | 2171 | ||
| 2141 | @deffn Command disable-command command | 2172 | @deffn Command disable-command command |
| 2142 | Require special confirmation to execute @var{command} from now on. The | 2173 | Require special confirmation to execute @var{command} from now on, and |
| 2143 | user's @file{.emacs} file is optionally altered so that this will apply | 2174 | optionally alter the user's @file{.emacs} file so that this will apply |
| 2144 | to future sessions. | 2175 | to future sessions. |
| 2145 | @end deffn | 2176 | @end deffn |
| 2146 | 2177 | ||
| 2147 | @defvar disabled-command-hook | 2178 | @defvar disabled-command-hook |
| 2148 | This variable is a normal hook that is run instead of a disabled command, | 2179 | This normal hook is run instead of a disabled command, when the user |
| 2149 | when the user runs the disabled command interactively. The hook functions | 2180 | invokes the disabled command interactively. The hook functions can use |
| 2150 | can use @code{this-command-keys} to determine what the user typed to run | 2181 | @code{this-command-keys} to determine what the user typed to run the |
| 2151 | the command, and thus find the command itself. | 2182 | command, and thus find the command itself. |
| 2152 | 2183 | ||
| 2153 | By default, @code{disabled-command-hook} contains a function that asks | 2184 | By default, @code{disabled-command-hook} contains a function that asks |
| 2154 | the user whether to proceed. | 2185 | the user whether to proceed. |
| @@ -2203,8 +2234,10 @@ minibuffer. | |||
| 2203 | @cindex keyboard macros | 2234 | @cindex keyboard macros |
| 2204 | 2235 | ||
| 2205 | A @dfn{keyboard macro} is a canned sequence of input events that can | 2236 | A @dfn{keyboard macro} is a canned sequence of input events that can |
| 2206 | be considered a command and made the definition of a key. Don't confuse | 2237 | be considered a command and made the definition of a key. The Lisp |
| 2207 | keyboard macros with Lisp macros (@pxref{Macros}). | 2238 | representation of a keyboard macro is a string or vector containing the |
| 2239 | events. Don't confuse keyboard macros with Lisp macros | ||
| 2240 | (@pxref{Macros}). | ||
| 2208 | 2241 | ||
| 2209 | @defun execute-kbd-macro macro &optional count | 2242 | @defun execute-kbd-macro macro &optional count |
| 2210 | This function executes @var{macro} as a sequence of events. If | 2243 | This function executes @var{macro} as a sequence of events. If |
| @@ -2232,26 +2265,15 @@ macro. Its value is a string or vector, or @code{nil}. | |||
| 2232 | @defvar executing-macro | 2265 | @defvar executing-macro |
| 2233 | This variable contains the string or vector that defines the keyboard | 2266 | This variable contains the string or vector that defines the keyboard |
| 2234 | macro that is currently executing. It is @code{nil} if no macro is | 2267 | macro that is currently executing. It is @code{nil} if no macro is |
| 2235 | currently executing. | 2268 | currently executing. A command can test this variable to behave |
| 2269 | differently when run from an executing macro. Do not set this variable | ||
| 2270 | yourself. | ||
| 2236 | @end defvar | 2271 | @end defvar |
| 2237 | 2272 | ||
| 2238 | @defvar defining-kbd-macro | 2273 | @defvar defining-kbd-macro |
| 2239 | This variable indicates whether a keyboard macro is being defined. It | 2274 | This variable indicates whether a keyboard macro is being defined. A |
| 2240 | is set to @code{t} by @code{start-kbd-macro}, and @code{nil} by | 2275 | command can test this variable to behave differently while a macro is |
| 2241 | @code{end-kbd-macro}. You can use this variable to make a command | 2276 | being defined. The commands @code{start-kbd-macro} and |
| 2242 | behave differently when run from a keyboard macro (perhaps indirectly by | 2277 | @code{end-kbd-macro} set this variable---do not set it yourself. |
| 2243 | calling @code{interactive-p}). However, do not set this variable | ||
| 2244 | yourself. | ||
| 2245 | @end defvar | 2278 | @end defvar |
| 2246 | 2279 | ||
| 2247 | @ignore @c It's hard to make this format ok. | ||
| 2248 | The user-level commands for defining, running and editing keyboard | ||
| 2249 | macros include @code{call-last-kbd-macro}, @code{insert-kbd-macro}, | ||
| 2250 | @code{start-kbd-macro}, @code{end-kbd-macro}, @code{kbd-macro-query}, | ||
| 2251 | and @code{name-last-kbd-macro}. | ||
| 2252 | @end ignore | ||
| 2253 | |||
| 2254 | @c Broke paragraph to prevent overfull hbox. --rjc 15mar92 | ||
| 2255 | The commands are described in the user's manual (@pxref{Keyboard | ||
| 2256 | Macros,,, emacs, The GNU Emacs Manual}). | ||
| 2257 | |||