diff options
author | Ludovic Courtes | 2007-07-29 10:30:23 +0000 |
---|---|---|
committer | Ludovic Courtes | 2007-07-29 10:30:23 +0000 |
commit | ff09ac326b8288098f780c07ce66ca6eb672618c (patch) | |
tree | 05acb7b4dd1320418612c5ac045b392fb35a9244 /src/guile | |
parent | 9e33c564d4bf526239c04d2de1f37bc0aaf92e5e (diff) | |
download | skribilo-ff09ac326b8288098f780c07ce66ca6eb672618c.tar.gz skribilo-ff09ac326b8288098f780c07ce66ca6eb672618c.tar.lz skribilo-ff09ac326b8288098f780c07ce66ca6eb672618c.zip |
Allow arbitrary keyword arguments in `define-markup'.
* src/guile/skribilo/lib.scm (define-markup)[fix-rest-arg]: Add
`:allow-other-keys' so that package like `html-navtabs' can require
extra keyword arguments.
git-archimport-id: skribilo@sv.gnu.org--2006/skribilo--devo--1.2--patch-142
Diffstat (limited to 'src/guile')
-rw-r--r-- | src/guile/skribilo/lib.scm | 41 |
1 files changed, 25 insertions, 16 deletions
diff --git a/src/guile/skribilo/lib.scm b/src/guile/skribilo/lib.scm index 3be013a..8c4c382 100644 --- a/src/guile/skribilo/lib.scm +++ b/src/guile/skribilo/lib.scm @@ -1,7 +1,7 @@ ;;; lib.scm -- Utilities. ;;; ;;; Copyright 2003, 2004 Erick Gallesio - I3S-CNRS/ESSI <eg@unice.fr> -;;; Copyright 2005, 2007 Ludovic Courtès <ludovic.courtes@laas.fr> +;;; Copyright 2005, 2007 Ludovic Courtès <ludo@gnu.org> ;;; ;;; ;;; This program is free software; you can redistribute it and/or modify @@ -73,29 +73,38 @@ (define-macro (define-markup bindings . body) ;; This is just an `(ice-9 optargs)' kind of `lambda*', with DSSSL ;; keyword-style conversion enabled. However, using `(ice-9 optargs)', the - ;; `#:rest' argument can only appear last, which is not what Skribe/DSSSL - ;; expect, hence `fix-rest-arg'. + ;; `:rest' argument can only appear last, which is not what Skribe/DSSSL + ;; expect, hence `fix-rest-arg'. In addition, all keyword arguments are + ;; allowed (hence `:allow-other-keys'); they are then checked by `verify'. (define (fix-rest-arg args) - (let loop ((args args) - (result '()) - (rest-arg #f)) + (let loop ((args args) + (result '()) + (rest-arg '()) + (has-keywords? #f)) (cond ((null? args) - (if rest-arg - (append (reverse result) rest-arg) - (reverse result))) + (let ((result (if has-keywords? + (cons :allow-other-keys result) + result))) + (append! (reverse! result) rest-arg))) ((list? args) - (let ((is-rest-arg? (eq? (car args) #:rest))) - (loop (if is-rest-arg? (cddr args) (cdr args)) - (if is-rest-arg? result (cons (car args) result)) - (if is-rest-arg? - (list (car args) (cadr args)) - rest-arg)))) + (let ((is-rest-arg? (eq? (car args) :rest)) + (is-keyword? (eq? (car args) :key))) + (if is-rest-arg? + (loop (cddr args) + result + (list (car args) (cadr args)) + (or has-keywords? is-keyword?)) + (loop (cdr args) + (cons (car args) result) + rest-arg + (or has-keywords? is-keyword?))))) ((pair? args) (loop '() (cons (car args) result) - (list #:rest (cdr args))))))) + (list #:rest (cdr args)) + has-keywords?))))) (let ((name (car bindings)) (opts (cdr bindings))) |