Mercurial > emacs
comparison lispref/commands.texi @ 89910:548375b6b1f8
Update unicode branch
author | Miles Bader <miles@gnu.org> |
---|---|
date | Mon, 19 Apr 2004 07:01:43 +0000 |
parents | 375f2633d815 |
children | 59dcbfe97385 |
comparison
equal
deleted
inserted
replaced
89909:68c22ea6027c | 89910:548375b6b1f8 |
---|---|
237 @defun interactive-form function | 237 @defun interactive-form function |
238 This function returns the @code{interactive} form of @var{function}. If | 238 This function returns the @code{interactive} form of @var{function}. If |
239 @var{function} is a command (@pxref{Interactive Call}), the value is a | 239 @var{function} is a command (@pxref{Interactive Call}), the value is a |
240 list of the form @code{(interactive @var{spec})}, where @var{spec} is | 240 list of the form @code{(interactive @var{spec})}, where @var{spec} is |
241 the descriptor specification used by the command's @code{interactive} | 241 the descriptor specification used by the command's @code{interactive} |
242 form to compute the function's arguments (@pxref{Using Interactive}). | 242 form to compute the function's arguments. If @var{function} is not a |
243 If @var{function} is not a command, @code{interactive-form} returns | 243 command, @code{interactive-form} returns @code{nil}. |
244 @code{nil}. | |
245 @end defun | 244 @end defun |
246 | 245 |
247 @node Interactive Codes | 246 @node Interactive Codes |
248 @comment node-name, next, previous, up | 247 @comment node-name, next, previous, up |
249 @subsection Code Characters for @code{interactive} | 248 @subsection Code Characters for @code{interactive} |
326 @cindex position argument | 325 @cindex position argument |
327 The position of point, as an integer (@pxref{Point}). No I/O. | 326 The position of point, as an integer (@pxref{Point}). No I/O. |
328 | 327 |
329 @item D | 328 @item D |
330 A directory name. The default is the current default directory of the | 329 A directory name. The default is the current default directory of the |
331 current buffer, @code{default-directory} (@pxref{System Environment}). | 330 current buffer, @code{default-directory} (@pxref{File Name Expansion}). |
332 Existing, Completion, Default, Prompt. | 331 Existing, Completion, Default, Prompt. |
333 | 332 |
334 @item e | 333 @item e |
335 The first or next mouse event in the key sequence that invoked the command. | 334 The first or next mouse event in the key sequence that invoked the command. |
336 More precisely, @samp{e} gets events that are lists, so you can look at | 335 More precisely, @samp{e} gets events that are lists, so you can look at |
338 | 337 |
339 You can use @samp{e} more than once in a single command's interactive | 338 You can use @samp{e} more than once in a single command's interactive |
340 specification. If the key sequence that invoked the command has | 339 specification. If the key sequence that invoked the command has |
341 @var{n} events that are lists, the @var{n}th @samp{e} provides the | 340 @var{n} events that are lists, the @var{n}th @samp{e} provides the |
342 @var{n}th such event. Events that are not lists, such as function keys | 341 @var{n}th such event. Events that are not lists, such as function keys |
343 and @sc{ascii} characters, do not count where @samp{e} is concerned. | 342 and @acronym{ASCII} characters, do not count where @samp{e} is concerned. |
344 | 343 |
345 @item f | 344 @item f |
346 A file name of an existing file (@pxref{File Names}). The default | 345 A file name of an existing file (@pxref{File Names}). The default |
347 directory is @code{default-directory}. Existing, Completion, Default, | 346 directory is @code{default-directory}. Existing, Completion, Default, |
348 Prompt. | 347 Prompt. |
501 invokes that command using the function @code{command-execute}. If the | 500 invokes that command using the function @code{command-execute}. If the |
502 command is a function, @code{command-execute} calls | 501 command is a function, @code{command-execute} calls |
503 @code{call-interactively}, which reads the arguments and calls the | 502 @code{call-interactively}, which reads the arguments and calls the |
504 command. You can also call these functions yourself. | 503 command. You can also call these functions yourself. |
505 | 504 |
506 @defun commandp object | 505 @defun commandp object &optional for-call-interactively |
507 Returns @code{t} if @var{object} is suitable for calling interactively; | 506 Returns @code{t} if @var{object} is suitable for calling interactively; |
508 that is, if @var{object} is a command. Otherwise, returns @code{nil}. | 507 that is, if @var{object} is a command. Otherwise, returns @code{nil}. |
509 | 508 |
510 The interactively callable objects include strings and vectors (treated | 509 The interactively callable objects include strings and vectors (treated |
511 as keyboard macros), lambda expressions that contain a top-level call to | 510 as keyboard macros), lambda expressions that contain a top-level call to |
512 @code{interactive}, byte-code function objects made from such lambda | 511 @code{interactive}, byte-code function objects made from such lambda |
513 expressions, autoload objects that are declared as interactive | 512 expressions, autoload objects that are declared as interactive |
514 (non-@code{nil} fourth argument to @code{autoload}), and some of the | 513 (non-@code{nil} fourth argument to @code{autoload}), and some of the |
515 primitive functions. | 514 primitive functions. |
516 | 515 |
517 A symbol satisfies @code{commandp} if its function definition satisfies | 516 A symbol satisfies @code{commandp} if its function definition |
518 @code{commandp}. | 517 satisfies @code{commandp}. Keys and keymaps are not commands. |
519 | 518 Rather, they are used to look up commands (@pxref{Keymaps}). |
520 Keys and keymaps are not commands. Rather, they are used to look up | 519 |
521 commands (@pxref{Keymaps}). | 520 If @var{for-call-interactively} is non-@code{nil}, then |
521 @code{commandp} returns @code{t} only for objects that | |
522 @code{call-interactively} could call---thus, not for keyboard macros. | |
522 | 523 |
523 See @code{documentation} in @ref{Accessing Documentation}, for a | 524 See @code{documentation} in @ref{Accessing Documentation}, for a |
524 realistic example of using @code{commandp}. | 525 realistic example of using @code{commandp}. |
525 @end defun | 526 @end defun |
526 | 527 |
659 (interactive "p") | 660 (interactive "p") |
660 (when print-message | 661 (when print-message |
661 (message "foo"))) | 662 (message "foo"))) |
662 @end example | 663 @end example |
663 | 664 |
665 @noindent | |
666 Defined in this way, the function does display the message when | |
667 called from a keyboard macro. | |
668 | |
664 The numeric prefix argument, provided by @samp{p}, is never @code{nil}. | 669 The numeric prefix argument, provided by @samp{p}, is never @code{nil}. |
665 | 670 |
666 @node Command Loop Info | 671 @node Command Loop Info |
667 @comment node-name, next, previous, up | 672 @comment node-name, next, previous, up |
668 @section Information from the Command Loop | 673 @section Information from the Command Loop |
724 | 729 |
725 @noindent | 730 @noindent |
726 We do not bind @code{this-command} with @code{let} because that would | 731 We do not bind @code{this-command} with @code{let} because that would |
727 restore the old value in case of error---a feature of @code{let} which | 732 restore the old value in case of error---a feature of @code{let} which |
728 in this case does precisely what we want to avoid. | 733 in this case does precisely what we want to avoid. |
734 | |
735 @defvar this-original-command | |
736 This has the same value as @code{this-command} except when command | |
737 remapping occurs (@pxref{Remapping Commands}). In that case, | |
738 @code{this-command} gives the command actually run (the result of | |
739 remapping), and @code{this-original-command} gives the command that | |
740 was specified to run but remapped into another command. | |
741 @end defvar | |
729 | 742 |
730 @defun this-command-keys | 743 @defun this-command-keys |
731 This function returns a string or vector containing the key sequence | 744 This function returns a string or vector containing the key sequence |
732 that invoked the present command, plus any previous commands that | 745 that invoked the present command, plus any previous commands that |
733 generated the prefix argument for this command. The value is a string | 746 generated the prefix argument for this command. The value is a string |
781 @result{} 5 | 794 @result{} 5 |
782 @end group | 795 @end group |
783 @end example | 796 @end example |
784 | 797 |
785 @noindent | 798 @noindent |
786 The value is 5 because that is the @sc{ascii} code for @kbd{C-e}. | 799 The value is 5 because that is the @acronym{ASCII} code for @kbd{C-e}. |
787 | 800 |
788 The alias @code{last-command-char} exists for compatibility with | 801 The alias @code{last-command-char} exists for compatibility with |
789 Emacs version 18. | 802 Emacs version 18. |
790 @end defvar | 803 @end defvar |
791 | 804 |
900 @math{2^{26}} | 913 @math{2^{26}} |
901 @end tex | 914 @end tex |
902 @ifnottex | 915 @ifnottex |
903 2**26 | 916 2**26 |
904 @end ifnottex | 917 @end ifnottex |
905 bit in the character code indicates a non-@sc{ascii} | 918 bit in the character code indicates a non-@acronym{ASCII} |
906 control character. | 919 control character. |
907 | 920 |
908 @sc{ascii} control characters such as @kbd{C-a} have special basic | 921 @sc{ascii} control characters such as @kbd{C-a} have special basic |
909 codes of their own, so Emacs needs no special bit to indicate them. | 922 codes of their own, so Emacs needs no special bit to indicate them. |
910 Thus, the code for @kbd{C-a} is just 1. | 923 Thus, the code for @kbd{C-a} is just 1. |
911 | 924 |
912 But if you type a control combination not in @sc{ascii}, such as | 925 But if you type a control combination not in @acronym{ASCII}, such as |
913 @kbd{%} with the control key, the numeric value you get is the code | 926 @kbd{%} with the control key, the numeric value you get is the code |
914 for @kbd{%} plus | 927 for @kbd{%} plus |
915 @tex | 928 @tex |
916 @math{2^{26}} | 929 @math{2^{26}} |
917 @end tex | 930 @end tex |
918 @ifnottex | 931 @ifnottex |
919 2**26 | 932 2**26 |
920 @end ifnottex | 933 @end ifnottex |
921 (assuming the terminal supports non-@sc{ascii} | 934 (assuming the terminal supports non-@acronym{ASCII} |
922 control characters). | 935 control characters). |
923 | 936 |
924 @item shift | 937 @item shift |
925 The | 938 The |
926 @tex | 939 @tex |
927 @math{2^{25}} | 940 @math{2^{25}} |
928 @end tex | 941 @end tex |
929 @ifnottex | 942 @ifnottex |
930 2**25 | 943 2**25 |
931 @end ifnottex | 944 @end ifnottex |
932 bit in the character code indicates an @sc{ascii} control | 945 bit in the character code indicates an @acronym{ASCII} control |
933 character typed with the shift key held down. | 946 character typed with the shift key held down. |
934 | 947 |
935 For letters, the basic code itself indicates upper versus lower case; | 948 For letters, the basic code itself indicates upper versus lower case; |
936 for digits and punctuation, the shift key selects an entirely different | 949 for digits and punctuation, the shift key selects an entirely different |
937 character with a different basic code. In order to keep within the | 950 character with a different basic code. In order to keep within the |
938 @sc{ascii} character set whenever possible, Emacs avoids using the | 951 @acronym{ASCII} character set whenever possible, Emacs avoids using the |
939 @tex | 952 @tex |
940 @math{2^{25}} | 953 @math{2^{25}} |
941 @end tex | 954 @end tex |
942 @ifnottex | 955 @ifnottex |
943 2**25 | 956 2**25 |
944 @end ifnottex | 957 @end ifnottex |
945 bit for those characters. | 958 bit for those characters. |
946 | 959 |
947 However, @sc{ascii} provides no way to distinguish @kbd{C-A} from | 960 However, @acronym{ASCII} provides no way to distinguish @kbd{C-A} from |
948 @kbd{C-a}, so Emacs uses the | 961 @kbd{C-a}, so Emacs uses the |
949 @tex | 962 @tex |
950 @math{2^{25}} | 963 @math{2^{25}} |
951 @end tex | 964 @end tex |
952 @ifnottex | 965 @ifnottex |
1016 Here are a few special cases in the symbol-naming convention for | 1029 Here are a few special cases in the symbol-naming convention for |
1017 function keys: | 1030 function keys: |
1018 | 1031 |
1019 @table @asis | 1032 @table @asis |
1020 @item @code{backspace}, @code{tab}, @code{newline}, @code{return}, @code{delete} | 1033 @item @code{backspace}, @code{tab}, @code{newline}, @code{return}, @code{delete} |
1021 These keys correspond to common @sc{ascii} control characters that have | 1034 These keys correspond to common @acronym{ASCII} control characters that have |
1022 special keys on most keyboards. | 1035 special keys on most keyboards. |
1023 | 1036 |
1024 In @sc{ascii}, @kbd{C-i} and @key{TAB} are the same character. If the | 1037 In @acronym{ASCII}, @kbd{C-i} and @key{TAB} are the same character. If the |
1025 terminal can distinguish between them, Emacs conveys the distinction to | 1038 terminal can distinguish between them, Emacs conveys the distinction to |
1026 Lisp programs by representing the former as the integer 9, and the | 1039 Lisp programs by representing the former as the integer 9, and the |
1027 latter as the symbol @code{tab}. | 1040 latter as the symbol @code{tab}. |
1028 | 1041 |
1029 Most of the time, it's not useful to distinguish the two. So normally | 1042 Most of the time, it's not useful to distinguish the two. So normally |
1031 @code{tab} into 9. Thus, a key binding for character code 9 (the | 1044 @code{tab} into 9. Thus, a key binding for character code 9 (the |
1032 character @kbd{C-i}) also applies to @code{tab}. Likewise for the other | 1045 character @kbd{C-i}) also applies to @code{tab}. Likewise for the other |
1033 symbols in this group. The function @code{read-char} likewise converts | 1046 symbols in this group. The function @code{read-char} likewise converts |
1034 these events into characters. | 1047 these events into characters. |
1035 | 1048 |
1036 In @sc{ascii}, @key{BS} is really @kbd{C-h}. But @code{backspace} | 1049 In @acronym{ASCII}, @key{BS} is really @kbd{C-h}. But @code{backspace} |
1037 converts into the character code 127 (@key{DEL}), not into code 8 | 1050 converts into the character code 127 (@key{DEL}), not into code 8 |
1038 (@key{BS}). This is what most users prefer. | 1051 (@key{BS}). This is what most users prefer. |
1039 | 1052 |
1040 @item @code{left}, @code{up}, @code{right}, @code{down} | 1053 @item @code{left}, @code{up}, @code{right}, @code{down} |
1041 Cursor arrow keys | 1054 Cursor arrow keys |
1103 @subsection Click Events | 1116 @subsection Click Events |
1104 @cindex click event | 1117 @cindex click event |
1105 @cindex mouse click event | 1118 @cindex mouse click event |
1106 | 1119 |
1107 When the user presses a mouse button and releases it at the same | 1120 When the user presses a mouse button and releases it at the same |
1108 location, that generates a @dfn{click} event. Mouse click events have | 1121 location, that generates a @dfn{click} event. All mouse click event |
1109 this form: | 1122 share the same format: |
1110 | 1123 |
1111 @example | 1124 @example |
1112 (@var{event-type} | 1125 (@var{event-type} @var{position} @var{click-count}) |
1113 (@var{window} @var{buffer-pos} (@var{x} . @var{y}) | 1126 @end example |
1114 @var{timestamp}) | |
1115 @var{click-count}) | |
1116 @end example | |
1117 | |
1118 or, for clicks on strings in the mode line, header line or marginal | |
1119 areas: | |
1120 | |
1121 @example | |
1122 (@var{event-type} | |
1123 (@var{window} @var{buffer-pos} (@var{x} . @var{y}) @var{timestamp} (@var{string} . @var{string-pos}) | |
1124 @var{click-count}) | |
1125 @end example | |
1126 | |
1127 Here is what the elements normally mean: | |
1128 | 1127 |
1129 @table @asis | 1128 @table @asis |
1130 @item @var{event-type} | 1129 @item @var{event-type} |
1131 This is a symbol that indicates which mouse button was used. It is | 1130 This is a symbol that indicates which mouse button was used. It is |
1132 one of the symbols @code{mouse-1}, @code{mouse-2}, @dots{}, where the | 1131 one of the symbols @code{mouse-1}, @code{mouse-2}, @dots{}, where the |
1139 This symbol also serves as the event type of the event. Key bindings | 1138 This symbol also serves as the event type of the event. Key bindings |
1140 describe events by their types; thus, if there is a key binding for | 1139 describe events by their types; thus, if there is a key binding for |
1141 @code{mouse-1}, that binding would apply to all events whose | 1140 @code{mouse-1}, that binding would apply to all events whose |
1142 @var{event-type} is @code{mouse-1}. | 1141 @var{event-type} is @code{mouse-1}. |
1143 | 1142 |
1144 @item @var{window} | 1143 @item @var{position} |
1145 This is the window in which the click occurred. | 1144 This is the position where the mouse click occurred. The actual |
1146 | 1145 format of @var{position} depends on what part of a window was clicked |
1147 @item @var{x}, @var{y} | 1146 on. The various formats are described below. |
1148 These are the pixel-denominated coordinates of the click, relative to | |
1149 the top left corner of @var{window}, which is @code{(0 . 0)}. | |
1150 | |
1151 @item @var{buffer-pos} | |
1152 This is the buffer position of the character clicked on. | |
1153 | |
1154 @item @var{timestamp} | |
1155 This is the time at which the event occurred, in milliseconds. (Since | |
1156 this value wraps around the entire range of Emacs Lisp integers in about | |
1157 five hours, it is useful only for relating the times of nearby | |
1158 events.) | |
1159 | |
1160 @item @var{string} | |
1161 This is the string on which the click occurred, including any | |
1162 properties. | |
1163 | |
1164 @item @var{string-pos} | |
1165 This is the position in the string on which the click occurred, | |
1166 relevant if properties at the click need to be looked up. | |
1167 | 1147 |
1168 @item @var{click-count} | 1148 @item @var{click-count} |
1169 This is the number of rapid repeated presses so far of the same mouse | 1149 This is the number of rapid repeated presses so far of the same mouse |
1170 button. @xref{Repeat Events}. | 1150 button. @xref{Repeat Events}. |
1171 @end table | 1151 @end table |
1172 | 1152 |
1173 The meanings of @var{buffer-pos}, @var{x} and @var{y} are somewhat | 1153 For mouse click events in the text area, mode line, header line, or in |
1174 different when the event location is in a special part of the screen, | 1154 the marginal areas, @var{position} has this form: |
1175 such as the mode line or a scroll bar. | 1155 |
1176 | 1156 @example |
1177 If the location is in a scroll bar, then @var{buffer-pos} is the symbol | 1157 (@var{window} @var{pos-or-area} (@var{x} . @var{y}) @var{timestamp} |
1178 @code{vertical-scroll-bar} or @code{horizontal-scroll-bar}, and the pair | 1158 @var{object} @var{text-pos} (@var{col} . @var{row}) |
1179 @code{(@var{x} . @var{y})} is replaced with a pair @code{(@var{portion} | 1159 @var{image} (@var{dx} . @var{dy}) (@var{width} . @var{height})) |
1180 . @var{whole})}, where @var{portion} is the distance of the click from | 1160 @end example |
1181 the top or left end of the scroll bar, and @var{whole} is the length of | 1161 |
1182 the entire scroll bar. | 1162 @table @asis |
1183 | 1163 @item @var{window} |
1184 If the position is on a mode line, the vertical line separating | 1164 This is the window in which the click occurred. |
1185 @var{window} from its neighbor to the right, or in a marginal area, | 1165 |
1186 then @var{buffer-pos} is the symbol @code{mode-line}, | 1166 @item @var{pos-or-area} |
1187 @code{header-line}, @code{vertical-line}, @code{left-margin}, or | 1167 This is the buffer position of the character clicked on in the text |
1188 @code{right-margin}. For the mode line, @var{y} does not have | 1168 area, or if clicked outside the text area, it is the window area in |
1189 meaningful data. For the vertical line, @var{x} does not have | 1169 which the click occurred. It is one of the symbols @code{mode-line}, |
1190 meaningful data. | 1170 @code{header-line}, @code{vertical-line}, @code{left-margin}, |
1171 @code{right-margin}, @code{left-fringe}, or @code{right-fringe}. | |
1172 | |
1173 @item @var{x}, @var{y} | |
1174 These are the pixel-denominated coordinates of the click, relative to | |
1175 the top left corner of @var{window}, which is @code{(0 . 0)}. | |
1176 For the mode or header line, @var{y} does not have meaningful data. | |
1177 For the vertical line, @var{x} does not have meaningful data. | |
1178 | |
1179 @item @var{timestamp} | |
1180 This is the time at which the event occurred, in milliseconds. | |
1181 | |
1182 @item @var{object} | |
1183 This is the object on which the click occurred. It is either | |
1184 @code{nil} if there is no string property, or it has the form | |
1185 (@var{string} . @var{string-pos}) when there is a string-type text | |
1186 property at the click position. | |
1187 | |
1188 @item @var{string} | |
1189 This is the string on which the click occurred, including any | |
1190 properties. | |
1191 | |
1192 @item @var{string-pos} | |
1193 This is the position in the string on which the click occurred, | |
1194 relevant if properties at the click need to be looked up. | |
1195 | |
1196 @item @var{text-pos} | |
1197 For clicks on a marginal area or on a fringe, this is the buffer | |
1198 position of the first visible character in the corresponding line in | |
1199 the window. For other events, it is the current buffer position in | |
1200 the window. | |
1201 | |
1202 @item @var{col}, @var{row} | |
1203 These are the actual coordinates of the glyph under the @var{x}, | |
1204 @var{y} position, possibly padded with default character width | |
1205 glyphs if @var{x} is beyond the last glyph on the line. | |
1206 | |
1207 @item @var{image} | |
1208 This is the image object on which the click occurred. It is either | |
1209 @code{nil} if there is no image at the position clicked on, or it is | |
1210 an image object as returned by @code{find-image} if click was in an image. | |
1211 | |
1212 @item @var{dx}, @var{dy} | |
1213 These are the pixel-denominated coordinates of the click, relative to | |
1214 the top left corner of @var{object}, which is @code{(0 . 0)}. If | |
1215 @var{object} is @code{nil}, the coordinates are relative to the top | |
1216 left corner of the character glyph clicked on. | |
1217 @end table | |
1218 | |
1219 For mouse clicks on a scroll-bar, @var{position} has this form: | |
1220 | |
1221 @example | |
1222 (@var{window} @var{area} (@var{portion} . @var{whole}) @var{timestamp} @var{part}) | |
1223 @end example | |
1224 | |
1225 @table @asis | |
1226 @item @var{window} | |
1227 This is the window whose scroll-bar was clicked on. | |
1228 | |
1229 @item @var{area} | |
1230 This is the scroll bar where the click occurred. It is one of the | |
1231 symbols @code{vertical-scroll-bar} or @code{horizontal-scroll-bar}. | |
1232 | |
1233 @item @var{portion} | |
1234 This is the distance of the click from the top or left end of | |
1235 the scroll bar. | |
1236 | |
1237 @item @var{whole} | |
1238 This is the length of the entire scroll bar. | |
1239 | |
1240 @item @var{timestamp} | |
1241 This is the time at which the event occurred, in milliseconds. | |
1242 | |
1243 @item @var{part} | |
1244 This is the part of the scroll-bar which was clicked on. It is one | |
1245 of the symbols @code{above-handle}, @code{handle}, @code{below-handle}, | |
1246 @code{up}, @code{down}, @code{top}, @code{bottom}, and @code{end-scroll}. | |
1247 @end table | |
1191 | 1248 |
1192 In one special case, @var{buffer-pos} is a list containing a symbol (one | 1249 In one special case, @var{buffer-pos} is a list containing a symbol (one |
1193 of the symbols listed above) instead of just the symbol. This happens | 1250 of the symbols listed above) instead of just the symbol. This happens |
1194 after the imaginary prefix keys for the event are inserted into the | 1251 after the imaginary prefix keys for the event are inserted into the |
1195 input stream. @xref{Key Sequence Input}. | 1252 input stream. @xref{Key Sequence Input}. |
1613 | 1670 |
1614 These two functions return the starting or ending position of a | 1671 These two functions return the starting or ending position of a |
1615 mouse-button event, as a list of this form: | 1672 mouse-button event, as a list of this form: |
1616 | 1673 |
1617 @example | 1674 @example |
1618 (@var{window} @var{buffer-position} (@var{x} . @var{y}) @var{timestamp}) | 1675 (@var{window} @var{pos-or-area} (@var{x} . @var{y}) @var{timestamp} |
1676 @var{object} @var{text-pos} (@var{col} . @var{row}) | |
1677 @var{image} (@var{dx} . @var{dy}) (@var{width} . @var{height})) | |
1619 @end example | 1678 @end example |
1620 | 1679 |
1621 @defun event-start event | 1680 @defun event-start event |
1622 This returns the starting position of @var{event}. | 1681 This returns the starting position of @var{event}. |
1623 | 1682 |
1634 event, the value is actually the starting position, which is the only | 1693 event, the value is actually the starting position, which is the only |
1635 position such events have. | 1694 position such events have. |
1636 @end defun | 1695 @end defun |
1637 | 1696 |
1638 @cindex mouse position list, accessing | 1697 @cindex mouse position list, accessing |
1639 These five functions take a position list as described above, and | 1698 These seven functions take a position list as described above, and |
1640 return various parts of it. | 1699 return various parts of it. |
1641 | 1700 |
1642 @defun posn-window position | 1701 @defun posn-window position |
1643 Return the window that @var{position} is in. | 1702 Return the window that @var{position} is in. |
1644 @end defun | 1703 @end defun |
1645 | 1704 |
1705 @defun posn-area position | |
1706 Return the window area recorded in @var{position}. It returns @code{nil} | |
1707 when the event occurred in the text area of the window; otherwise, it | |
1708 is a symbol identifying the area in which the the event occurred. | |
1709 @end defun | |
1710 | |
1646 @defun posn-point position | 1711 @defun posn-point position |
1647 Return the buffer position in @var{position}. This is an integer. | 1712 Return the buffer position in @var{position}. When the event occurred |
1713 in the text area of the window, in a marginal area, or on a fringe, | |
1714 this is an integer specifying a buffer position. Otherwise, the value | |
1715 is undefined. | |
1648 @end defun | 1716 @end defun |
1649 | 1717 |
1650 @defun posn-x-y position | 1718 @defun posn-x-y position |
1651 Return the pixel-based x and y coordinates in @var{position}, as a cons | 1719 Return the pixel-based x and y coordinates in @var{position}, as a cons |
1652 cell @code{(@var{x} . @var{y})}. | 1720 cell @code{(@var{x} . @var{y})}. |
1653 @end defun | 1721 @end defun |
1654 | 1722 |
1655 @defun posn-col-row position | 1723 @defun posn-col-row position |
1656 Return the row and column (in units of characters) of @var{position}, as | 1724 Return the row and column (in units of frame default characters) of |
1657 a cons cell @code{(@var{col} . @var{row})}. These are computed from the | 1725 @var{position}, as a cons cell @code{(@var{col} . @var{row})}. These |
1658 @var{x} and @var{y} values actually found in @var{position}. | 1726 are computed from the @var{x} and @var{y} values actually found in |
1727 @var{position}. | |
1728 @end defun | |
1729 | |
1730 @defun posn-actual-col-row position | |
1731 Return the actual row and column in @var{position}, as a cons cell | |
1732 @code{(@var{col} . @var{row})}. The values are the actual row number | |
1733 in the window, and the actual character number in that row. Return | |
1734 @code{nil} if @var{position} does not include the actual positions; in that | |
1735 case, @code{posn-col-row} can be used to get approximate values. | |
1736 @end defun | |
1737 | |
1738 @defun posn-string position | |
1739 Return the string object in @var{position}, either @code{nil}, or a | |
1740 cons cell @code{(@var{string} . @var{string-pos})}. | |
1741 @end defun | |
1742 | |
1743 @defun posn-image position | |
1744 Return the image object in @var{position}, either @code{nil}, or an | |
1745 image @code{(image ...)}. | |
1746 @end defun | |
1747 | |
1748 @defun posn-object position | |
1749 Return the image or string object in @var{position}, either | |
1750 @code{nil}, an image @code{(image ...)}, or a cons cell | |
1751 @code{(@var{string} . @var{string-pos})}. | |
1752 @end defun | |
1753 | |
1754 @defun posn-object-x-y position | |
1755 Return the pixel-based x and y coordinates relative to the upper left | |
1756 corner of the object in @var{position} as a cons cell @code{(@var{dx} | |
1757 . @var{dy})}. If the @var{position} is a buffer position, return the | |
1758 relative position in the character at that position. | |
1759 @end defun | |
1760 | |
1761 @defun posn-object-width-height position | |
1762 Return the pixel width and height of the object in @var{position} as a | |
1763 cons cell @code{(@var{width} . @var{height})}. If the @var{position} | |
1764 is a buffer position, return the size of the character at that position. | |
1659 @end defun | 1765 @end defun |
1660 | 1766 |
1661 @cindex mouse event, timestamp | 1767 @cindex mouse event, timestamp |
1662 @cindex timestamp of a mouse event | 1768 @cindex timestamp of a mouse event |
1663 @defun posn-timestamp position | 1769 @defun posn-timestamp |
1664 Return the timestamp in @var{position}. | 1770 Return the timestamp in @var{position}. This is the time at which the |
1771 event occurred, in milliseconds. | |
1665 @end defun | 1772 @end defun |
1666 | 1773 |
1667 These functions are useful for decoding scroll bar events. | 1774 These functions are useful for decoding scroll bar events. |
1668 | 1775 |
1669 @defun scroll-bar-event-ratio event | 1776 @defun scroll-bar-event-ratio event |
1794 @end ifnottex | 1901 @end ifnottex |
1795 bit, resulting in a value between 128 and 255. Only a unibyte string | 1902 bit, resulting in a value between 128 and 255. Only a unibyte string |
1796 can include these codes. | 1903 can include these codes. |
1797 | 1904 |
1798 @item | 1905 @item |
1799 Non-@sc{ascii} characters above 256 can be included in a multibyte string. | 1906 Non-@acronym{ASCII} characters above 256 can be included in a multibyte string. |
1800 | 1907 |
1801 @item | 1908 @item |
1802 Other keyboard character events cannot fit in a string. This includes | 1909 Other keyboard character events cannot fit in a string. This includes |
1803 keyboard events in the range of 128 to 255. | 1910 keyboard events in the range of 128 to 255. |
1804 @end itemize | 1911 @end itemize |
1963 the events that led to or were read by the current command. @xref{The | 2070 the events that led to or were read by the current command. @xref{The |
1964 Echo Area}. | 2071 Echo Area}. |
1965 | 2072 |
1966 If @var{inherit-input-method} is non-@code{nil}, then the current input | 2073 If @var{inherit-input-method} is non-@code{nil}, then the current input |
1967 method (if any) is employed to make it possible to enter a | 2074 method (if any) is employed to make it possible to enter a |
1968 non-@sc{ascii} character. Otherwise, input method handling is disabled | 2075 non-@acronym{ASCII} character. Otherwise, input method handling is disabled |
1969 for reading this event. | 2076 for reading this event. |
1970 | 2077 |
1971 If @code{cursor-in-echo-area} is non-@code{nil}, then @code{read-event} | 2078 If @code{cursor-in-echo-area} is non-@code{nil}, then @code{read-event} |
1972 moves the cursor temporarily to the echo area, to the end of any message | 2079 moves the cursor temporarily to the echo area, to the end of any message |
1973 displayed there. Otherwise @code{read-event} does not move the cursor. | 2080 displayed there. Otherwise @code{read-event} does not move the cursor. |
1993 This function reads and returns a character of command input. If the | 2100 This function reads and returns a character of command input. If the |
1994 user generates an event which is not a character (i.e. a mouse click or | 2101 user generates an event which is not a character (i.e. a mouse click or |
1995 function key event), @code{read-char} signals an error. The arguments | 2102 function key event), @code{read-char} signals an error. The arguments |
1996 work as in @code{read-event}. | 2103 work as in @code{read-event}. |
1997 | 2104 |
1998 In the first example, the user types the character @kbd{1} (@sc{ascii} | 2105 In the first example, the user types the character @kbd{1} (@acronym{ASCII} |
1999 code 49). The second example shows a keyboard macro definition that | 2106 code 49). The second example shows a keyboard macro definition that |
2000 calls @code{read-char} from the minibuffer using @code{eval-expression}. | 2107 calls @code{read-char} from the minibuffer using @code{eval-expression}. |
2001 @code{read-char} reads the keyboard macro's very next character, which | 2108 @code{read-char} reads the keyboard macro's very next character, which |
2002 is @kbd{1}. Then @code{eval-expression} displays its return value in | 2109 is @kbd{1}. Then @code{eval-expression} displays its return value in |
2003 the echo area. | 2110 the echo area. |
2039 | 2146 |
2040 @defvar input-method-function | 2147 @defvar input-method-function |
2041 If this is non-@code{nil}, its value specifies the current input method | 2148 If this is non-@code{nil}, its value specifies the current input method |
2042 function. | 2149 function. |
2043 | 2150 |
2044 @strong{Note:} Don't bind this variable with @code{let}. It is often | 2151 @strong{Warning:} don't bind this variable with @code{let}. It is often |
2045 buffer-local, and if you bind it around reading input (which is exactly | 2152 buffer-local, and if you bind it around reading input (which is exactly |
2046 when you @emph{would} bind it), switching buffers asynchronously while | 2153 when you @emph{would} bind it), switching buffers asynchronously while |
2047 Emacs is waiting will cause the value to be restored in the wrong | 2154 Emacs is waiting will cause the value to be restored in the wrong |
2048 buffer. | 2155 buffer. |
2049 @end defvar | 2156 @end defvar |
2173 @defvarx last-input-char | 2280 @defvarx last-input-char |
2174 This variable records the last terminal input event read, whether | 2281 This variable records the last terminal input event read, whether |
2175 as part of a command or explicitly by a Lisp program. | 2282 as part of a command or explicitly by a Lisp program. |
2176 | 2283 |
2177 In the example below, the Lisp program reads the character @kbd{1}, | 2284 In the example below, the Lisp program reads the character @kbd{1}, |
2178 @sc{ascii} code 49. It becomes the value of @code{last-input-event}, | 2285 @acronym{ASCII} code 49. It becomes the value of @code{last-input-event}, |
2179 while @kbd{C-e} (we assume @kbd{C-x C-e} command is used to evaluate | 2286 while @kbd{C-e} (we assume @kbd{C-x C-e} command is used to evaluate |
2180 this expression) remains the value of @code{last-command-event}. | 2287 this expression) remains the value of @code{last-command-event}. |
2181 | 2288 |
2182 @example | 2289 @example |
2183 @group | 2290 @group |
2817 @defvar kbd-macro-termination-hook | 2924 @defvar kbd-macro-termination-hook |
2818 This normal hook (@pxref{Standard Hooks}) is run when a keyboard | 2925 This normal hook (@pxref{Standard Hooks}) is run when a keyboard |
2819 macro terminates, regardless of what caused it to terminate (reaching | 2926 macro terminates, regardless of what caused it to terminate (reaching |
2820 the macro end or an error which ended the macro prematurely). | 2927 the macro end or an error which ended the macro prematurely). |
2821 @end defvar | 2928 @end defvar |
2929 | |
2930 @ignore | |
2931 arch-tag: e34944ad-7d5c-4980-be00-36a5fe54d4b1 | |
2932 @end ignore |