[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Including only definitions from a Lilypond file
From: |
David Kastrup |
Subject: |
Re: Including only definitions from a Lilypond file |
Date: |
Fri, 14 Aug 2020 13:48:25 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
Jérôme Plût <plut.jerome@gmail.com> writes:
> Hello everybody,
>
> I have some lilypond files that contain both music variables and
> typesetting instructions, like this:
>
> soprano = \relative {
> % music here...
> }
>
> \bookpart {
> % typesetting here...
> }
>
> I would like to include this file while importing the definitions and
> ignoring the typesetting. (The long-term goal is to display some
> statistics (range, etc.) about the various voices in the piece. So the
> including file will want to know what \soprano contains, but to
> replace all typesetting instructions by its own).
>
> I *could* do this by writing a separate (e.g. Perl) parser that looks
> only for music definitions, but it would be cleaner (and also more
> robust) if there existed a way to do this from inside Lilypond or
> Scheme. Ideally I would need the parser to obtain both the list of
> variables defined in the file and the contents of those variables.
>
> Before I start hacking something: does there already exist a simpler
> way to do this?
All of the elements in a score are routed through hooks you can
redefine. So you can just redefine your various hooks to do nothing and
then include the file.
The hooks all end in "-handler". I see
dak@lola:/usr/local/tmp/lilypond$ git grep -e -handler lily/parser.yy
lily/parser.yy: SCM proc = parser->lexer_->lookup_identifier
("toplevel-book-handler");
lily/parser.yy: SCM proc = parser->lexer_->lookup_identifier
("toplevel-bookpart-handler");
lily/parser.yy: ? "toplevel-book-handler"
lily/parser.yy: : "toplevel-bookpart-handler");
lily/parser.yy: SCM proc = parser->lexer_->lookup_identifier
("toplevel-score-handler");
lily/parser.yy: SCM proc = parser->lexer_->lookup_identifier
("toplevel-music-handler");
lily/parser.yy: SCM proc = parser->lexer_->lookup_identifier
("toplevel-text-handler");
lily/parser.yy: SCM proc = parser->lexer_->lookup_identifier
("toplevel-text-handler");
lily/parser.yy: SCM proc = parser->lexer_->lookup_identifier
("toplevel-text-handler");
lily/parser.yy: SCM proc = parser->lexer_->lookup_identifier
("toplevel-score-handler");
lily/parser.yy: SCM proc =
parser->lexer_->lookup_identifier ("context-mod-music-handler");
lily/parser.yy: SCM proc = parser->lexer_->lookup_identifier
("book-bookpart-handler");
lily/parser.yy: SCM proc = parser->lexer_->lookup_identifier
("book-score-handler");
lily/parser.yy: SCM proc = parser->lexer_->lookup_identifier
("book-music-handler");
lily/parser.yy: SCM proc = parser->lexer_->lookup_identifier
("book-text-handler");
lily/parser.yy: SCM proc = parser->lexer_->lookup_identifier
("book-text-handler");
lily/parser.yy: SCM proc = parser->lexer_->lookup_identifier
("book-text-handler");
lily/parser.yy: SCM proc = parser->lexer_->lookup_identifier
("book-score-handler");
lily/parser.yy: SCM proc = parser->lexer_->lookup_identifier
("bookpart-score-handler");
lily/parser.yy: SCM proc = parser->lexer_->lookup_identifier
("bookpart-music-handler");
lily/parser.yy: SCM proc = parser->lexer_->lookup_identifier
("bookpart-text-handler");
lily/parser.yy: SCM proc = parser->lexer_->lookup_identifier
("bookpart-text-handler");
lily/parser.yy: SCM proc = parser->lexer_->lookup_identifier
("bookpart-text-handler");
lily/parser.yy: SCM proc = parser->lexer_->lookup_identifier
("bookpart-score-handler");
lily/parser.yy: ("output-def-music-handler");
lily/parser.yy: ("output-def-music-handler");
lily/parser.yy: SCM proc = parser->lexer_->lookup_identifier
("context-mod-music-handler");
lily/parser.yy: SCM proc = parser->lexer_->lookup_identifier
("context-mod-music-handler");
--
David Kastrup