3 (cl:defpackage #:mdw-hacks
5 (cl:defparameter mdw-hacks::*previous-package* cl:*package*)
6 (cl:in-package #:mdw-hacks)
9 (setf *load-verbose* nil
10 *compile-verbose* nil)
13 (setf ext:*gc-verbose* nil
14 ext:*require-verbose* nil)
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.
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
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)
35 (setf ccl::*inhibit-greeting* t)
38 (setf ext:*warn-on-redefinition* nil)
40 ;; Obtain ASDF from somewhere.
43 ;; Get CMU CL and CCL to quit on EOF.
45 (setf ext:*batch-mode* t)
47 (setf ccl:*quit-on-eof* t)
49 ;; Tell SBCL where to find its source source.
51 (sb-ext:set-sbcl-source-location #p"/usr/share/sbcl-source/")
53 ;; Tell some Lisps about my home directory. CMU CL already has a search list
54 ;; which does the same job, and CCL sets up a logical-pathname host.
55 #+(and unix (or sbcl clisp ecl abcl))
56 (let* ((homestring (or #+sbcl (sb-ext:posix-getenv "HOME")
57 #+(or clisp ecl abcl) (ext:getenv "HOME")
58 #+abcl (java:jstatic "getProperty"
62 (home (pathname (concatenate 'string homestring "/"))))
63 (setf (logical-pathname-translations "HOME")
64 `(("HOME:**;*.*.*" ,(merge-pathnames "**/*.*" home nil)))))
65 (when (#.(car '(#+clisp ext:probe-directory
67 #p"/usr/share/common-lisp/")
68 (setf (logical-pathname-translations "CL")
69 '(("CL:SOURCE;**;*.*.*" #p"/usr/share/common-lisp/source/**/*.*")
70 ("CL:SYSTEMS;**;*.*.*" #p"/usr/share/common-lisp/systems/**/*.*"))))
74 (setf custom:*parse-namestring-ansi* t)
77 #+(and clisp readline)
79 (export '(*history-file* *history-size*))
80 (defvar *history-file* (format nil "~A/.clisp-history" (ext:getenv "HOME"))
81 "File to preserve the REPL history.")
82 (defvar *history-size* 1000)
83 (unless (and (probe-file *history-file*) nil)
84 (let (old-umask stream)
85 ;; Ugh. There's no proper open(2) veneer. Play with umask(2) to avoid
86 ;; a window in which an adversary can open the file.
88 (setf old-umask (os:umask #o077)
89 stream (open *history-file*
92 :if-does-not-exist :create))
93 (when stream (close stream))
94 (when old-umask (os:umask old-umask)))))
95 (readline:read-history *history-file*)
96 (if *history-size* (readline:stifle-history *history-size*)
97 (readline:unstifle-history))
98 (push (lambda () (readline:write-history *history-file*))
101 ;; Don't choke on shebang lines. This isn't here so that we can run Lisp
102 ;; scripts like proper Unix programs: `cl-launch' or `runlisp' do that. It's
103 ;; here so that we can `load' a script into a running Lisp without it choking
105 (set-dispatch-macro-character
107 (lambda (stream char arg)
108 (declare (ignore char arg))
109 (values (read-line stream))))
112 (export 'crank-swank)
113 (defun crank-swank (&rest args)
114 (let ((swank (find-package "SWANK")))
116 (load "/usr/share/common-lisp/source/slime/swank-loader.lisp")
117 (funcall (find-symbol "INIT" (find-package "SWANK-LOADER")))
118 (setf swank (find-package "SWANK")))
119 (set (find-symbol "*GLOBAL-DEBUGGER*" swank) nil)
120 (apply (find-symbol "CREATE-SERVER" swank) args)))
122 ;; Treat warnings as, err, warnings.
124 (setf asdf:*compile-file-failure-behaviour* :warn)
127 (pushnew :mdw *features*)
128 ;;#+(and cmu mp) (mp::startup-idle-and-top-level-loops)
129 (setf *package* *previous-package*)