diff options
| author | Phillip Lord | 2019-01-05 20:31:15 +0100 |
|---|---|---|
| committer | Phillip Lord | 2019-01-22 21:46:03 +0000 |
| commit | 7b31de4d107302ed91ce7519cd778b340a9880ee (patch) | |
| tree | efd0ca3ab5066991c8b6bafb6fceaa3d8c441a18 | |
| parent | fd943124439b7644392919bca8bc2a77e6316d92 (diff) | |
| download | emacs-7b31de4d107302ed91ce7519cd778b340a9880ee.tar.gz emacs-7b31de4d107302ed91ce7519cd778b340a9880ee.zip | |
Add hook for all events
* lisp/subr.el (input-event-functions): Add input-event-functions
* src/keyboard.c (read_char): Call input-event-functions on all hooks
| -rw-r--r-- | etc/NEWS | 4 | ||||
| -rw-r--r-- | lisp/subr.el | 6 | ||||
| -rw-r--r-- | src/keyboard.c | 4 |
3 files changed, 13 insertions, 1 deletions
| @@ -1189,11 +1189,13 @@ removed. | |||
| 1189 | 1189 | ||
| 1190 | * Lisp Changes in Emacs 27.1 | 1190 | * Lisp Changes in Emacs 27.1 |
| 1191 | 1191 | ||
| 1192 | +++ | 1192 | |
| 1193 | ** 'self-insert-command' takes the char to insert as (optional) argument. | 1193 | ** 'self-insert-command' takes the char to insert as (optional) argument. |
| 1194 | 1194 | ||
| 1195 | ** 'lookup-key' can take a list of keymaps as argument. | 1195 | ** 'lookup-key' can take a list of keymaps as argument. |
| 1196 | 1196 | ||
| 1197 | ** New hook `input-event-functions` run whenever a user-input is read. | ||
| 1198 | |||
| 1197 | +++ | 1199 | +++ |
| 1198 | ** 'condition-case' now accepts 't' to match any error symbol. | 1200 | ** 'condition-case' now accepts 't' to match any error symbol. |
| 1199 | 1201 | ||
diff --git a/lisp/subr.el b/lisp/subr.el index 2f2ea5e6c77..122a0d8da4c 100644 --- a/lisp/subr.el +++ b/lisp/subr.el | |||
| @@ -1289,6 +1289,12 @@ See `event-start' for a description of the value returned." | |||
| 1289 | The return value is a positive integer." | 1289 | The return value is a positive integer." |
| 1290 | (if (and (consp event) (integerp (nth 2 event))) (nth 2 event) 1)) | 1290 | (if (and (consp event) (integerp (nth 2 event))) (nth 2 event) 1)) |
| 1291 | 1291 | ||
| 1292 | (defvar input-event-functions nil | ||
| 1293 | ;; BEWARE: If it looks like this is not run anywhere, it's normal: | ||
| 1294 | ;; this is run in keyboard.c. | ||
| 1295 | "Special hook run each time a user-input event is read. | ||
| 1296 | Each function is called with one argument: the event.") | ||
| 1297 | |||
| 1292 | (defsubst event-line-count (event) | 1298 | (defsubst event-line-count (event) |
| 1293 | "Return the line count of EVENT, a mousewheel event. | 1299 | "Return the line count of EVENT, a mousewheel event. |
| 1294 | The return value is a positive integer." | 1300 | The return value is a positive integer." |
diff --git a/src/keyboard.c b/src/keyboard.c index 2d6fa91a16c..838dc242dd9 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -2919,6 +2919,8 @@ read_char (int commandflag, Lisp_Object map, | |||
| 2919 | if (! NILP (also_record)) | 2919 | if (! NILP (also_record)) |
| 2920 | record_char (also_record); | 2920 | record_char (also_record); |
| 2921 | 2921 | ||
| 2922 | Frun_hook_with_args (2, ((Lisp_Object []) {Qinput_event_functions, c})); | ||
| 2923 | |||
| 2922 | /* Wipe the echo area. | 2924 | /* Wipe the echo area. |
| 2923 | But first, if we are about to use an input method, | 2925 | But first, if we are about to use an input method, |
| 2924 | save the echo area contents for it to refer to. */ | 2926 | save the echo area contents for it to refer to. */ |
| @@ -11022,6 +11024,8 @@ syms_of_keyboard (void) | |||
| 11022 | 11024 | ||
| 11023 | DEFSYM (Qundefined, "undefined"); | 11025 | DEFSYM (Qundefined, "undefined"); |
| 11024 | 11026 | ||
| 11027 | DEFSYM (Qinput_event_functions, "input-event-functions"); | ||
| 11028 | |||
| 11025 | /* Hooks to run before and after each command. */ | 11029 | /* Hooks to run before and after each command. */ |
| 11026 | DEFSYM (Qpre_command_hook, "pre-command-hook"); | 11030 | DEFSYM (Qpre_command_hook, "pre-command-hook"); |
| 11027 | DEFSYM (Qpost_command_hook, "post-command-hook"); | 11031 | DEFSYM (Qpost_command_hook, "post-command-hook"); |