[Top][All Lists]

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

Re: find-file-noselect needs save-match-data

From: Herbert Euler
Subject: Re: find-file-noselect needs save-match-data
Date: Fri, 15 Jun 2007 09:59:18 +0800

> Excuse me but just another question: as Stefan said, 99% of
> non-trivial functions use regexps, does it mean that these 99%
> non-trivial functions shall not be put on the hooks that may be run
> between two regexp-sensitive functions/commands unless the putter
> saves match-data?

Normally, none of these functions will ever be put on a hook.
OTOH they may be called from other functions which are put on hooks.
It's the responsibility of *those* functions to use save-match-data.

Just like in the OP: find-file-noselect is not put on any hook.  It's some
other function from type-break which is put on a hook, so if there is a bug
it's in this other function, not in find-file-noselect.

Yes, this is the reason that I got wrong result (I mean some function
is put on a hook and it invokes functions like `find-file-noselect').
And the functions (like `find-file-noselect') are indeed not proper to
be put on a hook.

> Btw, `post-command-hook' is the source of the original problem.

Indeed.  If the problem you posted is considered as a bug (I wouldn't
consider it as such), then a possible fix is the patch below:

I did execute them as several single expressions, with several single
interactive commands.  As you said, "there's a lot of code executed
between each interactive command, so of course the match data can't be
assumed to be preserved."  This also convinces me that the problem I
posted is not a bug, although it may cause a surprise.  (I'm not sure
whether it's worthy to make it more clear to users, to avoid such a
surprising result.  Or I was too stupid not to understand the

Saving interesting match data immediately after invoking matching
functions, is that a good usage to avoid error caused by match data
changing?  If so, it seems to be an overall solution.

Thank you.

Guanpeng Xu

FREE pop-up blocking with the new MSN Toolbar - get it now! http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/

reply via email to

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