groff-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Groff-commit] groff/contrib/lilypond ChangeLog groff_lilypond...


From: Bernd Warken
Subject: [Groff-commit] groff/contrib/lilypond ChangeLog groff_lilypond...
Date: Mon, 11 Feb 2013 22:19:52 +0000

CVSROOT:        /cvsroot/groff
Module name:    groff
Changes by:     Bernd Warken <bwarken>  13/02/11 22:19:52

Modified files:
        contrib/lilypond: ChangeLog groff_lilypond.man groff_lilypond.pl 

Log message:
        A new request was added for including lilypond files into the groff 
document:
        .lilypond include ...
        The argument handling was improved.
        New version is groff_lilypond v0.3

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/groff/contrib/lilypond/ChangeLog?cvsroot=groff&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/groff/contrib/lilypond/groff_lilypond.man?cvsroot=groff&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/groff/contrib/lilypond/groff_lilypond.pl?cvsroot=groff&r1=1.2&r2=1.3

Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/groff/groff/contrib/lilypond/ChangeLog,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- ChangeLog   11 Feb 2013 00:22:39 -0000      1.2
+++ ChangeLog   11 Feb 2013 22:19:52 -0000      1.3
@@ -1,3 +1,11 @@
+2013-02-12  Bernd Warken  <address@hidden>
+
+       * contrib/lilypond: Version v0.3 for groff_lilypond
+       * groff_lilypond.pl: A new request was added for importing
+       lilypond files:
+       .lilypond include ...
+       The argument handling was improved.
+
 2013-02-11  Bernd Warken  <address@hidden>
 
        * contrib/lilypond: Version v0.2 for groff_lilypond

Index: groff_lilypond.man
===================================================================
RCS file: /cvsroot/groff/groff/contrib/lilypond/groff_lilypond.man,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- groff_lilypond.man  11 Feb 2013 00:22:39 -0000      1.2
+++ groff_lilypond.man  11 Feb 2013 22:19:52 -0000      1.3
@@ -114,9 +114,10 @@
 .\" --------------------------------------------------------------------
 .
 .SY groff_lilypond
-.OP option
+.OP options
+.OP -
 .OP --
-.OP \%filespec
+.OP \%filespec \[Ellipsis]
 .YS
 .
 .SY groff_lilypond
@@ -147,8 +148,9 @@
 .FONT CB groff_lilypond
 reads from standard input.
 .
-A single file can be given as an argument.
-.
+Several files can be used, including
+.FONT CB \[em]
+for standard input.
 .
 .\" --------------------------------------------------------------------
 .SH "OPTION OVERVIEW"
@@ -185,10 +187,16 @@
 part within a structure written in the
 .FONT CI groff
 language is the whole part between the marks
+.EX
 .FONT CB ".lilypond start"
+.EE
 and
-.FONT CB ".lilypond end" R .
+.EX
+.FONT CB ".lilypond end"
+.EE
+.
 .
+.P
 A
 .FONT CI groff
 file can have several of these
@@ -206,6 +214,41 @@
 .
 .
 .\" --------------------------------------------------------------------
+.SH "LY\-FILE INCLUSION"
+.\" --------------------------------------------------------------------
+.
+An additional command line for file inclusion of
+.FONT CI lilypond
+files is given by
+.EX
+FONT CB ".lilypond include \[Ellipsis]"
+.EE
+in
+.FONT CI groff
+files.
+.
+One or more file names can be included.
+.
+.
+.P
+If this command is written outside a
+.FONT CI lilypond
+part, one new
+.FONT CB .ly  R \file
+is created for all files in the argument, which will be transformed
+afterwards when writing is done.
+.
+.
+.P
+Within a
+.FONT CI lilypond
+part, the content of all these files will be added to the actually
+generated
+.FONT CB .ly
+file.
+.
+.
+.\" --------------------------------------------------------------------
 .SH "TRANSFORMATION MODE LY2EPS"
 .\" --------------------------------------------------------------------
 .

Index: groff_lilypond.pl
===================================================================
RCS file: /cvsroot/groff/groff/contrib/lilypond/groff_lilypond.pl,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- groff_lilypond.pl   11 Feb 2013 00:22:39 -0000      1.2
+++ groff_lilypond.pl   11 Feb 2013 22:19:52 -0000      1.3
@@ -8,7 +8,7 @@
 # Copyright (C) 2013 Free Software Foundation, Inc.
 # Written by Bernd Warken <address@hidden>.
 
-# Last update: 11 Feb 2013
+# Last update: 12 Feb 2013
 
 # This file is part of `groff'.
 
@@ -30,13 +30,26 @@
 use strict;
 use warnings;
 
-my $version = 'v0.2';
+my $version = 'v0.3';
 
 # for temporary directories see @tempdirs
 
 my $eps_mode = 'ly2eps';
