change search algorithm for templates

This commit is contained in:
SANO Masatoshi 2016-04-30 12:23:21 +09:00
parent 75dbb06188
commit 598cb5a7f5

View file

@ -16,8 +16,17 @@ exec ros -Q -m roswell -L sbcl-bin -- $0 "$@"
(declare (ignore cmd))
(if (and (equal subcmd "main") name)
(let* ((date (get-universal-time))
(path (format nil "templates/~A/~A.asd" name name)))
(setq path (probe-file (merge-pathnames path (ros.util:homedir))))
path)
(setq path
(or (probe-file (merge-pathnames (format nil "templates/~A/template.asd" name) (ros.util:homedir)))
(unless (find #\/ name)
(let ((dir (directory (merge-pathnames (format nil "templates/*/~A/template.asd" name) (ros.util:homedir)))))
(unless (= (length dir) 1)
(format *error-output* "ambiguous ~{~A~%~}" dir)
(quit -1))
(setq name (format nil "~{~A~^/~}" (last (pathname-directory (first dir)) 2)))
;; [fix me] '2' is not apropriate.
(first dir)))))
(when path
(load path)
(ql:quickload name :silent t)