scheme.el 21 KB

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