summaryrefslogtreecommitdiff
path: root/lib-src/startup.lisp
blob: e09d7322a301ee697c6ec6a51c46439731cdb4cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
;;; startup.lisp --- Lisp implementation configuration  -*- mode: lisp -*-

;;; Copyright (C) 2023  Sean Whitton <spwhitton@spwhitton.name>

;;; This file is free software; you can redistribute it and/or modify
;;; it under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3, or (at your option)
;;; any later version.

;;; This file is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.

;;; You should have received a copy of the GNU General Public License
;;; along with this program.  If not, see <https://www.gnu.org/licenses/>.

(require "asdf")
(in-package :cl-user)

#+package-local-nicknames
(let ((cl-user-file (merge-pathnames "src/dotfiles/lib-src/cl-user.lisp"
				     (user-homedir-pathname)))
      (cl-user-systems '(#:alexandria #:anaphora #:cl-ppcre #:consfigurator
			 #:named-readtables #:cl-interpol)))
  ;; We have to have them all the systems available in order to be able to
  ;; load cl-user.lisp, such that all packages are defined for the reader, and
  ;; all macro definitions are loaded for the compiler.
  (when (and (uiop:file-exists-p cl-user-file)
	     (every (lambda (s) (asdf:find-system s nil)) cl-user-systems))
    (mapc #'asdf:load-system cl-user-systems)

    (mapc #'use-package '(#:alexandria #:anaphora))
    (uiop:symbol-call '#:uiop/package-local-nicknames
		      '#:add-package-local-nickname '#:re '#:cl-ppcre)
    ;; Import everything in UIOP that can be imported without name conflicts.
    (do-external-symbols (symbol :uiop)
      (handler-case (import symbol)
	(package-error ())))

    (dolist (cons '((#:consfigurator

		     #:multiple-value-mapcan
		     #:lines #:unlines #:words #:unwords)))
      (let ((package (car cons)))
	(import (mapcar (lambda (s) (find-symbol (symbol-name s) package))
			(cdr cons)))))

    ;; Idea is to be free to build it up programmatically in cl-user.lisp.
    (unless (uiop:symbol-call '#:named-readtables '#:find-readtable :cl-user)
      (uiop:symbol-call '#:named-readtables '#:make-readtable :cl-user
			:merge '(:consfigurator)))

    ;; Load Swank if we have it in order to update its associations between
    ;; readtables and packages.
    (when (asdf:find-system "swank" nil)
      (asdf:load-system "swank"))
    ;; Want output indicating we had all the libraries.
    (load cl-user-file :verbose t)))


;;;; SBCL configuration

#+sbcl
(progn
  ;; Enable DROP-THEM restart for when we delete symbols from the exports list
  ;; in a DEFPACKAGE and then reevaluate that DEFPACKAGE.
  (setq *on-package-variance* '(:error t)))