Commit | Line | Data |
---|---|---|
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 | ||
9d5669bc MW |
37 | #+abcl |
38 | (setf ext:*warn-on-redefinition* nil) | |
39 | ||
297be13e MW |
40 | ;; Obtain ASDF from somewhere. |
41 | (require "asdf") | |
42 | ||
6a8c8070 | 43 | ;; Get CMU CL and CCL to quit on EOF. |
84739668 MW |
44 | #+cmu |
45 | (setf ext:*batch-mode* t) | |
6a8c8070 MW |
46 | #+ccl |
47 | (setf ccl:*quit-on-eof* t) | |
84739668 | 48 | |
2498576b MW |
49 | ;; Tell SBCL where to find its source source. |
50 | #+sbcl | |
43ef52b8 | 51 | (sb-ext:set-sbcl-source-location #p"/usr/share/sbcl-source/") |
2498576b | 52 | |
967daef9 MW |
53 | ;; Get SBCL to shut up about package variance. This is a standard result of |
54 | ;; my approach to symbol exports, and I don't care. | |
55 | #+sbcl | |
56 | (progn | |
57 | (unless (fboundp 'real-note-package-variance) | |
58 | (setf (symbol-function 'real-note-package-variance) | |
59 | (symbol-function 'sb-impl::note-package-variance))) | |
60 | (handler-bind ((sb-ext:package-lock-violation #'continue) | |
61 | (sb-kernel:redefinition-warning #'muffle-warning)) | |
62 | (defun sb-impl::note-package-variance | |
63 | (&rest args &key package &allow-other-keys) | |
64 | (let ((ignore (getf sb-ext:*on-package-variance* :ignore))) | |
65 | (unless (or (eq ignore t) | |
66 | (and (listp ignore) | |
67 | (member (package-name package) ignore))) | |
68 | (apply #'real-note-package-variance args))))) | |
69 | (setf sb-ext:*on-package-variance* '(:ignore t))) | |
70 | ||
0ad84131 | 71 | ;; Tell some Lisps about my home directory. CMU CL already has a search list |
6a8c8070 MW |
72 | ;; which does the same job, and CCL sets up a logical-pathname host. |
73 | #+(and unix (or sbcl clisp ecl abcl)) | |
9af2290b | 74 | (let* ((homestring (or #+sbcl (sb-ext:posix-getenv "HOME") |
6a8c8070 MW |
75 | #+(or clisp ecl abcl) (ext:getenv "HOME") |
76 | #+abcl (java:jstatic "getProperty" | |
77 | "java.lang.System" | |
78 | "user.home") | |
9af2290b MW |
79 | "/home/mdw")) |
80 | (home (pathname (concatenate 'string homestring "/")))) | |
ae8efc86 | 81 | (setf (logical-pathname-translations "HOME") |
fb65858f MW |
82 | `(("HOME:**;*.*.*" ,(merge-pathnames "**/*.*" home nil))))) |
83 | (when (#.(car '(#+clisp ext:probe-directory | |
84 | probe-file)) | |
85 | #p"/usr/share/common-lisp/") | |
86 | (setf (logical-pathname-translations "CL") | |
87 | '(("CL:SOURCE;**;*.*.*" #p"/usr/share/common-lisp/source/**/*.*") | |
88 | ("CL:SYSTEMS;**;*.*.*" #p"/usr/share/common-lisp/systems/**/*.*")))) | |
ae8efc86 | 89 | |
62d12c1f | 90 | ;; Various fixings. |
5927034b MW |
91 | #+clisp |
92 | (setf custom:*parse-namestring-ansi* t) | |
62d12c1f | 93 | |
0630988a MW |
94 | ;; CLisp history. |
95 | #+(and clisp readline) | |
96 | (progn | |
97 | (export '(*history-file* *history-size*)) | |
98 | (defvar *history-file* (format nil "~A/.clisp-history" (ext:getenv "HOME")) | |
99 | "File to preserve the REPL history.") | |
100 | (defvar *history-size* 1000) | |
101 | (unless (and (probe-file *history-file*) nil) | |
102 | (let (old-umask stream) | |
103 | ;; Ugh. There's no proper open(2) veneer. Play with umask(2) to avoid | |
104 | ;; a window in which an adversary can open the file. | |
105 | (unwind-protect | |
106 | (setf old-umask (os:umask #o077) | |
107 | stream (open *history-file* | |
108 | :direction :output | |
109 | :if-exists :overwrite | |
110 | :if-does-not-exist :create)) | |
111 | (when stream (close stream)) | |
112 | (when old-umask (os:umask old-umask))))) | |
113 | (readline:read-history *history-file*) | |
114 | (if *history-size* (readline:stifle-history *history-size*) | |
115 | (readline:unstifle-history)) | |
116 | (push (lambda () (readline:write-history *history-file*)) | |
117 | custom:*fini-hooks*)) | |
118 | ||
0712ae95 MW |
119 | ;; Don't choke on shebang lines. This isn't here so that we can run Lisp |
120 | ;; scripts like proper Unix programs: `cl-launch' or `runlisp' do that. It's | |
121 | ;; here so that we can `load' a script into a running Lisp without it choking | |
122 | ;; on the shebang. | |
86c2d6fd MW |
123 | (set-dispatch-macro-character |
124 | #\# #\! | |
9af2290b MW |
125 | (lambda (stream char arg) |
126 | (declare (ignore char arg)) | |
127 | (values (read-line stream)))) | |
86c2d6fd | 128 | |
ad7f3752 MW |
129 | ;; Use double-precision by default. |
130 | (setf *read-default-float-format* 'double-float) | |
131 | ||
e33edd60 | 132 | ;; Start up Swank. |
e623f041 | 133 | (export 'crank-swank) |
9af2290b MW |
134 | (defun crank-swank (&rest args) |
135 | (let ((swank (find-package "SWANK"))) | |
136 | (unless swank | |
d37d5787 | 137 | (load "/usr/share/common-lisp/source/slime/swank-loader.lisp") |
77619173 | 138 | (funcall (find-symbol "INIT" (find-package "SWANK-LOADER"))) |
9af2290b MW |
139 | (setf swank (find-package "SWANK"))) |
140 | (set (find-symbol "*GLOBAL-DEBUGGER*" swank) nil) | |
141 | (apply (find-symbol "CREATE-SERVER" swank) args))) | |
d37d5787 | 142 | |
d9667bfa | 143 | ;; Treat warnings as, err, warnings. |
5927034b MW |
144 | #+asdf |
145 | (setf asdf:*compile-file-failure-behaviour* :warn) | |
502738c0 | 146 | |
d37d5787 | 147 | ;; Done. |
6f7bbd84 | 148 | (pushnew :mdw *features*) |
d37d5787 | 149 | ;;#+(and cmu mp) (mp::startup-idle-and-top-level-loops) |
152e7f69 | 150 | (setf *package* *previous-package*) |