unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Retrieve front-advance from make-overlay
@ 2007-01-14 21:04 Lennart Borgman (gmail)
  2007-01-15  1:23 ` Stefan Monnier
  0 siblings, 1 reply; 9+ messages in thread
From: Lennart Borgman (gmail) @ 2007-01-14 21:04 UTC (permalink / raw)


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.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Retrieve front-advance from make-overlay
  2007-01-14 21:04 Retrieve front-advance from make-overlay Lennart Borgman (gmail)
@ 2007-01-15  1:23 ` Stefan Monnier
  2007-01-15  1:29   ` Lennart Borgman (gmail)
  0 siblings, 1 reply; 9+ messages in thread
From: Stefan Monnier @ 2007-01-15  1:23 UTC (permalink / raw)
  Cc: Emacs Devel

> 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.


        Stefan


PS: The comment says "easily" because you can of course insert+remove a char
to check whether the position of the overlay's boundary stays "in front"
or not.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Retrieve front-advance from make-overlay
  2007-01-15  1:23 ` Stefan Monnier
@ 2007-01-15  1:29   ` Lennart Borgman (gmail)
  2007-01-15  7:20     ` David Kastrup
  0 siblings, 1 reply; 9+ messages in thread
From: Lennart Borgman (gmail) @ 2007-01-15  1:29 UTC (permalink / raw)
  Cc: Emacs Devel

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.


> 
>         Stefan
> 
> 
> PS: The comment says "easily" because you can of course insert+remove a char
> to check whether the position of the overlay's boundary stays "in front"
> or not.
> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Retrieve front-advance from make-overlay
  2007-01-15  1:29   ` Lennart Borgman (gmail)
@ 2007-01-15  7:20     ` David Kastrup
  2007-01-15  9:18       ` Lennart Borgman (gmail)
  0 siblings, 1 reply; 9+ messages in thread
From: David Kastrup @ 2007-01-15  7:20 UTC (permalink / raw)
  Cc: Stefan Monnier, Emacs Devel

"Lennart Borgman (gmail)" <lennart.borgman@gmail.com> 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.

-- 
David Kastrup

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Retrieve front-advance from make-overlay
  2007-01-15  7:20     ` David Kastrup
@ 2007-01-15  9:18       ` Lennart Borgman (gmail)
  2007-01-15  9:59         ` David Kastrup
  0 siblings, 1 reply; 9+ messages in thread
From: Lennart Borgman (gmail) @ 2007-01-15  9:18 UTC (permalink / raw)
  Cc: Stefan Monnier, Emacs Devel

David Kastrup wrote:
> "Lennart Borgman (gmail)" <lennart.borgman@gmail.com> 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.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Retrieve front-advance from make-overlay
  2007-01-15  9:18       ` Lennart Borgman (gmail)
@ 2007-01-15  9:59         ` David Kastrup
  2007-01-15 15:39           ` Stefan Monnier
  0 siblings, 1 reply; 9+ messages in thread
From: David Kastrup @ 2007-01-15  9:59 UTC (permalink / raw)
  Cc: Stefan Monnier, Emacs Devel

"Lennart Borgman (gmail)" <lennart.borgman@gmail.com> writes:

> David Kastrup wrote:
>> "Lennart Borgman (gmail)" <lennart.borgman@gmail.com> 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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Retrieve front-advance from make-overlay
  2007-01-15  9:59         ` David Kastrup
@ 2007-01-15 15:39           ` Stefan Monnier
  0 siblings, 0 replies; 9+ messages in thread
From: Stefan Monnier @ 2007-01-15 15:39 UTC (permalink / raw)
  Cc: Lennart Borgman (gmail), Emacs Devel

> It was untested, and naturally, it is wrong.  Both calls to
> move-overlay.  You have to use

> (move-overlay ov 1 1 (current-buffer))

I'd recommend to stay away from "1" and use (point-min) instead.
It won't make any difference here, but using "1" is generally a bad habit,
so better avoid it even when it'd be safe.


        Stefan

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Retrieve front-advance from make-overlay
@ 2007-01-17 17:19 Stuart D. Herring
  2007-01-17 18:57 ` Stefan Monnier
  0 siblings, 1 reply; 9+ messages in thread
From: Stuart D. Herring @ 2007-01-17 17:19 UTC (permalink / raw)
  Cc: Lennart Borgman, Stefan Monnier, Emacs Devel

[Sorry if this is a repeat post and/or doesn't go into the thread
properly; my mailer didn't like my first attempt.]

> 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 seems to me that you should put the overlay on a single character in a
buffer and then insert once on either side of that character.  Would a
0-length overlay with front-advance but not rear-advance actually sit on
the range n to n-1 if you inserted before it?

Davis

-- 
This product is sold by volume, not by mass.  If it appears too dense or
too sparse, it is because mass-energy conversion has occurred during
shipping.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Retrieve front-advance from make-overlay
  2007-01-17 17:19 Stuart D. Herring
@ 2007-01-17 18:57 ` Stefan Monnier
  0 siblings, 0 replies; 9+ messages in thread
From: Stefan Monnier @ 2007-01-17 18:57 UTC (permalink / raw)
  Cc: Lennart Borgman, Emacs Devel

> It seems to me that you should put the overlay on a single character in a
> buffer and then insert once on either side of that character.  Would a
> 0-length overlay with front-advance but not rear-advance actually sit on
> the range n to n-1 if you inserted before it?

IIRC: Yes :-(


        Stefan

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2007-01-17 18:57 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-01-14 21:04 Retrieve front-advance from make-overlay Lennart Borgman (gmail)
2007-01-15  1:23 ` Stefan Monnier
2007-01-15  1:29   ` Lennart Borgman (gmail)
2007-01-15  7:20     ` David Kastrup
2007-01-15  9:18       ` Lennart Borgman (gmail)
2007-01-15  9:59         ` David Kastrup
2007-01-15 15:39           ` Stefan Monnier
  -- strict thread matches above, loose matches on Subject: below --
2007-01-17 17:19 Stuart D. Herring
2007-01-17 18:57 ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).