As mentioned a short time ago, I have implemented $load_pathname for
maxima. load_pathname is bound to the pathname of the file being
loaded. This allows the file to access other files relative to that
file. This is analogous to Lisp's *load-pathname*.
To be useful, I think maxima should provide ways to manipulate the
pathname. Is there already some package that can do that? If not, I
was thinking of pathname_directory, pathname_name, and pathname_type,
which are analogous to Lisp's pathname-directory, pathname-name, and
pathname-type.
Also, I noticed that filename_merge returns a Lisp pathname object.
Should it? Maxima can't really manipulate pathname objects.
Ray
P.S. Here is the simple patch that implements $load_pathname
Index: src/mload.lisp
===================================================================
RCS file: /cvsroot/maxima/maxima/src/mload.lisp,v
retrieving revision 1.56
diff -u -r1.56 mload.lisp
--- src/mload.lisp 23 Aug 2009 20:56:24 -0000 1.56
+++ src/mload.lisp 30 Nov 2009 13:58:49 -0000
@@ -109,19 +109,24 @@
;; know its small now, so print on same line.
(merror "Bad file spec: ~:M" user-object)))))
+(defmvar $load_pathname nil
+ "The full pathname of the file being loaded")
+
(defun $batchload (filename &aux expr (*mread-prompt* ""))
(declare (special *mread-prompt* *prompt-on-read-hang*))
(setq filename ($file_search1 filename '((mlist) $file_search_maxima)))
- (with-open-file (in-stream filename)
- (when $loadprint
- (format t "~&batching ~A~&" (cl:namestring (truename in-stream))))
- (cleanup)
- (newline in-stream)
- (loop while (and
- (setq expr (let (*prompt-on-read-hang*) (mread in-stream nil)))
- (consp expr))
- do (meval* (third expr)))
- (cl:namestring (truename in-stream))))
+ (let (($load_pathname filename))
+ (format t "$load_pathname = ~S~%" $load_pathname)
+ (with-open-file (in-stream filename)
+ (when $loadprint
+ (format t "~&batching ~A~&" (cl:namestring (truename in-stream))))
+ (cleanup)
+ (newline in-stream)
+ (loop while (and
+ (setq expr (let (*prompt-on-read-hang*) (mread in-stream nil)))
+ (consp expr))
+ do (meval* (third expr)))
+ (cl:namestring (truename in-stream)))))
;;returns appropriate error or existing pathname.
;; the second argument is a maxima list of variables
Index: src/suprv1.lisp
===================================================================
RCS file: /cvsroot/maxima/maxima/src/suprv1.lisp,v
retrieving revision 1.89
diff -u -r1.89 suprv1.lisp
--- src/suprv1.lisp 17 Nov 2009 11:03:16 -0000 1.89
+++ src/suprv1.lisp 30 Nov 2009 13:58:49 -0000
@@ -290,6 +290,7 @@
;; Should really get the truename of FILE.
(if printp (format t "~%~A being loaded.~%" file))
(let* ((path (pathname file))
+ ($load_pathname path)
(tem (errset #-sbcl (load (pathname file)) #+sbcl
(with-compilation-unit nil (load (pathname file))))))
(or tem (merror "Load failed for ~A" (namestring path)))
(namestring path)))