PATCH for getting output-suffix to work (Trackers 714 and 404)

classic Classic list List threaded Threaded
16 messages Options
Reply | Threaded
Open this post in threaded view
|

PATCH for getting output-suffix to work (Trackers 714 and 404)

Ian Hulin
Hi Carl,

Here's the first stage of work on these trackers,  I've taken the work Marek Klein did and polished it a little bit.
A patch is attached, also some .ly files I used to test it.

I'd like to do a phase 2 to this later to set up a property setting so we can do something like

\book \with {output-suffix = "Gibbon"}
{ music...}
\book \with {output-suffix = "Vole"}
{ music...}
\book \with {output-suffix = "Aardvark"}
{ music...}

or
\book {
output-suffix="Newt"
music...
}
but that's for the future

Cheers,

Ian Hulin


From 41253108ee2abaa1494f325b742a38041264b8f0 Mon Sep 17 00:00:00 2001
From: Ian Hulin <[hidden email]>
Date: Thu, 6 Aug 2009 16:20:52 +0100
Subject: [PATCH] Issues 714 and 404: Add greater user flexibility in naming output files
 using output-suffix.
 output name handling now moved to its own procedure in lily-library.scm

Signed-off-by: Ian Hulin <[hidden email]>
---
 scm/lily-library.scm |   49 ++++++++++++++++++++++++++++---------------------
 1 files changed, 28 insertions(+), 21 deletions(-)

diff --git a/scm/lily-library.scm b/scm/lily-library.scm
index ca52916..3bc47ef 100644
--- a/scm/lily-library.scm
+++ b/scm/lily-library.scm
@@ -127,28 +127,35 @@
 
   (ly:make-score music))
 
