From: Chris Hanson Date: Fri, 3 Feb 2017 01:37:59 +0000 (-0800) Subject: Reorganize and curate standard Scheme indentation rules. X-Git-Tag: mit-scheme-pucked-9.2.12~227^2~7 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=5c3106c1cf43d153a0082ee54273a20f2586c0ed;p=mit-scheme.git Reorganize and curate standard Scheme indentation rules. --- diff --git a/src/edwin/schmod.scm b/src/edwin/schmod.scm index e8bff1a9d..7ca1c7b4a 100644 --- a/src/edwin/schmod.scm +++ b/src/edwin/schmod.scm @@ -154,51 +154,96 @@ The following commands evaluate Scheme expressions: 1) state indent-point normal-indent)) +(define standard-scheme-indentations + `(;; R7RS keywords: + (begin . 0) + (case . 1) + (case-lambda . 0) + (cond-expand . 0) + (define . 1) + (define-library . 1) + (define-record-type . 3) + (define-syntax . 1) + (define-values . 1) + (delay . 0) + (delay-force . 0) + (do . 2) + (guard . 1) + (import . 0) + (lambda . 1) + (let . ,scheme-mode:indent-let-method) + (let* . 1) + (let*-syntax . 1) + (let*-values . 1) + (let-syntax . 1) + (let-values . 1) + (letrec . 1) + (letrec* . 1) + (letrec-syntax . 1) + (parameterize . 1) + (syntax-rules . ,scheme-mode:indent-let-method) + (unless . 1) + (when . 1) + + ;; R7RS procedures: + (call-with-current-continuation . 0) + (call-with-input-file . 1) + (call-with-output-file . 1) + (call-with-port . 1) + (call-with-values . 1) + (call/cc . 0) + (dynamic-wind . 3) + (with-exception-handler . 1) + (with-input-from-file . 1) + (with-output-to-file . 1) + + ;; SRFI keywords: + (and-let* . 1) + (receive . 2) + + ;; MIT/GNU Scheme keywords: + (declare . 0) + (define-structure . 1) + (fluid-let . 1) + (list-parser . 0) + (local-declare . 1) + (named-lambda . 1) + (object-parser . 0) + (vector-parser . 0) + + ;; MIT/GNU Scheme procedures: + (bind-condition-handler . 2) + (bind-restart . 3) + (call-with-append-file . 1) + (call-with-binary-append-file . 1) + (call-with-binary-input-file . 1) + (call-with-binary-output-file . 1) + (call-with-input-string . 1) + (call-with-output-string . 0) + (make-condition-type . 3) + (with-restart . 4) + (with-simple-restart . 2) + (within-continuation . 1) + )) + (define scheme-mode:indent-methods (make-string-table)) +(for-each (lambda (p) + (string-table-put! scheme-mode:indent-methods + (symbol->string (car p)) + (cdr p))) + standard-scheme-indentations) + +(define scheme-mode:indent-regexps + `(scheme-mode:indent-regexps + ("default" . #f) + ("def" . definition))) + (define (scheme-indent-method name method) (define-variable-local-value! (selected-buffer) (name->variable (symbol 'LISP-INDENT/ name) 'INTERN) - method)) - -(for-each (lambda (entry) - (for-each (lambda (name) - (string-table-put! scheme-mode:indent-methods - (symbol->string name) - (car entry))) - (cdr entry))) - `(;; R7RS: - (0 BEGIN COND-EXPAND) - (1 CALL-WITH-INPUT-FILE CALL-WITH-OUTPUT-FILE CALL-WITH-PORT - CALL-WITH-VALUES CASE CASE-LAMBDA GUARD LAMBDA LET* LET*-VALUES - LET-SYNTAX LET-VALUES LETREC LETREC* LETREC-SYNTAX PARAMETERIZE - UNLESS WHEN WITH-EXCEPTION-HANDLER WITH-INPUT-FROM-FILE - WITH-OUTPUT-TO-FILE) - (2 DO) - (3 DEFINE-RECORD-TYPE) - (,scheme-mode:indent-let-method LET SYNTAX-RULES) - - ;; SRFI - (1 AND-LET*) - (2 RECEIVE) - - ;; MIT/GNU Scheme: - (0 CALL-WITH-OUTPUT-STRING WITH-OUTPUT-TO-STRING) - (1 CALL-WITH-APPEND-FILE CALL-WITH-BINARY-APPEND-FILE - CALL-WITH-BINARY-INPUT-FILE CALL-WITH-BINARY-OUTPUT-FILE - CALL-WITH-INPUT-STRING DEFINE-STRUCTURE FLUID-LET LET*-SYNTAX - LIST-OF-TYPE? LOCAL-DECLARE NAMED-LAMBDA VECTOR-OF-TYPE? - WITH-INPUT-FROM-PORT WITH-INPUT-FROM-STRING WITH-OUTPUT-TO-PORT - WITHIN-CONTINUATION) - (2 BIND-CONDITION-HANDLER WITH-SIMPLE-RESTART) - (3 MAKE-CONDITION-TYPE) - (4 WITH-RESTART))) - -(define scheme-mode:indent-regexps - `(SCHEME-MODE:INDENT-REGEXPS - ("DEFAULT" . #F) - ("DEF" . DEFINITION))) + method)) ;;;; Completion