Improve reftex-format-special
[bpt/emacs.git] / lisp / progmodes / scheme.el
1 ;;; scheme.el --- Scheme (and DSSSL) editing mode -*- lexical-binding: t; -*-
2
3 ;; Copyright (C) 1986-1988, 1997-1998, 2001-2014 Free Software
4 ;; Foundation, Inc.
5
6 ;; Author: Bill Rozas <jinx@martigny.ai.mit.edu>
7 ;; Adapted-by: Dave Love <d.love@dl.ac.uk>
8 ;; Keywords: languages, lisp
9
10 ;; This file is part of GNU Emacs.
11
12 ;; GNU Emacs is free software: you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation, either version 3 of the License, or
15 ;; (at your option) any later version.
16
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
21
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
24
25 ;;; Commentary:
26
27 ;; The major mode for editing Scheme-type Lisp code, very similar to
28 ;; the Lisp mode documented in the Emacs manual. `dsssl-mode' is a
29 ;; variant of scheme-mode for editing DSSSL specifications for SGML
30 ;; documents. [As of Apr 1997, some pointers for DSSSL may be found,
31 ;; for instance, at <URL:http://www.sil.org/sgml/related.html#dsssl>.]
32 ;; All these Lisp-ish modes vary basically in details of the language
33 ;; syntax they highlight/indent/index, but dsssl-mode uses "^;;;" as
34 ;; the page-delimiter since ^L isn't normally a valid SGML character.
35 ;;
36 ;; For interacting with a Scheme interpreter See also `run-scheme' in
37 ;; the `cmuscheme' package and also the implementation-specific
38 ;; `xscheme' package.
39
40 ;; Here's a recipe to generate a TAGS file for DSSSL, by the way:
41 ;; etags --lang=scheme --regex='/[ \t]*(\(mode\|element\)[ \t
42 ;; ]+\([^ \t(
43 ;; ]+\)/\2/' --regex='/[ \t]*(element[ \t
44 ;; ]*([^)]+[ \t
45 ;; ]+\([^)]+\)[ \t
46 ;; ]*)/\1/' --regex='/(declare[^ \t
47 ;; ]*[ \t
48 ;; ]+\([^ \t
49 ;; ]+\)/\1/' "$@"
50
51 ;;; Code:
52 \f
53 (require 'lisp-mode)
54
55 (defvar scheme-mode-syntax-table
56 (let ((st (make-syntax-table))
57 (i 0))
58 ;; Symbol constituents
59 ;; We used to treat chars 128-256 as symbol-constituent, but they
60 ;; should be valid word constituents (Bug#8843). Note that valid
61 ;; identifier characters are Scheme-implementation dependent.
62 (while (< i ?0)
63 (modify-syntax-entry i "_ " st)
64 (setq i (1+ i)))
65 (setq i (1+ ?9))
66 (while (< i ?A)
67 (modify-syntax-entry i "_ " st)
68 (setq i (1+ i)))
69 (setq i (1+ ?Z))
70 (while (< i ?a)
71 (modify-syntax-entry i "_ " st)
72 (setq i (1+ i)))
73 (setq i (1+ ?z))
74 (while (< i 128)
75 (modify-syntax-entry i "_ " st)
76 (setq i (1+ i)))
77
78 ;; Whitespace
79 (modify-syntax-entry ?\t " " st)
80 (modify-syntax-entry ?\n "> " st)
81 (modify-syntax-entry ?\f " " st)
82 (modify-syntax-entry ?\r " " st)
83 (modify-syntax-entry ?\s " " st)
84
85 ;; These characters are delimiters but otherwise undefined.
86 ;; Brackets and braces balance for editing convenience.
87 (modify-syntax-entry ?\[ "(] " st)
88 (modify-syntax-entry ?\] ")[ " st)
89 (modify-syntax-entry ?{ "(} " st)
90 (modify-syntax-entry ?} "){ " st)
91 (modify-syntax-entry ?\| "\" 23bn" st)
92 ;; Guile allows #! ... !# comments.
93 ;; But SRFI-22 defines the comment as #!...\n instead.
94 ;; Also Guile says that the !# should be on a line of its own.
95 ;; It's too difficult to get it right, for too little benefit.
96 ;; (modify-syntax-entry ?! "_ 2" st)
97
98 ;; Other atom delimiters
99 (modify-syntax-entry ?\( "() " st)
100 (modify-syntax-entry ?\) ")( " st)
101 ;; It's used for single-line comments as well as for #;(...) sexp-comments.
102 (modify-syntax-entry ?\; "< 2 " st)
103 (modify-syntax-entry ?\" "\" " st)
104 (modify-syntax-entry ?' "' " st)
105 (modify-syntax-entry ?` "' " st)
106
107 ;; Special characters
108 (modify-syntax-entry ?, "' " st)
109 (modify-syntax-entry ?@ "' " st)
110 (modify-syntax-entry ?# "' 14" st)
111 (modify-syntax-entry ?\\ "\\ " st)
112 st))
113 \f
114 (defvar scheme-mode-abbrev-table nil)
115 (define-abbrev-table 'scheme-mode-abbrev-table ())
116
117 (defvar scheme-imenu-generic-expression
118 '((nil
119 "^(define\\(\\|-\\(generic\\(\\|-procedure\\)\\|method\\)\\)*\\s-+(?\\(\\sw+\\)" 4)
120 ("Types"
121 "^(define-class\\s-+(?\\(\\sw+\\)" 1)
122 ("Macros"
123 "^(\\(defmacro\\|define-macro\\|define-syntax\\)\\s-+(?\\(\\sw+\\)" 2))
124 "Imenu generic expression for Scheme mode. See `imenu-generic-expression'.")
125
126 (defun scheme-mode-variables ()
127 (set-syntax-table scheme-mode-syntax-table)
128 (setq local-abbrev-table scheme-mode-abbrev-table)
129 (setq-local paragraph-start (concat "$\\|" page-delimiter))
130 (setq-local paragraph-separate paragraph-start)
131 (setq-local paragraph-ignore-fill-prefix t)
132 (setq-local fill-paragraph-function 'lisp-fill-paragraph)
133 ;; Adaptive fill mode gets in the way of auto-fill,
134 ;; and should make no difference for explicit fill
135 ;; because lisp-fill-paragraph should do the job.
136 (setq-local adaptive-fill-mode nil)
137 (setq-local indent-line-function 'lisp-indent-line)
138 (setq-local parse-sexp-ignore-comments t)
139 (setq-local outline-regexp ";;; \\|(....")
140 (setq-local add-log-current-defun-function #'lisp-current-defun-name)
141 (setq-local comment-start ";")
142 (setq-local comment-add 1)
143 (setq-local comment-start-skip ";+[ \t]*")
144 (setq-local comment-use-syntax t)
145 (setq-local comment-column 40)
146 (setq-local parse-sexp-ignore-comments t)
147 (setq-local lisp-indent-function 'scheme-indent-function)
148 (setq mode-line-process '("" scheme-mode-line-process))
149 (setq-local imenu-case-fold-search t)
150 (setq imenu-generic-expression scheme-imenu-generic-expression)
151 (setq-local imenu-syntax-alist
152 '(("+-*/.<>=?!$%_&~^:" . "w")))
153 (setq font-lock-defaults
154 '((scheme-font-lock-keywords
155 scheme-font-lock-keywords-1 scheme-font-lock-keywords-2)
156 nil t (("+-*/.<>=!?$%_&~^:" . "w") (?#. "w 14"))
157 beginning-of-defun
158 (font-lock-mark-block-function . mark-defun)
159 (font-lock-syntactic-face-function
160 . scheme-font-lock-syntactic-face-function)
161 (parse-sexp-lookup-properties . t)
162 (font-lock-extra-managed-props syntax-table)))
163 (setq-local lisp-doc-string-elt-property 'scheme-doc-string-elt))
164
165 (defvar scheme-mode-line-process "")
166
167 (defvar scheme-mode-map
168 (let ((smap (make-sparse-keymap))
169 (map (make-sparse-keymap "Scheme")))
170 (set-keymap-parent smap lisp-mode-shared-map)
171 (define-key smap [menu-bar scheme] (cons "Scheme" map))
172 (define-key map [run-scheme] '("Run Inferior Scheme" . run-scheme))
173 (define-key map [uncomment-region]
174 '("Uncomment Out Region" . (lambda (beg end)
175 (interactive "r")
176 (comment-region beg end '(4)))))
177 (define-key map [comment-region] '("Comment Out Region" . comment-region))
178 (define-key map [indent-region] '("Indent Region" . indent-region))
179 (define-key map [indent-line] '("Indent Line" . lisp-indent-line))
180 (put 'comment-region 'menu-enable 'mark-active)
181 (put 'uncomment-region 'menu-enable 'mark-active)
182 (put 'indent-region 'menu-enable 'mark-active)
183 smap)
184 "Keymap for Scheme mode.
185 All commands in `lisp-mode-shared-map' are inherited by this map.")
186
187 ;; Used by cmuscheme
188 (defun scheme-mode-commands (map)
189 ;;(define-key map "\t" 'indent-for-tab-command) ; default
190 (define-key map "\177" 'backward-delete-char-untabify)
191 (define-key map "\e\C-q" 'indent-sexp))
192 \f
193 ;;;###autoload
194 (define-derived-mode scheme-mode prog-mode "Scheme"
195 "Major mode for editing Scheme code.
196 Editing commands are similar to those of `lisp-mode'.
197
198 In addition, if an inferior Scheme process is running, some additional
199 commands will be defined, for evaluating expressions and controlling
200 the interpreter, and the state of the process will be displayed in the
201 mode line of all Scheme buffers. The names of commands that interact
202 with the Scheme process start with \"xscheme-\" if you use the MIT
203 Scheme-specific `xscheme' package; for more information see the
204 documentation for `xscheme-interaction-mode'. Use \\[run-scheme] to
205 start an inferior Scheme using the more general `cmuscheme' package.
206
207 Commands:
208 Delete converts tabs to spaces as it moves back.
209 Blank lines separate paragraphs. Semicolons start comments.
210 \\{scheme-mode-map}"
211 (scheme-mode-variables))
212
213 (defgroup scheme nil
214 "Editing Scheme code."
215 :link '(custom-group-link :tag "Font Lock Faces group" font-lock-faces)
216 :group 'lisp)
217
218 (defcustom scheme-mit-dialect t
219 "If non-nil, scheme mode is specialized for MIT Scheme.
220 Set this to nil if you normally use another dialect."
221 :type 'boolean
222 :group 'scheme)
223
224 (defcustom dsssl-sgml-declaration
225 "<!DOCTYPE style-sheet PUBLIC \"-//James Clark//DTD DSSSL Style Sheet//EN\">
226 "
227 "An SGML declaration for the DSSSL file.
228 If it is defined as a string this will be inserted into an empty buffer
229 which is in `dsssl-mode'. It is typically James Clark's style-sheet
230 doctype, as required for Jade."
231 :type '(choice (string :tag "Specified string")
232 (const :tag "None" :value nil))
233 :group 'scheme)
234
235 (defcustom scheme-mode-hook nil
236 "Normal hook run when entering `scheme-mode'.
237 See `run-hooks'."
238 :type 'hook
239 :group 'scheme)
240
241 (defcustom dsssl-mode-hook nil
242 "Normal hook run when entering `dsssl-mode'.
243 See `run-hooks'."
244 :type 'hook
245 :group 'scheme)
246
247 ;; This is shared by cmuscheme and xscheme.
248 (defcustom scheme-program-name "scheme"
249 "Program invoked by the `run-scheme' command."
250 :type 'string
251 :group 'scheme)
252
253 (defvar dsssl-imenu-generic-expression
254 ;; Perhaps this should also look for the style-sheet DTD tags. I'm
255 ;; not sure it's the best way to organize it; perhaps one type
256 ;; should be at the first level, though you don't see this anyhow if
257 ;; it gets split up.
258 '(("Defines"
259 "^(define\\s-+(?\\(\\sw+\\)" 1)
260 ("Modes"
261 "^\\s-*(mode\\s-+\\(\\(\\sw\\|\\s-\\)+\\)" 1)
262 ("Elements"
263 ;; (element foo ...) or (element (foo bar ...) ...)
264 ;; Fixme: Perhaps it should do `root'.
265 "^\\s-*(element\\s-+(?\\(\\(\\sw\\|\\s-\\)+\\))?" 1)
266 ("Declarations"
267 "^(declare\\(-\\sw+\\)+\\>\\s-+\\(\\sw+\\)" 2))
268 "Imenu generic expression for DSSSL mode. See `imenu-generic-expression'.")
269
270 (defconst scheme-font-lock-keywords-1
271 (eval-when-compile
272 (list
273 ;;
274 ;; Declarations. Hannes Haug <hannes.haug@student.uni-tuebingen.de> says
275 ;; this works for SOS, STklos, SCOOPS, Meroon and Tiny CLOS.
276 (list (concat "(\\(define\\*?\\("
277 ;; Function names.
278 "\\(\\|-public\\|-method\\|-generic\\(-procedure\\)?\\)\\|"
279 ;; Macro names, as variable names. A bit dubious, this.
280 "\\(-syntax\\|-macro\\)\\|"
281 ;; Class names.
282 "-class"
283 ;; Guile modules.
284 "\\|-module"
285 "\\)\\)\\>"
286 ;; Any whitespace and declared object.
287 ;; The "(*" is for curried definitions, e.g.,
288 ;; (define ((sum a) b) (+ a b))
289 "[ \t]*(*"
290 "\\(\\sw+\\)?")
291 '(1 font-lock-keyword-face)
292 '(6 (cond ((match-beginning 3) font-lock-function-name-face)
293 ((match-beginning 5) font-lock-variable-name-face)
294 (t font-lock-type-face))
295 nil t))
296 ))
297 "Subdued expressions to highlight in Scheme modes.")
298
299 (defconst scheme-font-lock-keywords-2
300 (append scheme-font-lock-keywords-1
301 (eval-when-compile
302 (list
303 ;;
304 ;; Control structures.
305 (cons
306 (concat
307 "(" (regexp-opt
308 '("begin" "call-with-current-continuation" "call/cc"
309 "call-with-input-file" "call-with-output-file" "case" "cond"
310 "do" "else" "for-each" "if" "lambda" "λ"
311 "let" "let*" "let-syntax" "letrec" "letrec-syntax"
312 ;; R6RS library subforms.
313 "export" "import"
314 ;; SRFI 11 usage comes up often enough.
315 "let-values" "let*-values"
316 ;; Hannes Haug <hannes.haug@student.uni-tuebingen.de> wants:
317 "and" "or" "delay" "force"
318 ;; Stefan Monnier <stefan.monnier@epfl.ch> says don't bother:
319 ;;"quasiquote" "quote" "unquote" "unquote-splicing"
320 "map" "syntax" "syntax-rules") t)
321 "\\>") 1)
322 ;;
323 ;; It wouldn't be Scheme w/o named-let.
324 '("(let\\s-+\\(\\sw+\\)"
325 (1 font-lock-function-name-face))
326 ;;
327 ;; David Fox <fox@graphics.cs.nyu.edu> for SOS/STklos class specifiers.
328 '("\\<<\\sw+>\\>" . font-lock-type-face)
329 ;;
330 ;; Scheme `:' and `#:' keywords as builtins.
331 '("\\<#?:\\sw+\\>" . font-lock-builtin-face)
332 ;; R6RS library declarations.
333 '("(\\(\\<library\\>\\)\\s-*(?\\(\\sw+\\)?"
334 (1 font-lock-keyword-face)
335 (2 font-lock-type-face))
336 )))
337 "Gaudy expressions to highlight in Scheme modes.")
338
339 (defvar scheme-font-lock-keywords scheme-font-lock-keywords-1
340 "Default expressions to highlight in Scheme modes.")
341
342 (defconst scheme-sexp-comment-syntax-table
343 (let ((st (make-syntax-table scheme-mode-syntax-table)))
344 (modify-syntax-entry ?\; "." st)
345 (modify-syntax-entry ?\n " " st)
346 (modify-syntax-entry ?# "'" st)
347 st))
348
349 (put 'lambda 'scheme-doc-string-elt 2)
350 ;; Docstring's pos in a `define' depends on whether it's a var or fun def.
351 (put 'define 'scheme-doc-string-elt
352 (lambda ()
353 ;; The function is called with point right after "define".
354 (forward-comment (point-max))
355 (if (eq (char-after) ?\() 2 0)))
356
357 (defun scheme-font-lock-syntactic-face-function (state)
358 (when (and (null (nth 3 state))
359 (eq (char-after (nth 8 state)) ?#)
360 (eq (char-after (1+ (nth 8 state))) ?\;))
361 ;; It's a sexp-comment. Tell parse-partial-sexp where it ends.
362 (save-excursion
363 (let ((pos (point))
364 (end
365 (condition-case err
366 (let ((parse-sexp-lookup-properties nil))
367 (goto-char (+ 2 (nth 8 state)))
368 ;; FIXME: this doesn't handle the case where the sexp
369 ;; itself contains a #; comment.
370 (forward-sexp 1)
371 (point))
372 (scan-error (nth 2 err)))))
373 (when (< pos (- end 2))
374 (put-text-property pos (- end 2)
375 'syntax-table scheme-sexp-comment-syntax-table))
376 (put-text-property (- end 1) end 'syntax-table '(12)))))
377 ;; Choose the face to use.
378 (lisp-font-lock-syntactic-face-function state))
379
380 ;;;###autoload
381 (define-derived-mode dsssl-mode scheme-mode "DSSSL"
382 "Major mode for editing DSSSL code.
383 Editing commands are similar to those of `lisp-mode'.
384
385 Commands:
386 Delete converts tabs to spaces as it moves back.
387 Blank lines separate paragraphs. Semicolons start comments.
388 \\{scheme-mode-map}
389 Entering this mode runs the hooks `scheme-mode-hook' and then
390 `dsssl-mode-hook' and inserts the value of `dsssl-sgml-declaration' if
391 that variable's value is a string."
392 (setq-local page-delimiter "^;;;") ; ^L not valid SGML char
393 ;; Insert a suitable SGML declaration into an empty buffer.
394 ;; FIXME: This should use `auto-insert-alist' instead.
395 (and (zerop (buffer-size))
396 (stringp dsssl-sgml-declaration)
397 (not buffer-read-only)
398 (insert dsssl-sgml-declaration))
399 (setq font-lock-defaults '(dsssl-font-lock-keywords
400 nil t (("+-*/.<>=?$%_&~^:" . "w"))
401 beginning-of-defun
402 (font-lock-mark-block-function . mark-defun)))
403 (setq-local add-log-current-defun-function #'lisp-current-defun-name)
404 (setq-local imenu-case-fold-search nil)
405 (setq imenu-generic-expression dsssl-imenu-generic-expression)
406 (setq-local imenu-syntax-alist '(("+-*/.<>=?$%_&~^:" . "w"))))
407
408 ;; Extra syntax for DSSSL. This isn't separated from Scheme, but
409 ;; shouldn't cause much trouble in scheme-mode.
410 (put 'element 'scheme-indent-function 1)
411 (put 'mode 'scheme-indent-function 1)
412 (put 'with-mode 'scheme-indent-function 1)
413 (put 'make 'scheme-indent-function 1)
414 (put 'style 'scheme-indent-function 1)
415 (put 'root 'scheme-indent-function 1)
416 (put 'λ 'scheme-indent-function 1)
417
418 (defvar dsssl-font-lock-keywords
419 (eval-when-compile
420 (list
421 ;; Similar to Scheme
422 (list "(\\(define\\(-\\w+\\)?\\)\\>[ ]*\\\((?\\)\\(\\sw+\\)\\>"
423 '(1 font-lock-keyword-face)
424 '(4 font-lock-function-name-face))
425 (cons
426 (concat "(\\("
427 ;; (make-regexp '("case" "cond" "else" "if" "lambda"
428 ;; "let" "let*" "letrec" "and" "or" "map" "with-mode"))
429 "and\\|c\\(ase\\|ond\\)\\|else\\|if\\|"
430 "l\\(ambda\\|et\\(\\|*\\|rec\\)\\)\\|map\\|or\\|with-mode"
431 "\\)\\>")
432 1)
433 ;; DSSSL syntax
434 '("(\\(element\\|mode\\|declare-\\w+\\)\\>[ ]*\\(\\sw+\\)"
435 (1 font-lock-keyword-face)
436 (2 font-lock-type-face))
437 '("(\\(element\\)\\>[ ]*(\\(\\S)+\\))"
438 (1 font-lock-keyword-face)
439 (2 font-lock-type-face))
440 '("\\<\\sw+:\\>" . font-lock-constant-face) ; trailing `:' c.f. scheme
441 ;; SGML markup (from sgml-mode) :
442 '("<\\([!?][-a-z0-9]+\\)" 1 font-lock-keyword-face)
443 '("<\\(/?[-a-z0-9]+\\)" 1 font-lock-function-name-face)))
444 "Default expressions to highlight in DSSSL mode.")
445
446 \f
447 (defvar calculate-lisp-indent-last-sexp)
448
449
450 ;; FIXME this duplicates almost all of lisp-indent-function.
451 ;; Extract common code to a subroutine.
452 (defun scheme-indent-function (indent-point state)
453 "Scheme mode function for the value of the variable `lisp-indent-function'.
454 This behaves like the function `lisp-indent-function', except that:
455
456 i) it checks for a non-nil value of the property `scheme-indent-function'
457 \(or the deprecated `scheme-indent-hook'), rather than `lisp-indent-function'.
458
459 ii) if that property specifies a function, it is called with three
460 arguments (not two), the third argument being the default (i.e., current)
461 indentation."
462 (let ((normal-indent (current-column)))
463 (goto-char (1+ (elt state 1)))
464 (parse-partial-sexp (point) calculate-lisp-indent-last-sexp 0 t)
465 (if (and (elt state 2)
466 (not (looking-at "\\sw\\|\\s_")))
467 ;; car of form doesn't seem to be a symbol
468 (progn
469 (if (not (> (save-excursion (forward-line 1) (point))
470 calculate-lisp-indent-last-sexp))
471 (progn (goto-char calculate-lisp-indent-last-sexp)
472 (beginning-of-line)
473 (parse-partial-sexp (point)
474 calculate-lisp-indent-last-sexp 0 t)))
475 ;; Indent under the list or under the first sexp on the same
476 ;; line as calculate-lisp-indent-last-sexp. Note that first
477 ;; thing on that line has to be complete sexp since we are
478 ;; inside the innermost containing sexp.
479 (backward-prefix-chars)
480 (current-column))
481 (let ((function (buffer-substring (point)
482 (progn (forward-sexp 1) (point))))
483 method)
484 (setq method (or (get (intern-soft function) 'scheme-indent-function)
485 (get (intern-soft function) 'scheme-indent-hook)))
486 (cond ((or (eq method 'defun)
487 (and (null method)
488 (> (length function) 3)
489 (string-match "\\`def" function)))
490 (lisp-indent-defform state indent-point))
491 ((integerp method)
492 (lisp-indent-specform method state
493 indent-point normal-indent))
494 (method
495 (funcall method state indent-point normal-indent)))))))
496
497 \f
498 ;;; Let is different in Scheme
499
500 ;; (defun scheme-would-be-symbol (string)
501 ;; (not (string-equal (substring string 0 1) "(")))
502
503 ;; (defun scheme-next-sexp-as-string ()
504 ;; ;; Assumes that it is protected by a save-excursion
505 ;; (forward-sexp 1)
506 ;; (let ((the-end (point)))
507 ;; (backward-sexp 1)
508 ;; (buffer-substring (point) the-end)))
509
510 ;; This is correct but too slow.
511 ;; The one below works almost always.
512 ;;(defun scheme-let-indent (state indent-point)
513 ;; (if (scheme-would-be-symbol (scheme-next-sexp-as-string))
514 ;; (scheme-indent-specform 2 state indent-point)
515 ;; (scheme-indent-specform 1 state indent-point)))
516
517 (defun scheme-let-indent (state indent-point normal-indent)
518 (skip-chars-forward " \t")
519 (if (looking-at "[-a-zA-Z0-9+*/?!@$%^&_:~]")
520 (lisp-indent-specform 2 state indent-point normal-indent)
521 (lisp-indent-specform 1 state indent-point normal-indent)))
522
523 ;; (put 'begin 'scheme-indent-function 0), say, causes begin to be indented
524 ;; like defun if the first form is placed on the next line, otherwise
525 ;; it is indented like any other form (i.e. forms line up under first).
526
527 (put 'begin 'scheme-indent-function 0)
528 (put 'case 'scheme-indent-function 1)
529 (put 'delay 'scheme-indent-function 0)
530 (put 'do 'scheme-indent-function 2)
531 (put 'lambda 'scheme-indent-function 1)
532 (put 'let 'scheme-indent-function 'scheme-let-indent)
533 (put 'let* 'scheme-indent-function 1)
534 (put 'letrec 'scheme-indent-function 1)
535 (put 'let-values 'scheme-indent-function 1) ; SRFI 11
536 (put 'let*-values 'scheme-indent-function 1) ; SRFI 11
537 (put 'sequence 'scheme-indent-function 0) ; SICP, not r4rs
538 (put 'let-syntax 'scheme-indent-function 1)
539 (put 'letrec-syntax 'scheme-indent-function 1)
540 (put 'syntax-rules 'scheme-indent-function 1)
541 (put 'syntax-case 'scheme-indent-function 2) ; not r5rs
542 (put 'library 'scheme-indent-function 1) ; R6RS
543
544 (put 'call-with-input-file 'scheme-indent-function 1)
545 (put 'with-input-from-file 'scheme-indent-function 1)
546 (put 'with-input-from-port 'scheme-indent-function 1)
547 (put 'call-with-output-file 'scheme-indent-function 1)
548 (put 'with-output-to-file 'scheme-indent-function 1)
549 (put 'with-output-to-port 'scheme-indent-function 1)
550 (put 'call-with-values 'scheme-indent-function 1) ; r5rs?
551 (put 'dynamic-wind 'scheme-indent-function 3) ; r5rs?
552 \f
553 ;;;; MIT Scheme specific indentation.
554
555 (if scheme-mit-dialect
556 (progn
557 (put 'fluid-let 'scheme-indent-function 1)
558 (put 'in-package 'scheme-indent-function 1)
559 (put 'local-declare 'scheme-indent-function 1)
560 (put 'macro 'scheme-indent-function 1)
561 (put 'make-environment 'scheme-indent-function 0)
562 (put 'named-lambda 'scheme-indent-function 1)
563 (put 'using-syntax 'scheme-indent-function 1)
564
565 (put 'with-input-from-string 'scheme-indent-function 1)
566 (put 'with-output-to-string 'scheme-indent-function 0)
567 (put 'with-values 'scheme-indent-function 1)
568
569 (put 'syntax-table-define 'scheme-indent-function 2)
570 (put 'list-transform-positive 'scheme-indent-function 1)
571 (put 'list-transform-negative 'scheme-indent-function 1)
572 (put 'list-search-positive 'scheme-indent-function 1)
573 (put 'list-search-negative 'scheme-indent-function 1)
574
575 (put 'access-components 'scheme-indent-function 1)
576 (put 'assignment-components 'scheme-indent-function 1)
577 (put 'combination-components 'scheme-indent-function 1)
578 (put 'comment-components 'scheme-indent-function 1)
579 (put 'conditional-components 'scheme-indent-function 1)
580 (put 'disjunction-components 'scheme-indent-function 1)
581 (put 'declaration-components 'scheme-indent-function 1)
582 (put 'definition-components 'scheme-indent-function 1)
583 (put 'delay-components 'scheme-indent-function 1)
584 (put 'in-package-components 'scheme-indent-function 1)
585 (put 'lambda-components 'scheme-indent-function 1)
586 (put 'lambda-components* 'scheme-indent-function 1)
587 (put 'lambda-components** 'scheme-indent-function 1)
588 (put 'open-block-components 'scheme-indent-function 1)
589 (put 'pathname-components 'scheme-indent-function 1)
590 (put 'procedure-components 'scheme-indent-function 1)
591 (put 'sequence-components 'scheme-indent-function 1)
592 (put 'unassigned\?-components 'scheme-indent-function 1)
593 (put 'unbound\?-components 'scheme-indent-function 1)
594 (put 'variable-components 'scheme-indent-function 1)))
595
596 (provide 'scheme)
597
598 ;;; scheme.el ends here