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 code exits.
Here's an example. If I run the following command, and hit one of the arrow keys, I get an error.
(defun foobar ()
(interactive)
(setq r (read-char)))
I've tried read-char
, read-event
and read-char-exclusive
with and without ignore-errors
. I've tried read-char-choice
and logic that looks for the vector result a cursor key would give. Nothing works (although I can handle return and backspace perfectly.)
What do I need to do? I don't need the cursor keys to do anything; I just need to make it safe to press them.
(defun foobar() (interactive) (setq r (read-char)))
– ump May 17 '15 at 13:26read-char
from the minibuffer. Normally, you do not need the minibuffer if you are usingread-char
, so please help us understand why you use that combination (e.g. what you are really trying to do). The minibuffer is a buffer. In the general case it allows multiple-char input and editing.read-char
pays no attention to what buffer is current, and it reads only one event. – Drew May 17 '15 at 14:06