Re: Template management for LilyPond

2019-04-25 Thread Sandro Santilli
On Wed, Apr 24, 2019 at 05:32:43PM -0400, markjulie.com wrote:
> I am a new user to LilyPond 2.18.2 and Frescobaldi 2.20.0 having previously
> used Finale on MacOS. I would like to save some of the templates from the
> LilyPond documentation. I would like them to be available in the cloud
> (Google, Dropbox, or iCloud) for access on several of my devices.
> 
> Is there a folder in Application Support that I have not found? I could save
> the templates as .ly files or .txt files to a folder, but it is preferable
> to use New From Template -> then have the same templates available to
> multiple devices.

I don't know how Google, Dropbox or iCloud work but NextCloud
(http://nextcloud.org) has client apps that let you keep a local
folder in sync with the server (and thus all the other connected clients).

All the chain (server and client) is open source.

--strk;

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Template management for LilyPond

2019-04-25 Thread Michael Hendry
> On 24 Apr 2019, at 22:32, markjulie.com  wrote:
> 
> I am a new user to LilyPond 2.18.2 and Frescobaldi 2.20.0 having previously 
> used Finale on MacOS. I would like to save some of the templates from the 
> LilyPond documentation. I would like them to be available in the cloud 
> (Google, Dropbox, or iCloud) for access on several of my devices.
> 
> Is there a folder in Application Support that I have not found? I could save 
> the templates as .ly files or .txt files to a folder, but it is preferable to 
> use New From Template -> then have the same templates available to multiple 
> devices.
> 
> Mark

I haven’t actually used Dropbox with Lilypond and Frescobaldi, but I use it for 
a lot of music-related activities, particularly to keep jazz lead sheets on 
iPads and a laptop in sync with my iMac.

I can’t see your having any problem in accessing your template files - or 
indeed your .ly library - using Dropbox across numerous devices.

Michael


___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Template management for LilyPond

2019-04-25 Thread Andrew Bernard
Hi Mark,

In F. templates appear to be stored as snippets. This brings up the
interesting question of where in the file system snippets are stored.
Despite having used F, for years, I have no idea, and a search of my Linux
filesystems reveals nothing obvious. Perhaps they are in a database format
and not plain text files.

Does anybody know? [I supppose I better read the source code.]

If this question is answered, your solution is (possibly) easy - move that
folder to Dropbox or similar.

Andrew
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Template management for LilyPond

2019-04-25 Thread J Martin Rushton
On 25/04/2019 12:07, Andrew Bernard wrote:
> Hi Mark,
> 
> In F. templates appear to be stored as snippets. This brings up the
> interesting question of where in the file system snippets are stored.
> Despite having used F, for years, I have no idea, and a search of my
> Linux filesystems reveals nothing obvious. Perhaps they are in a
> database format and not plain text files.
> 
> Does anybody know? [I supppose I better read the source code.]
> 
> If this question is answered, your solution is (possibly) easy - move
> that folder to Dropbox or similar.
> 
> Andrew
> 
> 
> 
> ___
> lilypond-user mailing list
> lilypond-user@gnu.org
> https://lists.gnu.org/mailman/listinfo/lilypond-user
> 

$HOME/.config/frescobaldi/frescobaldi.conf

section [snippets]

Contains standard templates (which you may edit) plus any you have created.

-- 
J Martin Rushton MBCS



signature.asc
Description: OpenPGP digital signature
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Template management for LilyPond

2019-04-25 Thread Sven Axelsson
On Thu, 25 Apr 2019 at 13:08, Andrew Bernard 
wrote:

> Hi Mark,
>
> In F. templates appear to be stored as snippets. This brings up the
> interesting question of where in the file system snippets are stored.
> Despite having used F, for years, I have no idea, and a search of my Linux
> filesystems reveals nothing obvious. Perhaps they are in a database format
> and not plain text files.
>
> Does anybody know? [I supppose I better read the source code.]
>

At least in Frescobaldi 2, snippets and templates are not stored as files
but kept in the application settings file. This makes it hard to share them
between machines. On a Mac the file is here:
~/Library/Preferences/com.frescobaldi.frescobaldi.plist. On Linux it should
be somewhere in ~/.config, and on Windows settings are kept in the
Registry.

-- 
Sven Axelsson
++[>++>+++>++>++
><-]>.+..>+.>+.<<-.>>+.>.<<.
+++.>-.<<++.>>.<++.>>>++..>>.<.
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Template management for LilyPond

2019-04-25 Thread Andrew Bernard
Hi Sven,

That's terrible - storing potentially very large blocks of text in the
Windows registry. Given that the OP's request is very reasonable, this
sounds like the basis for a change request to Frescobaldi, to expose the
templates and snippets in a more accessible way. That would be something I
would be interested to work on. i think the concept of storing config and
data in a remote cloud enviroment post dates the original invention of
Frescobaldi, but it's a really good idea.

I'd prefer to change the subject here to Template management in
Frescobaldi, because that is what we are talking about.

Andrew


On Thu, 25 Apr 2019 at 22:00, Sven Axelsson  wrote:

>
> At least in Frescobaldi 2, snippets and templates are not stored as files
> but kept in the application settings file. This makes it hard to share them
> between machines. On a Mac the file is here:
> ~/Library/Preferences/com.frescobaldi.frescobaldi.plist. On Linux it should
> be somewhere in ~/.config, and on Windows settings are kept in the
> Registry.
>
>
>
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Template management for LilyPond

2019-04-25 Thread Urs Liska



Am 25. April 2019 14:00:04 MESZ schrieb Sven Axelsson :
>On Thu, 25 Apr 2019 at 13:08, Andrew Bernard 
>wrote:
>
>> Hi Mark,
>>
>> In F. templates appear to be stored as snippets. This brings up the
>> interesting question of where in the file system snippets are stored.
>> Despite having used F, for years, I have no idea, and a search of my
>Linux
>> filesystems reveals nothing obvious. Perhaps they are in a database
>format
>> and not plain text files.
>>
>> Does anybody know? [I supppose I better read the source code.]
>>
>
>At least in Frescobaldi 2, snippets and templates are not stored as
>files
>but kept in the application settings file. This makes it hard to share
>them
>between machines. On a Mac the file is here:
>~/Library/Preferences/com.frescobaldi.frescobaldi.plist. On Linux it
>should
>be somewhere in ~/.config, and on Windows settings are kept in the
>Registry.

I think it would be a valid feature request to (additionally) support an 
external folder  to load templates from or save them to.

This should not be difficult but I can't afford looking into it since I 
absolutely don't need it personally.

If you create an entry in the issue tracker 
(https://github.com/frescobaldi/frescobaldi/issues) I'll add the "wish" and 
"beginner" labels to it.

Best
Urs

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Function for /score block

2019-04-25 Thread Aaron Hill

On 2019-04-24 10:01 pm, foxfanfare wrote:

[ . . . ] The only thing
that might change is the name of the piece (here it is "IA"). I wonder, 
is
it possible, instead of copying each time the same instrumentation, to 
call
this block in a function and replace each time the name of the piece by 
the

one defined? For instance, something like "\instrumentation #"IA"" or
"\instrumentation #"IB"", etc...


I had to typeset some hymns for projection recently and wanted a way to 
reduce the amount of typing when it came to scores and books that were 
basically the same structurally.  (In my case, I was using a void 
function and calling print-book-with-defaults since I was constructing a 
\book, not the body of a \score.)


I found using ly:parser-include-string was helpful for this purpose.  
Consider the following:



\version "2.19.82"

Alice.Melody = \fixed f' { f4 g a bes c'1 }
Alice.Lyrics = \lyricmode { do re mi fa sol }

Bob.Melody = \fixed f' { c'4 bes d' g a1 }
Bob.Lyrics = \lyricmode { sol fa la re mi }

Global = {
  \key f \major
  s1*2 \bar "|."
}

makeItSo = #(define-music-function (label) (symbol?)
  (define (lookup section) (ly:parser-include-string
(format #f "\\~a.~a" label section)))
  #{ <<
   \new Staff \with {
 instrumentName = $(symbol->string label)
   } <<
 \Global
 \new Voice = "melody" { $(lookup 'Melody) }
   >>
   \new Lyrics \lyricsto "melody" { $(lookup 'Lyrics) }
 >> #} )

\makeItSo #'Alice
\makeItSo #'Bob


This \makeItSo is akin to a macro, able to inject a dynamically 
constructed string into the parser as if it were typed by hand.


-- Aaron Hill

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Function for /score block

2019-04-25 Thread David Kastrup
Aaron Hill  writes:

> I found using ly:parser-include-string was helpful for this purpose.

That's a sledgehammer.

> Consider the following:
>
> 
> \version "2.19.82"
>
> Alice.Melody = \fixed f' { f4 g a bes c'1 }
> Alice.Lyrics = \lyricmode { do re mi fa sol }
>
> Bob.Melody = \fixed f' { c'4 bes d' g a1 }
> Bob.Lyrics = \lyricmode { sol fa la re mi }
>
> Global = {
>   \key f \major
>   s1*2 \bar "|."
> }
>
> makeItSo = #(define-music-function (label) (symbol?)
>   (define (lookup section) (ly:parser-include-string
> (format #f "\\~a.~a" label section)))
>   #{ <<
>\new Staff \with {
>  instrumentName = $(symbol->string label)
>} <<
>  \Global
>  \new Voice = "melody" { $(lookup 'Melody) }
>>>
>\new Lyrics \lyricsto "melody" { $(lookup 'Lyrics) }
>  >> #} )
>
> \makeItSo #'Alice
> \makeItSo #'Bob
> 
>
> This \makeItSo is akin to a macro, able to inject a dynamically
> constructed string into the parser as if it were typed by hand.

With the same interface, I'd use

\version "2.19.82"

Alice.Melody = \fixed f' { f4 g a bes c'1 }
Alice.Lyrics = \lyricmode { do re mi fa sol }

Bob.Melody = \fixed f' { c'4 bes d' g a1 }
Bob.Lyrics = \lyricmode { sol fa la re mi }

Global = {
  \key f \major
  s1*2 \bar "|."
}

makeItSo =
#(define-music-function (label) (symbol?)
  (let ((name (symbol->string label))
(value (ly:parser-lookup label)))
   #{ <<
   \new Staff \with {
 instrumentName = #name
   } <<
 \Global
 \new Voice = "melody" { $value . Melody }
   >>
   \new Lyrics \lyricsto "melody" { $value . Lyrics }
 >> #} ))

\makeItSo #'Alice
\makeItSo #'Bob


But I don't like this kind of double-serve and it's not particularly
flexible, so I'd rather use


\version "2.19.82"

Alice.Melody = \fixed f' { f4 g a bes c'1 }
Alice.Lyrics = \lyricmode { do re mi fa sol }

Bob.Melody = \fixed f' { c'4 bes d' g a1 }
Bob.Lyrics = \lyricmode { sol fa la re mi }

Global = {
  \key f \major
  s1*2 \bar "|."
}

makeItSo =
#(define-music-function (name value) (markup? list?)
   #{ <<
   \new Staff \with {
 instrumentName = #name
   } <<
 \Global
 \new Voice = "melody" { $value . Melody }
   >>
   \new Lyrics \lyricsto "melody" { $value . Lyrics }
 >> #} )

\makeItSo "Alice" \Alice
\makeItSo "Bob" \Bob


Or you could also refer to this from a main variable by putting

Alice.name = "Alice"
Bob.name = "Bob"

and then fetching stuff from there.

-- 
David Kastrup

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Template management for LilyPond

2019-04-25 Thread Michael Hendry
> On 25 Apr 2019, at 13:00, Sven Axelsson  wrote:
> 
> ~/Library/Preferences/com.frescobaldi.frescobaldi.plist

This file doesn’t exist on my iMac, although I’ve been using Frescobaldi for (? 
>5) years.

I’d been in the habit of using my own template files directly from the working 
directory they’d been developed in, simply opening the file in Frescobaldi and 
Saving As into a new directory under a new name before starting on the 
specifics of a new piece.

Now that I come to look at Templates from the Frescobaldi menu (File -> New 
from Template) I see that I’d discovered this feature in the past, copied a 
template into Frescobaldi, and then forgotten about it!

Thinking about the directory structure needed for a Dropbox-supported 
multi-user setup, I realise that \include files would have to be supported too.

~/Dropbox/Lilypond would have several subdirectories:

e.g.
…/Template
…/Include
…/Working/Composition1
…/Working/Composition2

etc.

Frescobaldi would have to be set up to add the …/Include directory to the 
include path.

Assuming only one individual is working on the compositions, but from different 
computers, there wouldn’t be a problem with write-permissions, but care would 
have to be taken if the OP is part of a team.

This could be achieved without any need to request changes in Frescobaldi.

Michael
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Function for /score block

2019-04-25 Thread Aaron Hill

On 2019-04-25 7:37 am, David Kastrup wrote:

With the same interface, I'd use

\version "2.19.82"

Alice.Melody = \fixed f' { f4 g a bes c'1 }
Alice.Lyrics = \lyricmode { do re mi fa sol }

Bob.Melody = \fixed f' { c'4 bes d' g a1 }
Bob.Lyrics = \lyricmode { sol fa la re mi }

Global = {
  \key f \major
  s1*2 \bar "|."
}

makeItSo =
#(define-music-function (label) (symbol?)
  (let ((name (symbol->string label))
(value (ly:parser-lookup label)))
   #{ <<
   \new Staff \with {
 instrumentName = #name
   } <<
 \Global
 \new Voice = "melody" { $value . Melody }
   >>
   \new Lyrics \lyricsto "melody" { $value . Lyrics }
 >> #} ))

\makeItSo #'Alice
\makeItSo #'Bob



That makes so much more sense.  I did not know that dotted values could 
be referenced that way, which is why I opted for the "sledge" instead of 
ly:parser-lookup.  I also had the case where the value I was 
substituting was not the top-level value, but actually the bottom-level 
in the structure.


But even with that constraint, I found the following works and avoids 
the string concatenation:



\version "2.19.82"

Alice.Lyrics.StanzaI = \lyricmode { a b c }
Alice.Lyrics.StanzaII = \lyricmode { d e f }

Bob.Lyrics.StanzaI = \lyricmode { g h i }
Bob.Lyrics.StanzaII = \lyricmode { j k l }

foo = #(define-music-function (singer stanza) (symbol? symbol?)
  #{ \new Lyrics { $(ly:parser-lookup singer) . Lyrics . $stanza } #} )

\foo Alice StanzaI
\foo Bob StanzaII


Curious though why in the above, I can say "Alice" in lieu of "#'Alice". 
 Is it simply because the music function's type assertion of "symbol?" 
lets the parser consume the next string as such?



-- Aaron Hill

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Function for /score block

2019-04-25 Thread David Kastrup
Aaron Hill  writes:

> But even with that constraint, I found the following works and avoids
> the string concatenation:
>
> 
> \version "2.19.82"
>
> Alice.Lyrics.StanzaI = \lyricmode { a b c }
> Alice.Lyrics.StanzaII = \lyricmode { d e f }
>
> Bob.Lyrics.StanzaI = \lyricmode { g h i }
> Bob.Lyrics.StanzaII = \lyricmode { j k l }
>
> foo = #(define-music-function (singer stanza) (symbol? symbol?)
>   #{ \new Lyrics { $(ly:parser-lookup singer) . Lyrics . $stanza } #} )
>
> \foo Alice StanzaI
> \foo Bob StanzaII
> 
>
> Curious though why in the above, I can say "Alice" in lieu of
> "#'Alice". Is it simply because the music function's type assertion of
> "symbol?" lets the parser consume the next string as such?

Yes.  The more restrictive the predicate, the more work the parser will
invest to try converting it to the required type.  For better or worse,
LilyPond syntax is context dependent.  Music functions are as versatile
and "natural" as they are by using their predicates as context advice.

-- 
David Kastrup

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Template management for Frescobaldi (was: LilyPond)

2019-04-25 Thread Urs Liska

Hi Andrew,

Am 25.04.19 um 14:18 schrieb Andrew Bernard:

Hi Sven,

That's terrible - storing potentially very large blocks of text in the 
Windows registry.



I think storing it in a config file on Linux is only gradually less bad 
(it's less bad because that file is only relevant for a single 
application, but still I agree that a config file is not a good place 
for storing that kind of information.



Given that the OP's request is very reasonable, this sounds like the 
basis for a change request to Frescobaldi, to expose the templates and 
snippets in a more accessible way. That would be something I would be 
interested to work on. i think the concept of storing config and data 
in a remote cloud enviroment post dates the original invention of 
Frescobaldi, but it's a really good idea.



In fact templates are stored as snippets within the Frescobaldi 
configuration. One reasoning not to have them in an (external) directory 
may have been the need to manage both built-in and custom elements - but 
that should be rather trivial to address.


There should be a configurable root directory to store snippets and 
templates. I suggest that this can include a folder hierarchy that maps 
to an implicit hierarchy in snippets/templates categories. One directory 
within the Frescobaldi source directory could transparently be merged 
into  that hierarchy so built-in items can also be stored as independent 
files.


The current code to save a current document as template is in 
frescobaldi_app/snippet/template.py, the "New from template" function is 
implemented in frescobaldi_app/snippet/menu.py (if you want to start 
looking into the matter - although that would have to be completely 
rebuilt from scratch in another module, I suppose.


Best
Urs




I'd prefer to change the subject here to Template management in 
Frescobaldi, because that is what we are talking about.


Andrew


On Thu, 25 Apr 2019 at 22:00, Sven Axelsson > wrote:



At least in Frescobaldi 2, snippets and templates are not stored
as files but kept in the application settings file. This makes it
hard to share them between machines. On a Mac the file is here:
~/Library/Preferences/com.frescobaldi.frescobaldi.plist. On Linux
it should be somewhere in ~/.config, and on Windows settings are
kept in the Registry.



___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Template management for LilyPond

2019-04-25 Thread Andrew Bernard
Hi Michael,

But the OP was not requiring a multiuser development environment, but a
multi-device one. For multiple users on one project surely you would use
git nowadays, on github or your own server, pretty much the universal
answer (because it works so well).

The issue is about sharing _templates_ and _snippets_ not includes. I am
going to start on modifying F. to support that. Should not be difficult.
It's a logical request, and an idea that would not have been thought of
before cloud services became widely available.

Sure, you can load a file and 'save as'. But 'new from template' is
currently supported and a nice function.

Andrew




On Fri, 26 Apr 2019 at 01:43, Michael Hendry 
wrote:

>
> This could be achieved without any need to request changes in Frescobaldi.
>
>
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user