From: Paul Stoeber <paul.stoeber@stud.tu-ilmenau.de>
Cc: bug-gnu-emacs@gnu.org
Subject: Re: save-excursion doesn't save point?
Date: Sat, 8 Jun 2002 09:28:43 +0200 [thread overview]
Message-ID: <20020608072843.GA689936@bruegel.RZ.TU-Ilmenau.DE> (raw)
In-Reply-To: <87hekep83a.fsf@tc-1-100.kawasaki.gol.ne.jp>
On Sat, Jun 08, 2002 at 07:01:30AM +0000, Miles Bader wrote:
> paul.stoeber@stud.tu-ilmenau.de (Paul Stoeber) writes:
> > ;; Point has changed, but shuffle-lines has only one body form, which
> > ;; is a save-excursion form. Is that supposed to happen?
>
> Yes.
>
> save-excursion doesn't work by saving a character number, but setting a
> marker at the old point-location, and restoring to the marker later.
>
> If you insert or delete text adjacent to a marker, it will end up shoved
> to one side or the other -- and transpose-lines works by deleting and
> inserting.
>
> -Miles
> --
> [|nurgle|] ddt- demonic? so quake will have an evil kinda setting? one that
> will make every christian in the world foamm at the mouth?
> [iddt] nurg, that's the goal
>
> _______________________________________________
> Bug-gnu-emacs mailing list
> Bug-gnu-emacs@gnu.org
> http://mail.gnu.org/mailman/listinfo/bug-gnu-emacs
Thank you very much.
I use shuffle-lines to shuffle my music playlist.
It could be generally useful. Emacs already has shuffle-vector.
(defun shuffle-lines (beg end)
"Randomly permute lines in region (all permutations equally likely)."
(interactive "r")
(let ((pt (point)) (mk (mark)) (n (count-lines beg end)))
(goto-char beg)
(while (> n 1)
(let ((r (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)))
(goto-char pt)
(set-mark mk)))
---
We beg your acceptance of this elegant thimble.
-- Dodo
next prev parent reply other threads:[~2002-06-08 7:28 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-06-08 5:56 save-excursion doesn't save point? Paul Stoeber
2002-06-08 7:01 ` Miles Bader
2002-06-08 7:28 ` Paul Stoeber [this message]
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=20020608072843.GA689936@bruegel.RZ.TU-Ilmenau.DE \
--to=paul.stoeber@stud.tu-ilmenau.de \
--cc=bug-gnu-emacs@gnu.org \
/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).