From a0697fd5aaccde5d23b6eae5b0e4e9b7c55ba3cf Mon Sep 17 00:00:00 2001 From: "Taylor R. Campbell" Date: Mon, 3 Jul 2006 19:41:23 +0000 Subject: [PATCH] Change SAVE-EXCURSION and SCREEN-WINDOW-CONFIGURATION to make right-inserting copies of the point, rather than left-inserting. This way, insertion of text at point inside the SAVE-EXCURSION region will have no effect on the original point. Change SAVE-EXCURSION to select the original buffer after the supplied thunk returns. Remove PAREDIT-SAVE-EXCURSION, whose functionality is now subsumed by the new SAVE-EXCURSION. --- v7/src/edwin/buffrm.scm | 8 +++++--- v7/src/edwin/curren.scm | 13 ++++++++----- v7/src/edwin/paredit.scm | 28 ++++++---------------------- 3 files changed, 19 insertions(+), 30 deletions(-) diff --git a/v7/src/edwin/buffrm.scm b/v7/src/edwin/buffrm.scm index bd1730ac1..b90cb492c 100644 --- a/v7/src/edwin/buffrm.scm +++ b/v7/src/edwin/buffrm.scm @@ -1,8 +1,10 @@ #| -*-Scheme-*- -$Id: buffrm.scm,v 1.62 2003/02/14 18:28:11 cph Exp $ +$Id: buffrm.scm,v 1.63 2006/07/03 19:41:23 riastradh Exp $ -Copyright 1986, 1989-2000, 2002 Massachusetts Institute of Technology +Copyright 1986,1989,1990,1991,1992,1993 Massachusetts Institute of Technology +Copyright 1994,1995,1996,1997,1998,1999 Massachusetts Institute of Technology +Copyright 2000,2002,2006 Massachusetts Institute of Technology This file is part of MIT/GNU Scheme. @@ -398,7 +400,7 @@ Automatically becomes local when set in any fashion." (let ((buffer (window-buffer window))) (make-saved-window buffer - (mark-left-inserting-copy (window-point window)) + (mark-right-inserting-copy (window-point window)) (let ((ring (buffer-mark-ring buffer))) (if (ring-empty? ring) #f diff --git a/v7/src/edwin/curren.scm b/v7/src/edwin/curren.scm index 688d1189c..a540da192 100644 --- a/v7/src/edwin/curren.scm +++ b/v7/src/edwin/curren.scm @@ -1,8 +1,10 @@ #| -*-Scheme-*- -$Id: curren.scm,v 1.147 2003/02/14 18:28:11 cph Exp $ +$Id: curren.scm,v 1.148 2006/07/03 19:41:22 riastradh Exp $ -Copyright 1986, 1989-2001 Massachusetts Institute of Technology +Copyright 1986,1989,1990,1991,1992,1993 Massachusetts Institute of Technology +Copyright 1994,1995,1996,1997,1998,1999 Massachusetts Institute of Technology +Copyright 2000,2001,2006 Massachusetts Institute of Technology This file is part of MIT/GNU Scheme. @@ -661,14 +663,15 @@ The buffer is guaranteed to be selected at that time." (mark-column (current-point))) (define (save-excursion thunk) - (let ((point (mark-left-inserting-copy (current-point))) + (let ((point (mark-right-inserting-copy (current-point))) (mark (mark-right-inserting-copy (current-mark)))) (thunk) (let ((buffer (mark-buffer point))) (if (buffer-alive? buffer) (begin - (set-buffer-point! buffer point) - (set-buffer-mark! buffer mark)))))) + (select-buffer buffer) + (set-current-point! point) + (set-current-mark! mark)))))) ;;;; Mark and Region diff --git a/v7/src/edwin/paredit.scm b/v7/src/edwin/paredit.scm index 6b10a29ea..5819009a8 100644 --- a/v7/src/edwin/paredit.scm +++ b/v7/src/edwin/paredit.scm @@ -1,6 +1,6 @@ #| -*-Scheme-*- -$Id: paredit.scm,v 1.6 2006/07/03 19:05:02 riastradh Exp $ +$Id: paredit.scm,v 1.7 2006/07/03 19:41:23 riastradh Exp $ This code is written by Taylor R. Campbell and placed in the Public Domain. All warranties are disclaimed. @@ -653,7 +653,7 @@ With a numerical prefix argument N, kill N S-expressions backward in (let ((state (current-parse-state))) (cond ((parse-state-in-string? state) (insert-char #\") - (paredit-save-excursion + (save-excursion (lambda () (insert-char #\space) (insert-char #\")))) @@ -666,8 +666,8 @@ With a numerical prefix argument N, kill N S-expressions backward in '(#\w #\_)) (memv (char-syntax (mark-right-char point)) '(#\w #\_)))) - (paredit-save-excursion (lambda () - (insert-char #\space)))) + (save-excursion (lambda () + (insert-char #\space)))) (else (undo-record-point!) (split-sexp-at-point)))))) @@ -690,7 +690,7 @@ With a numerical prefix argument N, kill N S-expressions backward in (new-open (mark-left-inserting-copy new-open))) (insert-char close-char new-close) (mark-temporary! new-close) - (paredit-save-excursion + (save-excursion (lambda () (if (not (char=? (char-syntax (mark-left-char new-open)) #\space)) @@ -721,7 +721,7 @@ Both must be lists, strings, or atoms; error if there is mismatch." (editor-error "S-expressions to join have intervenining text.")) (else - (paredit-save-excursion + (save-excursion (lambda () (join-sexps left-point right-point)))))))))) @@ -789,22 +789,6 @@ Both must be lists, strings, or atoms; error if there is mismatch." (insert-char close after) (insert-space #t (mark1+ after))) (set-current-point! point)))) - -(define (paredit-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))))))))) (define (insert-newline-preserving-comment #!optional mark) (let ((mark (if (default-object? mark) (current-point) mark))) -- 2.25.1