scheme.el 21 KB

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