diff options
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | doc/user/compiler.skb | 3 | ||||
-rw-r--r-- | src/guile/skribilo.scm | 35 |
3 files changed, 39 insertions, 0 deletions
@@ -10,6 +10,7 @@ Copyright (C) 2005, 2006, 2007, 2008 Ludovic Courtès <ludo@gnu.org> ** Improved configure-time diagnostics ** `skribilo' now displays a call stack trace upon error when possible +** New `--custom' compiler option * New in Skribilo 0.9.1 diff --git a/doc/user/compiler.skb b/doc/user/compiler.skb index b208037..07fe724 100644 --- a/doc/user/compiler.skb +++ b/doc/user/compiler.skb @@ -80,6 +80,9 @@ conventions of Emacs' Outline mode (see ,(numref :text [Section] :ident `(#\t "engine" ,[Use ,(tt "engine") as the engine, i.e., as the output format. For details on engines and for a list of supported engines, see ,(numref :text [Chapter] :ident "engines").]) + `(#\c "custom=value" ,[Set engine +custom ,(tt [custom]) to ,(tt [value]), a constant. See Section ,(ref +:subsection "Engine Customs") for more information on customs.]) `("compat" "compat" ,[Use ,(tt "compat") as the compatibility mode. This defaults to ,(tt [skribilo]). Specifying ,(tt [skribe]) enables the ,(ref :text [Skribe] :url *skribe-url*) compatibility mode, diff --git a/src/guile/skribilo.scm b/src/guile/skribilo.scm index d69ae32..f192838 100644 --- a/src/guile/skribilo.scm +++ b/src/guile/skribilo.scm @@ -41,6 +41,7 @@ :use-module (skribilo config) :autoload (srfi srfi-1) (alist-cons) + :use-module (srfi srfi-13) :use-module (srfi srfi-37) :use-module (srfi srfi-39) @@ -67,6 +68,7 @@ specified reader syntax, and produce its output using the specified engine. -R, --reader=READER Use READER to parse the input file, e.g., `skribe' (default) or `outline'. -t, --target=ENGINE Use ENGINE as the output engine, e.g., `html'. + -c, --custom=C=VAL Use VAL as the value of ENGINE's custom C. -o, --output=FILE Write output to FILE. --compat=COMPAT Use COMPAT as the compatibility layer, e.g., `skribe'. @@ -166,6 +168,29 @@ Report bugs to <~a>.~%" (option '(#\t "target") #t #f (lambda (opt name arg result) (alist-cons :target arg result))) + (option '(#\c "custom") #t #f + (lambda (opt name arg result) + (let ((=-pos (string-index arg #\=))) + (if (not =-pos) + (leave (_ "~a: missing value for custom") arg) + (let ((custom (string-take arg =-pos)) + (value (string-drop arg (+ =-pos 1)))) + (catch 'read-error + (lambda () + (let ((custom (string->symbol custom)) + (value + (with-input-from-string value read)) + (result + (alist-delete :customs result eq?)) + (customs + (assoc-ref result :customs))) + (alist-cons + :customs + (alist-cons custom value customs) + result))) + (lambda (key . args) + (leave (_ "~a: invalid custom value") + value)))))))) (option '(#\o "output") #t #f (lambda (opt name arg result) (if (assoc :output result) @@ -242,6 +267,7 @@ Report bugs to <~a>.~%" (:source-path ".") (:image-path ".") (:sui-path ".") + (:customs) (:watched-symbols))) (define (parse-args args) @@ -266,6 +292,7 @@ options." (reader-name (string->symbol (assoc-ref options :reader))) (engine (string->symbol (assoc-ref options :target))) + (customs (assoc-ref options :customs)) (input-file (assoc-ref options :input)) (output-file (assoc-ref options :output)) @@ -316,6 +343,14 @@ options." ;; Load the user rc file (FIXME) ;;(load-rc) + (or (null? customs) + (let ((engine (lookup-engine engine))) + (for-each (lambda (custom+value) + (let ((custom (car custom+value)) + (value (cdr custom+value))) + (engine-custom-set! engine custom value))) + customs))) + ;; Evaluate expressions passed as `--eval'. (for-each (lambda (expr) (eval expr user-module)) |