unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: David Kastrup <dak@gnu.org>
Subject: Re: the second most recent key
Date: Thu, 26 Oct 2006 19:54:30 +0200	[thread overview]
Message-ID: <85odrzt12h.fsf@lola.goethe.zz> (raw)
In-Reply-To: mailman.282.1161884908.27805.help-gnu-emacs@gnu.org

vb <help-gnu-emacs@vsbe.com> 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

      parent reply	other threads:[~2006-10-26 17:54 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-25  7:45 pasting many times Bourgneuf Francois
2006-10-25 19:57 ` Eli Zaretskii
2006-10-25 22:41   ` the second most recent key vb
2006-10-25 23:03     ` Peter Dyballa
2006-10-25 23:14       ` vb
2006-10-26 15:38     ` Kevin Rodgers
2006-10-26 17:48       ` vb
     [not found]       ` <mailman.282.1161884908.27805.help-gnu-emacs@gnu.org>
2006-10-26 17:54         ` David Kastrup [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=85odrzt12h.fsf@lola.goethe.zz \
    --to=dak@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).