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: Oleh Krehel
Subject: Re: save-excursion and the mark
Date: Tue, 24 Feb 2015 00:14:31 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

Stefan Monnier <address@hidden> writes:

>> I have a package that might be using the feature.
>
> Where and how?

It's at https://github.com/abo-abo/lispy. There's a bunch of functions
that manipulate the active region sexp-wise. Some of them might use the
fact that the mark is restored. I can't be sure until I get a
`save-excursion' version that doesn't touch the mark.

>
>> None of the tests were failing when I wrapped `save-excursion' like
>> this:
>
>>     (defmacro lispy-save-excursion (&rest body)
>>       "More intuitive (`save-excursion' BODY)."
>>       (declare (indent 0))
>>       `(let ((activep (region-active-p))
>>              (mark (mark))
>>              (out (save-excursion
>>                     ,@body)))
>>          (when activep
>>            (set-mark mark))
>>          (when (bolp)
>>            (back-to-indentation))
>>          out))
>

> Hmm... this seems to redundantly save&restore the mark.  What is this
> supposed to illustrate/test?

Supposing that you would disable the mark storing/restoring in
`save-excursion', I rewrote my code to save/restore the mark on top of
that. It didn't hurt the tests.

It was hard for me to write my own `save-excursion' in Elisp to
completely test it, since it's not obvious how it works when chunks of
text are deleted.

Oleh



reply via email to

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