shadowing *maxima-tempdir* and *maxima-userdir*
- Subject: shadowing *maxima-tempdir* and *maxima-userdir*
- From: Robert Dodier
- Date: Thu, 15 Jun 2006 23:54:08 -0600
Hello,
Recently someone suggested shadowing *maxima-tempdir* and
*maxima-userdir* with Maxima variables.
Here is an implementation of that idea. maxima_tempdir and
maxima_userdir are the shadow variables. When those are
assigned a Maxima string, the corresponding Lisp variable is
assigned a Lisp string.
Comments? If no-one objects, I'll commit this.
Robert
Index: init-cl.lisp
===================================================================
RCS file: /cvsroot/maxima/maxima/src/init-cl.lisp,v
retrieving revision 1.66
diff -u -r1.66 init-cl.lisp
--- init-cl.lisp 23 May 2006 21:44:24 -0000 1.66
+++ init-cl.lisp 16 Jun 2006 05:39:58 -0000
@@ -28,6 +28,25 @@
(defvar *maxima-tempdir*)
(defvar *maxima-lang-subdir*)
+(defmvar $maxima_tempdir)
+(putprop '$maxima_tempdir 'shadow-string-assignment 'assign)
+(putprop '$maxima_tempdir '*maxima-tempdir* 'lisp-shadow)
+
+(defmvar $maxima_userdir)
+(putprop '$maxima_userdir 'shadow-string-assignment 'assign)
+(putprop '$maxima_userdir '*maxima-userdir* 'lisp-shadow)
+
+(defun shadow-string-assignment (var value)
+ (cond
+ ((mstringp value)
+ (set (get var 'lisp-shadow) (maybe-invert-string-case
(symbol-name (stripdollar value))))
+ value)
+ ((stringp value)
+ (set (get var 'lisp-shadow) value)
+ value)
+ (t
+ (merror "Attempt to assign a non-string to ~:M" var))))
+
(defun print-directories ()
(format t "maxima-prefix=~a~%" *maxima-prefix*)
(format t "maxima-imagesdir=~a~%" *maxima-imagesdir*)
@@ -264,7 +283,11 @@
(setq *maxima-userdir* (default-userdir)))
(if maxima-tempdir-env
(setq *maxima-tempdir* (maxima-parse-dirstring maxima-tempdir-env))
- (setq *maxima-tempdir* (default-tempdir))))
+ (setq *maxima-tempdir* (default-tempdir)))
+
+ ; Assign initial values for Maxima shadow variables
+ (setq $maxima_userdir *maxima-userdir*)
+ (setq $maxima_tempdir *maxima-tempdir*))
(let* ((ext #+gcl "o"
#+(or cmu scl) (c::backend-fasl-file-type c::*target-backend*)