aboutsummaryrefslogtreecommitdiffstats
path: root/lispref/commands.texi
diff options
context:
space:
mode:
Diffstat (limited to 'lispref/commands.texi')
-rw-r--r--lispref/commands.texi98
1 files changed, 94 insertions, 4 deletions
diff --git a/lispref/commands.texi b/lispref/commands.texi
index 10cd97400f8..514b55205a1 100644
--- a/lispref/commands.texi
+++ b/lispref/commands.texi
@@ -1087,7 +1087,7 @@ Lisp programs by representing the former as the integer 9, and the
1087latter as the symbol @code{tab}. 1087latter as the symbol @code{tab}.
1088 1088
1089Most of the time, it's not useful to distinguish the two. So normally 1089Most of the time, it's not useful to distinguish the two. So normally
1090@code{function-key-map} (@pxref{Translating Input}) is set up to map 1090@code{function-key-map} (@pxref{Translation Keymaps}) is set up to map
1091@code{tab} into 9. Thus, a key binding for character code 9 (the 1091@code{tab} into 9. Thus, a key binding for character code 9 (the
1092character @kbd{C-i}) also applies to @code{tab}. Likewise for the other 1092character @kbd{C-i}) also applies to @code{tab}. Likewise for the other
1093symbols in this group. The function @code{read-char} likewise converts 1093symbols in this group. The function @code{read-char} likewise converts
@@ -2051,14 +2051,14 @@ functions for event input are also available for use in Lisp programs.
2051See also @code{momentary-string-display} in @ref{Temporary Displays}, 2051See also @code{momentary-string-display} in @ref{Temporary Displays},
2052and @code{sit-for} in @ref{Waiting}. @xref{Terminal Input}, for 2052and @code{sit-for} in @ref{Waiting}. @xref{Terminal Input}, for
2053functions and variables for controlling terminal input modes and 2053functions and variables for controlling terminal input modes and
2054debugging terminal input. @xref{Translating Input}, for features you 2054debugging terminal input.
2055can use for translating or modifying input events while reading them.
2056 2055
2057 For higher-level input facilities, see @ref{Minibuffers}. 2056 For higher-level input facilities, see @ref{Minibuffers}.
2058 2057
2059@menu 2058@menu
2060* Key Sequence Input:: How to read one key sequence. 2059* Key Sequence Input:: How to read one key sequence.
2061* Reading One Event:: How to read just one event. 2060* Reading One Event:: How to read just one event.
2061* Event Mod:: How Emacs modifies events as they are read.
2062* Invoking the Input Method:: How reading an event uses the input method. 2062* Invoking the Input Method:: How reading an event uses the input method.
2063* Quoted Character Input:: Asking the user to specify a character. 2063* Quoted Character Input:: Asking the user to specify a character.
2064* Event Input Misc:: How to reread or throw away input events. 2064* Event Input Misc:: How to reread or throw away input events.
@@ -2088,7 +2088,7 @@ events---characters, symbols, and lists. The elements of the string or
2088vector are the events in the key sequence. 2088vector are the events in the key sequence.
2089 2089
2090Reading a key sequence includes translating the events in various 2090Reading a key sequence includes translating the events in various
2091ways. @xref{Translating Input}. 2091ways. @xref{Translation Keymaps}.
2092 2092
2093The argument @var{prompt} is either a string to be displayed in the 2093The argument @var{prompt} is either a string to be displayed in the
2094echo area as a prompt, or @code{nil}, meaning not to display a prompt. 2094echo area as a prompt, or @code{nil}, meaning not to display a prompt.
@@ -2229,6 +2229,15 @@ number of seconds; on these systems, @var{seconds} is rounded down.
2229If @var{seconds} is @code{nil}, @code{read-event} waits as long as 2229If @var{seconds} is @code{nil}, @code{read-event} waits as long as
2230necessary for input to arrive. 2230necessary for input to arrive.
2231 2231
2232If @var{seconds} is @code{nil}, Emacs is considered idle while waiting
2233for user input to arrive. Idle timers---those created with
2234@code{run-with-idle-timer} (@pxref{Idle Timers})---can run during this
2235period. However, if @var{seconds} is non-@code{nil}, the state of
2236idleness remains unchanged. If Emacs is non-idle when
2237@code{read-event} is called, it remains non-idle throughout the
2238operation of @code{read-event}; if Emacs is idle (which can happen if
2239the call happens inside an idle timer), it remains idle.
2240
2232If @code{read-event} gets an event that is defined as a help character, 2241If @code{read-event} gets an event that is defined as a help character,
2233then in some cases @code{read-event} processes the event directly without 2242then in some cases @code{read-event} processes the event directly without
2234returning. @xref{Help Functions}. Certain other events, called 2243returning. @xref{Help Functions}. Certain other events, called
@@ -2290,6 +2299,87 @@ This variable holds the total number of input events received so far
2290from the terminal---not counting those generated by keyboard macros. 2299from the terminal---not counting those generated by keyboard macros.
2291@end defvar 2300@end defvar
2292 2301
2302@node Event Mod
2303@subsection Modifying and Translating Input Events
2304
2305 Emacs modifies every event it reads according to
2306@code{extra-keyboard-modifiers}, then translates it through
2307@code{keyboard-translate-table} (if applicable), before returning it
2308from @code{read-event}.
2309
2310@c Emacs 19 feature
2311@defvar extra-keyboard-modifiers
2312This variable lets Lisp programs ``press'' the modifier keys on the
2313keyboard. The value is a character. Only the modifiers of the
2314character matter. Each time the user types a keyboard key, it is
2315altered as if those modifier keys were held down. For instance, if
2316you bind @code{extra-keyboard-modifiers} to @code{?\C-\M-a}, then all
2317keyboard input characters typed during the scope of the binding will
2318have the control and meta modifiers applied to them. The character
2319@code{?\C-@@}, equivalent to the integer 0, does not count as a control
2320character for this purpose, but as a character with no modifiers.
2321Thus, setting @code{extra-keyboard-modifiers} to zero cancels any
2322modification.
2323
2324When using a window system, the program can ``press'' any of the
2325modifier keys in this way. Otherwise, only the @key{CTL} and @key{META}
2326keys can be virtually pressed.
2327
2328Note that this variable applies only to events that really come from
2329the keyboard, and has no effect on mouse events or any other events.
2330@end defvar
2331
2332@defvar keyboard-translate-table
2333This variable is the translate table for keyboard characters. It lets
2334you reshuffle the keys on the keyboard without changing any command
2335bindings. Its value is normally a char-table, or else @code{nil}.
2336(It can also be a string or vector, but this is considered obsolete.)
2337
2338If @code{keyboard-translate-table} is a char-table
2339(@pxref{Char-Tables}), then each character read from the keyboard is
2340looked up in this char-table. If the value found there is
2341non-@code{nil}, then it is used instead of the actual input character.
2342
2343Note that this translation is the first thing that happens to a
2344character after it is read from the terminal. Record-keeping features
2345such as @code{recent-keys} and dribble files record the characters after
2346translation.
2347
2348Note also that this translation is done before the characters are
2349supplied to input methods (@pxref{Input Methods}). Use
2350@code{translation-table-for-input} (@pxref{Translation of Characters}),
2351if you want to translate characters after input methods operate.
2352@end defvar
2353
2354@defun keyboard-translate from to
2355This function modifies @code{keyboard-translate-table} to translate
2356character code @var{from} into character code @var{to}. It creates
2357the keyboard translate table if necessary.
2358@end defun
2359
2360 Here's an example of using the @code{keyboard-translate-table} to
2361make @kbd{C-x}, @kbd{C-c} and @kbd{C-v} perform the cut, copy and paste
2362operations:
2363
2364@example
2365(keyboard-translate ?\C-x 'control-x)
2366(keyboard-translate ?\C-c 'control-c)
2367(keyboard-translate ?\C-v 'control-v)
2368(global-set-key [control-x] 'kill-region)
2369(global-set-key [control-c] 'kill-ring-save)
2370(global-set-key [control-v] 'yank)
2371@end example
2372
2373@noindent
2374On a graphical terminal that supports extended @acronym{ASCII} input,
2375you can still get the standard Emacs meanings of one of those
2376characters by typing it with the shift key. That makes it a different
2377character as far as keyboard translation is concerned, but it has the
2378same usual meaning.
2379
2380 @xref{Translation Keymaps}, for mechanisms that translate event sequences
2381at the level of @code{read-key-sequence}.
2382
2293@node Invoking the Input Method 2383@node Invoking the Input Method
2294@subsection Invoking the Input Method 2384@subsection Invoking the Input Method
2295 2385