+(define (get-outfile-name parser base)
+(let*
+    ((output-suffix (ly:parser-lookup parser 'output-suffix))
+     (counter-alist (ly:parser-lookup parser 'counter-alist))
+     (output-count (assoc-ref counter-alist output-suffix))
+     (result base ) )
+
+    (if (string? output-suffix)
+ (set! result (format "~a-~a" base (string-regexp-substitute
+   "[^a-zA-Z0-9-]" "_" output-suffix))))
+    ;; must be careful: assoc-ref may return '().
+    (if (not (integer? output-count))
+ (set! output-count 0))
+
+    (if (> output-count 0)
+ (set! result (format #f "~a-~a" result output-count)))
+    
+    (ly:parser-define!
+  parser 'counter-alist (assoc-set! counter-alist output-suffix  (1+ output-count)))
+    result ) )
+
 (define (print-book-with parser book process-procedure)
   (let*
       ((paper (ly:parser-lookup parser '$defaultpaper))
        (layout (ly:parser-lookup parser '$defaultlayout))
-       (output-suffix (ly:parser-lookup parser 'output-suffix))
-       (counter-alist (ly:parser-lookup parser 'counter-alist))
-       (output-count (assoc-ref counter-alist output-suffix))
-       (base (ly:parser-output-name parser)) )
-      
-      (if (string? output-suffix)
- (set! base (format "~a-~a" base (string-regexp-substitute
-   "[^a-zA-Z0-9-]" "_" output-suffix))))
-
-    ;; must be careful: output-count is under user control.
-    (if (not (integer? output-count))
- (set! output-count 0))
+       (base (ly:parser-output-name parser))
+       (outfile-name (get-outfile-name parser base)) )
 
-    (if (> output-count 0)
- (set! base (format #f "~a-~a" base output-count)))
-    (ly:parser-define! parser 'counter-alist (assoc-set! counter-alist output-suffix (1+ output-count)))
-    (process-procedure book paper layout base)
-    ))
+      (process-procedure book paper layout outfile-name)  ) )
 
 (define-public (print-book-with-defaults parser book)
   (print-book-with parser book ly:book-process))
@@ -638,16 +645,16 @@ possibly turned off."
 
 (define-public (version-not-seen-message input-file-name)
   (ly:message
-   "~a:0: ~a: ~a"
+   "~a:0: ~a ~a"
     input-file-name
-    (_ "warning: ")
+    (_ "warning:")
     (format #f
     (_ "no \\version statement found, please add~afor future compatibility")
     (format #f "\n\n\\version ~s\n\n" (lilypond-version)))))
 
 (define-public (old-relative-not-used-message input-file-name)
   (ly:message
-   "~a:0: ~a: ~a"
+   "~a:0: ~a ~a"
     input-file-name
-    (_ "warning: ")
+    (_ "warning:")
     (_ "old relative compatibility not used")))
--
1.6.0.4


\include "english.ly"
\version "2.12.1"
\header {
  title = "Exsultate, Jubilate"
  subtitle = "Motet"
  subsubtitle = "K. 165"
  instrument = "Soprano Solo and Orchestra"
  composer = "W. A. Mozart"
  opus = "KV 165"
}
\paper {
 }
\midi {
  }
\layout{
  }
movonesettings = {
 \key f \major
 \time 4/4
 \tempo "Allegro" 4=128
   
 }
oboesmovoneMusic = \relative c' {
    r8 <a' c>8 <a c>8 <a c>8 <a c>4 r4 |
  }
hornsmovoneMusic = \relative c' {
  \key c \major r8 <c c'>8 <c c'>8 <c c'>8 <c c'>4 r4 |
}
VlnonemovoneMusic = \relative c' {
  <a' f'>4 c4~ c8 d16 e f g a f |
}
VlntwomovoneMusic = \relative c' {
 a'16 bflat c bflat a bflat c bflat a4 r4 |
}
VlamovoneMusic = \relative c' {
 \clef alto c16 bf a bf c bf a bf c4 r4 |
}
SopranomovoneMusic = \relative c' {
  R1 |
}
BCmovoneMusic = \relative c {
  \clef bass f8 f f f f f f f |
}

#(define output-suffix "Allegro")
\book {
\bookpart {
 \header {
  subtitle = "I. Allegro"
 }

 \score {

  \new StaffGroup {
     <<
       \new Staff = oboesmovone \with {instrumentName = "2 Oboi"
                                       midiInstrument = "oboe"}
     {
      \movonesettings \oboesmovoneMusic
     }
     \new Staff = hornsmovone \with {instrumentName = "2 Corni in F"
                                     midiInstrument = "french horn"}
     {
        \transposition f \time 4/4 \tempo "Allegro" \hornsmovoneMusic
     }
     \new GrandStaff  <<
        \new Staff = Vlnonemovone \with {instrumentName = "Violino I"
                                          midiInstrument = "violin"}
        {
          \movonesettings \VlnonemovoneMusic
        }
        \new Staff = Vlntwomovone \with {instrumentName = "Violino II"
                                          midiInstrument = "violin"}
        {
          \movonesettings \VlntwomovoneMusic
        }
       
      >>
     \new Staff = Vlamovone \with {instrumentName = "Viola"
                                      midiInstrument = "viola"}
     {
       \movonesettings \VlamovoneMusic
     }
     \new Staff = Sopranomovone \with {instrumentName = "Soprano"
                                       midiInstrument = "voice oohs"}
      {
        \movonesettings \SopranomovoneMusic
      }
      \new Staff = BCmovone \with { instrumentName = "Basso ed Organo"
                                    midiInstrument = "contrabass"}
      {
        \movonesettings \BCmovoneMusic
      }
      >>
    }
  }

}
}

movtwosettings = {
 \key a \major
 \time 3/4
 \tempo "Andante" 4=72
 }
oboesmovtwoMusic = \relative c' {
  \partial 8 r8
  |R2.   |
}
hornsmovtwoMusic = \relative c' {
  \partial 8 r8 |
  R2.   |
}
VlnonemovtwoMusic = \relative c'' {
  \partial 8 a8 |
  e'4. d16( cs) b8 cs |
}
VlntwomovtwoMusic = \relative c'' {
  \partial 8 a8 |
  cs4. b16( a) gs8 a |
}
VlamovtwoMusic = \relative c' {
  \clef alto
  \partial 8 a8 |
  e'4. d16( cs) b8 cs |
}
SopranomovtwoMusic = \relative c'' {
 \partial 8 r8
  |R2.   |
}
BCmovtwoMusic = \relative c {
  \clef bass
  \partial 8 r8
  r4 a'4 a, |
}

#(define output-suffix "Andante")
\book{
\bookpart{
  \header {
  subtitle = "II. Andante"
 }
  \score {
  \new StaffGroup {
     <<
       \new Staff = oboesmovtwo \with {instrumentName = "2 Oboi"
                                       midiInstrument = "oboe"}
     {
      \movtwosettings \oboesmovtwoMusic
     }
     \new Staff = hornsmovtwo \with {instrumentName = "2 Corni in F"
                                     midiInstrument = "french horn"}
     {
        \transposition f \time 4/4 \key e \major \tempo "Allegro" \hornsmovtwoMusic
     }
     \new GrandStaff  <<
        \new Staff = Vlnonemovtwo \with {instrumentName = "Violino I"
                                          midiInstrument = "violin"}
        {
          \movtwosettings \VlnonemovtwoMusic
        }
        \new Staff = Vlntwomovtwo \with {instrumentName = "Violino II"
                                          midiInstrument = "violin"}
        {
          \movtwosettings \VlntwomovtwoMusic
        }
       
      >>
     \new Staff = Vlamovtwo \with {instrumentName = "Viola"
                                      midiInstrument = "viola"}
     {
       \movtwosettings \VlamovtwoMusic
     }
     \new Staff = Sopranomovtwo \with {instrumentName = "Soprano"
                                       midiInstrument = "voice oohs"}
      {
        \movtwosettings \SopranomovtwoMusic
      }
      \new Staff = BCmovtwo \with { instrumentName = "Basso ed Organo"
                                    midiInstrument = "contrabass"}
      {
        \movtwosettings \BCmovtwoMusic
      }
      >>
    }
  }
   

}
}

\version "2.12.1"
\header {
  title = "Exsultate, Jubilate"
  subtitle = "Motet"
  subsubtitle = "K. 165"
  instrument = "Soprano Solo and Orchestra"
  composer = "W. A. Mozart"
  opus = "KV 165"
}
movonesettings = {
 \key f \major
 \time 4/4
 \tempo "Allegro" 4=128
   
 }
movtwosettings = {
 \key a \major
 \time 3/4
 \tempo "Andante" 4=72
 }
BCmovoneMusic = \relative c {
  \movonesettings
  \clef bass f8 f f f f f f f |
}
BCmovtwoMusic = \relative c {
\movtwosettings
  \clef bass
  \partial 8 r8
  r4 a'4 a, |
}
#(define output-suffix "Allegro")
\book {
\header {
                subtitle = "I Allegro"
        }
\score {
       
        \BCmovoneMusic
}
}
#(define output-suffix '())
\book {
\header {
        subtitle = "II. Andante"
}
\score {
        \BCmovtwoMusic
}
}

Reply | Threaded
Open this post in threaded view
|

Re: PATCH for getting output-suffix to work (Trackers 714 and 404)

reinhold
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Am Donnerstag, 6. August 2009 18:20:26 schrieb Ian Hulin:
>  Here's the first stage of work on these trackers,  I've taken the work
> Marek Klein did and polished it a little bit.

Great to see that this is not forgotten (like so many other not yet finished
patches)! Some comments below...

> +    (if (string? output-suffix)
> +       (set! result (format "~a-~a" base (string-regexp-substitute
> +                                        "[^a-zA-Z0-9-]" "_" output-suffix))))

This rules out any accented or other foreigh letters! E.g. all chinese suffixes
will simply turn into ______. Also, German instrument names like "Flöte" or
"Hörner" would become "Fl_te" and "H_rner" in the suffix.

I supose it would be better to use
  "[^[:alnum:]-+]"
as the regexp to allow all alpha-numeric letters.

>  (define-public (version-not-seen-message input-file-name)
>    (ly:message
> -   "~a:0: ~a: ~a"
> +   "~a:0: ~a ~a"
>      input-file-name
> -    (_ "warning: ")
> +    (_ "warning:")

Nice catch, but has nothing to do with output-suffix, so it should go into its
own patch.

Cheers,
Reinhold
- --
- ------------------------------------------------------------------
Reinhold Kainhofer, [hidden email], http://reinhold.kainhofer.com/
 * Financial & Actuarial Math., Vienna Univ. of Technology, Austria
 * http://www.fam.tuwien.ac.at/, DVR: 0005886
 * LilyPond, Music typesetting, http://www.lilypond.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iD8DBQFKewkITqjEwhXvPN0RAjYEAJ0TaV392KlkU//Xo+iQ45NDN4cIoACfeugc
7Xe8HmcDYvOtpTpWso0nDug=
=Fa8L
-----END PGP SIGNATURE-----

---

----
Join the Frogs!

Reply | Threaded
Open this post in threaded view
|

Re: PATCH for getting output-suffix to work (Trackers 714 and 404)

Neil Puttock
2009/8/6 Reinhold Kainhofer <[hidden email]>:

> Nice catch, but has nothing to do with output-suffix, so it should go into its
> own patch.

Ian, are you using git?  These warning message nitpicks were fixed in
March, so it looks like your patch is based on an old version of
LilyPond.

Regards,
Neil

---

----
Join the Frogs!

Reply | Threaded
Open this post in threaded view
|

Re: PATCH for getting output-suffix to work (Trackers 714 and 404)

Ian Hulin
Neil Puttock wrote:
2009/8/6 Reinhold Kainhofer [hidden email]:

  
Nice catch, but has nothing to do with output-suffix, so it should go into its
own patch.
    

Ian, are you using git?  These warning message nitpicks were fixed in
March, so it looks like your patch is based on an old version of
LilyPond.
  
Yeah, but I hadn't updated it in quite a while. I've trashed by old got repo, built a brand new one and reapplied the changes for this patch which I've attached.

Cheers, Ian



From 1fa4c60f1aa5ba693fc2f634bc9dee9cbd8b366c Mon Sep 17 00:00:00 2001
From: Ian Hulin <[hidden email]>
Date: Fri, 7 Aug 2009 00:23:30 +0100
Subject: [PATCH] Issues 714 and 404: Add greater user flexibility in naming output files
  using output-suffix.
  output name handling now moved to its own procedure in lily-library.scm

Signed-off-by: Ian Hulin <[hidden email]>
---
 scm/lily-library.scm |   38 +++++++++++++++++++++++---------------
 1 files changed, 23 insertions(+), 15 deletions(-)

diff --git a/scm/lily-library.scm b/scm/lily-library.scm
index adb2bdf..9e12968 100644
--- a/scm/lily-library.scm
+++ b/scm/lily-library.scm
@@ -130,27 +130,35 @@
 
   (ly:make-score music))
 
+(define (get-outfile-name parser base)
+(let*
+    ((output-suffix (ly:parser-lookup parser 'output-suffix))
+     (counter-alist (ly:parser-lookup parser 'counter-alist))
+     (output-count (assoc-ref counter-alist output-suffix))
+     (result base ) )
+
+    (if (string? output-suffix)
+ (set! result (format "~a-~a" base (string-regexp-substitute
+   "[^a-zA-Z0-9-]" "_" output-suffix))))
+    ;; must be careful: assoc-ref may return '().
+    (if (not (integer? output-count))
+ (set! output-count 0))
+
+    (if (> output-count 0)
+ (set! result (format #f "~a-~a" result output-count)))
+    
+    (ly:parser-define!
+  parser 'counter-alist (assoc-set! counter-alist output-suffix  (1+ output-count)))
+    result ) )
+
 (define (print-book-with parser book process-procedure)
   (let*
       ((paper (ly:parser-lookup parser '$defaultpaper))
        (layout (ly:parser-lookup parser '$defaultlayout))
-       (count (ly:parser-lookup parser 'output-count))
        (base (ly:parser-output-name parser))
-       (output-suffix (ly:parser-lookup parser 'output-suffix)) )
+       (outfile-name (get-outfile-name parser base)) )
 
-    (if (string? output-suffix)
- (set! base (format "~a-~a" base (string-regexp-substitute
-   "[^a-zA-Z0-9-]" "_" output-suffix))))
-
-    ;; must be careful: output-count is under user control.
-    (if (not (integer? count))
- (set! count 0))
-
-    (if (> count 0)
- (set! base (format #f "~a-~a" base count)))
-    (ly:parser-define! parser 'output-count (1+ count))
-    (process-procedure book paper layout base)
-    ))
+      (process-procedure book paper layout outfile-name)  ) )
 
 (define-public (print-book-with-defaults parser book)
   (print-book-with parser book ly:book-process))
--
1.6.0.4

Reply | Threaded
Open this post in threaded view
|

Re: PATCH for getting output-suffix to work (Trackers 714 and 404)

Ian Hulin
In reply to this post by reinhold
Reinhold Kainhofer wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Am Donnerstag, 6. August 2009 18:20:26 schrieb Ian Hulin:
  
 Here's the first stage of work on these trackers,  I've taken the work
Marek Klein did and polished it a little bit. 
    

Great to see that this is not forgotten (like so many other not yet finished 
patches)! Some comments below...

  
+    (if (string? output-suffix)
+       (set! result (format "~a-~a" base (string-regexp-substitute
+                                        "[^a-zA-Z0-9-]" "_" output-suffix))))
    

This rules out any accented or other foreigh letters! E.g. all chinese suffixes 
will simply turn into ______. Also, German instrument names like "Fl�te" or 
"H�rner" would become "Fl_te" and "H_rner" in the suffix.

I supose it would be better to use 
  "[^[:alnum:]-+]"
as the regexp to allow all alpha-numeric letters.
  

Reinhold -
There's a restriction with the gs back-end. Marek asked abourt this and Han-Wen confirmed that's why we're restricted to ujsing the ASCII set for filenames.  So we'll have to stick to work-rounds like "Floete" and "Hoerner" in the suffix names.

  
 (define-public (version-not-seen-message input-file-name)
   (ly:message
-   "~a:0: ~a: ~a"
+   "~a:0: ~a ~a"
     input-file-name
-    (_ "warning: ")
+    (_ "warning:")
    

Nice catch, but has nothing to do with output-suffix, so it should go into its 
own patch.

  
Sorted in my git repo.

Cheers,
Ian


Reply | Threaded
Open this post in threaded view
|

Re: PATCH for getting output-suffix to work (Trackers 714 and 404)

reinhold
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Am Mittwoch, 12. August 2009 14:32:37 schrieb Ian Hulin:

> Reinhold Kainhofer wrote:
> >> +    (if (string? output-suffix)
> >> +       (set! result (format "~a-~a" base (string-regexp-substitute
> >> +                                        "[^a-zA-Z0-9-]" "_"
> >> output-suffix))))
> >
> > This rules out any accented or other foreigh letters! E.g. all chinese
> > suffixes will simply turn into ______. Also, German instrument names like
> > "Fl�te" or "H�rner" would become "Fl_te" and "H_rner" in the suffix.
> >
> > I supose it would be better to use
> >   "[^[:alnum:]-+]"
> > as the regexp to allow all alpha-numeric letters.
>
> Reinhold -
> There's a restriction with the gs back-end. Marek asked abourt this and
> Han-Wen confirmed that's why we're restricted to ujsing the ASCII set
> for filenames.

Hmm, that's strange, since using a file name like "äúôÿßø¼¤³.ly" works just
fine. What causes problems is multi-byte unicode characters (i.e. anything
outside the ANSI charset), which allows umlaute and other accented vowels....

Cheers,
Reinhold


- --
- ------------------------------------------------------------------
Reinhold Kainhofer, [hidden email], http://reinhold.kainhofer.com/
 * Financial & Actuarial Math., Vienna Univ. of Technology, Austria
 * http://www.fam.tuwien.ac.at/, DVR: 0005886
 * LilyPond, Music typesetting, http://www.lilypond.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iD8DBQFKgs/mTqjEwhXvPN0RAly0AJ9AonsFrzYTcuyqnTlLlyeRTKHrqgCgoEZn
OlBMs15FKdSspzMh+iaCwGY=
=oRBG
-----END PGP SIGNATURE-----

---

----
Join the Frogs!

Reply | Threaded
Open this post in threaded view
|

Re: PATCH for getting output-suffix to work (Trackers 714 and 404)

Ian Hulin
Reinhold and Carl,
I've implemented Carl's comments and also investigated Reinhold's feedback here.  We can used Western European accented characters: acutes, graves, umlauts/diaereses on all vowels, scharfes s, Ash, Edh and thorn c cedilla and n tilde, but can't use the Extended Latin stuff like c hracek or A macron.

I've spent too long trying to get regexp to work here and I can't find a satisfactory fix (sigh).  I've marked the code with a FIXME comment block.

I seem to have picked up some unrelated line changes from git again.  The difference lines refer to split-at-predicate which I haven't touched.  My patch should only have changes to print-book-with and the new get-outfile-name function.  Carl, could yuo clean the patch up please? I don't know what to do here.

I've also attached the test file I was using to demonstrate the eight-bit code problem.

Cheers,

Ian

Reinhold Kainhofer wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Am Mittwoch, 12. August 2009 14:32:37 schrieb Ian Hulin:
  
Reinhold Kainhofer wrote:
    
+    (if (string? output-suffix)
+       (set! result (format "~a-~a" base (string-regexp-substitute
+                                        "[^a-zA-Z0-9-]" "_"
output-suffix))))
        
This rules out any accented or other foreigh letters! E.g. all chinese
suffixes will simply turn into ______. Also, German instrument names like
"Fl���te" or "H���rner" would become "Fl_te" and "H_rner" in the suffix.

I supose it would be better to use
  "[^[:alnum:]-+]"
as the regexp to allow all alpha-numeric letters.
      
Reinhold -
There's a restriction with the gs back-end. Marek asked abourt this and
Han-Wen confirmed that's why we're restricted to ujsing the ASCII set
for filenames. 
    

Hmm, that's strange, since using a file name like "������������������.ly" works just 
fine. What causes problems is multi-byte unicode characters (i.e. anything 
outside the ANSI charset), which allows umlaute and other accented vowels....

Cheers,
Reinhold


- -- 
- ------------------------------------------------------------------
Reinhold Kainhofer, [hidden email], http://reinhold.kainhofer.com/
 * Financial & Actuarial Math., Vienna Univ. of Technology, Austria
 * http://www.fam.tuwien.ac.at/, DVR: 0005886
 * LilyPond, Music typesetting, http://www.lilypond.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iD8DBQFKgs/mTqjEwhXvPN0RAly0AJ9AonsFrzYTcuyqnTlLlyeRTKHrqgCgoEZn
OlBMs15FKdSspzMh+iaCwGY=
=oRBG
-----END PGP SIGNATURE-----

______________________________________________        
This email has been scanned by Netintelligence        
http://www.netintelligence.com/email


  


From 6e4f9fe23f9a0a790cb688cfef8c4673df51d3aa Mon Sep 17 00:00:00 2001
From: Ian Hulin <[hidden email]>
Date: Thu, 13 Aug 2009 12:23:17 +0100
Subject: [PATCH] Issues 714 and 404: Add greater user flexibility in naming output files
  using output-suffix.
  output name handling now moved to its own procedure in lily-library.scm
 Amended to use ly:get-assoc to pick up initial value of parser variable
  output-count and remove redundant check on initial call.
 Removed regexp call which wasn't working anyway - Western European
 unaccented characters now supported in output-suffix.

Signed-off-by: Ian Hulin <[hidden email]>
---
 scm/lily-library.scm |  158 ++++++++++++++++++++++++++++----------------------
 1 files changed, 89 insertions(+), 69 deletions(-)

diff --git a/scm/lily-library.scm b/scm/lily-library.scm
index e7f1d29..d5bd1e2 100644
--- a/scm/lily-library.scm
+++ b/scm/lily-library.scm
@@ -6,9 +6,6 @@
 ;;;; (c) 1998--2009 Jan Nieuwenhuizen <[hidden email]>
 ;;;; Han-Wen Nienhuys <[hidden email]>
 
-; for take, drop, take-while, list-index, and find-tail:
-(use-modules (srfi srfi-1))
-
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; constants.
 
@@ -134,27 +131,43 @@
 
   (ly:make-score music))
 
+(define (get-outfile-name parser base)
+(let*
+    ((output-suffix (ly:parser-lookup parser 'output-suffix))
+     (counter-alist (ly:parser-lookup parser 'counter-alist))
+     (output-count (assoc-get output-suffix counter-alist 0))
+     (result base ) )
+    ;; Allow all ASCII alphanumerics,
+    ;;   including accents
+    ;; FIXME
+    ;; eight-bit accented chars like C caron will be passed through
+    ;; and will crash the ghostscript backend.
+    ;; Previous regexp using pattern "[^A-Za-z0-9-]" didn't work and
+    ;; can't get this one to fly, either
+    
+    ;(if (string? output-suffix)
+    ;(set! result (format "~a-~a" base (string-regexp-substitute
+    ;   "[^[:alnum:]-]" "_" output-suffix))))
+    (if (string? output-suffix)
+ (set! result (format "~a-~a" base output-suffix)))
+
+
+    ;; assoc-get call will always have returned a number
+    (if (> output-count 0)
+ (set! result (format #f "~a-~a" result output-count)))
+    
+    (ly:parser-define!
+  parser 'counter-alist (assoc-set! counter-alist output-suffix  (1+ output-count)))
+    result ) )
+
 (define (print-book-with parser book process-procedure)
   (let*
       ((paper (ly:parser-lookup parser '$defaultpaper))
        (layout (ly:parser-lookup parser '$defaultlayout))
-       (count (ly:parser-lookup parser 'output-count))
        (base (ly:parser-output-name parser))
-       (output-suffix (ly:parser-lookup parser 'output-suffix)) )
+       (outfile-name (get-outfile-name parser base)) )
 
-    (if (string? output-suffix)
- (set! base (format "~a-~a" base (string-regexp-substitute
-   "[^a-zA-Z0-9-]" "_" output-suffix))))
-
-    ;; must be careful: output-count is under user control.
-    (if (not (integer? count))
- (set! count 0))
-
-    (if (> count 0)
- (set! base (format #f "~a-~a" base count)))
-    (ly:parser-define! parser 'output-count (1+ count))
-    (process-procedure book paper layout base)
-    ))
+      (process-procedure book paper layout outfile-name)  ) )
 
 (define-public (print-book-with-defaults parser book)
   (print-book-with parser book ly:book-process))
@@ -341,29 +354,53 @@ found."
    (cons x acc))))
  '() lst) '()))
 
-(define (split-at-predicate pred lst)
-  "Split LST into two lists at the first element that returns #f for
-  (PRED previous_element element). Return the two parts as a pair.
-  Example: (split-at-predicate < '(1 2 3 2 1)) ==> ((1 2 3) . (2 1))"
-  (if (null? lst)
-      (list lst)
-      (let ((i (list-index pred (cdr lst) lst)))
-        (if i
-            (cons (take lst (1+ i)) (drop lst (1+ i)))
-            (list lst)))))
-
-(define-public (split-list-by-separator lst pred)
-  "Split LST at each element that satisfies PRED, and return the parts
-  (with the separators removed) as a list of lists. Example:
-  (split-list-by-separator '(a 0 b c 1 d) number?) ==> ((a) (b c) (d))"
-  (let loop ((result '()) (lst lst))
-    (if (and lst (not (null? lst)))
-        (loop
-          (append result
-                  (list (take-while (lambda (x) (not (pred x))) lst)))
-          (let ((tail (find-tail pred lst)))
-            (if tail (cdr tail) #f)))
-       result)))
+(define (split-at-predicate predicate lst)
+ "Split LST = (a_1 a_2 ... a_k b_1 ... b_k)
+  into L1 = (a_1 ... a_k ) and L2 =(b_1 .. b_k)
+  Such that (PREDICATE a_i a_{i+1}) and not (PREDICATE a_k b_1).
+  L1 is copied, L2 not.
+
+  (split-at-predicate (lambda (x y) (= (- y x) 2)) '(1 3 5 9 11) (cons '() '()))"
+
+ ;; " Emacs is broken
+
+ (define (inner-split predicate lst acc)
+   (cond
+    ((null? lst) acc)
+    ((null? (cdr lst))
+     (set-car! acc (cons (car lst) (car acc)))
+     acc)
+    ((predicate (car lst) (cadr lst))
+     (set-car! acc (cons (car lst) (car acc)))
+     (inner-split predicate (cdr lst) acc))
+    (else
+     (set-car! acc (cons (car lst) (car acc)))
+     (set-cdr! acc (cdr lst))
+     acc)))
+
+ (let* ((c (cons '() '())))
+   (inner-split predicate lst  c)
+   (set-car! c (reverse! (car c)))
+   c))
+
+(define-public (split-list-by-separator lst sep?)
+   "(display (split-list-by-separator '(a b c / d e f / g) (lambda (x) (equal? x '/))))
+   =>
+   ((a b c) (d e f) (g))
+  "
+   ;; " Emacs is broken
+   (define (split-one sep?  lst acc)
+     "Split off the first parts before separator and return both parts."
+     (if (null? lst)
+ (cons acc '())
+ (if (sep? (car lst))
+     (cons acc (cdr lst))
+     (split-one sep? (cdr lst) (cons (car lst) acc)))))
+  
+   (if (null? lst)
+       '()
+       (let* ((c (split-one sep? lst '())))
+ (cons (reverse! (car c) '()) (split-list-by-separator (cdr c) sep?)))))
 
 (define-public (offset-add a b)
   (cons (+ (car a) (car b))
@@ -555,27 +592,12 @@ possibly turned off."
    (reverse matches))
 
 ;;;;;;;;;;;;;;;;
-;; other
-
+; other
 (define (sign x)
   (if (= x 0)
       0
       (if (< x 0) -1 1)))
 
-(define-public (binary-search start end getter target-val)
-  (_i "Find the index between @var{start} and @var{end} (an integer)
-which will produce the closest match to @var{target-val} when
-applied to function @var{getter}.")
-  (if (<= end start)
-      start
-      (let* ((compare (quotient (+ start end) 2))
-     (get-val (getter compare)))
- (cond
- ((< target-val get-val)
-  (set! end (1- compare)))
- ((< get-val target-val)
-  (set! start (1+ compare))))
- (binary-search start end getter target-val))))
 
 (define-public (car< a b)
   (< (car a) (car b)))
@@ -618,19 +640,17 @@ applied to function @var{getter}.")
 
 ;;; FONT may be font smob, or pango font string...
 (define-public (font-name-style font)
-  ;; FIXME: ughr, barf: feta-alphabet is actually emmentaler
-  (if (and (string? font)
-   (string-prefix? "feta-alphabet" font))
-      (string-append "emmentaler"
-     "-"
-     (substring font
- (string-length "feta-alphabet")
- (string-length font)))
+      ;; FIXME: ughr, (ly:font-name) sometimes also has Style appended.
       (let* ((font-name (ly:font-name font))
-     (full-name (if font-name font-name (ly:font-file-name font))))
- (if (string-prefix? "Aybabtu" full-name)
-    "aybabtu"
-    (string-downcase full-name)))))
+     (full-name (if font-name font-name (ly:font-file-name font)))
+     (name-style (string-split full-name #\-)))
+ ;; FIXME: ughr, barf: feta-alphabet is actually emmentaler
+ (if (string-prefix? "feta-alphabet" full-name)
+    (list "emmentaler"
+  (substring  full-name (string-length "feta-alphabet")))
+    (if (not (null? (cdr name-style)))
+    name-style
+    (append name-style '("Regular"))))))
 
 (define-public (modified-font-metric-font-scaling font)
   (let* ((designsize (ly:font-design-size font))
--
1.6.0.4


\version "2.12.1"
\header {
  title = "Exsultate, Jubilate"
  subtitle = "Motet"
  subsubtitle = "K. 165"
  instrument = "Soprano Solo and Orchestra"
  composer = "W. A. Mozart"
  opus = "KV 165"
}
movonesettings = {
 \key f \major
 \time 4/4
 \tempo "Allegro" 4=128
   
 }
movtwosettings = {
 \key a \major
 \time 3/4
 \tempo "Andante" 4=72
 }
BCmovoneMusic = \relative c {
  \movonesettings
  \clef bass f8 f f f f f f f |
}
BCmovtwoMusic = \relative c {
\movtwosettings
  \clef bass
  \partial 8 r8
  r4 a'4 a, |
}
%#(define output-suffix "Čača-Allegro") %This fails with current code
#(define output-suffix "Schloß-Allegro")
\book {
\header {
                subtitle = "Première-Allegro"
        }
\score {
       
        \BCmovoneMusic
}
}
#(define output-suffix "Flöten-Andante")
\book {
\header {
        subtitle = "II. Andante"
}
\score {
        \BCmovtwoMusic
}
}

Reply | Threaded
Open this post in threaded view
|

Re: PATCH for getting output-suffix to work (Trackers 714 and 404)

Carl Sorensen
Ian,

This patch can't be applied because it has lots of changes that are outside
of your scope.

It appears that you made your changes on an old version of master, then
created your patch against the current version.

Can you do the following:

If are working on the branch master in your local repository, do

git pull -r

This will update master, but still keep all of your local changes
separate and in the most recent commit.

Then make a new copy of the patch.

Also, please give one more try on the regexp. The hyphen in your [ ]
expression should have a \ before it so it will stand for a hyphen, instead
of a range marker.

I'd recommend that you use [^\w\-] as I think it's the simplest
non-alphanumeric and non-hyphen regex.

Thanks,

Carl

On 8/13/09 5:44 AM, "Ian Hulin" <[hidden email]> wrote:

> Reinhold and Carl,
> I've implemented Carl's comments and also investigated Reinhold's feedback
> here.  We can used Western European accented characters: acutes, graves,
> umlauts/diaereses on all vowels, scharfes s, Ash, Edh and thorn c cedilla and
> n tilde, but can't use the Extended Latin stuff like c hracek or A macron.
>
> I've spent too long trying to get regexp to work here and I can't find a
> satisfactory fix (sigh).  I've marked the code with a FIXME comment block.
>
> I seem to have picked up some unrelated line changes from git again.  The
> difference lines refer to split-at-predicate which I haven't touched.  My
> patch should only have changes to print-book-with and the new get-outfile-name
> function.  Carl, could yuo clean the patch up please? I don't know what to do
> here.
>
> I've also attached the test file I was using to demonstrate the eight-bit code
> problem.
>
> Cheers,
>
> Ian
>
> Reinhold Kainhofer wrote:
>>  
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> Am Mittwoch, 12. August 2009 14:32:37 schrieb Ian Hulin:
>>  
>>  
>>>  
>>> Reinhold Kainhofer wrote:
>>>    
>>>  
>>>>  
>>>>>  
>>>>> +    (if (string? output-suffix)
>>>>> +       (set! result (format "~a-~a" base (string-regexp-substitute
>>>>> +                                        "[^a-zA-Z0-9-]" "_"
>>>>> output-suffix))))
>>>>>        
>>>>>  
>>>>  
>>>> This rules out any accented or other foreigh letters! E.g. all chinese
>>>> suffixes will simply turn into ______. Also, German instrument names like
>>>> "Fl���te" or "H���rner" would become "Fl_te" and "H_rner" in the suffix.
>>>>
>>>> I supose it would be better to use
>>>>   "[^[:alnum:]-+]"
>>>> as the regexp to allow all alpha-numeric letters.
>>>>      
>>>>  
>>>  
>>> Reinhold -
>>> There's a restriction with the gs back-end. Marek asked abourt this and
>>> Han-Wen confirmed that's why we're restricted to ujsing the ASCII set
>>> for filenames.
>>>    
>>>  
>>  
>>
>> Hmm, that's strange, since using a file name like "������������������.ly"
>> works just
>> fine. What causes problems is multi-byte unicode characters (i.e. anything
>> outside the ANSI charset), which allows umlaute and other accented vowels....
>>
>> Cheers,
>> Reinhold
>>
>>
>> - --
>> - ------------------------------------------------------------------
>> Reinhold Kainhofer, [hidden email], http://reinhold.kainhofer.com/
>>  * Financial & Actuarial Math., Vienna Univ. of Technology, Austria
>>  * http://www.fam.tuwien.ac.at/, DVR: 0005886
>>  * LilyPond, Music typesetting, http://www.lilypond.org
>> -----BEGIN PGP SIGNATURE-----
>> Version: GnuPG v1.4.9 (GNU/Linux)
>>
>> iD8DBQFKgs/mTqjEwhXvPN0RAly0AJ9AonsFrzYTcuyqnTlLlyeRTKHrqgCgoEZn
>> OlBMs15FKdSspzMh+iaCwGY=
>> =oRBG
>> -----END PGP SIGNATURE-----
>>
>> ______________________________________________
>> This email has been scanned by Netintelligence
>> http://www.netintelligence.com/email
>>
>>
>>  
>

&������,
Reply | Threaded
Open this post in threaded view
|

Re: PATCH for getting output-suffix to work (Trackers 714 and 404)

Valentin Villenave
Administrator
In reply to this post by Ian Hulin
2009/8/12 Ian Hulin <[hidden email]>:
> There's a restriction with the gs back-end. Marek asked abourt this and
> Han-Wen confirmed that's why we're restricted to ujsing the ASCII set for
> filenames.  So we'll have to stick to work-rounds like "Floete" and
> "Hoerner" in the suffix names.

Could this be related to
http://lists.gnu.org/archive/html/bug-lilypond/2009-08/msg00021.html ?

Regards,
Valentin

---

----
Join the Frogs!

Reply | Threaded
Open this post in threaded view
|

Re: PATCH for getting output-suffix to work (Trackers 714 and 404)

Ian Hulin
On 14/08/2009 14:16, Valentin Villenave wrote:

> 2009/8/12 Ian Hulin<[hidden email]>:
>    
>> There's a restriction with the gs back-end. Marek asked abourt this and
>> Han-Wen confirmed that's why we're restricted to ujsing the ASCII set for
>> filenames.  So we'll have to stick to work-rounds like "Floete" and
>> "Hoerner" in the suffix names.
>>      
> Could this be related to
> http://lists.gnu.org/archive/html/bug-lilypond/2009-08/msg00021.html ?
>    
Yes it is very much related, but the investigationj I've done shows that
the restriction applies only to 8-bit Unicode characters, Western
European accented characters (all vowels with acute, grave,
diaeresis/Umlaut, tilde, circumflex, æ, ø, ß, þ, ð, ñ, ç
plus their uppercase versions will work.  Anything with a Unicode value
greater than x0FF will cause gs to barf.

So a Czech chacha (čača) in the filename will definitely kill the gs
back-end stone dead.

Cheers,
Ian


---

----
Join the Frogs!

Reply | Threaded
Open this post in threaded view
|

Re: PATCH for getting output-suffix to work (Trackers 714 and 404)

Ian Hulin
In reply to this post by Ian Hulin
Hi Carl,
I've done a bit of poking around with the regexp and it appears that any unicode alphabetic satisfies either the
[:alnum:] or [a-zAz0-9] patterns. In either case it lets through letters with unicode > 0FF which is what upsets my version of ghostscript. Patrick has reported that gs 8.70 is happy with these characters. I've got 8.64 as my default gs supplied by Ubuntu, and 8.65 files supplied in the lilypond directories.

The string-regexp-substitute does get rid of things like space and ©, ®, but µ is valid. It doesn't accept the  Perl-type patterns like \w or \W, and "-" doesn't need to be escaped (in fact it complains if you do try it.
Anyhow Reinhold, you can use your "Flöte" suffixes and the Scandinavians can use things like "Fløjt".

The patch I've got here is what I developed from the released lily-library.scm. I trashed and regenerated my git
repository, and have done a git pull -r, so anything you see outside of the block where I've added the new
get-outfile-name function and the end of print-book-with has been added by git. I've even double-checked and
eliminated the white-space differences.

Cheers,
Ian

_______________________________________________________________________________________________________________


Ian,
This patch can't be applied because it has lots of changes that are outside
of your scope.
It appears that you made your changes on an old version of master, then
created your patch against the current version.
Can you do the following:
If are working on the branch master in your local repository, do
git pull -r
This will update master, but still keep all of your local changes
separate and in the most recent commit.
Then make a new copy of the patch.
Also, please give one more try on the regexp. The hyphen in your [ ]
expression should have a \ before it so it will stand for a hyphen, instead
of a range marker.
I'd recommend that you use [^\w\-] as I think it's the simplest
non-alphanumeric and non-hyphen regex.
Thanks,
Carl

From 86045357d9b0673b566aa079ca872f46cc15a901 Mon Sep 17 00:00:00 2001
From: Ian Hulin <[hidden email]>
Date: Tue, 18 Aug 2009 11:45:13 +0100
Subject: [PATCH] Issues 714 and 404: Add greater user flexibility in naming output files
   using output-suffix.
   output name handling now moved to its own procedure in lily-library.scm
  Amended to use ly:get-assoc to pick up initial value of parser variable
   output-count and remove redundant check on initial call.
  Accented characters now supported in output-suffix.

Signed-off-by: Ian Hulin <[hidden email]>
---
 scm/lily-library.scm |   86 ++++++++++++++++++++------------------------------
 1 files changed, 34 insertions(+), 52 deletions(-)

diff --git a/scm/lily-library.scm b/scm/lily-library.scm
index e7f1d29..152f6f1 100644
--- a/scm/lily-library.scm
+++ b/scm/lily-library.scm
@@ -52,10 +52,6 @@
 (define-public (moment-min a b)
   (if (ly:moment<? a b) a b))
 
-(define-public (moment<=? a b)
-  (or (equal? a b)
-      (ly:moment<? a b)))
-
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; arithmetic
 (define-public (average x . lst)
@@ -134,27 +130,35 @@
 
   (ly:make-score music))
 
+
+(define (get-outfile-name parser base)
+(let*
+    ((output-suffix (ly:parser-lookup parser 'output-suffix))
+     (counter-alist (ly:parser-lookup parser 'counter-alist))
+     (output-count (assoc-get output-suffix counter-alist 0))
+     (result base ) )
+    ;; Allow all ASCII alphanumerics,
+    ;;   including accents
+    (if (string? output-suffix)
+    (set! result (format "~a-~a" base (string-regexp-substitute
+     "[^-[:alnum:]]" "_" output-suffix))))
+
+    ;; assoc-get call will always have returned a number
+    (if (> output-count 0)
+ (set! result (format #f "~a-~a" result output-count)))
+    
+    (ly:parser-define!
+  parser 'counter-alist (assoc-set! counter-alist output-suffix  (1+ output-count)))
+    result ) )
+
 (define (print-book-with parser book process-procedure)
   (let*
       ((paper (ly:parser-lookup parser '$defaultpaper))
        (layout (ly:parser-lookup parser '$defaultlayout))
-       (count (ly:parser-lookup parser 'output-count))
        (base (ly:parser-output-name parser))
-       (output-suffix (ly:parser-lookup parser 'output-suffix)) )
+       (outfile-name (get-outfile-name parser base)) )
 
-    (if (string? output-suffix)
- (set! base (format "~a-~a" base (string-regexp-substitute
-   "[^a-zA-Z0-9-]" "_" output-suffix))))
-
-    ;; must be careful: output-count is under user control.
-    (if (not (integer? count))
- (set! count 0))
-
-    (if (> count 0)
- (set! base (format #f "~a-~a" base count)))
-    (ly:parser-define! parser 'output-count (1+ count))
-    (process-procedure book paper layout base)
-    ))
+      (process-procedure book paper layout outfile-name)  ) )
 
 (define-public (print-book-with-defaults parser book)
   (print-book-with parser book ly:book-process))
@@ -347,7 +351,7 @@ found."
   Example: (split-at-predicate < '(1 2 3 2 1)) ==> ((1 2 3) . (2 1))"
   (if (null? lst)
       (list lst)
-      (let ((i (list-index pred (cdr lst) lst)))
+      (let ((i (list-index predicate (cdr lst) lst)))
         (if i
             (cons (take lst (1+ i)) (drop lst (1+ i)))
             (list lst)))))
@@ -396,8 +400,6 @@ found."
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; intervals
 
-(define-public empty-interval '(+inf.0 . -inf.0))
-
 (define-public (interval-length x)
   "Length of the number-pair X, when an interval"
   (max 0 (- (cdr x) (car x))))
@@ -453,10 +455,6 @@ found."
     (inf? (cdr i))
     (> (car i) (cdr i)))))
 
-(define-public (add-point interval p)
-  (cons (min (interval-start interval) p)
-        (max (interval-end interval) p)))
-
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; string
@@ -562,20 +560,6 @@ possibly turned off."
       0
       (if (< x 0) -1 1)))
 
-(define-public (binary-search start end getter target-val)
-  (_i "Find the index between @var{start} and @var{end} (an integer)
-which will produce the closest match to @var{target-val} when
-applied to function @var{getter}.")
-  (if (<= end start)
-      start
-      (let* ((compare (quotient (+ start end) 2))
-     (get-val (getter compare)))
- (cond
- ((< target-val get-val)
-  (set! end (1- compare)))
- ((< get-val target-val)
-  (set! start (1+ compare))))
- (binary-search start end getter target-val))))
 
 (define-public (car< a b)
   (< (car a) (car b)))
@@ -618,19 +602,17 @@ applied to function @var{getter}.")
 
 ;;; FONT may be font smob, or pango font string...
 (define-public (font-name-style font)
-  ;; FIXME: ughr, barf: feta-alphabet is actually emmentaler
-  (if (and (string? font)
-   (string-prefix? "feta-alphabet" font))
-      (string-append "emmentaler"
-     "-"
-     (substring font
- (string-length "feta-alphabet")
- (string-length font)))
+      ;; FIXME: ughr, (ly:font-name) sometimes also has Style appended.
       (let* ((font-name (ly:font-name font))
-     (full-name (if font-name font-name (ly:font-file-name font))))
- (if (string-prefix? "Aybabtu" full-name)
-    "aybabtu"
-    (string-downcase full-name)))))
+     (full-name (if font-name font-name (ly:font-file-name font)))
+     (name-style (string-split full-name #\-)))
+ ;; FIXME: ughr, barf: feta-alphabet is actually emmentaler
+ (if (string-prefix? "feta-alphabet" full-name)
+    (list "emmentaler"
+  (substring  full-name (string-length "feta-alphabet")))
+    (if (not (null? (cdr name-style)))
+    name-style
+    (append name-style '("Regular"))))))
 
 (define-public (modified-font-metric-font-scaling font)
   (let* ((designsize (ly:font-design-size font))
--
1.6.0.4

Reply | Threaded
Open this post in threaded view
|

RE: PATCH for getting output-suffix to work (Trackers 714 and 404)

Ian Hulin
In reply to this post by Ian Hulin
Hi Carl and all,

Here is a patch containing just the lines I've changed.

I've done a bit of poking around with the regexp and it appears that any
unicode alphabetic satisfies either the [:alnum:] or [a-zAz0-9] patterns.
In either case it lets through letters with unicode > 0FF which is what upsets my version of ghostscript. Patrick has reported that gs 8.70 is happy with these characters. I've got 8.64 as my default gs supplied by Ubuntu, and 8.65 files supplied in the lilypond directories,  but can't figure out how to install 8.7.

The string-regexp-substitute does get rid of things like space and ©, ®, but µ is valid. It doesn't accept the Perl-type patterns like \w or \W, and "-" doesn't need to be escaped (in fact it complains if you do try it.

Anyhow Reinhold,  can use "Flöte" and the Scandinavians can use things like "Fløjt" in output-suffix now.

Cheers,
Ian



From b2f17a0e2dc0c884e0f16a84045ec74a28ae3585 Mon Sep 17 00:00:00 2001
From: Ian Hulin <ian@ian-desktop.(none)>
Date: Wed, 19 Aug 2009 15:18:05 +0100
Subject: [PATCH] Issues 714 and 404: Add greater user flexibility in naming output files
    using output-suffix.
    output name handling now moved to its own procedure in lily-library.scm
   Amended to use ly:get-assoc to pick up initial value of parser variable
    output-count and remove redundant check on initial call.
   Accented characters now supported in output-suffix.

---
 scm/lily-library.scm |   37 +++++++++++++++++++++++--------------
 1 files changed, 23 insertions(+), 14 deletions(-)

diff --git a/scm/lily-library.scm b/scm/lily-library.scm
index e7f1d29..0437e60 100644
--- a/scm/lily-library.scm
+++ b/scm/lily-library.scm
@@ -134,27 +134,36 @@
 
   (ly:make-score music))
 
+
+(define (get-outfile-name parser base)
+(let*
+    ((output-suffix (ly:parser-lookup parser 'output-suffix))
+     (counter-alist (ly:parser-lookup parser 'counter-alist))
+     (output-count (assoc-get output-suffix counter-alist 0))
+     (result base ) )
+    ;; Allow all ASCII alphanumerics,
+    ;;   including accents
+    (if (string? output-suffix)
+    (set! result (format "~a-~a" base (string-regexp-substitute
+     "[^-[:alnum:]]" "_" output-suffix))))
+
+    ;; assoc-get call will always have returned a number
+    (if (> output-count 0)
+ (set! result (format #f "~a-~a" result output-count)))
+    
+    (ly:parser-define!
+  parser 'counter-alist (assoc-set! counter-alist output-suffix  (1+ output-count)))
+    result ) )
+
 (define (print-book-with parser book process-procedure)
   (let*
       ((paper (ly:parser-lookup parser '$defaultpaper))
        (layout (ly:parser-lookup parser '$defaultlayout))
        (count (ly:parser-lookup parser 'output-count))
        (base (ly:parser-output-name parser))
-       (output-suffix (ly:parser-lookup parser 'output-suffix)) )
+       (outfile-name (get-outfile-name parser base)) )
 
-    (if (string? output-suffix)
- (set! base (format "~a-~a" base (string-regexp-substitute
-   "[^a-zA-Z0-9-]" "_" output-suffix))))
-
-    ;; must be careful: output-count is under user control.
-    (if (not (integer? count))
- (set! count 0))
-
-    (if (> count 0)
- (set! base (format #f "~a-~a" base count)))
-    (ly:parser-define! parser 'output-count (1+ count))
-    (process-procedure book paper layout base)
-    ))
+      (process-procedure book paper layout outfile-name))
 
 (define-public (print-book-with-defaults parser book)
   (print-book-with parser book ly:book-process))
--
1.6.0.4

Reply | Threaded
Open this post in threaded view
|

Re: RE: PATCH for getting output-suffix to work (Trackers 714 and 404)

Ian Hulin
Oops, a closing parenthesis got missed out in the source. Here is s corrected patch, please ignore the previous one - apologies for the noise.

Cheers,
Ian Hulin

Ian Hulin wrote:
Hi Carl and all,

Here is a patch containing just the lines I've changed.

I've done a bit of poking around with the regexp and it appears that any
unicode alphabetic satisfies either the [:alnum:] or [a-zAz0-9] patterns.
In either case it lets through letters with unicode > 0FF which is what upsets my version of ghostscript. Patrick has reported that gs 8.70 is happy with these characters. I've got 8.64 as my default gs supplied by Ubuntu, and 8.65 files supplied in the lilypond directories,  but can't figure out how to install 8.7.

The string-regexp-substitute does get rid of things like space and ©, ®, but µ is valid. It doesn't accept the Perl-type patterns like \w or \W, and "-" doesn't need to be escaped (in fact it complains if you do try it.

Anyhow Reinhold,  can use "Flöte" and the Scandinavians can use things like "Fløjt" in output-suffix now.

Cheers,
Ian




This email has been scanned by Netintelligence
http://www.netintelligence.com/email



From 1ac60ab3ccd4c30b7c3b16adc9077d7faf983a63 Mon Sep 17 00:00:00 2001
From: Ian Hulin <ian@nanny-ogg.(none)>
Date: Thu, 20 Aug 2009 09:26:59 +0100
Subject: [PATCH] Issues 714 and 404: Add greater user flexibility in naming output files
    using output-suffix.
    output name handling now moved to its own procedure in lily-library.scm
   Amended to use ly:get-assoc to pick up initial value of parser variable
    output-count and remove redundant check on initial call.
   Accented characters now supported in output-suffix.

---
 scm/lily-library.scm |   37 +++++++++++++++++++++++--------------
 1 files changed, 23 insertions(+), 14 deletions(-)

diff --git a/scm/lily-library.scm b/scm/lily-library.scm
index e7f1d29..4622982 100644
--- a/scm/lily-library.scm
+++ b/scm/lily-library.scm
@@ -134,27 +134,36 @@
 
   (ly:make-score music))
 
+
+(define (get-outfile-name parser base)
+(let*
+    ((output-suffix (ly:parser-lookup parser 'output-suffix))
+     (counter-alist (ly:parser-lookup parser 'counter-alist))
+     (output-count (assoc-get output-suffix counter-alist 0))
+     (result base ) )
+    ;; Allow all ASCII alphanumerics,
+    ;;   including accents
+    (if (string? output-suffix)
+    (set! result (format "~a-~a" base (string-regexp-substitute
+     "[^-[:alnum:]]" "_" output-suffix))))
+
+    ;; assoc-get call will always have returned a number
+    (if (> output-count 0)
+ (set! result (format #f "~a-~a" result output-count)))
+    
+    (ly:parser-define!
+  parser 'counter-alist (assoc-set! counter-alist output-suffix  (1+ output-count)))
+    result ) )
+
 (define (print-book-with parser book process-procedure)
   (let*
       ((paper (ly:parser-lookup parser '$defaultpaper))
        (layout (ly:parser-lookup parser '$defaultlayout))
        (count (ly:parser-lookup parser 'output-count))
        (base (ly:parser-output-name parser))
-       (output-suffix (ly:parser-lookup parser 'output-suffix)) )
+       (outfile-name (get-outfile-name parser base)) )
 
-    (if (string? output-suffix)
- (set! base (format "~a-~a" base (string-regexp-substitute
-   "[^a-zA-Z0-9-]" "_" output-suffix))))
-
-    ;; must be careful: output-count is under user control.
-    (if (not (integer? count))
- (set! count 0))
-
-    (if (> count 0)
- (set! base (format #f "~a-~a" base count)))
-    (ly:parser-define! parser 'output-count (1+ count))
-    (process-procedure book paper layout base)
-    ))
+      (process-procedure book paper layout outfile-name)) )
 
 (define-public (print-book-with-defaults parser book)
   (print-book-with parser book ly:book-process))
--
1.6.0.4

Reply | Threaded
Open this post in threaded view
|

Re: RE: PATCH for getting output-suffix to work (Trackers 714 and 404)

Neil Puttock
2009/8/20 Ian Hulin <[hidden email]>:
> Oops, a closing parenthesis got missed out in the source. Here is s
> corrected patch, please ignore the previous one - apologies for the noise.

LGTM.

Can you fix the indentation and remove the spaces between parentheses?

+    ;;   including accents

this can go on the previous line

+ (set! result (format #f "~a-~a" result output-count)))
+

trailing space

+  parser 'counter-alist (assoc-set! counter-alist output-suffix  (1+
output-count)))

extraneous space after output-suffix

Regards,
Neil

---

----
Join the Frogs!

Reply | Threaded
Open this post in threaded view
|

Re: RE: PATCH for getting output-suffix to work (Trackers 714 and 404)

Ian Hulin
Neil Puttock wrote:
2009/8/20 Ian Hulin [hidden email]:
  
Oops, a closing parenthesis got missed out in the source. Here is s
corrected patch, please ignore the previous one - apologies for the noise.
    

LGTM.

Can you fix the indentation and remove the spaces between parentheses?

+    ;;   including accents

this can go on the previous line

+ (set! result (format #f "~a-~a" result output-count)))
+

trailing space

+  parser 'counter-alist (assoc-set! counter-alist output-suffix  (1+
output-count)))

extraneous space after output-suffix

  
Sorted, revised patch attached. 
Carl, is this ready to push or does it need reviewing on rietveld?

Cheers,

Ian


From 87504a757a98b6a5ff64c8dd67bc2f114de6acfb Mon Sep 17 00:00:00 2001
From: Ian Hulin <ian@nanny-ogg.(none)>
Date: Fri, 21 Aug 2009 16:35:40 +0100
Subject: [PATCH] Issues 714 and 404: Add greater user flexibility in naming output files
    using output-suffix.
    output name handling now moved to its own procedure in lily-library.scm
   Amended to use ly:get-assoc to pick up initial value of parser variable
    output-count and remove redundant check on initial call.
   Accented characters now supported in output-suffix.

---
 scm/lily-library.scm |   36 ++++++++++++++++++++++--------------
 1 files changed, 22 insertions(+), 14 deletions(-)

diff --git a/scm/lily-library.scm b/scm/lily-library.scm
index e7f1d29..1b10b5b 100644
--- a/scm/lily-library.scm
+++ b/scm/lily-library.scm
@@ -134,27 +134,35 @@
 
   (ly:make-score music))
 
+
+(define (get-outfile-name parser base)
+(let*
+    ((output-suffix (ly:parser-lookup parser 'output-suffix))
+     (counter-alist (ly:parser-lookup parser 'counter-alist))
+     (output-count (assoc-get output-suffix counter-alist 0))
+     (result base ))
+    ;; Allow all ASCII alphanumerics, including accents
+    (if (string? output-suffix)
+        (set! result (format "~a-~a" base (string-regexp-substitute
+            "[^-[:alnum:]]" "_" output-suffix))))
+
+    ;; assoc-get call will always have returned a number
+    (if (> output-count 0) (set! result (format #f "~a-~a" result output-count)))
+
+    (ly:parser-define!
+        parser 'counter-alist
+        (assoc-set! counter-alist output-suffix (1+ output-count)))
+    result))
+
 (define (print-book-with parser book process-procedure)
   (let*
       ((paper (ly:parser-lookup parser '$defaultpaper))
        (layout (ly:parser-lookup parser '$defaultlayout))
        (count (ly:parser-lookup parser 'output-count))
        (base (ly:parser-output-name parser))
-       (output-suffix (ly:parser-lookup parser 'output-suffix)) )
+       (outfile-name (get-outfile-name parser base)))
 
-    (if (string? output-suffix)
- (set! base (format "~a-~a" base (string-regexp-substitute
-   "[^a-zA-Z0-9-]" "_" output-suffix))))
-
-    ;; must be careful: output-count is under user control.
-    (if (not (integer? count))
- (set! count 0))
-
-    (if (> count 0)
- (set! base (format #f "~a-~a" base count)))
-    (ly:parser-define! parser 'output-count (1+ count))
-    (process-procedure book paper layout base)
-    ))
+      (process-procedure book paper layout outfile-name)))
 
 (define-public (print-book-with-defaults parser book)
   (print-book-with parser book ly:book-process))
--
1.6.0.4

Reply | Threaded
Open this post in threaded view
|

Re: RE: PATCH for getting output-suffix to work (Trackers 714 and 404)

Carl Sorensen



On 8/23/09 10:28 AM, "Ian Hulin" <[hidden email]> wrote:

> Neil Puttock wrote:
>>  
>> 2009/8/20 Ian Hulin <[hidden email]> <mailto:[hidden email]> :
>>  
>>  
>>>  
>>> Oops, a closing parenthesis got missed out in the source. Here is s
>>> corrected patch, please ignore the previous one - apologies for the noise.
>>>    
>>>  
>>  
>>
>> LGTM.
>>
>> Can you fix the indentation and remove the spaces between parentheses?
>>
>> +    ;;   including accents
>>
>> this can go on the previous line
>>
>> + (set! result (format #f "~a-~a" result output-count)))
>> +
>>
>> trailing space
>>
>> +  parser 'counter-alist (assoc-set! counter-alist output-suffix  (1+
>> output-count)))
>>
>> extraneous space after output-suffix
>>
>>  
> Sorted, revised patch attached. 
> Carl, is this ready to push or does it need reviewing on rietveld?

Thanks for your patience, Ian.  This has been a crazy week for me.

The patch is now pushed and the issue has been labeled fixed.

Thanks,

Carl


---

----
Join the Frogs!