Lisp: Move sbclrc helpers to :ambrevar system.
parent
2a87387690
commit
5bb213037a
|
@ -24,4 +24,6 @@
|
|||
(:import-from #:unix-opts)
|
||||
;; Top-level packages:
|
||||
(:use-reexport
|
||||
#:ambrevar/shell))
|
||||
#:ambrevar/debug
|
||||
#:ambrevar/shell
|
||||
#:ambrevar/syspack))
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
(uiop:define-package #:ambrevar/debug
|
||||
(:documentation "Progamming helpers")
|
||||
(:use :common-lisp)
|
||||
(:import-from #:serapeum #:export-always)
|
||||
(:import-from #:cl-ppcre))
|
||||
(in-package #:ambrevar/debug)
|
||||
|
||||
;; TODO: Implement SLY function instead.
|
||||
;; https://github.com/joaotavora/sly/issues/362
|
||||
(export-always 'trace-all)
|
||||
(defun trace-all (regexp &optional (package *package*))
|
||||
(let ((package (if (packagep package)
|
||||
package
|
||||
(uiop:ensure-package package)))
|
||||
(result nil))
|
||||
(do-symbols (s package)
|
||||
(when (and (eq (symbol-package s) package)
|
||||
(ppcre:scan regexp (string s)))
|
||||
(push s result)))
|
||||
(eval `(trace ,@result))))
|
|
@ -0,0 +1,36 @@
|
|||
(uiop:define-package #:ambrevar/syspack
|
||||
(:documentation "ASDF and package management helpers")
|
||||
(:use :common-lisp)
|
||||
(:import-from #:serapeum #:export-always))
|
||||
(in-package #:ambrevar/syspack)
|
||||
|
||||
(export-always 'exported-symbols)
|
||||
(declaim (ftype (function ((or symbol package))) exported-symbols))
|
||||
(defun exported-symbols (package)
|
||||
"List exported symbols of PACKAGE."
|
||||
(let ((package (if (packagep package)
|
||||
package
|
||||
(find-package package)))
|
||||
(symbols))
|
||||
(do-external-symbols (s package symbols)
|
||||
(when (eq (symbol-package s) package)
|
||||
(push s symbols)))
|
||||
symbols))
|
||||
|
||||
(export-always 'system-depends-on)
|
||||
(declaim (ftype (function (string)) system-depends-on))
|
||||
(defun system-depends-on (system)
|
||||
"List SYSTEM dependencies, even if SYSTEM is an inferred system.
|
||||
From: https://gitlab.common-lisp.net/asdf/asdf/issues/10#note_5018."
|
||||
(let (depends)
|
||||
(labels ((iter (openlist)
|
||||
(if (null openlist) depends
|
||||
;; Is this a subsystem of SYSTEM?
|
||||
(let ((find (search system (first openlist))))
|
||||
(if (and find (zerop find))
|
||||
(iter (append (asdf:system-depends-on (asdf:find-system (first openlist))) (rest openlist)))
|
||||
;; If not, it's a direct dependency: collect it.
|
||||
(progn
|
||||
(pushnew (first openlist) depends :test 'equalp)
|
||||
(iter (rest openlist))))))))
|
||||
(iter (list system)))))
|
56
.sbclrc
56
.sbclrc
|
@ -1,9 +1,5 @@
|
|||
;; -*- mode: common-lisp; -*-
|
||||
|
||||
;; WARNING: Changing the *print-case* may break some packages, e.g. Mito.
|
||||
;; Also see https://www.cliki.net/Case%20sensitivity.
|
||||
;; (setf *print-case* :downcase)
|
||||
|
||||
;;; The following lines added by ql:add-to-init-file:
|
||||
;; #-quicklisp
|
||||
;; (let ((quicklisp-init (merge-pathnames ".quicklisp/setup.lisp"
|
||||
|
@ -14,9 +10,9 @@
|
|||
;; Some OSes package Lisp compilers in a way that ASDF is not automatically loaded.
|
||||
(require "asdf")
|
||||
|
||||
(uiop:define-package ambrevar
|
||||
(:use :cl))
|
||||
(in-package :ambrevar)
|
||||
(uiop:define-package #:guix
|
||||
(:use :common-lisp))
|
||||
(in-package #:guix)
|
||||
|
||||
(export '*guix-profiles-dir*)
|
||||
(defvar *guix-profiles-dir* "~/.guix-extra-profiles/"
|
||||
|
@ -52,52 +48,6 @@ The actual profiles are in the subsubdirectories.")
|
|||
;; Set it by default.
|
||||
(set-cffi-library-dirs)
|
||||
|
||||
(export 'exported-symbols)
|
||||
(declaim (ftype (function ((or symbol package))) exported-symbols))
|
||||
(defun exported-symbols (package)
|
||||
"List exported symbols of PACKAGE."
|
||||
(let ((package (if (packagep package)
|
||||
package
|
||||
(find-package package)))
|
||||
(symbols))
|
||||
(do-external-symbols (s package symbols)
|
||||
(when (eq (symbol-package s) package)
|
||||
(push s symbols)))
|
||||
symbols))
|
||||
|
||||
(export 'system-depends-on)
|
||||
(declaim (ftype (function (string)) system-depends-on))
|
||||
(defun system-depends-on (system)
|
||||
"List SYSTEM dependencies, even if SYSTEM is an inferred system.
|
||||
From: https://gitlab.common-lisp.net/asdf/asdf/issues/10#note_5018."
|
||||
(let (depends)
|
||||
(labels ((iter (openlist)
|
||||
(if (null openlist) depends
|
||||
;; Is this a subsystem of SYSTEM?
|
||||
(let ((find (search system (first openlist))))
|
||||
(if (and find (zerop find))
|
||||
(iter (append (asdf:system-depends-on (asdf:find-system (first openlist))) (rest openlist)))
|
||||
;; If not, it's a direct dependency: collect it.
|
||||
(progn
|
||||
(pushnew (first openlist) depends :test 'equalp)
|
||||
(iter (rest openlist))))))))
|
||||
(iter (list system)))))
|
||||
|
||||
(export 'trace-all)
|
||||
(defun trace-all (regexp &optional (package *package*)) ; TODO: Implement SLY function instead.
|
||||
(asdf:load-system :cl-ppcre)
|
||||
(let ((package (if (packagep package)
|
||||
package
|
||||
(uiop:ensure-package package)))
|
||||
(result nil))
|
||||
(do-symbols (s package)
|
||||
(when (and (eq (symbol-package s) package)
|
||||
(funcall (symbol-function (find-symbol (string 'scan)
|
||||
(find-package 'ppcre)))
|
||||
regexp (string s)))
|
||||
(push s result)))
|
||||
(eval `(trace ,@result))))
|
||||
|
||||
(in-package :cl-user)
|
||||
|
||||
;; Uncomment the following to increase the debug details.
|
||||
|
|
Loading…
Reference in New Issue