Re: Regexp Functions
On 2020-06-09 12:42 am, Freeman Gilmore wrote: I do no tthink this is what i want. Let me try again Say you have "Xsdfghjkl" If "x" is the first character then replace the "g" if it exist with "Y" => "XsdYfhjkl"X /(^A.*)B/ is the general pattern: () Match the regex below and capture its match into backreference number 1. ^ Assert position at the beginning of a line. A Match the character "A" literally. .*Match any single character that is NOT a line break character between zero and unlimited times, as many times as possible, giving back as needed (greedy). B Match the character "B" literally. Since "A" and "B" above are literals, they may be replaced with "X" and "g", respectively, if that is what you wanted. Consider: (regexp-substitute/global #f "(^X.*)g" "Xsdfghjkl" 'pre 1 "Y" 'post) "XsdfYhjkl" Note that regular expressions can be a powerful tool [1], but they can also create more problems than they solve [2]. [1]: https://xkcd.com/208/ [2]: https://xkcd.com/1171/ Your original problem involved conditionally replacing a substring based on whether the string starts with a particular prefix. Consider: ((lambda (s) (if (string-prefix? "X" s) (string-join (string-split s #\g) "Y") s)) "Xsdfghjkl") "XsdfYhjkl" In the above, we have separated the task into a few parts. First is checking the prefix of the string, as the absence of the desired text means no work needs to be done. When replacing, we use string-split and string-join to achieve our goal. This works because we are looking for a single character to replace. A more general approach would need to use several of the string-* family of procedures: (define (string-find-replace s1 s2 s3) "Return the string @var{s1}, where all occurrences of @var{s2} are replaced by @var{s3}." (let ((index (string-contains s1 s2))) (if (number? index) (string-append (string-take s1 index) s3 (string-find-replace (string-drop s1 (+ index (string-length s2))) s2 s3)) s1))) ((lambda (s) (if (string-prefix? "XX" s) (string-find-replace s "gg" "YY") s)) "XXssddffgghhjjkkll") "XXssddffYYhhjjkkll" Hopefully you can see that in this situation, regexp-substitute/global becomes the more succinct way to express things: (regexp-substitute/global #f "(^XX.*)gg" "XXssddffgghhjjkkll" 'pre 1 "YY" 'post) "XXssddffYYhhjjkkll" -- Aaron Hill
Re: Identify included files
On 09/06/2020 15:57, Fr. Samuel Springuel wrote: On 9 Jun, 2020, at 5:54 AM, Matt Wallis wrote: I found https://lists.gnu.org/archive/html/lilypond-user/2020-05/msg00148.html very interesting. It describes how to get lilypond to print out dependencies. Have you looked into this? That’s from the start of this thread and I’m making use of it in the with-deps.ly file (and in parse-only.ly on the GNUmake_dependencies branch). I don’t use it exactly as it was originally presented in that message because the format wasn’t make-freindly, but ly:source-files is the starting point for generating the list of prerequisites. Sorry - I should have read more carefully! Be clear about the difference between = and :=. You are using = when := would work fine. That’s a good point. I’m carrying over some bad practices from the original Makefile example in the documentation and should clean that up as much as possible. Put everything that moves (!) into a variable. For example, I'd have PDF_DIR := PDF/ Include the backslash when you define a directory (as above). This is a habit I've got into and now rely on. It helps me. Can you elaborate on this? Why would this be better than what I’ve got? Good question. I've been doing this out of habit for so long, I had to think hard to remember why! I've come up with two reasons: 1. The trailing slash in foo/ forces it to be a directory. For example, even when foo does not exist you can't treat foo/ as a regular file: $ cat > foo/ bash: foo/: Is a directory 2. An accidental extra slash causes no problems, but an accidental missing slash changes the meaning: foo//bar is the same as foo/bar, but foobar is not the same as foo/bar Matt
Re: How to pass a fraction as a parameter for a Scheme function
On 2020-06-09 12:43 pm, Paolo Prete wrote: Hello, I don't understand how to use a fraction as a parameter for a scheme function. More specifically, this gives me an error: proportionalNotationDur = #(define-music-function (parser location frac) (scheme?) #{ \set Score.proportionalNotationDuration = #(ly:make-moment frac) #}) { \proportionalNotationDur 1/16 c' c' c' c' } You should use the fraction? type predicate if you want to accept 1/16 for input. The resulting value is a pair with the numerator as the car and the denominator as the cdr. Alternately, you can use the rational? type predicate so the value is numeric. However, you will then need to use Scheme syntax for the input: #1/16 instead of 1/16. -- Aaron Hill
Re: How to pass a fraction as a parameter for a Scheme function
Paolo Prete writes: > Hello, > > I don't understand how to use a fraction as a parameter for a scheme > function. More specifically, this gives me an error: > > > > proportionalNotationDur = #(define-music-function (parser location frac) > (scheme?) #{ \set > Score.proportionalNotationDuration = #(ly:make-moment frac) #}) > { > \proportionalNotationDur 1/16 > c' c' c' c' > } > > > > How can I fix it? > Thanks! A fraction is a number _pair_ (because \time 4/4 is different from \time 2/2), not rational number. For ly:make-moment, you need to convert to a rational number or two integers. The predicate should really, really, really cater to the correct type: scheme? is just asking for trouble. Personally, I'd rather use a duration in order to write 16 instead of 1/16 and 16*3 instead of 3/16. But for the usage you want, one can do proportionalNotationDur = #(define-music-function (parser location frac) (fraction?) #{ \set Score.proportionalNotationDuration = #(fraction->moment frac) #}) { \proportionalNotationDur 1/16 c' c' c' c' } -- David Kastrup
Re: How to pass a fraction as a parameter for a Scheme function
Am Dienstag, 09. Juni 2020 21:43 CEST, Paolo Prete schrieb: > Hello, > > I don't understand how to use a fraction as a parameter for a scheme > function. More specifically, this gives me an error: > > > > proportionalNotationDur = #(define-music-function (parser location frac) > (scheme?) #{ \set > Score.proportionalNotationDuration = #(ly:make-moment frac) #}) > { > \proportionalNotationDur 1/16 > c' c' c' c' > } > > > > How can I fix it? You declare the function to take a scheme value. Shouldn't that then be passed one, i.e: { \proportionalNotationDur #1/16 c' c' c' c' } > Thanks! -- Ralf Mattes Hochschule für Musik Freiburg Projektleitung HISinOne Schwarzwaldstr. 141, D-79102 Freiburg http://www.mh-freiburg.de
How to pass a fraction as a parameter for a Scheme function
Hello, I don't understand how to use a fraction as a parameter for a scheme function. More specifically, this gives me an error: proportionalNotationDur = #(define-music-function (parser location frac) (scheme?) #{ \set Score.proportionalNotationDuration = #(ly:make-moment frac) #}) { \proportionalNotationDur 1/16 c' c' c' c' } How can I fix it? Thanks!
Re: Regexp Functions
On 2020-06-09 9:25 am, Michael Gerdau wrote: [sent this earlier and forgot to include the list...] That definition helps. I use the Guile manual, the section Regular Expressions is miss leading about what is there.I only went there because Arron Hill told me about it And the introduction states "A full description of regular expressions and their syntax is beyond the scope of this manual"; and the URL goes nowhere. And I would guess knowing what to read elsewhere that is consistent with the guile version Lilypond uses may be a probleblen. I am open to a good ron cryptic reference? I personally really like the perlre manpage. It is THE reference for all Perl Regular Expressions from which many other current regexp engines are derived. Just be aware that Guile uses GNU's version of POSIX extended regular expressions (ERE), which is significantly more limited than Perl-compatible regular expressions (PCRE). GNU adds some features beyond the core POSIX standard, such as shorthands for word characters (\w) and whitespace (\s). But it omits the one for digits (\d) that is included in PCRE. Instead, one must use either /[0-9]/ or /[[:digit:]]/, the latter being an example of a POSIX character class. GNU ERE includes support for the {,n} quantifier that matches an item between zero and n times; however, quantifiers in POSIX ERE are always greedy, whereas PCRE supports lazy and possessive variants. POSIX ERE permits only basic unnamed capturing groups, although GNU ERE does add support for backreferences: /.(.)(.)\2\1/ will match 'xyzzy'. However, PCRE additionally handles non-capturing groups, named groups, and many forms of lookarounds and conditionals. -- Aaron Hill
Re: Regexp Functions
[sent this earlier and forgot to include the list...] > That definition helps. I use the Guile manual, the section Regular > Expressions is miss leading about what is there.I only went there > because Arron Hill told me about it And the introduction states "A > full description of regular expressions and their syntax is beyond the > scope of this manual"; and the URL goes nowhere. And I would guess > knowing what to read elsewhere that is consistent with the guile > version Lilypond uses may be a probleblen. I am open to a good ron > cryptic reference? I personally really like the perlre manpage. It is THE reference for all Perl Regular Expressions from which many other current regexp engines are derived. Kind regards, Michael -- Michael Gerdau email: m...@qata.de GPG-keys available on request or at public keyserver
Re: Orchestral strings, how to organise score and parts for divisi, solos, desks etc.
On 6/7/2020 3:26 AM, Rutger Hofman wrote: Well, it turned out to keep that tutorial short. Still, I think it will have its use, since questions about temp staves/divisi turn up at regular intervals. My first attempt is here: https://www.rutgerhofman.nl/lilypond/divisi-doc/divisi-doc.html Please, have a look, say what you (don't) like. I still debate in my head what the best venue for this would be. Rutger On 6/2/20 11:33 AM, Lib Lists wrote: On Mon, 1 Jun 2020 at 22:16, Rutger Hofman wrote: I am thinking of sharing my experiences as a user in this field by contributing a tutorial or a practical experiences story (or whatever) on this topic. It would make a distinction between: 1) temporary staves 2) divisi allocation over groups of staves since these are different concepts, and they are handled differently by the Lilypond user, although both depend on keepAliveInterfaces. And I could contribute a bit on techniques to have >2 voices per staff, rhythmically homophonic or rhythmically polyphonic, especially in the context of divisi staves. What would be the best venue for this? Lilypond docs? User list? Scores of Beauty? If it gets into the Lilypond docs, it is there to "stay forever" which would be nice. One elaborate example of my experiences is found in the score and parts of "3 Bruchstücke aus Wozzeck" by Alban Berg, see https://imslp.org/wiki/Wozzeck%2C_Op.7_(Berg%2C_Alban) (travel to the tab [Arrangements and Transcriptions]). One can have a look at e.g. the Violins I part, mvt. 1, Bars 396-404; there is a 5-fold divisi which is folded into one staff in the full score. Or practically any instrument group, for that matter. Rutger Wow, this is great! Thank you for sharing this with everyone! I'm excited to study this more. :)
Re: Identify included files
> On 9 Jun, 2020, at 5:54 AM, Matt Wallis wrote: > > I found > https://lists.gnu.org/archive/html/lilypond-user/2020-05/msg00148.html very > interesting. > It describes how to get lilypond to print out dependencies. Have you looked > into this? That’s from the start of this thread and I’m making use of it in the with-deps.ly file (and in parse-only.ly on the GNUmake_dependencies branch). I don’t use it exactly as it was originally presented in that message because the format wasn’t make-freindly, but ly:source-files is the starting point for generating the list of prerequisites. > Be clear about the difference between = and :=. You are using = when := would > work fine. That’s a good point. I’m carrying over some bad practices from the original Makefile example in the documentation and should clean that up as much as possible. > Put everything that moves (!) into a variable. For example, I'd have > > PDF_DIR := PDF/ > > Include the backslash when you define a directory (as above). This is a habit > I've got into and now rely on. It helps me. Can you elaborate on this? Why would this be better than what I’ve got? ✝✝ Fr. Samuel, OSB (R. Padraic Springuel) St. Anselm’s Abbey 4501 South Dakota Ave, NE Washington, DC, 20017 202-269-2300 (c) 202-853-7036 PAX ☧ ΧΡΙΣΤΟΣ
Re: Regexp Functions
That looks good Thank you, ƒg On Tue, Jun 9, 2020 at 10:26 AM Phil Holmes wrote: > > I've always found http://www.regular-expressions.info/ very helpful. > > -- > Phil Holmes > > > - Original Message - > From: "Freeman Gilmore" > To: "Jacques Menu" > Cc: "Lilypond-User Mailing List" > Sent: Tuesday, June 09, 2020 2:55 PM > Subject: Re: Regexp Functions > > > On Tue, Jun 9, 2020 at 6:51 AM Jacques Menu wrote: > > > > Hello Freeman, > > > > > Le 9 juin 2020 à 09:43, Freeman Gilmore a > > > écrit : > > > > > > On Tue, Jun 9, 2020 at 1:25 AM Michael Gerdau wrote: > > >> > > >> Hi! > > >> > > >> I find your description difficult to understand. Maybe you could > > >> provide an set of examples showing exactly what you wish to be modified > > >> into what. > > > Sorry, that is the problem I have when someone asks about what i am > > > doing or trying to do. For me I find it best to just ask what I want > > > to know. Arron as well as some others answer my question when I do > > > not include these kinds of detail they do add confusion. Arron on my > > > initial post did not understand what I was asking eathere. > > > > > > So I will try again.Say you have "Xsdfghjkl" If "x" is the first > > > character then replace the "g" if it exist with "Y" => "XsdYfhjkl"X > > > > > >> Apart from that your problem sounds as if it is trivial when using non > > >> greedy regular expressions. > > > > > > I do not know what this means: non greedy regular expressions? > > > > Greedy relates to how many characters are consumed by regular expressions > > when a match if found. > > > > You may need to learn more deeply about these to reach your goal. > > That definition helps. I use the Guile manual, the section Regular > Expressions is miss leading about what is there.I only went there > because Arron Hill told me about it And the introduction states "A > full description of regular expressions and their syntax is beyond the > scope of this manual"; and the URL goes nowhere. And I would guess > knowing what to read elsewhere that is consistent with the guile > version Lilypond uses may be a probleblen. I am open to a good ron > cryptic reference? > > Thank you, ƒg > > > > > JM > > > > > >
Re: Regexp Functions
Thank you that should help, ƒg On Tue, Jun 9, 2020 at 10:01 AM Jacques Menu wrote: > > Hello Freeman, > > The reference I use is http://www.cplusplus.com/reference/regex/ECMAScript/ . > > Greed is mentioned under ‘Quantifiers‘ > > HTH! > > JM > > > Le 9 juin 2020 à 15:55, Freeman Gilmore a écrit > > : > > > > On Tue, Jun 9, 2020 at 6:51 AM Jacques Menu wrote: > >> > >> Hello Freeman, > >> > >>> Le 9 juin 2020 à 09:43, Freeman Gilmore a > >>> écrit : > >>> > >>> On Tue, Jun 9, 2020 at 1:25 AM Michael Gerdau wrote: > > Hi! > > I find your description difficult to understand. Maybe you could provide > an set of examples showing exactly what you wish to be modified into > what. > >>> Sorry, that is the problem I have when someone asks about what i am > >>> doing or trying to do. For me I find it best to just ask what I want > >>> to know. Arron as well as some others answer my question when I do > >>> not include these kinds of detail they do add confusion. Arron on my > >>> initial post did not understand what I was asking eathere. > >>> > >>> So I will try again.Say you have "Xsdfghjkl" If "x" is the first > >>> character then replace the "g" if it exist with "Y" => "XsdYfhjkl"X > >>> > Apart from that your problem sounds as if it is trivial when using non > greedy regular expressions. > >>> > >>> I do not know what this means: non greedy regular expressions? > >> > >> Greedy relates to how many characters are consumed by regular expressions > >> when a match if found. > >> > >> You may need to learn more deeply about these to reach your goal. > > > > That definition helps. I use the Guile manual, the section Regular > > Expressions is miss leading about what is there.I only went there > > because Arron Hill told me about it And the introduction states "A > > full description of regular expressions and their syntax is beyond the > > scope of this manual"; and the URL goes nowhere. And I would guess > > knowing what to read elsewhere that is consistent with the guile > > version Lilypond uses may be a probleblen. I am open to a good ron > > cryptic reference? > > > > Thank you, ƒg > > > >> > >> JM >
Re: Regexp Functions
I've always found http://www.regular-expressions.info/ very helpful. -- Phil Holmes - Original Message - From: "Freeman Gilmore" To: "Jacques Menu" Cc: "Lilypond-User Mailing List" Sent: Tuesday, June 09, 2020 2:55 PM Subject: Re: Regexp Functions On Tue, Jun 9, 2020 at 6:51 AM Jacques Menu wrote: Hello Freeman, > Le 9 juin 2020 à 09:43, Freeman Gilmore a > écrit : > > On Tue, Jun 9, 2020 at 1:25 AM Michael Gerdau wrote: >> >> Hi! >> >> I find your description difficult to understand. Maybe you could >> provide an set of examples showing exactly what you wish to be modified >> into what. > Sorry, that is the problem I have when someone asks about what i am > doing or trying to do. For me I find it best to just ask what I want > to know. Arron as well as some others answer my question when I do > not include these kinds of detail they do add confusion. Arron on my > initial post did not understand what I was asking eathere. > > So I will try again.Say you have "Xsdfghjkl" If "x" is the first > character then replace the "g" if it exist with "Y" => "XsdYfhjkl"X > >> Apart from that your problem sounds as if it is trivial when using non >> greedy regular expressions. > > I do not know what this means: non greedy regular expressions? Greedy relates to how many characters are consumed by regular expressions when a match if found. You may need to learn more deeply about these to reach your goal. That definition helps. I use the Guile manual, the section Regular Expressions is miss leading about what is there.I only went there because Arron Hill told me about it And the introduction states "A full description of regular expressions and their syntax is beyond the scope of this manual"; and the URL goes nowhere. And I would guess knowing what to read elsewhere that is consistent with the guile version Lilypond uses may be a probleblen. I am open to a good ron cryptic reference? Thank you, ƒg JM
Re: Regexp Functions
Hello Freeman, The reference I use is http://www.cplusplus.com/reference/regex/ECMAScript/ . Greed is mentioned under ‘Quantifiers‘ HTH! JM > Le 9 juin 2020 à 15:55, Freeman Gilmore a écrit : > > On Tue, Jun 9, 2020 at 6:51 AM Jacques Menu wrote: >> >> Hello Freeman, >> >>> Le 9 juin 2020 à 09:43, Freeman Gilmore a écrit >>> : >>> >>> On Tue, Jun 9, 2020 at 1:25 AM Michael Gerdau wrote: Hi! I find your description difficult to understand. Maybe you could provide an set of examples showing exactly what you wish to be modified into what. >>> Sorry, that is the problem I have when someone asks about what i am >>> doing or trying to do. For me I find it best to just ask what I want >>> to know. Arron as well as some others answer my question when I do >>> not include these kinds of detail they do add confusion. Arron on my >>> initial post did not understand what I was asking eathere. >>> >>> So I will try again.Say you have "Xsdfghjkl" If "x" is the first >>> character then replace the "g" if it exist with "Y" => "XsdYfhjkl"X >>> Apart from that your problem sounds as if it is trivial when using non greedy regular expressions. >>> >>> I do not know what this means: non greedy regular expressions? >> >> Greedy relates to how many characters are consumed by regular expressions >> when a match if found. >> >> You may need to learn more deeply about these to reach your goal. > > That definition helps. I use the Guile manual, the section Regular > Expressions is miss leading about what is there.I only went there > because Arron Hill told me about it And the introduction states "A > full description of regular expressions and their syntax is beyond the > scope of this manual"; and the URL goes nowhere. And I would guess > knowing what to read elsewhere that is consistent with the guile > version Lilypond uses may be a probleblen. I am open to a good ron > cryptic reference? > > Thank you, ƒg > >> >> JM
Re: Regexp Functions
On Tue, Jun 9, 2020 at 6:51 AM Jacques Menu wrote: > > Hello Freeman, > > > Le 9 juin 2020 à 09:43, Freeman Gilmore a écrit > > : > > > > On Tue, Jun 9, 2020 at 1:25 AM Michael Gerdau wrote: > >> > >> Hi! > >> > >> I find your description difficult to understand. Maybe you could provide > >> an set of examples showing exactly what you wish to be modified into what. > > Sorry, that is the problem I have when someone asks about what i am > > doing or trying to do. For me I find it best to just ask what I want > > to know. Arron as well as some others answer my question when I do > > not include these kinds of detail they do add confusion. Arron on my > > initial post did not understand what I was asking eathere. > > > > So I will try again.Say you have "Xsdfghjkl" If "x" is the first > > character then replace the "g" if it exist with "Y" => "XsdYfhjkl"X > > > >> Apart from that your problem sounds as if it is trivial when using non > >> greedy regular expressions. > > > > I do not know what this means: non greedy regular expressions? > > Greedy relates to how many characters are consumed by regular expressions > when a match if found. > > You may need to learn more deeply about these to reach your goal. That definition helps. I use the Guile manual, the section Regular Expressions is miss leading about what is there.I only went there because Arron Hill told me about it And the introduction states "A full description of regular expressions and their syntax is beyond the scope of this manual"; and the URL goes nowhere. And I would guess knowing what to read elsewhere that is consistent with the guile version Lilypond uses may be a probleblen. I am open to a good ron cryptic reference? Thank you, ƒg > > JM > >
Re: Regexp Functions
Hello Freeman, > Le 9 juin 2020 à 09:43, Freeman Gilmore a écrit : > > On Tue, Jun 9, 2020 at 1:25 AM Michael Gerdau wrote: >> >> Hi! >> >> I find your description difficult to understand. Maybe you could provide an >> set of examples showing exactly what you wish to be modified into what. > Sorry, that is the problem I have when someone asks about what i am > doing or trying to do. For me I find it best to just ask what I want > to know. Arron as well as some others answer my question when I do > not include these kinds of detail they do add confusion. Arron on my > initial post did not understand what I was asking eathere. > > So I will try again.Say you have "Xsdfghjkl" If "x" is the first > character then replace the "g" if it exist with "Y" => "XsdYfhjkl"X > >> Apart from that your problem sounds as if it is trivial when using non >> greedy regular expressions. > > I do not know what this means: non greedy regular expressions? Greedy relates to how many characters are consumed by regular expressions when a match if found. You may need to learn more deeply about these to reach your goal. JM
Re: Orchestral strings, how to organise score and parts for divisi, solos, desks etc.
On Sun, 7 Jun 2020 at 10:26, Rutger Hofman wrote: > > Well, it turned out to keep that tutorial short. Still, I think it will > have its use, since questions about temp staves/divisi turn up at > regular intervals. > > My first attempt is here: > > https://www.rutgerhofman.nl/lilypond/divisi-doc/divisi-doc.html > > Please, have a look, say what you (don't) like. > > I still debate in my head what the best venue for this would be. > > Rutger Thank you so much for this! I'll read it during the next couple of weeks. Cheers, Lib
Re: Identify included files
On 09/06/2020 10:54, Matt Wallis wrote: Include the backslash when you define a directory (as above). s/backslash/slash/
Re: Identify included files
On 06/06/2020 16:34, Fr. Samuel Springuel wrote: I have now updated the repository I posted earlier (https://github.com/rpspringuel/lilypond_make) to contain two additional branches: GNUmake_dependencies: Implements dependency generation as described in the GNUmake manual mad-scientist_dependencies: Implements dependency generation as described in the article that Matt linked. Right now I’ve used a simple sed script in the recipe to add the midi file to the targets of the dly file generated by LilyPond, but I haven’t given up on a more general solution. Comments from anyone willing to look these over and play around with them are greatly appreciated. Hi Samuel, Great work! I have not had a play, but I have had a quick look through https://github.com/rpspringuel/lilypond_make/blob/mad-scientist_dependencies/Makefile Just a few comments, mostly general things about makefiles, practices that I usually follow. Be clear about the difference between = and :=. You are using = when := would work fine. Put everything that moves (!) into a variable. For example, I'd have PDF_DIR := PDF/ Include the backslash when you define a directory (as above). This is a habit I've got into and now rely on. It helps me. Use `mkdir -p` to create dirs because it doesn't fail if the directory exists. Having said that, this goes against another principle I often try to follow: Write software according to Dijkstra's weakest preconditions, by making it as fragile as possible (but no more fragile!). That way the program will break if the implementation does not follow the design, making it easier for bugs to become apparent. With the `mkdir -p` example, it could be argued that because these directory targets only come into play via order-only prerequisites, they should never be called upon unless the directory does not exist... I found https://lists.gnu.org/archive/html/lilypond-user/2020-05/msg00148.html very interesting. It describes how to get lilypond to print out dependencies. Have you looked into this? Best regards, Matt
Re: Increase/decrease space after barline or after time signature
Hi Paolo, Am 09.06.20 um 00:31 schrieb Paolo Prete: Hello, how can I increase/decrease the horizontal gap between 1) the time signature and the first note of the bar 2) the barline and the first note of the bar ...? \version "2.20.0" \layout { \override Score.TimeSignature.extra-spacing-width = #'(0 . 10) % for 1) \override Score.BarLine.extra-spacing-width = #'(0 . 10) % 2) % for 2) } \new Staff \relative { \time 3/4 c'4 c c c c c } Best Lukas
Re: Regexp Functions
On Tue, Jun 9, 2020 at 1:25 AM Michael Gerdau wrote: > > Hi! > > I find your description difficult to understand. Maybe you could provide an > set of examples showing exactly what you wish to be modified into what. Sorry, that is the problem I have when someone asks about what i am doing or trying to do. For me I find it best to just ask what I want to know. Arron as well as some others answer my question when I do not include these kinds of detail they do add confusion. Arron on my initial post did not understand what I was asking eathere. So I will try again.Say you have "Xsdfghjkl" If "x" is the first character then replace the "g" if it exist with "Y" => "XsdYfhjkl"X > Apart from that your problem sounds as if it is trivial when using non greedy > regular expressions. I do not know what this means: non greedy regular expressions? Thank you, ƒg As Aaron already wrote you need expressions to capture the whole block and isolate the subexpressions you wish to operate on (A, ... and x in your case - if I understand you correctly) > > Kind regards, > Michael > > Mobil gesendet > > Am 09.06.2020 um 07:00 schrieb Freeman Gilmore : > > > Caio and Arron: > > I am writing this at the top to start over and answer Caio's questions. > Say you have an accidental string name "A..." and the stem is up; then the > same accidental with the stem down would be named "-A...". "A".. would > be a short string like LilyPond uses for accidentals. > > If you want to use the accidental more than one time say 2 then write the > strings like this, "A...x2" and "-A...x2". But the second name is wrong, > the "x2" part needs to go with the stem."A...x2" is the logical entry but > the "x" needs to be replaced with "-x". Before I do this I need a space > before the "x", i replace "x",, if it exists with " x" if it exists. I > now have the 4 possibilities "A...", "-A...", "A... x2", "-A... x2". > > My question is, is there a procedure that sees the [-] then searches for "x" > and replaces it with "-x". > > I could add the "-" to the "x" at entry but want to keep it simple, x (times > ) 2 is logical (and saves a stroke). The next step would be to split the > strings into two strings if a space exists.So "A... x2" becomes "A..." > " x2" and "-A... x2" becomes "-A..." "-x2" ; two glyph each to form > ligatures. > > Thank you, ƒg > > On Mon, Jun 8, 2020 at 4:31 PM Aaron Hill wrote: >> >> On 2020-06-08 12:47 pm, Caio Barros wrote: >> > Hello! >> > >> > Em seg., 8 de jun. de 2020 às 08:37, Freeman Gilmore < >> > freeman.gilm...@gmail.com> escreveu: >> > >> >> If the string is "A ... B ... " , using Regexp Functions is it >> >> possible, if 'A' matches [-] then 'B' would be replaced by "C"?'A' >> >> is first in the string. Position of B is not constant.and may not be >> >> there. >> >> >> > >> > Can you provide a little more context of what you are trying to do and >> > what >> > this has to to with lilypond? What tools are you using to find and >> > replace >> > strings using regex? >> >> LilyPond -> Guile -> (use-modules (ice-9 regex)) >> >> Or I could be making the wrong assumption here. ¯\_(ツ)_/¯ >> >> >> (display >>(regexp-substitute/global #f >> (make-regexp "(^A.*)B" regexp/newline) >> (string-join '("A ... B ..." "D ... B ..." >> "A ... E ..." "A ... B ...") >> "\n" 'suffix) >> 'pre 1 "C" 'post)) >> >> >> >> A ... C ... >> D ... B ... >> A ... E ... >> A ... C ... >> >> >> The key here is to use a capturing group for the portion of the string >> before "B" that you need to preserve in the substitution. >> >> >> -- Aaron Hill >>
Re: Regexp Functions
On Mon, Jun 8, 2020 at 4:31 PM Aaron Hill wrote: > > On 2020-06-08 12:47 pm, Caio Barros wrote: > > Hello! > > > > Em seg., 8 de jun. de 2020 às 08:37, Freeman Gilmore < > > freeman.gilm...@gmail.com> escreveu: > > > >> If the string is "A ... B ... " , using Regexp Functions is it > >> possible, if 'A' matches [-] then 'B' would be replaced by "C"?'A' > >> is first in the string. Position of B is not constant.and may not be > >> there. > >> > > > > Can you provide a little more context of what you are trying to do and > > what > > this has to to with lilypond? What tools are you using to find and > > replace > > strings using regex? > > LilyPond -> Guile -> (use-modules (ice-9 regex)) > > Or I could be making the wrong assumption here. ¯\_(ツ)_/¯ > > > (display >(regexp-substitute/global #f > (make-regexp "(^A.*)B" regexp/newline) > (string-join '("A ... B ..." "D ... B ..." > "A ... E ..." "A ... B ...") > "\n" 'suffix) > 'pre 1 "C" 'post)) > > > > A ... C ... > D ... B ... > A ... E ... > A ... C ... > > > The key here is to use a capturing group for the portion of the string > before "B" that you need to preserve in the substitution. I do no tthink this is what i want. Let me try again Say you have "Xsdfghjkl" If "x" is the first character then replace the "g" if it exist with "Y" => "XsdYfhjkl"X Thank you,ƒg > > > -- Aaron Hill >