emacs-devel
[Top][All Lists]
Advanced

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

Re: save-excursion and the mark


From: Magnar Sveen
Subject: Re: save-excursion and the mark
Date: Wed, 15 Apr 2015 04:14:04 +0000

There are millions of lines of elisp that you've never seen. Emacs is after all the eminently hackable editor. And you're making breaking changes to a core API out of a sense of cleanliness? You've now been made aware of one case where the change is harmful, and your conclusion is "this is the one case where it is harmful". No, it's the first case where it's been detected - and that's because expand-region is widely used by thousands of people - and thankfully it even has tests. People's code is going to break.

You are maintaining an API with many thousands of users. Don't break it. If you must, deprecate it. Introduce save-point, and add "You probably want to use save-point" to the docstring of save-excursion.


On Tue, Apr 14, 2015 at 10:17 PM Stefan Monnier <address@hidden> wrote:
> If you are indeed going forward with this change (why is that?),

There are various problems with the previous save-excursion semantics,
all linked to the mark-saving part of it, and this part is useless in
98% of the cases, useful in 1%, and harmful in 1%, so it's better to get
rid of it in my view.

Among the various problems, I actually fixed some recently (before
throwing out the code), but the remaining ones are ugly:
saving/restoring the mark includes saving/restoring the mark-active
state as well, and in the general case you'd also want to run the
(de)activate-mark-hook, which could break even more uses of
save-excursion which never expected it to run such hook code.

> then maybe we could get a save-mark function?

Since you're the only user so far, better write explicitly the exact
saving/restoring you need (especially since it's not obvious to me what
it is you really need, I guess you could start with something along the
lines of (cl-letf (((mark)) (mark-active mark-active)) ...)).


        Stefan

reply via email to

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