bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#13260: 24.3.50; save match data for core functions like `delete-char


From: Stefan Monnier
Subject: bug#13260: 24.3.50; save match data for core functions like `delete-char' and `delete-backward-char'?
Date: Sun, 23 Dec 2012 19:54:00 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

>>> I know the policy is to let any function assume the match data
>>> are not saved, but I think an exception would be useful here.
>> Why?
> Because delete-char is very low-level and because it is hard to
> guess why it would modify the match data -- hence very easy to
> assume it will not, while it does.

AFAIK delete-char does not modify the match-data any more than other
buffer-modifying operations (such as delete-region, insert, ...).
They all just modify the buffer, which is turn can modify the match-data
because it runs various hooks which can do all kinds of things.

> Principle of least surprise?

The rule "expect the match-data to be destroyed all the time" is the one
that leads to the least surprise.  99% of the functions can destroy the
match-data, even though they may preserve it in 99% of
the circumstances.

And in 99% of the cases where they do destroy the match-data, nobody
cares anyway, which is why we shouldn't always save-match-data.


        Stefan





reply via email to

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