[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: save-excursion and the mark
From: |
Artur Malabarba |
Subject: |
Re: save-excursion and the mark |
Date: |
Tue, 24 Feb 2015 00:12:14 +0000 |
2015-02-23 23:14 GMT+00:00 Oleh Krehel <address@hidden>:
> 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.
I think the following should do it.
(cl-letf* (((point-marker))
((current-buffer)))
;; Your code here.
)
> 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 couldn't have hut the tests, given that it's redundant :-) (for now
at least).
> 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.
I think it just follows the point marker. Test the snippet above and
see if it works for you.
Re: save-excursion and the mark, Barry Warsaw, 2015/02/24