[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 7b31de4: Add hook for all events
From: |
Phillip Lord |
Subject: |
[Emacs-diffs] master 7b31de4: Add hook for all events |
Date: |
Tue, 22 Jan 2019 16:46:39 -0500 (EST) |
branch: master
commit 7b31de4d107302ed91ce7519cd778b340a9880ee
Author: Phillip Lord <address@hidden>
Commit: Phillip Lord <address@hidden>
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
---
etc/NEWS | 4 +++-
lisp/subr.el | 6 ++++++
src/keyboard.c | 4 ++++
3 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/etc/NEWS b/etc/NEWS
index 2118747..b0bbaeb 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1189,11 +1189,13 @@ removed.
* Lisp Changes in Emacs 27.1
-+++
+
** 'self-insert-command' takes the char to insert as (optional) argument.
** 'lookup-key' can take a list of keymaps as argument.
+** New hook `input-event-functions` run whenever a user-input is read.
+
+++
** 'condition-case' now accepts 't' to match any error symbol.
diff --git a/lisp/subr.el b/lisp/subr.el
index 2f2ea5e..122a0d8 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -1289,6 +1289,12 @@ See `event-start' for a description of the value
returned."
The return value is a positive integer."
(if (and (consp event) (integerp (nth 2 event))) (nth 2 event) 1))
+(defvar input-event-functions nil
+ ;; BEWARE: If it looks like this is not run anywhere, it's normal:
+ ;; this is run in keyboard.c.
+ "Special hook run each time a user-input event is read.
+Each function is called with one argument: the event.")
+
(defsubst event-line-count (event)
"Return the line count of EVENT, a mousewheel event.
The return value is a positive integer."
diff --git a/src/keyboard.c b/src/keyboard.c
index 2d6fa91..838dc24 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -2919,6 +2919,8 @@ read_char (int commandflag, Lisp_Object map,
if (! NILP (also_record))
record_char (also_record);
+ Frun_hook_with_args (2, ((Lisp_Object []) {Qinput_event_functions, c}));
+
/* Wipe the echo area.
But first, if we are about to use an input method,
save the echo area contents for it to refer to. */
@@ -11022,6 +11024,8 @@ syms_of_keyboard (void)
DEFSYM (Qundefined, "undefined");
+ DEFSYM (Qinput_event_functions, "input-event-functions");
+
/* Hooks to run before and after each command. */
DEFSYM (Qpre_command_hook, "pre-command-hook");
DEFSYM (Qpost_command_hook, "post-command-hook");
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master 7b31de4: Add hook for all events,
Phillip Lord <=