Re: [frogs] [PATCH]: Tracker 836 - Allow output filename and output-suffix to be specified for a \book block |
[ Thread Index |
Date Index
| More lilynet.net/frogs Archives
]
- To: frogs@xxxxxxxxxxx
- Subject: Re: [frogs] [PATCH]: Tracker 836 - Allow output filename and output-suffix to be specified for a \book block
- From: Neil Puttock <n.puttock@xxxxxxxxx>
- Date: Wed, 28 Oct 2009 01:05:57 +0000
- Cc: "lilypond-devel@xxxxxxx" <lilypond-devel@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=ADZ5NAUpYDxaQANGVmLCBMu9xpH2phfW5eJcso4d6jg=; b=hffEPV0jd5wnz56SOAmMOLw1gZgTWrZBO3liSXpcNUdnteP/RdBmgbVzK+OoU1KMf8 DUHqfIfm98j0E4cU1s6PStVCBW0IRgl3/tuvzCV2bAQLXou/3yOIcVEZn5NFOJnk/kPt DVKMtLRC2Pr/BW5Hch3qPJy3eNukGT8kMnsWc=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=KzbFZGR8lTmJtKjW5DXYe7r0FZBThRTH2ybTfstTIfv0B5B8R9rpm4+MBzHlFPhwSi psrvReMPuzj4Zy2nzyYE1wMnslU+Gp5JTf4h8oWeSytqI8MVdncWJ+i2El8diyuaLP0D xi4q8uU3NzA9jsoD+e4esujmGaXDj0fnF+/bQ=
2009/10/27 Carl Sorensen <c_sorensen@xxxxxxx>:
> The patch looks good to me. Neil?
Not bad, Ian, but you need to keep an eye on trailing spaces and indentation.
+ PARSER->lexer_->set_identifier (ly_symbol2scm
("book-output-suffix"), SCM_BOOL_F);
+ PARSER->lexer_->set_identifier (ly_symbol2scm
("book-filename"), SCM_BOOL_F);
indentation
+bookOutputName =
+#(define-music-function (parser location newfilename) (string?)
+ (_i "Direct output for the current book block to @var{newfilename}")
+ (set! book-filename newfilename)
+ (make-music 'SequentialMusic 'void #t))
+
+bookOutputSuffix =
+#(define-music-function (parser location newsuffix) (string?)
+ (_i "Set the output filename suffix for the current book block to
+@var{newsuffix}")
+ (set! book-output-suffix newsuffix)
+ (make-music 'SequentialMusic 'void #t))
+
+ %% why a function?
indentation
+ (make-music 'SequentialMusic 'void #t))
You could add a `make-void-music' function for this as it's used in
quite a few places.
+;; return any suffix value for output filename allowing for settings by
+;; calls to \bookOutputName
I'd document this inside the function as a string (ditto for
get-current-suffix).
+(define (get-current-filename parser)
+ (let* (
+ (book-filename (ly:parser-lookup parser 'book-filename)))
+ (if (not book-filename)
+ (ly:parser-output-name parser)
+ (ly:parser-lookup parser 'book-filename))))
indentation
+(define (get-current-filename parser)
+ (let* (
+ (book-filename (ly:parser-lookup parser 'book-filename)))
(let (book-filename (ly:parser-lookup parser 'book-filename)))
+ (ly:parser-lookup parser 'book-filename))))
book-filename)))
+(define (get-current-suffix parser)
+ (let* (
+ (book-output-suffix (ly:parser-lookup parser 'book-output-suffix)))
+ (if (string? book-output-suffix)
+ (ly:parser-lookup parser 'book-output-suffix)
+ (ly:parser-lookup parser 'output-suffix))))
indentation
+ (let* (
+ (book-output-suffix (ly:parser-lookup parser 'book-output-suffix)))
(let (book-output-suffix (ly:parser-lookup parser 'book-output-suffix)))
+ (ly:parser-lookup parser 'book-output-suffix)
book-output-suffix
+(define-public current-outfile-name #f) ; for use by regression tests
I don't understand this; have you added it for use later?
+(define (get-outfile-name parser)
+ ;; user can now override the base file name, so we have to use
+ ;; the file-name concatenated with any potential output-suffix value
+ ;; as the key to out internal a-list
+ (let* (
+ (base-name (get-current-filename parser))
+ (output-suffix (get-current-suffix parser))
+ (alist-key (format "~a~a" base-name output-suffix))
+ (counter-alist (ly:parser-lookup parser 'counter-alist))
+ (output-count (assoc-get alist-key counter-alist 0))
+ (result base-name))
indentation
+ (let* (
+ (base-name (get-current-filename parser))
(let* ((base-name (get-current-filename parser))
The patch doesn't work due to the following gremlins:
base (string-regexp-substitute
base-name (string-regexp-substitute
(outfile-name (get-outfile-name parser base)))
(outfile-name (get-outfile-name parser)))
BTW, have you installed git-cl yet? It would be much easier to review
your patches using Rietveld.
Regards,
Neil
---
----
Join the Frogs!