[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Retrieve front-advance from make-overlay
From: |
David Kastrup |
Subject: |
Re: Retrieve front-advance from make-overlay |
Date: |
Mon, 15 Jan 2007 10:59:44 +0100 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) |
"Lennart Borgman (gmail)" <address@hidden> writes:
> David Kastrup wrote:
>> "Lennart Borgman (gmail)" <address@hidden> writes:
>>
>>> Stefan Monnier wrote:
>>>>> Is it possible to retrieve from an overlay the parameters front-advance
>>>>> and
>>>>> rear-advance that was given to make-overlay?
>>>>> Without that it is not possible to make a new copy of an overlay AFAICS.
>>>> The source code of `copy-overlay' answers this question.
>>> Thanks. Indeed it does ;-) -- BTW copy-overlay is not mentioned in Info.
>>
>> (defun overlay-polarities (ov)
>> (let ((buf (overlay-buffer ov))
>> (start (overlay-start ov))
>> (end (overlay-end ov)))
>> (unwind-protect
>> (with-temp-buffer
>> (move-overlay ov 1 1)
>> (insert " ")
>> (list (> (overlay-start ov) 1)
>> (> (overlay-end ov) 1)))
>> (move-overlay ov buf start end))))
>>
>> This at least has the advantage of not touching the original buffer.
>> But it is tasteless nevertheless.
>
>
> Thanks David, I did not that one. I will try it.
It was untested, and naturally, it is wrong. Both calls to
move-overlay. You have to use
(move-overlay ov 1 1 (current-buffer))
and
(move-overlay ov start end buf)
instead, respectively. There are probably more errors: I still did
not test it.
It is basically just a sketch, but should be close to working.
--
David Kastrup