dot/lisp-init.lisp, dot/shell-rc: Support CCL and ABCL as Lisp systems.
[profile] / dot / lisp-init.lisp
CommitLineData
7914c3fa
MW
1;;; -*-lisp-*-
2
152e7f69 3(cl:defpackage #:mdw-hacks
e623f041 4 (:use #:cl))
152e7f69
MW
5(cl:defparameter mdw-hacks::*previous-package* cl:*package*)
6(cl:in-package #:mdw-hacks)
d37d5787
MW
7
8;; Shut up.
1865da17
MW
9(setf *load-verbose* nil
10 *compile-verbose* nil)
5927034b
MW
11
12#+cmu
3ec148f0
MW
13(setf ext:*gc-verbose* nil
14 ext:*require-verbose* nil)
d37d5787 15
4e7092a3
MW
16#+ecl
17(let ((old-output *standard-output*)
18 (old-prompt si:*tpl-prompt-hook*))
19 ;; There doesn't seem to be a good way to do this, so we do it the bad
20 ;; way. Since the herald is printed to `*standard-outout*', we set (not
21 ;; bind!) that to a bit bucket, and then arrange to restore it just before
22 ;; the first REPL prompt is written.
23 ;;
24 ;; One more awful part is that, having intercepted the prompt hook, I need
25 ;; to restore and invoke the old version, and there isn't a clean way to do
26 ;; this.
27 (when (<= (ext:argc) 1)
28 (setf *standard-output* (make-broadcast-stream)
29 si:*tpl-prompt-hook* (lambda ()
30 (setf *standard-output* old-output
31 si:*tpl-prompt-hook* old-prompt)
32 (si::tpl-prompt)))))
33
6a8c8070
MW
34#+ccl
35(setf ccl::*inhibit-greeting* t)
36
297be13e
MW
37;; Obtain ASDF from somewhere.
38(require "asdf")
39
6a8c8070 40;; Get CMU CL and CCL to quit on EOF.
84739668
MW
41#+cmu
42(setf ext:*batch-mode* t)
6a8c8070
MW
43#+ccl
44(setf ccl:*quit-on-eof* t)
84739668 45
2498576b
MW
46;; Tell SBCL where to find its source source.
47#+sbcl
43ef52b8 48(sb-ext:set-sbcl-source-location #p"/usr/share/sbcl-source/")
2498576b 49
0ad84131 50;; Tell some Lisps about my home directory. CMU CL already has a search list
6a8c8070
MW
51;; which does the same job, and CCL sets up a logical-pathname host.
52#+(and unix (or sbcl clisp ecl abcl))
9af2290b 53(let* ((homestring (or #+sbcl (sb-ext:posix-getenv "HOME")
6a8c8070
MW
54 #+(or clisp ecl abcl) (ext:getenv "HOME")
55 #+abcl (java:jstatic "getProperty"
56 "java.lang.System"
57 "user.home")
9af2290b
MW
58 "/home/mdw"))
59 (home (pathname (concatenate 'string homestring "/"))))
ae8efc86 60 (setf (logical-pathname-translations "HOME")
fb65858f
MW
61 `(("HOME:**;*.*.*" ,(merge-pathnames "**/*.*" home nil)))))
62(when (#.(car '(#+clisp ext:probe-directory
63 probe-file))
64 #p"/usr/share/common-lisp/")
65 (setf (logical-pathname-translations "CL")
66 '(("CL:SOURCE;**;*.*.*" #p"/usr/share/common-lisp/source/**/*.*")
67 ("CL:SYSTEMS;**;*.*.*" #p"/usr/share/common-lisp/systems/**/*.*"))))
ae8efc86 68
62d12c1f 69;; Various fixings.
5927034b
MW
70#+clisp
71(setf custom:*parse-namestring-ansi* t)
62d12c1f 72
0630988a
MW
73;; CLisp history.
74#+(and clisp readline)
75(progn
76 (export '(*history-file* *history-size*))
77 (defvar *history-file* (format nil "~A/.clisp-history" (ext:getenv "HOME"))
78 "File to preserve the REPL history.")
79 (defvar *history-size* 1000)
80 (unless (and (probe-file *history-file*) nil)
81 (let (old-umask stream)
82 ;; Ugh. There's no proper open(2) veneer. Play with umask(2) to avoid
83 ;; a window in which an adversary can open the file.
84 (unwind-protect
85 (setf old-umask (os:umask #o077)
86 stream (open *history-file*
87 :direction :output
88 :if-exists :overwrite
89 :if-does-not-exist :create))
90 (when stream (close stream))
91 (when old-umask (os:umask old-umask)))))
92 (readline:read-history *history-file*)
93 (if *history-size* (readline:stifle-history *history-size*)
94 (readline:unstifle-history))
95 (push (lambda () (readline:write-history *history-file*))
96 custom:*fini-hooks*))
97
0712ae95
MW
98;; Don't choke on shebang lines. This isn't here so that we can run Lisp
99;; scripts like proper Unix programs: `cl-launch' or `runlisp' do that. It's
100;; here so that we can `load' a script into a running Lisp without it choking
101;; on the shebang.
86c2d6fd
MW
102(set-dispatch-macro-character
103 #\# #\!
9af2290b
MW
104 (lambda (stream char arg)
105 (declare (ignore char arg))
106 (values (read-line stream))))
86c2d6fd 107
d37d5787 108;; Start up swank.
e623f041 109(export 'crank-swank)
9af2290b
MW
110(defun crank-swank (&rest args)
111 (let ((swank (find-package "SWANK")))
112 (unless swank
d37d5787 113 (load "/usr/share/common-lisp/source/slime/swank-loader.lisp")
77619173 114 (funcall (find-symbol "INIT" (find-package "SWANK-LOADER")))
9af2290b
MW
115 (setf swank (find-package "SWANK")))
116 (set (find-symbol "*GLOBAL-DEBUGGER*" swank) nil)
117 (apply (find-symbol "CREATE-SERVER" swank) args)))
d37d5787 118
d9667bfa 119;; Treat warnings as, err, warnings.
5927034b
MW
120#+asdf
121(setf asdf:*compile-file-failure-behaviour* :warn)
502738c0 122
d37d5787 123;; Done.
6f7bbd84 124(pushnew :mdw *features*)
d37d5787 125;;#+(and cmu mp) (mp::startup-idle-and-top-level-loops)
152e7f69 126(setf *package* *previous-package*)