From: Michael Heerdegen <michael_heerdegen@web.de>
To: help-gnu-emacs@gnu.org
Subject: Re: Keybinding that cycles call to a function
Date: Fri, 27 Nov 2020 21:47:48 +0100 [thread overview]
Message-ID: <87h7pa5xxn.fsf@web.de> (raw)
In-Reply-To: trinity-d7d93dff-5c3d-416e-87cc-f405fd444da2-1606438841162@3c-app-mailcom-bs06
daniela-spit@gmx.it writes:
> If I have a function that takes a number. How can a make a
> keybinding that cycles through the values n = 0, 1, 2?
Evaluating (eq this-command last-command) will tell you if you have a
repeated call.
Then you will have to check for the current "state". If there is no way
to find out, you will have to "remember" the last state in some way.
There are several ways to do this. Simplest way (IMO): use a (special,
i.e. defvar'ed) variable.
There are also solutions for command repeating that check the last
invocation time, and only repeated invocations in a time less than some
time limit it count as repetition (similar to double mouse clicks).
Michael.
prev parent reply other threads:[~2020-11-27 20:47 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-27 1:00 Keybinding that cycles call to a function daniela-spit
2020-11-27 20:47 ` Michael Heerdegen [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=87h7pa5xxn.fsf@web.de \
--to=michael_heerdegen@web.de \
--cc=help-gnu-emacs@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).