2016-01-16 save-excursion changed semantics

Recently, when coding on a new Emacs (compiled from source), I stumbled upon a strange behavior of save-excursion: it didn’t restore the mark status. I was quite sure that it should do that, but – for lack of better ideas – I C-h f‘d it. And here is what I learned:

Before Emacs 25.1, ‘save-excursion’ used to save the mark state.
To save the marker state as well as the point and buffer, use
‘save-mark-and-excursion’.

It turns out that the new save-mark-and-excursion is a macro defined in simple.el.

I’d expect a few strange behaviors of my code now unless I replace some of save-excursion‘s with save-mark-and-excursion‘s. I just counted the occurrences of save-excursion in my files (using M-x rgrep and M-x how-many) and it was about 70. I guess I’ll have something to do soon…

Edit: as suggested by one of the readers in private email, this is most probably not something you should worry about too much – a vast majority of uses of save-excursion didn’t rely on it saving the mark position anyway. So please don’t panic, just remember that if your code starts to act weird, this might be a reason (which is possible, though rather unlikely).

CategoryEnglish, CategoryBlog, CategoryEmacs