[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to test whether any code runs after same command invocation?

From: Michael Heerdegen
Subject: How to test whether any code runs after same command invocation?
Date: Fri, 14 Feb 2014 12:09:48 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)


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?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]