summaryrefslogtreecommitdiff
path: root/src/guile/skribilo.scm
diff options
context:
space:
mode:
authorLudovic Court`es2005-11-28 16:41:24 +0000
committerLudovic Court`es2005-11-28 16:41:24 +0000
commit4686c3d129e4ebb3edc97e53a20a5f9db682f993 (patch)
tree89d05c18ea5b9106b965b122a809ff2a0997878e /src/guile/skribilo.scm
parent559d3f64f4b051a39c91a3d53d3b41deee8ae42f (diff)
downloadskribilo-4686c3d129e4ebb3edc97e53a20a5f9db682f993.tar.gz
skribilo-4686c3d129e4ebb3edc97e53a20a5f9db682f993.tar.lz
skribilo-4686c3d129e4ebb3edc97e53a20a5f9db682f993.zip
More `%skribilo-module-reader' fixes.
* src/guile/skribilo.scm: Removed the executable bit. * configure.ac: Produce `src/guile/skribilo/utils/Makefile'. * src/guile/skribilo.scm: Call `set-current-reader' after the `use-modules' clause. (process-option-specs): Use `:kw'-style keywords. (*skribilo-output-port*): New. (doskribe): Use the above fluid. (main): Honor the `-o' option. * src/guile/skribilo/debug.scm: Use `(skribilo utils syntax)' and `%skribilo-module-reader'. * src/guile/skribilo/module.scm: Likewise. * src/guile/skribilo/output.scm: Likewise. * src/guile/skribilo/resolve.scm: Likewise. * src/guile/skribilo/verify.scm: Likewise. * src/guile/skribilo/parameters.scm (make-expect): New. (define-number-parameter): New. (define-list-parameter): New. * src/guile/skribilo/utils/Makefile.am (guilemoduledir): Fixed. * src/guile/skribilo/evaluator.scm (%evaluate): Commented out debugging statement. git-archimport-id: lcourtes@laas.fr--2004-libre/skribilo--devel--1.2--patch-14
Diffstat (limited to 'src/guile/skribilo.scm')
-rw-r--r--[-rwxr-xr-x]src/guile/skribilo.scm55
1 files changed, 31 insertions, 24 deletions
diff --git a/src/guile/skribilo.scm b/src/guile/skribilo.scm
index 92c5b35..de7dac2 100755..100644
--- a/src/guile/skribilo.scm
+++ b/src/guile/skribilo.scm
@@ -62,9 +62,6 @@ exec ${GUILE-guile} --debug -l $0 -c "(apply $main (cdr (command-line)))" "$@"
:autoload (skribilo engine) (*current-engine*)
:use-module (skribilo utils syntax))
-;; Install the Skribilo module syntax reader.
-(set-current-reader %skribilo-module-reader)
-
(use-modules (skribilo evaluator)
(skribilo debug)
(skribilo parameters)
@@ -75,13 +72,18 @@ exec ${GUILE-guile} --debug -l $0 -c "(apply $main (cdr (command-line)))" "$@"
(ice-9 getopt-long))
+;; Install the Skribilo module syntax reader.
+(set-current-reader %skribilo-module-reader)
+
+(if (not (keyword? :kw))
+ (error "guile-reader sucks"))
-(define* (process-option-specs longname #:key (alternate #f)
- (arg #f) (help #f)
- #:rest thunk)
+(define* (process-option-specs longname
+ :key (alternate #f) (arg #f) (help #f)
+ :rest thunk)
"Process STkLos-like option specifications and return getopt-long option
specifications."
`(,(string->symbol longname)
@@ -181,6 +183,7 @@ specifications."
(with-input-from-string expr
(lambda () (eval (read))))))
+
; (define skribilo-options
; ;; Skribilo options in getopt-long's format, as computed by
; ;; `raw-options->getopt-long'.
@@ -217,7 +220,7 @@ Processes a Skribilo/Skribe source file and produces its output.
--help Give this help list
--version Print program version
-"))
+~%"))
(define (skribilo-show-version)
(format #t "skribilo ~a~%" (skribilo-release)))
@@ -371,15 +374,22 @@ Processes a Skribilo/Skribe source file and produces its output.
; *skribe-src*)
; (skribe-eval-port (current-input-port) *skribe-engine*))))
+(define *skribilo-output-port* (make-parameter (current-output-port)))
+
(define (doskribe)
- (let ((user-module (current-module)))
+ (let ((output-port (current-output-port))
+ (user-module (current-module)))
(dynamic-wind
(lambda ()
+ ;; FIXME: Using this technique, anything written to `stderr' will
+ ;; also end up in the output file (e.g. Guile warnings).
+ (set-current-output-port (*skribilo-output-port*))
(set-current-module (make-run-time-module)))
(lambda ()
- (format #t "engine is ~a~%" (*current-engine*))
+ ;;(format #t "engine is ~a~%" (*current-engine*))
(skribe-eval-port (current-input-port) (*current-engine*)))
(lambda ()
+ (set-current-output-port output-port)
(set-current-module user-module)))))
@@ -393,6 +403,7 @@ Processes a Skribilo/Skribe source file and produces its output.
skribilo-options))
(engine (string->symbol
(option-ref options 'target "html")))
+ (output-file (option-ref options 'output #f))
(debugging-level (option-ref options 'debug "0"))
(load-path (option-ref options 'load-path "."))
(bib-path (option-ref options 'bib-path "."))
@@ -446,26 +457,22 @@ Processes a Skribilo/Skribe source file and produces its output.
(error "you can specify at most one input file and one output file"
files))
- (let* ((source-file (if (null? files) #f (car files)))
- (dest-file (if (or (not source-file)
- (null? (cdr files)))
- #f
- (cadr files)))
- (do-it! (lambda ()
- (if (string? dest-file)
- (with-output-to-file dest-file doskribe)
- (doskribe)))))
+ (let* ((source-file (if (null? files) #f (car files))))
- (parameterize ((*destination-file* dest-file)
- (*source-file* source-file))
+ (if (and output-file (file-exists? output-file))
+ (delete-file output-file))
- (if (and dest-file (file-exists? dest-file))
- (delete-file dest-file))
+ (parameterize ((*destination-file* output-file)
+ (*source-file* source-file)
+ (*skribilo-output-port*
+ (if (string? output-file)
+ (open-output-file output-file)
+ (current-output-port))))
;; (start-stack 7
(if source-file
- (with-input-from-file source-file do-it!)
- (do-it!))))))))
+ (with-input-from-file source-file doskribe)
+ (doskribe))))))))
(define main skribilo)