diff options
author | Ludovic Courtes | 2007-02-07 23:07:16 +0000 |
---|---|---|
committer | Ludovic Courtes | 2007-02-07 23:07:16 +0000 |
commit | 897b708f2d2c8ab23ae9166d17ebe7d3e6853200 (patch) | |
tree | 2807be80f9178a77d6ebde79b2ce5bcfd4ebc1a9 /src/guile | |
parent | e9c75da91462305b1449d0d95af6f67ae51e941b (diff) | |
download | skribilo-897b708f2d2c8ab23ae9166d17ebe7d3e6853200.tar.gz skribilo-897b708f2d2c8ab23ae9166d17ebe7d3e6853200.tar.lz skribilo-897b708f2d2c8ab23ae9166d17ebe7d3e6853200.zip |
evaluator: Slight module-related cleanups.
* src/guile/skribilo/evaluator.scm (%evaluate): Take an additional MODULE
argument. Updated callers.
(evaluate-document-from-port): Likewise.
(load-document): Take additional MODULE and READER arguments.
(include-document): Have MODULE default to `(*skribilo-user-module*)'
instead of `(current-module)'.
git-archimport-id: skribilo@sv.gnu.org--2006/skribilo--devo--1.2--patch-57
Diffstat (limited to 'src/guile')
-rw-r--r-- | src/guile/skribilo/evaluator.scm | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/src/guile/skribilo/evaluator.scm b/src/guile/skribilo/evaluator.scm index a397f29..5067b59 100644 --- a/src/guile/skribilo/evaluator.scm +++ b/src/guile/skribilo/evaluator.scm @@ -57,11 +57,11 @@ ;;; ;;; %EVALUATE ;;; -(define (%evaluate expr) +(define (%evaluate expr module) ;; Evaluate EXPR in the current module. EXPR is an arbitrary S-expression ;; that may contain calls to the markup functions defined in a markup ;; package such as `(skribilo package base)', e.g., `(bold "hello")'. - (let ((result (eval expr (current-module)))) + (let ((result (eval expr module))) (if (ast? result) (let ((file (source-property expr 'filename)) (line (source-property expr 'line)) @@ -93,7 +93,8 @@ ;;; (define* (evaluate-document-from-port port engine :key (env '()) - (reader (*document-reader*))) + (reader (*document-reader*)) + (module (*skribilo-user-module*))) (with-debug 2 'evaluate-document-from-port (debug-item "engine=" engine) (debug-item "reader=" reader) @@ -110,9 +111,11 @@ (let loop ((exp (reader port))) (if (eof-object? exp) - (evaluate-document (%evaluate exp) e :env env) + (evaluate-document (%evaluate exp module) + e :env env) (begin - (evaluate-document (%evaluate exp) e :env env) + (evaluate-document (%evaluate exp module) + e :env env) (loop (reader port))))))))))) @@ -127,7 +130,12 @@ ;; List of the names of files already loaded. (define *loaded-files* (make-parameter '())) -(define* (load-document file :key (engine #f) (path #f) :allow-other-keys + +(define* (load-document file + :key engine path + (module (*skribilo-user-module*)) + (reader (*document-reader*)) + :allow-other-keys :rest opt) (with-debug 4 'load-document (debug-item " engine=" engine) @@ -167,7 +175,9 @@ ;; Load it (with-input-from-file filep (lambda () - (evaluate-document-from-port (current-input-port) ei))) + (evaluate-document-from-port (current-input-port) ei + :module module + :reader reader))) (*loaded-files* (cons filep (*loaded-files*)))))))) @@ -176,7 +186,7 @@ ;;; (define* (include-document file :key (path (*document-path*)) (reader (*document-reader*)) - (module (current-module))) + (module (*skribilo-user-module*))) (unless (every string? path) (raise (condition (&invalid-argument-error (proc-name 'include-document) (argument path))))) @@ -203,4 +213,4 @@ (car res) (reverse! res)) (Loop (reader (current-input-port)) - (cons (%evaluate exp) res)))))))))) + (cons (%evaluate exp module) res)))))))))) |