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