Showing revision 1

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 most 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…

CategoryEnglish, CategoryBlog, CategoryEmacs