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: Mon, 23 Feb 2015 12:34:19 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

Stefan Monnier <address@hidden> writes:

> `save-excursion' is defined to save&restore the mark (as well as its
> being active or not).
>
> But I'm having a hard time finding a piece of code where we actually
> make use of this.  Can someone point me to such code (either in Emacs or
> in some external package)?  I.e. point me to code which would misbehave
> if save-excursion were to stop saving&restoring the mark (and/or its
> activation status).

I have a package that might be using the feature. 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))

I can test `save-excursion' again if you modify it.

Oleh






reply via email to

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