[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [MIT-Scheme-devel] forcing left-insertion or right-insertion in Edwi
From: |
Taylor R. Campbell |
Subject: |
Re: [MIT-Scheme-devel] forcing left-insertion or right-insertion in Edwin |
Date: |
Tue, 27 Jun 2006 15:22:48 +0000 |
User-agent: |
IMAIL/1.21; Edwin/3.116; MIT-Scheme/7.7.90.+ |
The obvious solution is to mimic SAVE-EXCURSION, but to make a
right-inserting copy of the point instead of a left-inserting copy.
Why does SAVE-EXCURSION make a left-inserting copy of the point, but a
right-inserting copy of the mark?
This definition of SAVE-EXCURSION makes more sense to me, and more
closely mirrors that in GNU Emacs:
(define (save-excursion thunk)
(let ((point) (mark))
(dynamic-wind
(lambda ()
(set! point (mark-right-inserting-copy (current-point)))
(set! mark (mark-right-inserting-copy (current-mark))))
thunk
(lambda ()
(let ((point (set! point))
(mark (set! mark)))
(let ((buffer (mark-buffer point)))
(if (buffer-alive? buffer)
(begin (select-buffer buffer)
(set-current-point! point)
(set-current-mark! mark)))))))))