all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* How to test whether any code runs after same command invocation?
@ 2014-02-14 11:09 Michael Heerdegen
  2014-02-14 14:27 ` Stefan Monnier
  0 siblings, 1 reply; 10+ messages in thread
From: Michael Heerdegen @ 2014-02-14 11:09 UTC (permalink / raw)
  To: emacs-devel

Hello,

This is a simple task I face quite often: Consider some piece of code
runs at different times, and you want to distinguish whether the last
time this code was run was before the current command invocation or not
(i.e., whether the code was run multiple times for the same command -
I mean the same command _call_).

Example: I use some code that propertizes any dired buffer in a way that
the mouse tooltip over any directory shows the directory contents.
Since that can take a long time for huge directory hierarchies, I want
to use a timeout.  But if you have marked files you operate on, the code
is run multiple times when refreshing the files' lines, so the timeout
must be relative to command invocation, it must not be reset to 0 when
the code is run anew.

I currently do this by (defvar counter 0) and adding a fun to
post-command-hook that increases the counter.  Is there a cleverer way?
Something of the form

(eq foo (setq foo (clever-expression)))

without the need to push to any hook?

Thanks!

Michael.




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

end of thread, other threads:[~2014-02-15 12:25 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-14 11:09 How to test whether any code runs after same command invocation? Michael Heerdegen
2014-02-14 14:27 ` Stefan Monnier
2014-02-14 15:08   ` Michael Heerdegen
2014-02-14 17:15     ` Stefan Monnier
2014-02-14 17:42       ` Michael Heerdegen
2014-02-14 20:55         ` Stefan Monnier
2014-02-15 10:46           ` Michael Heerdegen
2014-02-14 18:41       ` Thien-Thi Nguyen
2014-02-15 10:36         ` Michael Heerdegen
2014-02-15 12:25           ` Thien-Thi Nguyen

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.