slime for mit scheme
很多人写过 Scheme 开发环境的设置。但 Scheme 毕竟是一种 Lisp ,是 Lisp 就应该用 Slime。 Chicken Scheme 有一个扩展叫 Chicken Slime, 安装非常简单,但功能极差。安装之后几乎没用。 Slime本身带的,contrib目录下的swank-kawa.scm swank-larceny.scm swank-mit-scheme.scm 一个都不能用。 好在这位先生修复了对Mit Scheme的支持。照他指导安装就可以用了。 但他说 "也可以将修复过的swank.scm删掉最后一行直接替换Mit Scheme源代码里面的swank.scm,重新编译Mit Scheme。"我试过,不行。另外Slime的最新版也不行。我用2.4版才行。 除了照他的指导设置 ~/.scheme.init 和 ~/.emacs 之外,再在 ~/.emacs 上添加以下内容增加Slime对Scheme的语法高亮和自动缩进: ;; 因为修改过的swank与slime版本不匹配 (setq slime-protocol-version 'ignore) ;; 因为slime默认的语法高亮是用于 Common Lisp 的,而我们要的是 Scheme 的语法高亮 ;; 这是从 scheme.el 直接复制过来的。 (defun scheme-mode-font-lock-setup () (interactive) (setq local-abbrev-table scheme-mode-abbrev-table) (set (make-local-variable 'paragraph-start) (concat "$\\|" page-delimiter)) (set (make-local-variable 'paragraph-separate) paragraph-start) (set (make-local-variable 'paragraph-ignore-fill-prefix) t) (set (make-local-variable 'fill-paragraph-function) 'lisp-fill-paragraph) ;; Adaptive fill mode gets in the way of auto-fill, ;; and should make no difference for explicit fill ;; because lisp-fill-paragraph should do the job. (set (make-local-variable 'adaptive-fill-mode) nil) (set (make-local-variable 'indent-line-function) 'lisp-indent-line) (set (make-local-variable 'parse-sexp-ignore-comments) t) (set (make-local-variable 'outline-regexp) ";;; \\|(....") (set (make-local-variable 'comment-start) ";") (set (make-local-variable 'comment-add) 1) ;; Look within the line for a ; following an even number of backslashes ;; after either a non-backslash or the line beginning. (set (make-local-variable 'comment-start-skip) "\\(\\(^\\|[^\\\\\n]\\)\\(\\\\\\\\\\)*\\);+[ \t]*") (set (make-local-variable 'font-lock-comment-start-skip) ";+ *") (set (make-local-variable 'comment-column) 40) (set (make-local-variable 'parse-sexp-ignore-comments) t) (set (make-local-variable 'lisp-indent-function) 'scheme-indent-function) (setq mode-line-process '("" scheme-mode-line-process)) (set (make-local-variable 'imenu-case-fold-search) t) (setq imenu-generic-expression scheme-imenu-generic-expression) (set (make-local-variable 'imenu-syntax-alist) '(("+-*/.<>=?!$%_&~^:" . "w"))) (setq ;;(make-local-variable 'font-lock-defaults) font-lock-defaults '((scheme-font-lock-keywords scheme-font-lock-keywords-1 scheme-font-lock-keywords-2) nil t (("+-*/.<>=!?$%_&~^:" . "w") (?#. "w 14")) beginning-of-defun (font-lock-mark-block-function . mark-defun) (font-lock-syntactic-face-function . scheme-font-lock-syntactic-face-function) (parse-sexp-lookup-properties . t) (font-lock-extra-managed-props syntax-table))) (set (make-local-variable 'lisp-doc-string-elt-property) 'scheme-doc-string-elt)) ;; 把 slime-repl 的语法高亮设成 Scheme 的 (add-hook 'slime-repl-mode-hook (lambda () (font-lock-mode nil) (scheme-mode-font-lock-setup) (font-lock-mode t))) ;; 把 slime-repl 的自动缩进设置成 Scheme 的 (add-hook 'slime-repl-mode-hook (lambda () (setq lisp-indent-function 'scheme-indent-function)))![]()