Skip to main content
OverflowAI is here! AI power for your Stack Overflow for Teams knowledge community. Learn more
7 votes
Accepted

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

You could try: (defun my-run-fkpiawh () (remove-hook 'pre-command-hook #'my-run-fkpiawh) (run-hooks 'first-keypress-in-a-while-hook)) (run-with-idle-timer 1200 t (lambda () ...
Stefan's user avatar
  • 26.5k
6 votes

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

I guess a solution of your problem is setting a flag with an idle timer, https://www.gnu.org/software/emacs/manual/html_node/elisp/Idle-Timers.html and checking/unsetting it with post-self-insert-...
Vera Johanna's user avatar
4 votes
Accepted

Isearch + Dired fast navigation

Change \r to 'return: (add-hook 'isearch-mode-end-hook (lambda () (when (and (eq major-mode 'dired-mode) (not isearch-mode-end-hook-quit) (eq last-input-event '...
Drew's user avatar
  • 77.8k
3 votes
Accepted

How to use unread-command-events variable?

How can i achieve my goal? Should i take another approach? IIUC the problem arises from a misuse of nconc. The value of unread-command-events is often nil, in which case nconc will not alter it in-...
Basil's user avatar
  • 12.4k
3 votes
Accepted

How to access mouse event coordinates? (conveniently)

There is a list of functions with the posn prefix to extract that information and more from mouse events. One caveat is that many of them require a start/end event: (let ((e (read-event))) (when (...
wasamasa's user avatar
  • 22.2k
2 votes

Remap input event in all contexts

function-key-map and input-decode-map definitely apply in the middle of a key-sequence as well.
Stefan's user avatar
  • 26.5k
2 votes
Accepted

elisp - detect line change event to trigger function

The answer to “I want to detect (…) event” is usually to use the appropriate hook. The manual has a list of standard hooks. There's no hook that triggers on a line change, so the next thing is to look ...
Gilles 'SO- stop being evil''s user avatar
2 votes
Accepted

On installing a handler for SIGUSR1

Could someone explain when and why one would choose one of these approaches over the other? Use the 1st one. See bug#65577: Eli Zaretskii: Stefan, it sounds like the ... example is some left-over ...
shynur's user avatar
  • 5,318
2 votes

`define-key` redefines behavior of slow mouse click, but not fast mouse click

A mouse click results in multiple events. If you want the action to take place upon the button press, and the button-release to be ignored, you can use this, for example: (define-key org-mode-map [...
Drew's user avatar
  • 77.8k
1 vote
Accepted

query-replace: ignore events not binded in query-replace-map

Try this ... (defvar my-do-nothing-map (let ((map (make-keymap))) (set-char-table-range (nth 1 map) t 'ignore) map)) (set-keymap-parent query-replace-map my-do-nothing-map) The proposed ...
mxnt's user avatar
  • 686
1 vote
Accepted

Make "M-x repeat" Ignore Movement Commands

Based on Drew's answer below I wrote the following code that works for my purpose. Sharing here in hope it is helpful for others! ;; Make M-x repeat ignore movement commands ...
nslamberth's user avatar
1 vote

Make "M-x repeat" Ignore Movement Commands

Someone else will hopefully answer your real question, which is about how to do what you want to do. It's not very clear to me what you really want to do, or why. In particular, if you want to repeat ...
Drew's user avatar
  • 77.8k
1 vote
Accepted

input event <nil>

Now that you've added a mention that you see the same thing with emacs -Q, and you see it when you roll the mouse wheel over a menu-bar menu: On MS Windows, at least, I see the same thing. And I see ...
Drew's user avatar
  • 77.8k
1 vote

input event <nil>

You should see this instead: <menu-bar> <wheel-down> is undefined <menu-bar> <double-wheel-down> is undefined Does it still happen if you start Emacs with -Q? If it does, then ...
db48x's user avatar
  • 18.2k
1 vote
Accepted

Understanding of Emacs way of managing user input events

How Emacs manages input events is documented at C-hig (elisp)Command Loop. See particularly "Input Event", "Reading Input", and "Special Events". The basic command loop ...
phils's user avatar
  • 51.5k
1 vote

tooltip-functions not working?

Not exactly an answer, but a dirty workaround: give up using tooltip-functions and bind the function directly to mouse-movement, like this: (defun my-tooltip (event) (interactive "e") (...
toomas's user avatar
  • 183
1 vote

unread-command-events and batch mode

This is expected behavior, but you can circumvent this problem by let-binding executing-kbd-macro to t, which will convince the minibuffer commands to read from unread-command-events rather than from ...
Stefan's user avatar
  • 26.5k
1 vote

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

Edit: With the new information and test case provided in the question, it's clear that this answer is incorrect (or at least inadequate). Clearly there are indeed additional input event queue(s) ...
phils's user avatar
  • 51.5k
1 vote
Accepted

`read-event`: How to cancel a mouse event once read

Whenever you click on the mouse, two events are generated. In this case down-mouse-1 and mouse-1. Your code consumes down-mouse-1, but leaves the second in the queue. If you consume both, the problem ...
Lindydancer's user avatar
  • 6,170
1 vote

Sample code for events management

Passing a value of 0 for the SECONDS arg of read-char means it will immediately return nil, always. (And your code never changes the value of key, so it remains 0. So the iteration goes on forever, ...
Drew's user avatar
  • 77.8k
1 vote
Accepted

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

my-count-clocks in the following Elisp section defines a function that counts clocks in the current org-mode section. It does not descent into sub-sections. You can easily modify my-count-clocks to ...
Tobias's user avatar
  • 33.2k
1 vote
Accepted

Wait for release a key to go on in a loop

Release of a keyboard key is not an event that is detected by Emacs. (But release of a mouse button is an event seen by Emacs.) Maybe change from reading and acting on a single character to acting on ...
Drew's user avatar
  • 77.8k

Only top scored, non community-wiki answers of a minimum length are eligible