Skip to content

Commit

Permalink
Add el lib
Browse files Browse the repository at this point in the history
  • Loading branch information
jcs090218 committed Oct 22, 2024
1 parent f9bab01 commit e90211e
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 31 deletions.
36 changes: 36 additions & 0 deletions lisp/_el_lib.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
;;; _el_lib.el --- Emacs Lisp Layer
;;; Commentary:
;;; Code:

;;
;;; Includes

(require "uiop")

;;
;;; Core

(defun qob-el-2str (object)
"Convert to string."
(cond ((stringp object) object)
((pathnamep object) (namestring object))
(t (format nil "~A" object))))

(defun qob-el-memq (elt list)
"Mimic `memq' function."
(member elt list :test #'eq))

(defun qob-el-member (elt list)
"Mimic `member' function."
(member elt list :test #'string=))

(defun qob-el-file-name-directory (filename)
"Return the directory component in file name FILENAME."
(setq filename (qob-el-2str filename))
(let ((dir (directory-namestring filename))
(dirve (char filename 0)))
(if (uiop:os-windows-p)
(concatenate 'string (string dirve) ":" dir)
dir)))

;;; End of _el_lib.lisp
34 changes: 10 additions & 24 deletions lisp/_prepare.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -95,25 +95,12 @@ Argument ENV-NAME is used to get the argument string."
(defvar qob-quicklisp-installed-p (uiop:getenv "QOB_QUICKLISP_INSTALLED")
"Return non-nil if Quicklisp is already installed.")

;;
;;; Elisp Layer

(defun qob-el-memq (elt list)
"Mimic `memq' function."
(member elt list :test #'eq))

(defun qob-el-member (elt list)
"Mimic `member' function."
(member elt list :test #'string=))

;;
;;; Utils

(defun qob-2str (object)
"Convert to string."
(cond ((stringp object) object)
((pathnamep object) (namestring object))
(t (format nil "~A" object))))
(apply #'qob-el-2str object))

(defun qob--sinr (len-or-list form-1 form-2)
"If LEN-OR-LIST has length of 1; return FORM-1, else FORM-2."
Expand Down Expand Up @@ -175,7 +162,7 @@ the `qob-start' execution.")
(ultralisp . "http://dist.ultralisp.org/"))
"Mapping of source name and url.")

(defun qob-install-quicklisp ()
(defun qob-init-ql ()
"Install Quicklisp if not installed."
(let* ((quicklisp-dir (uiop:merge-pathnames* "quicklisp/" qob-dot))
(quicklisp-init (uiop:merge-pathnames* "setup.lisp" quicklisp-dir)))
Expand Down Expand Up @@ -203,7 +190,7 @@ If optional argument WITH-TEST is non-nil; include test ASD files as well."

(defun qob-load-system (filename)
"Load the system from ASD's FILENAME; and return the registered name."
(let ((dir (uiop:pathname-parent-directory-pathname filename))
(let ((dir (qob-el-file-name-directory filename))
(file (pathname-name filename)))
(push dir asdf:*central-registry*)
(asdf:load-system file)
Expand All @@ -213,15 +200,14 @@ If optional argument WITH-TEST is non-nil; include test ASD files as well."
"Return a system of given NAME."
(asdf/system-registry:registered-system name))

(defun qob-setup ()
(defun qob-init-system ()
"Setup the system."
(qob-install-quicklisp)
;; (let ((files (qob-asd-files t)))
;; (mapc (lambda (file)
;; (qob-load-system file)
;; (qob-info "Load ASD file ~A" file))
;; files))
)
(qob-init-ql)
(let ((files (qob-asd-files t)))
(mapc (lambda (file)
(qob-load-system file)
(qob-info "Load ASD file ~A" file))
files)))

;;
;;; Externals
Expand Down
2 changes: 1 addition & 1 deletion lisp/core/dists.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

;;; Code

(qob-setup)
(qob-init-ql)

(defun qob-dists--print (dists)
"Print list of dists."
Expand Down
8 changes: 4 additions & 4 deletions lisp/core/install.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@

;;; Code

(qob-setup)
(qob-init-ql)

;; TODO: Install package.

(ql:quickload "vecto")
(dolist (name qob-args)
(qob-info "Installing package ~A..." name)
(ql:quickload name))

;;; End of core/install.lisp
6 changes: 4 additions & 2 deletions src/utils.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ Argument CMD is used to extract positional arguments and options."

(defun call-script (script cmd)
"Run the lisp implementation with the SCRIPT and CMD."
(let ((prepare (lisp-script "_prepare"))
(let ((el (lisp-script "_el_lib"))
(prepare (lisp-script "_prepare"))
(no-ql (lisp-script "_no_ql"))
(ql (lisp-script "_ql"))
(script (lisp-script script)))
Expand All @@ -98,7 +99,8 @@ Argument CMD is used to extract positional arguments and options."
(list "--load" no-ql)
(list "--load" (quicklisp-lisp)
"--load" ql))
(list "--load" prepare
(list "--load" el
"--load" prepare
"--script" script))
cmd)))

Expand Down

0 comments on commit e90211e

Please sign in to comment.