* Understanding save-excursion
@ 2011-03-20 18:35 Deniz Dogan
0 siblings, 0 replies; 2+ messages in thread
From: Deniz Dogan @ 2011-03-20 18:35 UTC (permalink / raw)
To: emacs-help
Why isn't point and mark restored after calling this function?
(defun mark-paragraph-and-sort-lines ()
(interactive "*")
(save-excursion
(mark-paragraph)
(sort-lines nil (point) (mark))))
--
Deniz Dogan
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Understanding save-excursion
[not found] <mailman.4.1300646175.13228.help-gnu-emacs@gnu.org>
@ 2011-03-21 8:45 ` David Kastrup
0 siblings, 0 replies; 2+ messages in thread
From: David Kastrup @ 2011-03-21 8:45 UTC (permalink / raw)
To: help-gnu-emacs
Deniz Dogan <deniz.a.m.dogan@gmail.com> writes:
> Why isn't point and mark restored after calling this function?
>
> (defun mark-paragraph-and-sort-lines ()
> (interactive "*")
> (save-excursion
> (mark-paragraph)
> (sort-lines nil (point) (mark))))
What makes you think they aren't restored? Point and mark are saved in
_pointers_, and pointers move along with text that is copied.
This would presumably do what you want if point was saved in a
rear-sticky pointer and mark in a front-sticky pointer. Or just in
integers.
As it is, it is not all too clear what happens when you transfer
material to and from the boundaries of the region.
--
David Kastrup
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-03-21 8:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-20 18:35 Understanding save-excursion Deniz Dogan
[not found] <mailman.4.1300646175.13228.help-gnu-emacs@gnu.org>
2011-03-21 8:45 ` David Kastrup
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).