all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* save-excursion doesn't save point?
@ 2002-06-08  5:56 Paul Stoeber
  2002-06-08  7:01 ` Miles Bader
  0 siblings, 1 reply; 6+ messages in thread
From: Paul Stoeber @ 2002-06-08  5:56 UTC (permalink / 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'.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2002-06-11 19:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2002-06-08  8:35     ` Miles Bader
2002-06-11 17:11     ` Kevin Rodgers
2002-06-11 19:06       ` Miles Bader

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.