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

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

Re: the second most recent key


From: David Kastrup
Subject: Re: the second most recent key
Date: Thu, 26 Oct 2006 19:54:30 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

vb <address@hidden> writes:

> On Thursday 26 October 2006 08:38, Kevin Rodgers wrote:
>> vb wrote:
>> > Is there a way to know what was the key pressed immediately before the
>> > last key pressed.
>> >
>> > Say there is a macro assigned to a certain key, and the function of this
>> > certain key depends on the key pressed immediately before the function
>> > was invoked.
>> >
>> > Is there a way to know what key that was?
>>
>> (let* ((recent-keys (recent-keys))
>>         (keys-length (length recent-keys))) ; should be 100
>>    (aref recent-keys (- keys-length (length (this-command-keys)) 1)))
>
> Kevin,
>
> thank you for spending your time writing this code. Looks like this
> is exactly what's needed, even accounting for the number of keys
> involved in the current command.
>
> Do I understand it right that Lisp allows local variable named
> exactly the same as a function (recent-keys in your example)? An
> interesting feature...

Not just local variables, but variables in general.  Lisp symbols have
a four-fold existence: they have a value, a function, a property list,
and a name.  You can access those with `symbol-value',
`symbol-function', `symbol-plist', and `symbol-name'.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum


reply via email to

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