Questions tagged [events]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
28
votes
4answers
6k views

How can I simulate an arbitary key event from Elisp?

Is it possible to simulate an arbitrary key event from elisp? I am aware of ways that I can find the binding for a given key, and then call that command interactively, but what if that key event is ...
9
votes
2answers
348 views

Translating strings to keypresses

Given a string in elisp, I'd like to simulate emacs receiving whatever keypresses are necessary to re-create that string. So given the string "Hello" emacs would act exactly the same as if I had ...
7
votes
2answers
597 views

Looking for something like a `first-keypress-in-a-while-hook`

Suppose that I have an Emacs session running, and that I step away from my computer for, say, 20 minutes. Upon returning to my Emacs session, at some point I will press some key while the Emacs ...
6
votes
3answers
102 views

How to detect if `read-event` or `y-or-n-p` is running?

In haskell-doc-mode we have a timer that shows useful tips in minibuffer when cursor is idle for a moment. In other part of Haskell Mode there is code asking questions using y-or-n-p or read-event. ...
5
votes
1answer
585 views

Send input to multiple buffers simultaneously

Is there something like multiple-cursors, but that would send input into multiple buffers at once? Use case: I want to send the same shell commands to a number of virtual machines and see the output ...
4
votes
1answer
180 views

How can I convert a C-key code into a 'normal' key code?

Background With jumping packages like Ace and Avy, you can start a function, provide a query char, and then jump to somewhere based on further input. (Lately I've preferred Avy, but that's irrelevant ...
3
votes
1answer
203 views

Making read-char input robust? [closed]

I need to read a char at a time to interactively build a filter string while I show the results in a regular buffer. And what I've written works, except when a cursor key is pressed - then bang, I ...
3
votes
1answer
180 views

Process unread-command-events and redisplay

(defun pretend (keys) (dolist (e (reverse (listify-key-sequence (kbd keys)))) (push e unread-command-events) ;; (mystery-function) (redisplay t) (sleep-for 0.1))) (pretend "M-x my-...
2
votes
0answers
43 views

Control or set the emacs mouse button event polling rate?

I have been using artist-mode and noticed that even at moderate mouse movement speeds the mouse event polling rate (here for down-mouse-1) does not seem to keep up (so lines end up with scattered ...
1
vote
1answer
108 views

How to access mouse event coordinates? (conveniently)

When getting events from (read-event) it's possible to access only mouse events using (mouse-movement-p event). Inspecting the events I've found I can get the Y pixel location using (cdr (nth 2 (nth ...
1
vote
1answer
79 views

How to get the string representation of a keymap event?

I'd like to get the string representation of a keymap event. For instance 19 should be printed as C-s, 1 as C-a etc... I could make my own function to do that but since describe-keyis capable of ...
1
vote
1answer
33 views

Remap input event in all contexts

I'm currently trying to implement a virtual keyboard. For this to work I need to remap input events in all contexts. I'm aware of the variables function-key-map and it's siblings, as well as input ...
1
vote
1answer
313 views

How to use unread-command-events variable?

I want to generate some input from my command programmatically. I have tried using unread-command-events variable for that, see: (defun unread_test () "Repeat input after toggling input method" (...
1
vote
1answer
216 views

elisp - detect line change event to trigger function

I want to detect line change event (arrow-,arrow- or mouse click) to trigger my function call. Below example handled arrow- arrow- but can not handle mouse click or C-n C-p line change event. (defun ...
1
vote
1answer
32 views

unread-command-events and batch mode

I'm writing tests for an interactive function. I've been using the unread-command-events variable in conjunction with call-interactively to verify that it does the right thing. However, I just ...
1
vote
1answer
102 views

Wait for release a key to go on in a loop

I have this loop: (catch 'QUIT (while (search-forward-regexp "\\([^\n\\]\\(?:\\\\\\\\\\)*\\|^\\(?:\\\\\\\\\\)+\\)%.*\n" nil t) (save-excursion (let ((b (make-...
1
vote
1answer
326 views

Help with my double tap key-binding function

I'm writing a function to enable binding a "double tap" on a key (or one key then another key in rapid succession) to a function. It almost works, but not quite. Here is the code I have in my lisp ...
1
vote
1answer
195 views

How to move point with mousepointer on shift-click in emacs

I want to write some functionality that fires whenever I shift-click a point in an emacs buffer. Problem is that when shift is pressed, the point is not changing when clicking. To make things more ...
1
vote
0answers
19 views

How to make the mouse only change point only when clicked in the same window?

I want to change the mouse behaviour in Emacs: When I click between windows (i.e. from one window into another)), I only want to select the new window and not change point. This is the behaviour ...
1
vote
1answer
64 views

tooltip-functions not working?

Years ago, when Emacs was at 21.*, I had a function that displayed a tooltip when I hovered the mouse on certain words in the buffer. Now, in 26.3, I want to use that function again, but it does not ...
1
vote
0answers
46 views

read-event read entire arrow key instead of escape

In graphical emacs on OS X, (read-event) in the scratch buffer produces left, however in iterm2 (which I configured to send esc-* for arrow keys), I get something like (read-event) 27 OD when I ...
0
votes
1answer
32 views

How to count the number of clocks of some given duration?

I want to collect statistics about some clocked events; more specifically I need to count the number of clocked events (belonging to some subtree for instance) whose duration is in some predefined ...
0
votes
1answer
158 views

mode-line refresh with alerts and weechat

Note - The original post incorrectly diagnosed this as a terminal issue. Further testing showed this not to be the case - the issue is a race condition in the alert package. I've crossed-out the now ...
0
votes
1answer
131 views

file-notify-add-watch : get file path string

I would to do a specific action (create an org-mod link) when a new file appears in a given directory. For that I need to catch the event but also the path of the new file. I managed to use file-...