Re: define-markup-command

2023-04-08 Thread Jean Abou Samra
Le vendredi 07 avril 2023 à 13:11 -0400, Ken Ledeen a écrit :
> Hi All,  
> Thanks to Jean Abou Samra I can now create \markup that goes to a place in a 
> youtube video.
> 
> These are of the form:
> 
> fis4^\markup \with-url#"[https://youtu.be.](https://youtu.be.)..?t=SEC" {ref} 
> where "SEC" is replaced with the number of seconds in from the start.
> 
> I would like to create a function to simplify things so instead of having the 
> entire URL repeated everywhere, would have something that looks like
> 
> fis4^\mymk "215". 
> 
> So far, I remain entirely confused about creating a new markup command.  I 
> won't bother describing my many failed attempts.  I am clearly missing some 
> basic concepts. I have no problem creating scheme functions to do various 
> manipulations, but extending the markup function has eluded me.
> 
> Any guidance would be most appreciated!    


Try

```
\version "2.24.1"

mymk =
#(define-scheme-function (sec) (index?)
   #{
 \markup \with-url
   #(format #f "https://youtu.be/blablabla?t=~a"; sec)
   #(number->string sec)
   #})

{
  fis4^\mymk 215
}
```

Note that this is a regular syntax function returning a markup (defined with 
define-scheme-function) rather than a markup command, but you can also define a 
markup command if you wish:

```
\version "2.24.1"

#(define-markup-command (mymk layout props sec) (index?)
   (interpret-markup
layout props
#{
  \markup \with-url
#(format #f "https://youtu.be/blablabla?t=~a"; sec)
#(number->string sec)
#}))

{
  fis4^\markup \mymk #215
}
```


Note that you have to enter `\markup` mode to use markup commands.

Markup mode is quite different from the normal mode (for example, `\markup b1` 
just writes “b1”, while in normal mode, also called “notes mode”, “b1” is a B 
whole note; this is also the reason why you have to put a `#` before `215` when 
calling the markup command). Syntax functions and markup command have different 
use cases, but in this particular instance it happens that both can be used 
without a lot of difference.

Best,

Jean


signature.asc
Description: This is a digitally signed message part


define-markup-command

2023-04-07 Thread Ken Ledeen
Hi All,

Thanks to Jean Abou Samra I can now create \markup that goes to a place in
a youtube video.

These are of the form:

fis4^\markup \with-url#"https://youtu.be...?t=SEC"; {ref} where "SEC" is
replaced with the number of seconds in from the start.

I would like to create a function to simplify things so instead of having
the entire URL repeated everywhere, would have something that looks like

fis4^\mymk "215".

So far, I remain entirely confused about creating a new markup command.  I
won't bother describing my many failed attempts.  I am clearly missing some
basic concepts. I have no problem creating scheme functions to do various
manipulations, but extending the markup function has eluded me.

Any guidance would be most appreciated!

Ken Ledeen

Mobile:   617-817-3183

www.nevo.com
www.bitsbook.com
tiny.cc/KenLedeen 


Re: How to use optional arguments / parameters in a define-markup-command

2019-11-05 Thread Urs Liska
5. November 2019 11:19, "Thomas Morley"  schrieb:

> Am Di., 5. Nov. 2019 um 09:14 Uhr schrieb Karsten Reincke 
> :
> 
>> On Mon, 2019-11-04 at 23:06 +0100, Thomas Morley wrote:
>> Am Mo., 4. Nov. 2019 um 18:00 Uhr schrieb Karsten Reincke 
>> :
>> [...]
>> Let me quote another part of my reply:
>> 
>> Am Fr., 1. Nov. 2019 um 16:01 Uhr schrieb Thomas Morley
>> :
>> 
>>> For variable amount of args I'd go for list? (or the like) and let the
>>> body of your code sort it out.
>> 
>> And that's basically what you do in your example-code.
>> 
>> You are totally correct. Unfortunately, I did not read your mail as 
>> thoroughly as
>> it should had been done. So, I had to find th solution by myself. But of 
>> course.
>> it stays your idea.
> 
> Well, not my idea, I just pointed to that coding-principle
> 
>>> #(define (assign keyValue assocList defaultValue)
>>> (string? list?)
>> ^^
>> As far as I can tell this line is superfluous, returning #f.
>> 
>> Yep, you are right. Due to the fact, that I later on decided also to allow 
>> other
>> default values than strings, I erased the third type test without 
>> considering that
>> then a third type is missed. So it is indeed better to erase the complete 
>> line.
> 
> You miss the point.
> There is no type-checking of this kind in guile-definitions.
> The line (string? list?) is an expression of its own, returning #f.
> If you try three elements there like in
> (define (x a b c) (string? list? string?) (list a b c))
> you'll get an error.
> 
> Type-checking of this kind is done in _LilyPond's_ functions and for
> markup-commands.
> Don't confuse them.

To be more explicit:

  (string? list?)

is an expression that calls the procedure `string?` and passes it the value 
`list?`.
What this effectively does is to check whether `list?` is a string, and since 
`list?` is a procedure itself the result of the evaluation is `#f`.

Urs
> 
> Cheers,
> Harm



Re: How to use optional arguments / parameters in a define-markup-command

2019-11-05 Thread Thomas Morley
Am Di., 5. Nov. 2019 um 09:14 Uhr schrieb Karsten Reincke :
>
> On Mon, 2019-11-04 at 23:06 +0100, Thomas Morley wrote:
> > Am Mo., 4. Nov. 2019 um 18:00 Uhr schrieb Karsten Reincke 
> > :
> > [...]
> > Let me quote another part of my reply:
> >
> > Am Fr., 1. Nov. 2019 um 16:01 Uhr schrieb Thomas Morley
> > :
> >
> > > For variable amount of args I'd go for list? (or the like) and let the
> > > body of your code sort it out.
> >
> > And that's basically what you do in your example-code.
>
> You are totally correct. Unfortunately, I did not read your mail as 
> thoroughly as
> it should had been done. So, I had to find th solution by myself. But of 
> course.
> it stays your idea.

Well, not my idea, I just pointed to that coding-principle

