help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

last-input-event and X/non-X


From: Tim X
Subject: last-input-event and X/non-X
Date: Sat, 26 Aug 2006 18:31:41 +1000
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.50 (gnu/linux)

I have some code which uses last-input-event to test what was last
entered by the user. However, I've noticed that this value can vary
depending on whether you are running under X or within a console. I'm
wondering what the standard emacs lisp idiom is for handling this. 

As an example, I have some code in a conditional which is like

((= last-input-event 127)
 (do-somehting))

Under the console, this block will execute if the user hits backspace
to indicate a character has been deleted. However, if I execute this
code under X, I will get a wrong-type-argument number-or-marker-p
backspace error. This is because under X, rather than a number,
last-input-event will hold the symbol 'backspace. 

Now, I could fix this by doing something like
((or (eq last-input-event 127) 
     (eq last-input-event 'backspace)) 
 (do-something)) 

but that seems a bit clunky to me. Also, I'm not sure how well this
will work with other character sets or encodings or on other
platforms, like Windows. 

Any advice appreciated.

thanks,

Tim

-- 
tcross (at) rapttech dot com dot au


reply via email to

[Prev in Thread] Current Thread [Next in Thread]