Questions tagged [events]

35 questions
32
votes
4 answers

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 not bound to a command? As one example, what if I…
nispio
  • 8,175
  • 2
  • 35
  • 73
9
votes
2 answers

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 pressed Shift+H,e,l,l,o. Note that this is not always…
Joseph Garvin
  • 2,061
  • 8
  • 21
7
votes
2 answers

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 window has the focus. This would be an example of the…
kjo
  • 3,145
  • 14
  • 42
6
votes
3 answers

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. The problem is haskell-doc-mode does not know about…
Gracjan Polak
  • 1,082
  • 6
  • 21
5
votes
1 answer

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 in the real time. Maybe multi-term can do…
wvxvw
  • 11,222
  • 2
  • 30
  • 55
4
votes
1 answer

Isearch + Dired fast navigation

After seeing this post and one of its comments, I am trying to implement the following convenient search pattern in dired: Press C-s to start isearch Type the substring I am looking for Possibly jump between all matching results by typing C-s…
unvarnished
  • 129
  • 5
4
votes
1 answer

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-function-") This function is intended to take key…
Sean Allred
  • 6,861
  • 16
  • 85
4
votes
1 answer

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 here.) I have had both bound to C-' C-; (with…
Sean Allred
  • 6,861
  • 16
  • 85
3
votes
2 answers

input event

I don't know what I did caused Emacs to emit such a message: is undefined Screenshot: How did I issue this input event? In other words, what does this stand for? Now I know how to reproduce it: (emacs -Q, of…
shynur
  • 4,065
  • 1
  • 3
  • 23
3
votes
1 answer

Is there a reliable way read an existing event, if any, and remove it from the queue with zero delay?

An answer to another question suggests that supplying a timeout of 0.0 to read-event (as the optional SECONDS parameter) will always return nil immediately, and, if I'm reading the code in Emacs' keyboard.c correctly, even a (very) very small…
user13929
3
votes
1 answer

Making read-char input robust?

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 get a "non-character input event message" and my…
ump
  • 61
  • 3
2
votes
0 answers

Inconsistency between read-key and read-key-sequence-vector w.r.t. conditional application of local-function-key-map translations

While working with read-key-sequence-vector and read-key, I found that the former applies the local-function-key-map translations in a conditional manner but the latter does not. I am using Emacs 28.1 on a macOS system. The function…
Susam Pal
  • 161
  • 5
2
votes
2 answers

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 globally enabled through: (progn (global-set-key…
halloleo
  • 1,215
  • 9
  • 23
2
votes
1 answer

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" (interactive) (let ((kseq (listify-key-sequence…
Srv19
  • 479
  • 3
  • 15
2
votes
1 answer

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 printing the string representation of an event there…
syl20bnr
  • 2,095
  • 11
  • 21
1
2 3