From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Michael Heerdegen Newsgroups: gmane.emacs.devel Subject: How to test whether any code runs after same command invocation? Date: Fri, 14 Feb 2014 12:09:48 +0100 Message-ID: <87eh36kl1f.fsf@web.de> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1392376218 22090 80.91.229.3 (14 Feb 2014 11:10:18 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 14 Feb 2014 11:10:18 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Feb 14 12:10:25 2014 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WEGf1-0004B5-TQ for ged-emacs-devel@m.gmane.org; Fri, 14 Feb 2014 12:10:24 +0100 Original-Received: from localhost ([::1]:51113 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WEGf1-0007Hp-FW for ged-emacs-devel@m.gmane.org; Fri, 14 Feb 2014 06:10:23 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43290) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WEGep-0007HY-Gm for emacs-devel@gnu.org; Fri, 14 Feb 2014 06:10:20 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WEGei-0002jH-7n for emacs-devel@gnu.org; Fri, 14 Feb 2014 06:10:11 -0500 Original-Received: from plane.gmane.org ([80.91.229.3]:45033) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WEGei-0002iV-1y for emacs-devel@gnu.org; Fri, 14 Feb 2014 06:10:04 -0500 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1WEGeh-0003pW-7A for emacs-devel@gnu.org; Fri, 14 Feb 2014 12:10:03 +0100 Original-Received: from ip-90-186-97-10.web.vodafone.de ([90.186.97.10]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 14 Feb 2014 12:10:03 +0100 Original-Received: from michael_heerdegen by ip-90-186-97-10.web.vodafone.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 14 Feb 2014 12:10:03 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 27 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: ip-90-186-97-10.web.vodafone.de User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) Cancel-Lock: sha1:OnEG8b83QbN14sJ7LmH9iO3QbUw= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:169602 Archived-At: 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.