all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* 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 --
     [not found] <mailman.4.1300646175.13228.help-gnu-emacs@gnu.org>
2011-03-21  8:45 ` Understanding save-excursion David Kastrup
2011-03-20 18:35 Deniz Dogan

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.