From: John Mandereau <john.mandereau@gmail.com>
Date: Fri, 29 Feb 2008 16:12:58 +0000 (+0100)
Subject: Add addversion lilypond-book fragment option
X-Git-Tag: release/2.11.42-1~7^2~15^2~9
X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=f6caefb696b778cd8f49acc127583253f020248c;p=lilypond.git

Add addversion lilypond-book fragment option
---

diff --git a/Documentation/user/lilypond-book.itely b/Documentation/user/lilypond-book.itely
index edafa9e528..ed457215df 100644
--- a/Documentation/user/lilypond-book.itely
+++ b/Documentation/user/lilypond-book.itely
@@ -656,6 +656,10 @@ will be printed with a verbatim block like
   f2 e
 @end example
 
+@item addversion
+(Only for Texinfo output.)  Prepend line @code{\version
+@@w{"@@version@{@}"}} to @code{verbatim} output.
+
 @item texidoc
 (Only for Texinfo output.)  If @command{lilypond} is called with the
 @option{--header=@/texidoc} option, and the file to be processed is
diff --git a/scripts/lilypond-book.py b/scripts/lilypond-book.py
index 824cbabef9..0da7ce4828 100644
--- a/scripts/lilypond-book.py
+++ b/scripts/lilypond-book.py
@@ -197,6 +197,7 @@ default_ly_options = { 'alt': "[image of music]" }
 #
 # Is this pythonic?  Personally, I find this rather #define-nesque. --hwn
 #
+ADDVERSION = 'addversion'
 AFTER = 'after'
 BEFORE = 'before'
 DOCBOOK = 'docbook'
@@ -682,6 +683,9 @@ output = {
 @verbatim
 %(verb)s@end verbatim
 ''',
+
+        ADDVERSION: r'''\version @w{"@version{}"}
+%(verb)s'''
     },
 }
 
@@ -1260,6 +1264,8 @@ class Lilypond_snippet (Snippet):
         substr = ''
         if VERBATIM in self.option_dict:
             verb = self.verb_ly ()
+            if ADDVERSION in self.option_dict:
+                verb = output[TEXINFO][ADDVERSION] % vars ()
             substr += output[TEXINFO][VERBATIM] % vars ()
             if not QUOTE in self.option_dict:
                 substr = output[TEXINFO][NOQUOTE] % {'str':substr}