[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

save-excursion doesn't save point?

From: Paul Stoeber
Subject: save-excursion doesn't save point?
Date: Sat, 8 Jun 2002 07:56:00 +0200
User-agent: Mutt/1.3.28i

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")
    (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
            (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'.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]