[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Keybinding that cycles call to a function
From: |
Michael Heerdegen |
Subject: |
Re: Keybinding that cycles call to a function |
Date: |
Fri, 27 Nov 2020 21:47:48 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
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.