File: extensions.lsp

package info (click to toggle)
nyquist 3.20%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 58,008 kB
  • sloc: ansic: 74,743; lisp: 17,929; java: 10,723; cpp: 6,690; sh: 171; xml: 58; makefile: 40; python: 15
file content (37 lines) | stat: -rw-r--r-- 1,520 bytes parent folder | download | duplicates (3)
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
;; extensions.lsp -- load extensions' autoload.lsp files from
;;    all sub-directories

(defun load-extensions ()
  (let* ((extpath (strcat (current-path)))
         (content (listdir extpath))
         (cwd (setdir "."))
         isdir inf)
    ;; make the current directory be the extpath
    (setdir extpath nil)

    ;; find and process each directory in extpath
    (dolist (dirname content)
      ;; test each dirname to see if it is a directory by using setdir
      ;; ignore ., .., and other hidden files
      (setf isdir (and (not (string-equal (subseq dirname 0 1) "."))
                       (setdir dirname nil))) ;; do not print error if any
      (cond (isdir ;; we found a directory
             (setf inf (open "autoload.lsp"))
             (setdir "..") ;; go back to lib directory
             (cond (inf
                    (close inf) ;; it was only open to check for it
                    (format t "Loading extension ~A ..." dirname)
                    (setdir dirname nil)
                    (load "autoload.lsp" :verbose nil)
                    (setdir "..")
                    (format t " done.\n"))))))

    ;; restore the original current working directory
    (setdir cwd nil)))


;; warning: you MUST invoke the function from here so that (current-path)
;; will return the directory of extensions.lsp (this file) -- this is the
;; path where we look for extensions. If you move this call to another file
;; in another directory, it will look there for extensions!
(load-extensions)