Skip to content

Commit

Permalink
Merge branch 'db/cleanup-module.lisp' of https://github.com/exot/stumpwm
Browse files Browse the repository at this point in the history
 into exot-db/cleanup-module.lisp

Conflicts:
	module.lisp
  • Loading branch information
David Bjergaard committed Mar 16, 2014
2 parents 4f142bc + 50ac1c1 commit ba34780
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions module.lisp
Expand Up @@ -32,10 +32,6 @@
find-module
add-to-load-path))

(defun module-string-as-directory (dir)
(unless (string= "/" (subseq dir (1- (length dir))))
(setf dir (concat dir "/")))
(pathname dir))
(defvar *contrib-dir*
#.(asdf:system-relative-pathname (asdf:find-system :stumpwm)
(make-pathname :directory
Expand All @@ -52,22 +48,24 @@
(flatten
(mapcar (lambda (dir)
(let ((asd-file (car (directory
(make-pathname :directory
(directory-namestring dir)
(make-pathname :directory (directory-namestring dir)
:name :wild
:type "asd")))))
(when asd-file
(directory (directory-namestring asd-file)))))
;; TODO, make this truely recursive
(directory (concat (if (stringp path) path
(directory-namestring path)) "*/*")))))
(directory-namestring path))
"*/*")))))

(defvar *load-path* nil
"A list of paths in which modules can be found, by default it is
populated by any asdf systems found in the first two levels of
`*contrib-dir*' set from the configure script when StumpWM was built, or
later by the user using `set-contrib-dir'")

(defun sync-asdf-central-registry (load-path)
"Sync `load-path' with `asdf:*central-registry*'"
"Sync `LOAD-PATH' with `ASDF:*CENTRAL-REGISTRY*'"
(setf asdf:*central-registry*
(union load-path asdf:*central-registry*)))

Expand All @@ -80,8 +78,10 @@
(init-load-path *contrib-dir*)

(defcommand set-contrib-dir (dir) ((:string "Directory: "))
"Sets the location of the contrib modules"
(setf *contrib-dir* (module-string-as-directory dir))
"Sets the location of the contrib modules"
(when (stringp dir)
(setf dir (pathname (concat dir "/"))))
(setf *contrib-dir* dir)
(init-load-path *contrib-dir*))

(define-stumpwm-type :module (input prompt)
Expand All @@ -101,9 +101,11 @@
(if name
(find name (list-modules) :test #'string=)
nil))

(defun ensure-pathname (path)
(if (stringp path) (first (directory path))
path))

(defun add-to-load-path (path)
"If `PATH' is not in `*LOAD-PATH*' add it, check if `PATH' contains
an asdf system, and if so add it to the central registry"
Expand Down

0 comments on commit ba34780

Please sign in to comment.