> >
> > > #(define (assign keyValue assocList defaultValue)
> > >   (string? list?)
> > ^^
> > As far as I can tell this line is superfluous, returning #f.
> >
> Yep, you are right. Due to the fact, that I later on decided also to allow 
> other
> default values than strings, I erased the third type test without considering 
> that
> then a third type is missed. So it is indeed better to erase the complete 
> line.

You miss the point.
There is no type-checking of this kind in guile-definitions.
The line (string? list?) is an expression of its own, returning #f.
If you try three elements there like in
(define (x a b c) (string? list? string?) (list a b c))
you'll get an error.

Type-checking of this kind is done in _LilyPond's_ functions and for
markup-commands.
Don't confuse them.

Cheers,
  Harm



Re: How to use optional arguments / parameters in a define-markup-command

2019-11-05 Thread Karsten Reincke
On Mon, 2019-11-04 at 23:45 +, Urs Liska wrote:
Dear Urs;

many thanks for your comments and hints! I admire how thoroughly you read other
work and how many time you spend with helping others!
> Hi Karsten,
> 
> 4. November 2019 17:59, "Karsten Reincke"  schrieb:
> [...]
> > Here is a pure scheme / guile solution using lisp association lists (demoed 
> > by
> > using the box example from the extend tutorial). 
> 
> I see one major issue with your approach: it pollutes the namespace with a
> multitude of global variables.
The global variables are only syntactical sugar. I've attached a version which
does not use any global variable any longer

> 
> I don't want to push you towards using openLilyLib ;-) but oll-core includes a
> macro "with-options" (created by Stéfano Troncaro) that allows the 
> modification
> of define-music-function (I'm not sure about markup functions right now) so 
> that
> the function accepts an optional \with { } clause, performs validation against
> mandatory and optional arguments (optionally along with their types) and can
> provide default values - all without necessarily using #(define XXX) and
> creating global variables.
> 
> The code starts here: 
> https://github.com/openlilylib/oll-core/blob/master/internal/options.ily#L245
> 
This is a nice example using the main feature of LISP: even code can become a
parameter and vice versa. But for my purpose, it is too sophisticated. 

> Urs

wit best regards
Karsten
-- 
  Karsten Reincke/\/\   (+49|0) 170 / 927 78 57
 Im Braungeröll 31   >oo<  mailto:k.rein...@fodina.de
60431 Frankfurt a.M.  \/http://www.fodina.de/kr/

\version "2.18.2"

% A pure scheme / guile solution to define a LilyPond markup
% command with a variable list of arguments by using a
% technique of lisp scheme / guile called association lists 
% (demoed by using the box example from the extend tutorial). 

% The target is, that the users of the function may insert 
% the arguments they really need (without having to deal with 
% those, they do not need) and that they may insert the arguments
% they want to use in the order they prefer 

% feel free to adopt this example under the following terms:

% Copyright 2019 Karsten Reincke, Frankfurt

% Permission is hereby granted, free of charge, to any person 
% obtaining a copy of this software and associated documentation 
% files (the "Software"), to deal in the Software without 
% restriction, including without limitation the rights to use, 
% copy, modify, merge, publish, distribute, sublicense, and/or sell 
% copies of the Software, and to permit persons to whom the 
% Software is furnished to do so, subject to the following conditions:

% The above copyright notice and this permission notice shall be 
% included in all copies or substantial portions of the Software.

% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 
% OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 
% HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 
% WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
% FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 
% OR OTHER DEALINGS IN THE SOFTWARE.
 

% 1) we need a function - let us name it "assign" 
% (you will understand in a short time, why) - which takes 
% a key, an association list (alist) and a default value. 
% If the alist contains any pair with the same key, 
% then function shall return the corresponding value, 
% otherwise the given default value

#(define (assign keyValue assocList defaultValue)
  (let* ((localPair (assoc keyValue assocList)))
(if localPair (cdr localPair) defaultValue)
  )
)

% 2.) we define a markup function using a flexible variable 
% parameter list: 
% a) At the beginning we define the local parameter variables 
% and let them be instantiated by our assign function. 
% b) Then we manipulate the given values in any way. 
% c) And finally we return - as a markup 'object' - 
% a box containing the result of our manipulation:


