all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / 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

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.