-foreach (@ARGV) {
-    if (/^(-v|--version).*$/) {
+{
+    my $minus_minus = 0;
+    my @FILES = ();
+    foreach (@ARGV) {
+       if ($minus_minus) {
+           push @FILES, $_;
+           next;
+       }
+       if (/^--$/) { # argument `--'
+           $minus_minus = 1;
+           next;
+       } elsif (/^(-|[^-].*)$/) { # argument `-' or file name
+           push @FILES, $_;
+           next;
+       } elsif (/^(-v|--version).*$/) {
        &version;
        goto QUIT;
     } elsif (/^(-h|--help).*$/) {
@@ -48,7 +61,11 @@
     } elsif (/^--ly2eps.*$/) {
        $eps_mode = 'ly2eps';
        shift;
+       } else {
+           die "wrong argument for groff_lilypond: $_";
+       }
     }
+    @ARGV = @FILES;
 }
 
 my $dir_time;
@@ -112,7 +129,61 @@
 
 foreach (<>) {
     chomp;
-    if (/^\.\s*lilypond\s+start/) {
+    if (/^(\.\s*lilypond\s+include)(.*$)/) { # `.lilypond include file...'
+       my $args = $2;
+       $args =~ s/\s*$//;
+       my @files = ();
+       while ($args) {
+           if ($args =~ /^\s+"([^"]+)"(.*)$/) { # ` "file name"...'
+               push @files, $1;
+               $args = $2;
+           } elsif ($args =~ /^\s+'([^']+)'(.*)$/) { # ` 'file name'...'
+               push @files, $1;
+               $args = $2;
+           } elsif ($args =~ /^\s+(\S+)(.*)$/) { # ` filename...'
+               push @files, $1;
+               $args = $2;
+           }
+       }
+       unless ($lilypond_mode) { # then FILE_LY must be opened
+           $ly_number++;
+           $file_numbered = $file_prefix . $ly_number;
+           $file_ly =  $file_numbered . '.ly';
+
+           open FILE_LY, ">", $file_ly or
+               die "cannot open .ly file: $!";
+       }
+
+       foreach (@files) { # included .ly files
+           my $file = $_;
+           unless ($file) {
+               print STDERR "Empty file name at `.lilypond include'\n";
+               next;
+           }
+           unless (-e $file) {
+               print STDERR
+                   "File `$file' at `.lilypond include' does not exist.\n";
+               next;
+           }
+           unless (-r $file) {
+               print STDERR
+                   "File `$file' at `.lilypond include' is not readable.\n";
+               next;
+           }
+
+           open FILE, "<", "$file" # for reading
+               or die "file `$file' could not be read: $!";
+           foreach (<FILE>) {
+               chomp;
+               print FILE_LY $_ . "\n";
+           }
+           close FILE;
+       }
+       unless ($lilypond_mode) {
+           close FILE_LY;
+           &create_eps;
+       }
+    } elsif (/^\.\s*lilypond\s+start/) { # `.lilypond start'
        die "Line `.lilypond stop' expected." if ($lilypond_mode);
        $lilypond_mode = 1;
        $ly_number++;
@@ -121,25 +192,44 @@
        open FILE_LY, ">", $file_ly or
            die "cannot open .ly file: $!";
        next;
-    } elsif (/^\.\s*lilypond\s+stop/) {
+    } elsif (/^\.\s*lilypond\s+stop/) { # `.lilypond stop'
        die "Line `.lilypond start' expected." unless ($lilypond_mode);
        $lilypond_mode = 0;
        close FILE_LY;
+       &create_eps;
+       next;
+    } elsif ($lilypond_mode) {
+       print FILE_LY $_ . "\n";
+    } else {
+       print $_ . "\n";
+    }
+}
+
+# unlink glob $file_prefix . "*.[a-df-z]*";
 
-       if ($eps_mode =~ /^pdf2eps$/) {
+sub create_eps() {
+    if ($eps_mode =~ /^pdf2eps$/) { # `--pdf2eps'
+       # `$ lilypond --pdf --output=file_with_no_extension file.ly'
+       # .pdf is added automatically
            system "lilypond", "--pdf", "--output=$file_numbered", $file_ly
                and die 'Program lilypond does not work.';
-           # .pdf is added automatically
+       # `$ pdf2ps file.pdf file.ps'
            system 'pdf2ps', $file_numbered . '.pdf', $file_numbered . '.ps'
                and die 'Program pdf2ps does not work.';
+       # `$ ps2eps file.ps'
            system 'ps2eps', $file_numbered . '.ps'
                and die 'Program ps2eps does not work.';
+
+       # print into groff output
            print '.PSPIC ' . $file_numbered  . '.eps' . "\n";
-       } elsif ($eps_mode =~ /^ly2eps$/) {
+    } elsif ($eps_mode =~ /^ly2eps$/) { # `--ly2eps'
+       # `$ lilypond --ps -dbackend=eps -dgs-load-fonts
+       #      output=file_without_extension file.ly'
+       # extensions are added automatically
            system 'lilypond', '--ps', '-dbackend=eps',
            '-dgs-load-fonts', "--output=$file_numbered", $file_ly
                and die 'Program lilypond does not work.';
-           # extensions are added automatically
+
            foreach (glob $file_numbered . '-*' . '.eps') {
                print '.PSPIC ' . $_ . "\n";
            }
@@ -147,16 +237,8 @@
        } else {
            die "Wrong eps mode: $eps_mode";
        }
-       next;
-    } elsif ($lilypond_mode) {
-       print FILE_LY $_ . "\n";
-    } else {
-       print $_ . "\n";
-    }
 }
 
-unlink glob $file_prefix . "*.[a-df-z]*";
-
 sub version {
     print "groff_lilypond version $version is part of groff\n";
 }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]