#(define-markup-command (mybox layout props AL)
  (list?)
  (let*
( (la (assign "k1" AL "blank"))
  (lb (assign "k2" AL ""))
  (lc (assign "k3" AL '()))
  (ld (assign "k4" AL "blank"))
  (le (assign "k5" AL ""))
  (lresult "result")
)
;  because we used an empty list (nil) as default value
(if (eq? lc '()) (set! lc ""))
; our 'manupilation' is a concatenation ;-)
(set! lresult (string-append la lb lc ld le))

(interpret-markup layout props
  #{
\markup \box { #lresult }
  #}
)
   )
 )  

\markup \mybox #'(("k5" . "V5")("k1" . "V1"))

Re: How to use optional arguments / parameters in a define-markup-command

2019-11-05 Thread Karsten Reincke
On Mon, 2019-11-04 at 23:06 +0100, Thomas Morley wrote:
> Am Mo., 4. Nov. 2019 um 18:00 Uhr schrieb Karsten Reincke 
> :
> [...]
> Let me quote another part of my reply:
> 
> Am Fr., 1. Nov. 2019 um 16:01 Uhr schrieb Thomas Morley
> :
> 
> > For variable amount of args I'd go for list? (or the like) and let the
> > body of your code sort it out.
> 
> And that's basically what you do in your example-code.

You are totally correct. Unfortunately, I did not read your mail as thoroughly 
as
it should had been done. So, I had to find th solution by myself. But of course.
it stays your idea.

> 
> > #(define (assign keyValue assocList defaultValue)
> >   (string? list?)
> ^^
> As far as I can tell this line is superfluous, returning #f.
> 
Yep, you are right. Due to the fact, that I later on decided also to allow other
default values than strings, I erased the third type test without considering 
that
then a third type is missed. So it is indeed better to erase the complete line.

Thanks for the hint.


> Cheers,
>   Harm

Best regards, Karsten
-- 
  Karsten Reincke/\/\   (+49|0) 170 / 927 78 57
 Im Braungeröll 31   >oo<  mailto:k.rein...@fodina.de
60431 Frankfurt a.M.  \/http://www.fodina.de/kr/





Re: How to use optional arguments / parameters in a define-markup-command

2019-11-04 Thread Urs Liska
Hi Karsten,

4. November 2019 17:59, "Karsten Reincke"  schrieb:

> Dear friends
> 
> A few days ago, I asked whether anyone knows how one can use variable 
> parameter
> lists = optional arguments = flexible argumentlists in a markup function. I 
> was
> told that such an opportunity does not exist (Thomas Morley) resp. must be
> simulated by some embedded property features (Urs Liska). Many thanks for 
> these
> quick answers. They preserved me from doing unnecessary work.
> 
> Here is a pure scheme / guile solution using lisp association lists (demoed by
> using the box example from the extend tutorial). 

I see one major issue with your approach: it pollutes the namespace with a 
multitude of global variables.

I don't want to push you towards using openLilyLib ;-) but oll-core includes a 
macro "with-options" (created by Stéfano Troncaro) that allows the modification 
of define-music-function (I'm not sure about markup functions right now) so 
that the function accepts an optional \with { } clause, performs validation 
against mandatory and optional arguments (optionally along with their types) 
and can provide default values - all without necessarily using #(define XXX) 
and creating global variables.

The code starts here: 
https://github.com/openlilylib/oll-core/blob/master/internal/options.ily#L245

and here is an example function that is defined that way (all my functions 
using that macro are still in private repositories). It prints text centered 
above and below a given music (in my case it was a measure.

The define-music-function clause is modified by the with-option macro 
(available after \include "oll-core/package.ily").
Then there's one additional list where the options are defined, in this case 
there are three options, "above", "below" and "horizontal-padding", defined as 
markups and number, with default values. Inside the function they are available 
through an alist with the name of props (which is admittedly incosistent and 
should be changed).

The function could for example be used like

\annotateCenteredMusic \with { above = "Hello" } { c'1 }
or even

\annotateCenteredMusic { c'1 }
(which would not make any sense in this specific case because the defaults are 
empty markups).

annotateCenteredMusic =
#(with-options define-music-function (music)(ly:music?)
   `(strict
 (? above ,markup? ,(markup #:null))
 (? below ,markup? ,(markup #:null))
 (? horizontal-padding ,number? 2)
 )
   ;; Store data in a closure to drag it over from the music-function stage
   ;; to before-line-breaking and stencil
   (let ((upper
  ;; apply \Xg (ascender/descender placeholder) for non-null markups
  ;; NOTE:
  ;; in multiline markups the \Xg markup command has to be applied
  ;; manually at one point in the last line if that last line
  ;; doesn't contain a descender!
  (let ((original (assq-ref props 'above)))
(if (equal? original (markup #:null))
original
(markup #:Xg original
 (lower
  (let ((original (assq-ref props 'below)))
(if (equal? original (markup #:null))
original
(markup #:Xg original
 (music-stil #f)
 (upper-stil #f)
 (lower-stil #f)
 (upper-padding (getOption '(mozart centered staff-padding-up)))
 (lower-padding (getOption '(mozart centered staff-padding-down)))
 (horizontal-padding (assq-ref props 'horizontal-padding)))
 #{
   \tweak before-line-breaking
   #(lambda (grob)
  ;; Create the three markup stencils *now* and store it in the closure
  ;; so we can use its dimensions to affect the layout.
  (set! music-stil #{ \getBareScoreMarkupStencil #grob #music #})
  (set! upper-stil (grob-interpret-markup grob upper))
  (set! lower-stil (grob-interpret-markup grob lower))
  (let*
   ((max-text-width
 (max
  (interval-length (ly:stencil-extent upper-stil X))
  (interval-length (ly:stencil-extent lower-stil X
(music-width (interval-length (ly:stencil-extent music-stil X)))
(width-diff
 (abs (/ (- max-text-width music-width) 2)))
(dummy (ly:message "Music width: ~a" width-diff))
)

  (ly:grob-set-property! grob 'Y-extent
;; Include the markups in the Y-extent of the MMR
;; so it won't get cut off the page
(cons
 (min
  (- 0 2 lower-padding (interval-length (ly:stencil-extent 
lower-stil Y)))
  (car (ly:stencil-extent music-stil Y)))
 (max
  (+ 2 upper-padding (interval-length (ly:stencil-extent upper-stil 
Y)))
  (cdr (ly:stencil-extent music-stil Y)))
  ))

  (ly:grob-set-property! grob 'minimum-length
;; widen the measure to encompass music content, upper, 

Re: How to use optional arguments / parameters in a define-markup-command

2019-11-04 Thread Thomas Morley
Am Mo., 4. Nov. 2019 um 18:00 Uhr schrieb Karsten Reincke :
>
> Dear friends
>
> A few days ago, I asked whether anyone knows how one can use variable 
> parameter
> lists = optional arguments = flexible argumentlists in a markup function. I 
> was
> told that such an opportunity does not exist (Thomas Morley)

Let me quote another part of my reply:

Am Fr., 1. Nov. 2019 um 16:01 Uhr schrieb Thomas Morley
:

> For variable amount of args I'd go for list? (or the like) and let the
> body of your code sort it out.

And that's basically what you do in your example-code.

> resp. must be
> simulated by some embedded property features (Urs Liska).

That's not exactly what Urs wrote...

> #(define (assign keyValue assocList defaultValue)
>   (string? list?)
^^
As far as I can tell this line is superfluous, returning #f.

>   (let* ((localPair (assoc keyValue assocList)))
> (if localPair (cdr localPair) defaultValue)
>   )
> )

Check for assoc-get resp. ly:assoc-get doing.


Cheers,
  Harm



How to use optional arguments / parameters in a define-markup-command

2019-11-04 Thread Karsten Reincke
Dear friends

A few days ago, I asked whether anyone knows how one can use variable parameter
lists = optional arguments = flexible argumentlists in a markup function. I was
told that such an opportunity does not exist (Thomas Morley) resp. must be
simulated by some embedded property features (Urs Liska). Many thanks for these
quick answers. They preserved me from doing unnecessary work.

Here is a pure scheme / guile solution using lisp association lists (demoed by
using the box example from the extend tutorial). The target is, that the users 
of
our function may insert the arguments they really need (without having to deal
with those, they do not need) and that they may insert the arguments they want 
to
use in the order they prefer [The running version is attached as a file. Each
substantial portions of the code is distributed under the terms of the MIT
license. I assume that the function shall be interpreted on the lilypond 
level]: 

First, we should define the keys, we want to use (they must be communicated to 
the
users of our function)

#(define ka "k1")
#(define kb "k2")
#(define kc "k3")
#(define kd "k4")
#(define ke "k5")

Second, we should define the respective default values

#(define dva "blank") ; a filled string
#(define dvb "") ; an empty string
#(define dvc '()) ; a null value
#(define dvd "blank") ; 
#(define dve "") ; 

Third, we need a function - let us name it "assign" (you will understand in a
short time, why) - which takes a key, an associationlist (alist) and a default
value. If the alist contains any pair with the same key, then function shall
return the corresponding value, otherwise the given default value

#(define (assign keyValue assocList defaultValue)
  (string? list?)
  (let* ((localPair (assoc keyValue assocList)))
(if localPair (cdr localPair) defaultValue)
  )
)

Based on this pre-work, we can now define a markup function. In the beginning we
define the local parameter variables and let them be instantiated by our assign
function. Then we manipulate the given values in any way. And finally we return 
-
as a markup 'object' - a box containing the result of our manipulation:

#(define-markup-command (mybox layout props AL)
  (list?)
  (let*
( (la (assign ka AL dva))
  (lb (assign kb AL dvb))
  (lc (assign kc AL dvc))
  (ld (assign kd AL dvd))
  (le (assign ke AL dve))
  (lresult "result")
)
;  because we used an empty list (nil) as default value
(if (eq? lc '()) (set! lc ""))
; our 'manupilation' is norhing else but a concatenation ;-)
(set! lresult (string-append la lb lc ld le))

(interpret-markup layout props
  #{
\markup \box { #lresult }
  #}
)
   )
 )  

This function can be called in any markup context like

\markup \mybox #'(("k5" . "V5")("k1" . "V1"))

The result is a box containing the text "V1blankV5": V1 is given by the second
(sic!) argument - the values of the possible keys k2 and k3 are ignored, because
their default values are "" and an empty list = null - the blank is default 
value
of the unused key k4, and V5 is given by the first (sic!) argument.


best regards Karsten


-- 
  Karsten Reincke/\/\   (+49|0) 170 / 927 78 57
 Im Braungeröll 31   >oo<  mailto:k.rein...@fodina.de
60431 Frankfurt a.M.  \/http://www.fodina.de/kr/

\version "2.18.2"

% A pure scheme / guile solution to define a LilyPond markup
% command with a variable list of arguments by using a
% technique of lisp scheme / guile called association lists 
% (demoed by using the box example from the extend tutorial). 

% The target is, that the users of the function may insert 
% the arguments they really need (without having to deal with 
% those, they do not need) and that they may insert the arguments
% they want to use in the order they prefer 

% feel free to adopt this example under the following terms:

% Copyright 2019 Karsten Reincke, Frankfurt

% Permission is hereby granted, free of charge, to any person 
% obtaining a copy of this software and associated documentation 
% files (the "Software"), to deal in the Software without 
% restriction, including without limitation the rights to use, 
% copy, modify, merge, publish, distribute, sublicense, and/or sell 
% copies of the Software, and to permit persons to whom the 
% Software is furnished to do so, subject to the following conditions:

% The above copyright notice and this permission notice shall be 
% included in all copies or substantial portions of the Software.

% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 
% OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
% NONINFRINGEMENT. IN NO EVENT SHALL THE AUT

Re: define-markup-command with variable number of arguments

2019-11-02 Thread Urs Liska



Am 01.11.19 um 16:01 schrieb Thomas Morley:

Am Fr., 1. Nov. 2019 um 15:34 Uhr schrieb Karsten Reincke :


does anyone has / know about an example of a define-markup-command 
implementation
using a variable number of arguments / parameters?

Nope, optional arguments are not possible using define-markup-command.


Unfortunately, in my system (Linux Ubuntu 19.10 with Lilypond 2.18...) the 
normal
GUILE / scheme syntax (define (x y . args) ) (doanythingwith args) ) seems to
executable.

The tutorial LilyPond Extending mentions that there exist such an opportunity
(page 19.), but does not contain any example.

The section of the Extending-tutorial refers to functions, not to the
define-markup-command which is a macro.
(At least if I've identified the section you refer to correctly, I
usually use the big-page-html-version of the docs.)

You could go for properties (see define-markup-commands.scm), but the
syntax in coding and calling it differs ofcourse and you may encounter
unwished side-effects (if namings interfer with grob-properties).

For variable amount of args I'd go for list? (or the like) and let the
body of your code sort it out.



An approach that I personally like very much for its way the input code 
"speaks" is the \with {} clause. You use that by the ly:context-mod? 
predicate and then you can stuff arbitrary key=value pairs in it (and 
parse that within the body, as Harm said).


Urs




Cheers,
   Harm





Re: define-markup-command with variable number of arguments

2019-11-01 Thread Thomas Morley
Am Fr., 1. Nov. 2019 um 15:34 Uhr schrieb Karsten Reincke :

> does anyone has / know about an example of a define-markup-command 
> implementation
> using a variable number of arguments / parameters?

Nope, optional arguments are not possible using define-markup-command.

> Unfortunately, in my system (Linux Ubuntu 19.10 with Lilypond 2.18...) the 
> normal
> GUILE / scheme syntax (define (x y . args) ) (doanythingwith args) ) seems to
> executable.
>
> The tutorial LilyPond Extending mentions that there exist such an opportunity
> (page 19.), but does not contain any example.

The section of the Extending-tutorial refers to functions, not to the
define-markup-command which is a macro.
(At least if I've identified the section you refer to correctly, I
usually use the big-page-html-version of the docs.)

You could go for properties (see define-markup-commands.scm), but the
syntax in coding and calling it differs ofcourse and you may encounter
unwished side-effects (if namings interfer with grob-properties).

For variable amount of args I'd go for list? (or the like) and let the
body of your code sort it out.


Cheers,
  Harm



define-markup-command with variable number of arguments

2019-11-01 Thread Karsten Reincke
Dear friends;

does anyone has / know about an example of a define-markup-command 
implementation
using a variable number of arguments / parameters?

Unfortunately, in my system (Linux Ubuntu 19.10 with Lilypond 2.18...) the 
normal
GUILE / scheme syntax (define (x y . args) ) (doanythingwith args) ) seems to
executable.

The tutorial LilyPond Extending mentions that there exist such an opportunity
(page 19.), but does not contain any example.

Any help is appreciated.

many thanks Karsten
 
-- 
  Karsten Reincke/\/\   (+49|0) 170 / 927 78 57
 Im Braungeröll 31   >oo<  mailto:k.rein...@fodina.de
60431 Frankfurt a.M.  \/http://www.fodina.de/kr/





Re: define and define-markup-command

2019-01-22 Thread Paolo Cantamessa
Thank-you David,
now it works with "layout props" and ##{ music #}

Cheers

Paolo


[image: Mailtrack]
<https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&;>
Sender
notified by
Mailtrack
<https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&;>
22/01/19,
22:01:26

Il giorno mar 22 gen 2019 alle ore 20:40 David Kastrup  ha
scritto:

> Paolo Cantamessa  writes:
>
> > Hello guys,
> > I need to undesrtand how work "define" and "define-markup-command".
> >
> > This work: 
> > #(define (testA txt mus y-offset)
> >#{\markup \vcenter {
> >  #txt
> >  \column {
> >\null
> >\vspace #1
> >\score {
> >  { $mus }
> >  \layout {
> >indent = 0
> >\override Score.Clef.space-alist.time-signature =
> #'(extra-space
> > . 0.5)
> >\override Score.TimeSignature.space-alist.first-note =
> > #'(extra-space . 0)
> >  }
> >}
> >\vspace #(1+ y-offset)
> >\null
> >  }
> >  \hspace #.5
> >} #})
> >
> > \relative c'' {
> >   \set Staff.instrumentName = #(testA "Strumento" #{ c''4 #} -.01)
> >   c4 d e f
> > }
>
> Scheme function, used in a Scheme expression.
>
> > 
> >
> > This doesn't work:
> > #(define-markup-command (testB props layout txt mus y-offset)(markup?
> > ly:music? number?)
> >(interpret-markup props layout #{
>
> Ugh ugh ugh.  It's "layout props", not "props layout".  Likely does not
> make a difference in this case since your use is also the wrong way
> round, but it is pretty awful.
>
> >  \markup \vcenter {
> >#txt
> >\column {
> >  \null
> >  \vspace #1
> >  \score {
> >{ $mus }
> >\layout {
> >  indent = 0
> >  \override Score.Clef.space-alist.time-signature =
> > #'(extra-space . 0.5)
> >  \override Score.TimeSignature.space-alist.first-note =
> > #'(extra-space . 0)
> >}
> >  }
> >  \vspace #(1+ y-offset)
> >  \null
> >}
> >\hspace #.5
> >  } #}))
> >
> >
> > \relative c'' {
> >   \set Staff.instrumentName = ""%\markup \testB "Strumento" { c''4 }
> #-.01
> >   c4 d e f
> > }
>
> Problem here is that markup arguments are parsed in markup mode.
> Version 21.0 will contain an experimental feature where { c''4 } is
> actually being parsed in music mode.  The current 2.19.82 (and the
> upcoming 2.20) will not contain such a feature.  So you'd need to write
>
> ##{ c''4 #} instead, making this again a Scheme mode argument.
>
> --
> David Kastrup
>
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: define and define-markup-command

2019-01-22 Thread David Kastrup
Paolo Cantamessa  writes:

> Hello guys,
> I need to undesrtand how work "define" and "define-markup-command".
>
> This work: 
> #(define (testA txt mus y-offset)
>#{\markup \vcenter {
>  #txt
>  \column {
>\null
>\vspace #1
>\score {
>  { $mus }
>  \layout {
>indent = 0
>\override Score.Clef.space-alist.time-signature = #'(extra-space
> . 0.5)
>\override Score.TimeSignature.space-alist.first-note =
> #'(extra-space . 0)
>  }
>}
>\vspace #(1+ y-offset)
>\null
>  }
>  \hspace #.5
>} #})
>
> \relative c'' {
>   \set Staff.instrumentName = #(testA "Strumento" #{ c''4 #} -.01)
>   c4 d e f
> }

Scheme function, used in a Scheme expression.

> 
>
> This doesn't work:
> #(define-markup-command (testB props layout txt mus y-offset)(markup?
> ly:music? number?)
>(interpret-markup props layout #{

Ugh ugh ugh.  It's "layout props", not "props layout".  Likely does not
make a difference in this case since your use is also the wrong way
round, but it is pretty awful.

>  \markup \vcenter {
>#txt
>\column {
>  \null
>  \vspace #1
>  \score {
>{ $mus }
>\layout {
>  indent = 0
>  \override Score.Clef.space-alist.time-signature =
> #'(extra-space . 0.5)
>  \override Score.TimeSignature.space-alist.first-note =
> #'(extra-space . 0)
>}
>  }
>  \vspace #(1+ y-offset)
>  \null
>}
>\hspace #.5
>  } #}))
>
>
> \relative c'' {
>   \set Staff.instrumentName = ""%\markup \testB "Strumento" { c''4 } #-.01
>   c4 d e f
> }

Problem here is that markup arguments are parsed in markup mode.
Version 21.0 will contain an experimental feature where { c''4 } is
actually being parsed in music mode.  The current 2.19.82 (and the
upcoming 2.20) will not contain such a feature.  So you'd need to write

##{ c''4 #} instead, making this again a Scheme mode argument.

-- 
David Kastrup

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


define and define-markup-command

2019-01-22 Thread Paolo Cantamessa
Hello guys,
I need to undesrtand how work "define" and "define-markup-command".

This work: 
#(define (testA txt mus y-offset)
   #{\markup \vcenter {
 #txt
 \column {
   \null
   \vspace #1
   \score {
 { $mus }
 \layout {
   indent = 0
   \override Score.Clef.space-alist.time-signature = #'(extra-space
. 0.5)
   \override Score.TimeSignature.space-alist.first-note =
#'(extra-space . 0)
 }
   }
   \vspace #(1+ y-offset)
   \null
 }
 \hspace #.5
   } #})

\relative c'' {
  \set Staff.instrumentName = #(testA "Strumento" #{ c''4 #} -.01)
  c4 d e f
}
------------

This doesn't work:
#(define-markup-command (testB props layout txt mus y-offset)(markup?
ly:music? number?)
   (interpret-markup props layout #{
 \markup \vcenter {
   #txt
   \column {
 \null
 \vspace #1
 \score {
   { $mus }
   \layout {
 indent = 0
 \override Score.Clef.space-alist.time-signature =
#'(extra-space . 0.5)
 \override Score.TimeSignature.space-alist.first-note =
#'(extra-space . 0)
   }
 }
 \vspace #(1+ y-offset)
 \null
   }
   \hspace #.5
 } #}))


\relative c'' {
  \set Staff.instrumentName = ""%\markup \testB "Strumento" { c''4 } #-.01
  c4 d e f
}



[image: Mailtrack]
<https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&;>
Sender
notified by
Mailtrack
<https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&;>
22/01/19,
18:13:16
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Using \score in define-markup-command

2016-02-29 Thread tisimst
On Mon, Feb 29, 2016 at 2:07 PM, David Kastrup [via Lilypond] <
ml-node+s1069038n187897...@n5.nabble.com> wrote:

> tisimst <[hidden email]
> <http:///user/SendEmail.jtp?type=node&node=187897&i=0>> writes:
>
> > By the way, did the syntax for define-markup-command get simplified
> > like define-music-function so the "layout props" args aren't necessary
> > anymore?  Just curious.
>
> No.  Neither does it do all the smart argument detection and default
> arguments that music/event/scheme functions do.
>
> Markups are a pretty messy area of their own.
>

I can only imagine. Thanks for all your hard work to make
define-music-function easier to use!

Best,
Abraham




--
View this message in context: 
http://lilypond.1069038.n5.nabble.com/Using-score-in-define-markup-command-tp187892p187898.html
Sent from the User mailing list archive at Nabble.com.___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Using \score in define-markup-command

2016-02-29 Thread David Kastrup
tisimst  writes:

> By the way, did the syntax for define-markup-command get simplified
> like define-music-function so the "layout props" args aren't necessary
> anymore?  Just curious.

No.  Neither does it do all the smart argument detection and default
arguments that music/event/scheme functions do.

Markups are a pretty messy area of their own.

-- 
David Kastrup

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


Re: Using \score in define-markup-command

2016-02-29 Thread tisimst
Harm,

On Mon, Feb 29, 2016 at 1:27 PM, Thomas Morley-2 [via Lilypond] <
ml-node+s1069038n187894...@n5.nabble.com> wrote:

> 2016-02-29 20:57 GMT+01:00 Abraham Lee <[hidden email]
> <http:///user/SendEmail.jtp?type=node&node=187894&i=0>>:
> >
> > Any suggestions?
> >
> > - Abraham
> >
>
>
> Uhh, markup-mode
>
> #(define-markup-command (ezscore layout props mus) (ly:music?)
>   (interpret-markup layout props
> #{
>   \markup {
> \score {
>   \relative c'' { #mus }
> }
>   }
> #}))
>
> \markup { I'd like to do this: "\\ezscore { c8[ c] } }" }
>
> \markup { You can do this: \ezscore ##{ { c8[ c] } #} }
>
> mus = { c8[ c] }
> \markup { or this: \ezscore #mus }
>

(face-palm) Ah ha! I knew it was something obvious. Thank you, Harm.

By the way, did the syntax for define-markup-command get simplified like
define-music-function so the "layout props" args aren't necessary anymore?
Just curious.

Best,
Abraham




--
View this message in context: 
http://lilypond.1069038.n5.nabble.com/Using-score-in-define-markup-command-tp187892p187896.html
Sent from the User mailing list archive at Nabble.com.___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Using \score in define-markup-command

2016-02-29 Thread Thomas Morley
2016-02-29 20:57 GMT+01:00 Abraham Lee :
> All,
>
> I'm trying to utilize the \score markup command within a custom
> define-markup-command that accepts a music expression, but I can't figure
> out how. I'm probably missing something obvious, but here's a minimal
> example:
>
> 
>
> \version "2.19.36"
>
> \markup {
>   I know I can do this:
>   \score {
> \relative c'' { c8[ c] }
>   }
> }
>
> #(define-markup-command (ezscore layout props mus) (ly:music?)
>   (interpret-markup layout props
> #{
>   \markup {
> \score {
>   \relative c'' { #mus }
> }
>   }
> #}))
>
> \markup { But I'd like to do this: \ezscore { c8[ c] } }
>
> 
>
> Any suggestions?
>
> - Abraham
>


Uhh, markup-mode

#(define-markup-command (ezscore layout props mus) (ly:music?)
  (interpret-markup layout props
#{
  \markup {
\score {
  \relative c'' { #mus }
}
  }
#}))

\markup { I'd like to do this: "\\ezscore { c8[ c] } }" }

\markup { You can do this: \ezscore ##{ { c8[ c] } #} }

mus = { c8[ c] }
\markup { or this: \ezscore #mus }


HTH,
  Harm

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


Using \score in define-markup-command

2016-02-29 Thread Abraham Lee
All,

I'm trying to utilize the \score markup command within a custom
define-markup-command that accepts a music expression, but I can't figure
out how. I'm probably missing something obvious, but here's a minimal
example:



\version "2.19.36"

\markup {
  I know I can do this:
  \score {
\relative c'' { c8[ c] }
  }
}

#(define-markup-command (ezscore layout props mus) (ly:music?)
  (interpret-markup layout props
#{
  \markup {
\score {
  \relative c'' { #mus }
}
  }
#}))

\markup { But I'd like to do this: \ezscore { c8[ c] } }



Any suggestions?

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


Re: Move markup relative to parent from inside define-markup-command?

2012-03-22 Thread Nick Payne

On 23/03/12 14:23, David Nalesnik wrote:

Hi Nick,

On Thu, Mar 22, 2012 at 9:29 PM, Nick Payne 
mailto:nick.pa...@internode.on.net>> wrote:


I'm using define-markup-command to simplify the indication of
barring for a single chord, but what I have at the moment defaults
to being centred on the note, and the vertical line indicating how
many strings to cover is overlaid by the notehead unless the
markup position is tweaked. Is it possible, if I have an
additional numeric argument for the amount of shift needed, to
apply that shift from inside the define-markup-command rather than
having to use an external tweak? 



Do you mean something like the following (which duplicates the image 
you've uploaded)?


 \version "2.15.32"

#(define-markup-command (mbarre layout props fretnum vdrop offset) 
(markup? number? number?)

   (interpret-markup layout props
   #{
  \markup \translate #(cons offset 0) \small \bold { \concat {
   \postscript #(string-append "0.1 setlinewidth 0.7 -0.5 moveto 0 -"
   (number->string vdrop) " rlineto 0.5 0 rlineto stroke") 
$fretnum } } #}

   )
)

\relative c'' {
4^\markup { \mbarre "V" #2.3 #0 } ^\markup { \mbarre "V" 
#2.3 #-1.5 }

}


Thanks. That's exactly what I was after.

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


Re: Move markup relative to parent from inside define-markup-command?

2012-03-22 Thread David Nalesnik
Hi Nick,

On Thu, Mar 22, 2012 at 9:29 PM, Nick Payne wrote:

> I'm using define-markup-command to simplify the indication of barring for
> a single chord, but what I have at the moment defaults to being centred on
> the note, and the vertical line indicating how many strings to cover is
> overlaid by the notehead unless the markup position is tweaked. Is it
> possible, if I have an additional numeric argument for the amount of shift
> needed, to apply that shift from inside the define-markup-command rather
> than having to use an external tweak?


Do you mean something like the following (which duplicates the image you've
uploaded)?

 \version "2.15.32"

#(define-markup-command (mbarre layout props fretnum vdrop offset) (markup?
number? number?)
   (interpret-markup layout props
   #{
  \markup \translate #(cons offset 0) \small \bold { \concat {
   \postscript #(string-append "0.1 setlinewidth 0.7 -0.5 moveto 0 -"
   (number->string vdrop) " rlineto 0.5 0 rlineto stroke") $fretnum } }
#}
   )
)

\relative c'' {
4^\markup { \mbarre "V" #2.3 #0 } ^\markup { \mbarre "V" #2.3
#-1.5 }
}


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


Move markup relative to parent from inside define-markup-command?

2012-03-22 Thread Nick Payne
I'm using define-markup-command to simplify the indication of barring 
for a single chord, but what I have at the moment defaults to being 
centred on the note, and the vertical line indicating how many strings 
to cover is overlaid by the notehead unless the markup position is 
tweaked. Is it possible, if I have an additional numeric argument for 
the amount of shift needed, to apply that shift from inside the 
define-markup-command rather than having to use an external tweak? This 
is what I have at the moment:


\version "2.15.32"

#(define-markup-command (mbarre layout props fretnum vdrop) (markup? 
number?)

(interpret-markup layout props
#{ \markup \small \bold { \concat { \postscript #(string-append 
"0.1 setlinewidth 0.7 -0.5 moveto 0 -"
(number->string vdrop) " rlineto 0.5 0 rlineto stroke") 
$fretnum } } #}

)
)

\relative c'' {
4^\markup { \mbarre "CV" #2.3 } -\tweak #'extra-offset #'(-1.5 
. 0)^\markup { \mbarre "CV" #2.3 }

}

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


Re: \score inside define-markup-command

2009-02-25 Thread Michael Käppler

Hi Nicolas,
many thanks for that hint!
Using make-score was the point. But also very nice you showed me how to 
deal with layout settings in such a "scheme score".


Michael


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


Re: \score inside define-markup-command

2009-02-24 Thread Nicolas Sceaux

Le 23 févr. 09 à 10:36, Michael Käppler a écrit :



Hi,

I don't know if it will work, but perhaps you can try to type
\displayMusic {<< \clef #testclef  a4 h c >>} to get the scheme  
version of your music,

and to copy/paste the output you got after the #:score markup ...
good idea! But it still doesn't work. Let's look at the following  
minimal example:


#(define-markup-command (testmusic layout props a b c) (number?  
number? number?)

(interpret-markup layout props (markup #:score
 (make-music
'SequentialMusic
'elements
(list (make-music
'EventChord
'elements
(list (make-music
'NoteEvent
'duration
(ly:make-duration 2 0 1 1)
'pitch
(ly:make-pitch a b c))
)))


Try the following:

\version "2.12.2"
#(define-markup-command (testmusic layout props music) (ly:music?)
  (let ((score (ly:make-score music))
(score-layout (ly:output-def-clone $defaultlayout)))
;; possibly, change some settings in the \layout block
(ly:output-def-set-variable! score-layout 'indent 0)
;; add the \layout block to the score
(ly:score-add-output-def! score score-layout)
(interpret-markup layout props (markup #:vcenter #:score score

\markup { a piece of music \testmusic ##{ a' b' c'' d'' #} inside a  
markup }


nicolas



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


Re: \score inside define-markup-command

2009-02-23 Thread Michael Käppler


Hi,

I don't know if it will work, but perhaps you can try to type
\displayMusic {<< \clef #testclef  a4 h c >>} to get the scheme 
version of your music,

and to copy/paste the output you got after the #:score markup ...
good idea! But it still doesn't work. Let's look at the following 
minimal example:


#(define-markup-command (testmusic layout props a b c) (number? number? 
number?)

 (interpret-markup layout props (markup #:score
  (make-music
 'SequentialMusic
 'elements
 (list (make-music
 'EventChord
 'elements
 (list (make-music
 'NoteEvent
 'duration
 (ly:make-duration 2 0 1 1)
 'pitch
 (ly:make-pitch a b c))
)))


<<
c2^\markup \testmusic #-1 #0 #0
>>

It fails with a bunch of error messages for which my knowledge of scheme 
isn't enough to understand.


/usr/local/lilypond/usr/share/lilypond/current/scm/markup.scm:208:10: In 
procedure string-append in expression (string-append make-name ": " ...):
/usr/local/lilypond/usr/share/lilypond/current/scm/markup.scm:208:10: 
Wrong type (expecting string): (1 "unknown" #Music((elements #Music((pitch . #) (duration . #>))((display-methods #) (name . NoteEvent) 
(types general-music event note-event rhythmic-event melodic-event)) >
))((display-methods # #parser)> #) (name . EventChord) 
(iterator-ctor . #ly:event-chord-iterator::constructor>) (length-callback . 
#) 
(to-relative-callback . #ly:music-sequence::event-chord-relative-callback>) (types general-music 
event-chord simultaneous-music)) >
))((display-methods #) (name . 
SequentialMusic) (length-callback . #ly:music-sequence::cumulative-length-callback>) (start-callback . 
#) 
(elements-callback . #) (iterator-ctor . 
#) (types 
general-music sequential-music)) >

)

Can anyone help?

Michael


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


Re: \score inside define-markup-command

2009-02-23 Thread Tao Cumplido
LP syntax can always be expressed in Scheme.
\displayMusic { a'4 } will show you how the LP expression a'4 is written in 
Scheme.

I haven't tried it but I suppose that's the way to go.

Regards,

Tao


 Original-Nachricht 
> Datum: Mon, 23 Feb 2009 01:01:23 +0100
> Von: "Michael Käppler" 
> An: lilypond-user@gnu.org
> Betreff: \\score inside define-markup-command

> Hi all,
> is it possible to use the \score markup function in a new defined markup 
> function construct?
> 
> For example,
> 
> #(define-markup-command (test layout props testclef) (string?)
>(interpret-markup layout props (markup #:score ( << \clef #testclef 
> a4 h c >>
> 
> 
> This is invalid code because it mixes LilyPond and Scheme syntax. How 
> can I achieve something similar to what's expressed in this dummy code 
> piece?
> 
> Regards,
> Michael
> 
> 
> ___
> lilypond-user mailing list
> lilypond-user@gnu.org
> http://lists.gnu.org/mailman/listinfo/lilypond-user

-- 
Pt! Schon vom neuen GMX MultiMessenger gehört? Der kann`s mit allen: 
http://www.gmx.net/de/go/multimessenger


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


Re: \score inside define-markup-command

2009-02-23 Thread Gilles THIBAULT



#(define-markup-command (test layout props testclef) (string?)
  (interpret-markup layout props (markup #:score ( << \clef #testclef a4 h 
c >>



This is invalid code because it mixes LilyPond and Scheme syntax. How can 
I achieve something similar to what's expressed in this dummy code piece?


I don't know if it will work, but perhaps you can try to type
\displayMusic {<< \clef #testclef  a4 h c >>} to get the scheme version of 
your music,

and to copy/paste the output you got after the #:score markup ...

Gilles




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


\score inside define-markup-command

2009-02-22 Thread Michael Käppler

Hi all,
is it possible to use the \score markup function in a new defined markup 
function construct?


For example,

#(define-markup-command (test layout props testclef) (string?)
  (interpret-markup layout props (markup #:score ( << \clef #testclef 
a4 h c >>



This is invalid code because it mixes LilyPond and Scheme syntax. How 
can I achieve something similar to what's expressed in this dummy code 
piece?


Regards,
Michael


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


Re: numbers as arguments in define-markup-command

2006-12-29 Thread Han-Wen Nienhuys
Orm Finnendahl escreveu:
> Hi,
> 
> I try to define a markup for vertical arrows and can't get the
> function to take two numbers as arguments. Using strings as arguments
> or a number and a string works. It seems the last argument to
> define-markup-command has to be a string. Does anybody know why and
> how to make it work with numbers? I'd rather supply the y-offset and
> length of the arrow as a number.
> 
> This doesn't work:
> 
> \version "2.11.2"
> 
> #(define-markup-command (varrow layout props yoff len) (number? number?)
>   (interpret-markup layout props
>(markup
> #:line
> (#:postscript
>  (string-append 
>   "1 1 scale 0.1 setlinewidth 0 "
>   (number->string yoff)
>   " translate 0 0 moveto -0.25 1 lineto 0.25 1 lineto 0 0 lineto 
> closepath fill 0 1 moveto 0 "
>   (number->string len)
>   " rlineto stroke")
> 
> {c4^\markup {\varrow #3 #10}}
> 
> lilypond signals an error about the 10 being an unbound variable. I
> don't get this error when supplying the "10" directly as a string:

try 

  #10 } 

iso 

  #10}


-- 

Han-Wen Nienhuys - [EMAIL PROTECTED] - http://www.xs4all.nl/~hanwen

LilyPond Software Design
 -- Code for Music Notation
http://www.lilypond-design.com



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


numbers as arguments in define-markup-command

2006-12-29 Thread Orm Finnendahl
Hi,

I try to define a markup for vertical arrows and can't get the
function to take two numbers as arguments. Using strings as arguments
or a number and a string works. It seems the last argument to
define-markup-command has to be a string. Does anybody know why and
how to make it work with numbers? I'd rather supply the y-offset and
length of the arrow as a number.

This doesn't work:

\version "2.11.2"

#(define-markup-command (varrow layout props yoff len) (number? number?)
  (interpret-markup layout props
   (markup
#:line
(#:postscript
 (string-append 
  "1 1 scale 0.1 setlinewidth 0 "
  (number->string yoff)
  " translate 0 0 moveto -0.25 1 lineto 0.25 1 lineto 0 0 lineto closepath 
fill 0 1 moveto 0 "
  (number->string len)
  " rlineto stroke")

{c4^\markup {\varrow #3 #10}}

lilypond signals an error about the 10 being an unbound variable. I
don't get this error when supplying the "10" directly as a string:

This works:

\version "2.11.2"

#(define-markup-command (varrow layout props yoff len) (number? string?)
  (interpret-markup layout props
   (markup
#:line
(#:postscript
 (string-append 
  "1 1 scale 0.1 setlinewidth 0 "
  (number->string yoff)
  " translate 0 0 moveto -0.25 1 lineto 0.25 1 lineto 0 0 lineto closepath 
fill 0 1 moveto 0 "
  len
  " rlineto stroke")

{c4^\markup {\varrow #3 #"10"}}



--
Orm


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