From: Paul Stoeber <paul.stoeber@stud.tu-ilmenau.de>
Subject: save-excursion doesn't save point?
Date: Sat, 8 Jun 2002 07:56:00 +0200 [thread overview]
Message-ID: <20020608055559.GA689668@bruegel.RZ.TU-Ilmenau.DE> (raw)
In GNU Emacs 21.2.1 (powerpc-unknown-linux-gnu)
of 2002-05-26 on xyz
configured using `configure --prefix=/e --without-x'
Important settings:
value of $LC_ALL: nil
value of $LC_COLLATE: nil
value of $LC_CTYPE: nil
value of $LC_MESSAGES: nil
value of $LC_MONETARY: nil
value of $LC_NUMERIC: nil
value of $LC_TIME: nil
value of $LANG: C
locale-coding-system: nil
default-enable-multibyte-characters: nil
;; This is my `*scratch*' buffer, and This is line 1.
;;
;;--- test line Alpha ---
;;--- test line Beta ---
;;
;; M-x eval-buffer. Go to test line "Alpha". C-a C-SPC C-n C-n.
;; ESC : (point). Result is 109. M-x shuffle-lines. The two
;; test lines are transposed now. The cursor rests on test line
;; "Beta". ESC : (point). Result is 58. Point has changed, but
;; shuffle-lines has only one body form, which is a save-excursion
;; form. Is that supposed to happen?
;; un-random used instead of random to make this test deterministic
(defun un-random (n)
(1- n))
(defun shuffle-lines (beg end)
"Randomly permute lines in region (all permutations equally likely)."
(interactive "r")
(save-excursion
(let ((n (count-lines beg end)))
(goto-char beg)
(while (> n 1)
(let ((r (un-random n)))
(if (zerop r);; special case for transpose-lines
nil
(set-mark (point))
(next-line r)
(transpose-lines 0)))
(next-line 1)
(setq n (1- n))))))
;; If you'd like to put this function into the main distribution,
;; don't forget to replace `un-random' with `random'.
next reply other threads:[~2002-06-08 5:56 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-06-08 5:56 Paul Stoeber [this message]
2002-06-08 7:01 ` save-excursion doesn't save point? Miles Bader
2002-06-08 7:28 ` Paul Stoeber
2002-06-08 8:35 ` Miles Bader
2002-06-11 17:11 ` Kevin Rodgers
2002-06-11 19:06 ` Miles Bader
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20020608055559.GA689668@bruegel.RZ.TU-Ilmenau.DE \
--to=paul.stoeber@stud.tu-ilmenau.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).