help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Saving (and finding) markers (Was: Re: point moved despite save-excu


From: Eli Zaretskii
Subject: Re: Saving (and finding) markers (Was: Re: point moved despite save-excursion, after deleting/reinserting region)
Date: Thu, 18 Oct 2018 21:32:00 +0300

> From: "Garreau\, Alexandre" <galex-713@galex-713.eu>
> Cc: help-gnu-emacs@gnu.org
> Date: Thu, 18 Oct 2018 20:08:05 +0200
> 
> I’m unaware of what other side-effects might happens because of deleting
> and reinserting a region of text, but how, within a region, get all the
> markers?

You can't, because it makes no sense to do that.  Markers exist so
that you could _avoid_ doing this stuff by hand as much as possible.
If you are going to move markers by hand, you might as well not use
markers at all, or stop caring for those which happened to be there.

In general, Emacs already does the best it could with markers, when
text around them is edited; you are unlikely to do better.

I pointed you to replace-buffer-contents function, because AFAIU in
your situation it will modify the text while keeping as many markers
(including point) intact as possible.  Did you try using it?

> I guess these must be updated somehow when anything is changed, so there
> must be a list of them somewhere, thereas allowing to fetch them
> according a given region.

We don't expose the list of buffer's markers to Lisp.  There's
buffer-has-marker-at, but it's just a predicate.

> I’d like to try this method as it looks straightforward

I _really_ suggest to try replace-buffer-contents first.  It should do
the job cleanly and efficiently in many cases, and I very much doubt
that you could do better.



reply via email to

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