all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* erase-buffer and marker-position
@ 2013-02-26  4:11 Thorsten Jolitz
  2013-02-26  4:46 ` Stefan Monnier
  0 siblings, 1 reply; 3+ messages in thread
From: Thorsten Jolitz @ 2013-02-26  4:11 UTC (permalink / raw)
  To: help-gnu-emacs


Hi List, 

what is the canonical way to remember/restore the (relative) old
marker-position when a buffer is erased? Without any further action,
marker-position is '1' after a buffer is erased and new content was
inserted. Thats somehow logical behaviour, since in the empty buffer,
marker is at position 1, and the new content is inserted after the
marker.

However, in my use case the new content inserted after erasing the
buffer often is a superset (or subset) of the old content and may
contain the content around the old marker-position.

What I would need is a way to keep the marker at its position as if the
content before and after the marker would have been erased, and the new
content would have been inserted before and after the marker. That is
(with * -> marker-position):

,------------------
| old text before 
| amazing * theorem
| old text after
`------------------

gives

,------------------
| new text before 
| new text before 
| new text before 
| amazing * theorem
| new text after
| new text after
`------------------

after erasing and inserting, instead of

,------------------
| * new text before
| new text before 
| new text before 
| amazing theorem
| new text after
| new text after
`------------------

-- 
cheers,
Thorsten





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

* Re: erase-buffer and marker-position
  2013-02-26  4:11 erase-buffer and marker-position Thorsten Jolitz
@ 2013-02-26  4:46 ` Stefan Monnier
  2013-02-26  4:50   ` Thorsten Jolitz
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Monnier @ 2013-02-26  4:46 UTC (permalink / raw)
  To: help-gnu-emacs

> what is the canonical way to remember/restore the (relative) old
> marker-position when a buffer is erased?

You can try and be more careful about how the buffer is "rebuilt".
E.g. insert-file-content with the `replace' argument will try and notice
if only the beginning/end of the file was modified.

Another option is to turn the markers into bookmarks.


        Stefan




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

* Re: erase-buffer and marker-position
  2013-02-26  4:46 ` Stefan Monnier
@ 2013-02-26  4:50   ` Thorsten Jolitz
  0 siblings, 0 replies; 3+ messages in thread
From: Thorsten Jolitz @ 2013-02-26  4:50 UTC (permalink / raw)
  To: help-gnu-emacs

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> what is the canonical way to remember/restore the (relative) old
>> marker-position when a buffer is erased?
>
> You can try and be more careful about how the buffer is "rebuilt".
> E.g. insert-file-content with the `replace' argument will try and notice
> if only the beginning/end of the file was modified.
>
> Another option is to turn the markers into bookmarks.

Thanks, sounds like promising alternatives to 'erase', I will check them
out. 

-- 
cheers,
Thorsten




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

end of thread, other threads:[~2013-02-26  4:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-26  4:11 erase-buffer and marker-position Thorsten Jolitz
2013-02-26  4:46 ` Stefan Monnier
2013-02-26  4:50   ` Thorsten Jolitz

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.