r11296: add optional final rightcol files
[lml2.git] / files.lisp
index 445e5487c63b15e948d338b2dd2ba210ed4b6675..9c5dd2ed95906fb91ceb6749a3d62df9e59fc997 100644 (file)
   (defvar *sources-dir* nil)
   )
 
-(defmacro lml-file-name (file &optional (type :source))
-  (let ((f file))
-    (when (and (consp f) (eql (car f) 'cl:quote))
-      (setq f (cadr f)))
-    (when (symbolp f)
-      (setq f (string-downcase (symbol-name f))))
-    (when (stringp f)
-      (unless (position #\. f)
-       (setq f (concatenate 'string f ".html"))))
-    (if *sources-dir*
-       (merge-pathnames
-        (make-pathname :name `,(pathname-name f)
-                       :type `,(pathname-type f)
-                       :directory `,(pathname-directory f))
-        (ecase type
-          (:source *sources-dir*)
-          (:output *output-dir*)))
+(defun lml-file-name (f &optional (type :source))
+  (when (and (consp f) (eql (car f) 'cl:quote))
+    (setq f (cadr f)))
+  (when (symbolp f)
+    (setq f (string-downcase (symbol-name f))))
+  (when (stringp f)
+    (unless (position #\. f)
+      (setq f (concatenate 'string f ".html"))))
+  (if (or (and (eq type :source) *sources-dir*)
+         (and (eq type :output) *output-dir*))
+      (merge-pathnames
+       (make-pathname :name (pathname-name f)
+                     :type (pathname-type f)
+                     :directory (pathname-directory f))
+       (ecase type
+        (:source *sources-dir*)
+        (:output *output-dir*)))
       (if (stringp f)
          (parse-namestring f)
-       f))))
+         f)))
 
 (defmacro with-dir ((output &key sources) &body body)
   (let ((output-dir (gensym))
          (*sources-dir* ,sources-dir))
       ,@body))))
 
-(defun lml-load-path (file)
+(defun lml-load-path (file &key optional)
   (if (probe-file file)
       (with-open-file (in file :direction :input)
         (do ((form (read in nil 'eof) (read in nil 'eof)))
            ((eq form 'eof))
          (eval form)))
-    (format *trace-output* "Warning: unable to load LML file ~S" file)))
+    (unless optional
+      (format *trace-output* "Warning: unable to load LML file ~S" file))))
 
 (defun process-dir (dir &key sources)
   (with-dir (dir :sources sources)
@@ -73,8 +74,8 @@
        (format *trace-output* "~&; Processing ~A~%" file)
        (lml-load-path file)))))
 
-(defun lml-load (file)
-  (lml-load-path (eval `(lml-file-name ,file :source))))
+(defun lml-load (file &key optional)
+  (lml-load-path (eval `(lml-file-name ,file :source)) :optional optional))
 
 (defun insert-file (file)
   (print-file-contents file *html-stream*))