From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Paul Stoeber Newsgroups: gmane.emacs.bugs Subject: save-excursion doesn't save point? Date: Sat, 8 Jun 2002 07:56:00 +0200 Sender: bug-gnu-emacs-admin@gnu.org Message-ID: <20020608055559.GA689668@bruegel.RZ.TU-Ilmenau.DE> NNTP-Posting-Host: localhost.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1023515843 17789 127.0.0.1 (8 Jun 2002 05:57:23 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Sat, 8 Jun 2002 05:57:23 +0000 (UTC) Return-path: Original-Received: from fencepost.gnu.org ([199.232.76.164]) by main.gmane.org with esmtp (Exim 3.33 #1 (Debian)) id 17GZE2-0004co-00 for ; Sat, 08 Jun 2002 07:57:23 +0200 Original-Received: from localhost ([127.0.0.1] helo=fencepost.gnu.org) by fencepost.gnu.org with esmtp (Exim 3.34 #1 (Debian)) id 17GZDm-0003BR-00; Sat, 08 Jun 2002 01:57:06 -0400 Original-Received: from bruegel.rz.tu-ilmenau.de ([141.24.190.37]) by fencepost.gnu.org with esmtp (Exim 3.34 #1 (Debian)) id 17GZCE-00035k-00 for ; Sat, 08 Jun 2002 01:55:30 -0400 Original-Received: (from past-in@localhost) by bruegel.rz.tu-ilmenau.de (SGI-8.9.3/8.9.3) id HAA03600 for bug-gnu-emacs@gnu.org; Sat, 8 Jun 2002 07:56:02 +0200 (MDT) Original-To: bug-gnu-emacs@gnu.org Content-Disposition: inline User-Agent: Mutt/1.3.28i Errors-To: bug-gnu-emacs-admin@gnu.org X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.0.9 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Bug reports for GNU Emacs, the Swiss army knife of text editors List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.emacs.bugs:1871 X-Report-Spam: http://spam.gmane.org/gmane.emacs.bugs:1871 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'.