From: Arthur Gleckler Date: Wed, 31 Jul 1991 18:24:47 +0000 (+0000) Subject: Add INSERT-PARENTHESES and MOVE-PAST-CLOSE-AND-REINDENT and bind them to keys. X-Git-Tag: 20090517-FFI~10415 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=a970c968c9ec9bf3c55d384627c535021c66ff27;p=mit-scheme.git Add INSERT-PARENTHESES and MOVE-PAST-CLOSE-AND-REINDENT and bind them to keys. --- diff --git a/v7/src/edwin/lspcom.scm b/v7/src/edwin/lspcom.scm index ba7324f2e..2eee5727a 100644 --- a/v7/src/edwin/lspcom.scm +++ b/v7/src/edwin/lspcom.scm @@ -1,6 +1,6 @@ ;;; -*-Scheme-*- ;;; -;;; $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/edwin/lspcom.scm,v 1.152 1991/05/10 05:13:10 cph Exp $ +;;; $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/edwin/lspcom.scm,v 1.153 1991/07/31 18:24:47 arthur Exp $ ;;; ;;; Copyright (c) 1986, 1989-91 Massachusetts Institute of Technology ;;; @@ -221,6 +221,48 @@ rigidly along with this one." (lambda (mark) (lisp-indent-sexp mark))) +(define-command insert-parentheses + "Insert a pair of matching parentheses, leaving the point after the +open parenthesis. With argument, wrap parentheses around that many +following sexps.)" + "P" + (lambda (argument) + (if argument + (set-current-point! (skip-chars-forward " \t")) + (or (group-start? (current-point)) + (memv (char->syntax-code standard-syntax-table + (mark-left-char (current-point))) + '(#\\ #\> #\( #\space #\.)) + (insert-char #\space))) + (insert-char #\() + (let ((mark (mark-right-inserting-copy (current-point)))) + (insert-char #\) + (if (and argument + (exact-nonnegative-integer? argument)) + (forward-sexp (current-point) argument 'LIMIT) + (current-point))) + (or argument + (group-end? (current-point)) + (memv (char->syntax-code standard-syntax-table + (mark-right-char (current-point))) + '(#\\ #\> #\( #\) #\space)) + (insert-char #\space)) + (set-current-point! mark)))) + +(define-command move-past-close-and-reindent + "Move past next right parenthesis, delete indentation before it, and +indent after it." + () + (lambda () + (set-current-point! (mark-1+ (forward-up-list (current-point) 1 'limit))) + (let delete-more-indentation ((before-parenthesis (current-point))) + (if (mark= before-parenthesis + (horizontal-space-end (line-start (current-point) 0))) + (begin ((ref-command delete-indentation) #f) + (delete-more-indentation (current-point))))) + (move-thing mark+ 1) + ((ref-command newline-and-indent)))) + ;;;; Motion Covers (define forward-sexp)