From b0b2a5c5d285efaaf6d0d70220e33fcb6d2231b3 Mon Sep 17 00:00:00 2001 From: Alex Shinn Date: Thu, 19 Dec 2013 23:34:24 +0900 Subject: [PATCH] Adding conf-get-cdr. --- lib/chibi/config.scm | 10 ++++++++++ lib/chibi/config.sld | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/chibi/config.scm b/lib/chibi/config.scm index af0f1d15..10193e06 100644 --- a/lib/chibi/config.scm +++ b/lib/chibi/config.scm @@ -241,7 +241,17 @@ (if (or (pair? res) (null? res)) res (list res)) (if (pair? opt) (car opt) '())))) +;;> Equivalent to \scheme{conf-get} but always returns the +;;> \scheme{cdr} as-is without possibly taking its \scheme{car}. + +(define (conf-get-cdr config key . opt) + (let ((cell (conf-get-cell config key))) + (if (not cell) + (and (pair? opt) (car opt)) + (cdr cell)))) + ;;> Equivalent to \scheme{conf-get-list} but returns a list of all +;;> cascaded configs appended together. (define (conf-get-multi config key) (if (not config) diff --git a/lib/chibi/config.sld b/lib/chibi/config.sld index 08bf1243..387bfe4e 100644 --- a/lib/chibi/config.sld +++ b/lib/chibi/config.sld @@ -2,8 +2,8 @@ (define-library (chibi config) (export make-conf conf? conf-load conf-load-in-path conf-load-cascaded conf-verify conf-extend conf-append conf-set conf-unfold-key - conf-get conf-get-list conf-get-multi - conf-specialize read-from-file conf-source) + conf-get conf-get-list conf-get-cdr conf-get-multi + conf-specialize read-from-file conf-source conf-head conf-parent) (import (scheme base) (scheme read) (scheme write) (scheme file) (scheme time) (srfi 1)) ;; This is only used for config verification, it's acceptable to