unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Keybinding that cycles call to a function
@ 2020-11-27  1:00 daniela-spit
  2020-11-27 20:47 ` Michael Heerdegen
  0 siblings, 1 reply; 2+ messages in thread
From: daniela-spit @ 2020-11-27  1:00 UTC (permalink / raw)
  To: Help Gnu Emacs

If I have a function that takes a number.  How can a make a
keybinding that cycles through the values n  = 0, 1, 2?

(defun fn (n)
   (interactive "n Enter Value: ")
   body-of-func)



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Keybinding that cycles call to a function
  2020-11-27  1:00 Keybinding that cycles call to a function daniela-spit
@ 2020-11-27 20:47 ` Michael Heerdegen
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Heerdegen @ 2020-11-27 20:47 UTC (permalink / raw)
  To: help-gnu-emacs

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.




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-11-27 20:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-27  1:00 Keybinding that cycles call to a function daniela-spit
2020-11-27 20:47 ` Michael Heerdegen

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).