X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=scm%2Flily-library.scm;h=b49dfbe0bd1e9fe7e834ddf50150636fedae0576;hb=47db9a3883d726ca53e2133a3b2298f78dd6a32e;hp=472a82da24c4a785a5ef6c267f48f25327773d8c;hpb=99b6f3aa3558b01c9d4158b19a1f1794c534f89c;p=lilypond.git diff --git a/scm/lily-library.scm b/scm/lily-library.scm index 472a82da24..b49dfbe0bd 100644 --- a/scm/lily-library.scm +++ b/scm/lily-library.scm @@ -1,6 +1,6 @@ ;;;; This file is part of LilyPond, the GNU music typesetter. ;;;; -;;;; Copyright (C) 1998--2014 Jan Nieuwenhuizen +;;;; Copyright (C) 1998--2015 Jan Nieuwenhuizen ;;;; Han-Wen Nienhuys ;;;; ;;;; LilyPond is free software: you can redistribute it and/or modify @@ -889,6 +889,26 @@ Handy for debugging, possibly turned off." (reverse matches)) +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; numbering styles + +(define-public (number-format number-type num . custom-format) + "Print NUM accordingly to the requested NUMBER-TYPE. +Choices include @code{roman-lower} (by default), +@code{roman-upper}, @code{arabic} and @code{custom}. +In the latter case, CUSTOM-FORMAT must be supplied +and will be applied to NUM." + (cond + ((equal? number-type 'roman-lower) + (fancy-format #f "~(~@r~)" num)) + ((equal? number-type 'roman-upper) + (fancy-format #f "~@r" num)) + ((equal? number-type 'arabic) + (fancy-format #f "~d" num)) + ((equal? number-type 'custom) + (fancy-format #f (car custom-format) num)) + (else (fancy-format #f "~(~@r~)" num)))) + ;;;;;;;;;;;;;;;; ;; other