emacs+sbcl+slime搭建lisp环境

来源:互联网 发布:航悦淘宝上的冰冰精华 编辑:程序博客网 时间:2024/05/20 16:11

emacs+sbcl+slime搭建lisp环境

本文介绍搭建学习lisp的环境。
主要参考:
http://cliki.net/Getting%20Started
http://www.gigamonkeys.com/book/
http://www.jonathanfischer.net/modern-common-lisp-on-osx/
http://cnlox.is-programmer.com/posts/34114.html

好,下面上货:
1、首先安装emacs,可以在这里下载https://emacsformacosx.com/。
2、安装sbcl。
首先下载sbcl的安装包,然后执行如下命令(参考:http://www.jonathanfischer.net/modern-common-lisp-on-osx/):
$ cd Downloads/$ tar xjf sbcl-1.0.29-x86-darwin-binary-r2.tar.bz2$ cd sbcl-1.0.29-x86-darwin$ sudo sh install.sh
3、查看是否安装成功,执行sbcl命令:


4、安装quicklisp,参考这里:http://www.jonathanfischer.net/modern-common-lisp-on-osx/

5、安装slime(参考官方即可)

6、安装完成后,需要把这三个关联到一起,修改emacs的启动文件:
(custom-set-variables ;; custom-set-variables was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. '(add-to-list (quote custom-theme-load-path) t) '(tool-bar-mode nil) '(tooltip-mode nil))(custom-set-faces ;; custom-set-faces was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. );;;;slime configure(setq inferior-lisp-program "/usr/local/bin/sbcl");设置优先使用哪种Common Lisp实现(add-to-list 'load-path "~/.emacs.d/slime");设置Slime路径(require 'slime)(slime-setup)(require 'slime-autoloads)(slime-setup '(slime-fancy slime-banner));;显示行号(global-linum-mode t)

7、尝试编写一个hello world程序。
进入emacs 编辑一个新文件test.lisp
(princ "hello world"

8、在emacs中使用 M-x slime

9、看到命令提示符后,输入如下内容:
(load "~/Project/lisp/project/test.lisp")

10、查看输入结果: