[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: |
Bastien |
Subject: |
bug#13260: 24.3.50; save match data for core functions like `delete-char' and `delete-backward-char'? |
Date: |
Mon, 24 Dec 2012 02:24:07 +0100 |
User-agent: |
Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.3.50 (gnu/linux) |
Hi Stefan,
Stefan Monnier <monnier@iro.umontreal.ca> writes:
> 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.
Okay.
>> 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.
That's fine -- but what about "should"?
For all the functions like (defun x () "..." (save-match-data ...))
the match data is saved. For 99% of these functions, it's a design
choice saying "these functions *should* save the match data". (Yes,
there are such functions!)
> 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.
I'm fine with a rule like "anything that modifies the buffer should
be assumed to destroy the match data" -- given your explanation above.
But I'm not convinced this should apply to all other functions.
--
Bastien