summaryrefslogtreecommitdiff
path: root/lily
diff options
context:
space:
mode:
authorValentin Villenave <valentin@villenave.net>2016-03-07 10:06:52 +0100
committerValentin Villenave <valentin@villenave.net>2016-03-07 10:19:14 +0100
commit0fa6f042cccacb643d46781dde23617c71a9753e (patch)
treebe2599847c2099f33e0b7129c702bf953921de51 /lily
parent1e339d5efe13a725a4f0c2d8dfc3d40390446b89 (diff)
(Optionally) embed ly source files inside generated PDF
By using the new -dembed-source-code command line switch, users may now include their LilyPond source code in the generated PDF (using the pdfmark EMBED feature); although the PDF is not modified in any visible way, embedded .ly files should appear in viewers that support this feature (other viewers should degrade gracefully). This patch adds a new ly:source-files function (with an optional parser arg) that allows to retrieve the list of (non distribution-provided) ly files involved in making the current score.
Diffstat (limited to 'lily')
-rw-r--r--lily/sources.cc25
1 files changed, 25 insertions, 0 deletions
diff --git a/lily/sources.cc b/lily/sources.cc
index b42300f47a..5d865fe706 100644
--- a/lily/sources.cc
+++ b/lily/sources.cc
@@ -86,3 +86,28 @@ Sources::~Sources ()
}
}
+#include "lily-parser.hh"
+#include "lily-lexer.hh"
+#include "lily-imports.hh"
+#include "fluid.hh"
+
+LY_DEFINE (ly_source_files, "ly:source-files", 0, 1, 0,
+ (SCM parser_smob),
+ "A list of LilyPond files being processed;"
+ "a PARSER may optionally be specified.")
+{
+
+ if (SCM_UNBNDP (parser_smob))
+ parser_smob = scm_fluid_ref (Lily::f_parser);
+ Lily_parser *parser = LY_ASSERT_SMOB (Lily_parser, parser_smob, 1);
+ Includable_lexer *lex = parser->lexer_;
+
+ SCM lst = SCM_EOL;
+ for (vector<string>::const_iterator
+ i = lex->file_name_strings_.begin();
+ i != lex->file_name_strings_.end(); ++i)
+ {
+ lst = scm_cons (ly_string2scm (*i), lst);
+ }
+ return scm_reverse_x (lst, SCM_EOL);
+}