unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Michael Heerdegen <michael_heerdegen@web.de>
Cc: emacs-devel@gnu.org
Subject: Re: How to test whether any code runs after same command invocation?
Date: Fri, 14 Feb 2014 12:15:12 -0500	[thread overview]
Message-ID: <jwvob29oc4f.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <87d2ip91gp.fsf@web.de> (Michael Heerdegen's message of "Fri, 14 Feb 2014 16:08:06 +0100")

>> > 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
>> Not sure I understand.  Do you use after-change-functions, by any
>> chance?
> I after-advice dired-insert-set-properties.

Then why is the code run multiple times?

> I didn't want to cope with that.  Also, this was just an example, I have
> other, quite different use cases of the raised issue.

The general idea might still apply: try and make it lazier.  E.g. change
your code so that rather than doing the job right away, it just writes
down somewhere what jobs needs to be done, and then later (e.g. in
post-command-hook, jit-lock, timer, you name it) look at what was
written down (if anything) and do it then, once.
Of course, it can't always be done.

> What's that?

"Wall clock" is this thing that you can get from your watch, your phone,
or the `current-time' function ;-)


        Stefan



  reply	other threads:[~2014-02-14 17:15 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvob29oc4f.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    --cc=michael_heerdegen@web.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

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