[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Help-source-highlight] regexp for scheme blocks in lilypond language
From: |
Federico Bruni |
Subject: |
[Help-source-highlight] regexp for scheme blocks in lilypond language |
Date: |
Wed, 18 Jan 2012 09:54:31 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux i686; rv:9.0) Gecko/20111222 Thunderbird/9.0.1 |
Hi,
lilypond files can contain blocks of scheme code in several ways.
The main challenge is handling conflicts between single and multiline
and especially blocks where the number of parentheses cannot be known in
advance (there's a way to match balanced parentheses?).
Scheme strings can be single line. 4 examples:
\applyMusic #unfold-repeats \bottom
\Score tempoWholesPerMinute = #(ly:make-moment 120 4)
system-system-spacing #'padding = #8
tagline = \markup { \override #'(box-padding . 1.0) \override
#'(baseline-skip . 2.7) { "Hello" } }
Strings that should be highlighted:
#unfold-repeats
#(ly:make-moment 120 4)
#'padding
any #'(\.) occurence in that single line
There are also two kinds of scheme blocks (I can match the first not the
second, because I cannot guess the number of parentheses):
#'((basic-distance . 12)
(minimum-distance . 6)
(padding . 1)
(stretchability . 12))
#(define (naturalize-pitch p)
(let ((o (ly:pitch-octave p))
(a (* 4 (ly:pitch-alteration p)))
;; alteration, a, in quarter tone steps,
;; for historical reasons
(n (ly:pitch-notename p)))
(cond
((and (> a 1) (or (eq? n 6) (eq? n 2)))
(set! a (- a 2))
(set! n (+ n 1)))
((and (< a -1) (or (eq? n 0) (eq? n 3)))
(set! a (+ a 2))
(set! n (- n 1))))
(cond
((> a 2) (set! a (- a 4)) (set! n (+ n 1)))
((< a -2) (set! a (+ a 4)) (set! n (- n 1))))
(if (< n 0) (begin (set! o (- o 1)) (set! n (+ n 7))))
(if (> n 6) (begin (set! o (+ o 1)) (set! n (- n 7))))
(ly:make-pitch o n (/ a 4))))
This is very problematic because this kind of block is placed at the
beginning of a lilypond file and many snippets in the LilyPond
documentation have such blocks.
My current lilypond.lang can't handle it and all the highlighting gets
messed, see:
http://lists.gnu.org/archive/html/lilypond-user/2012-01/msg00013.html
(see also my reply to that email)
I attach also an example file.
Sorry for the confusion, I'm in a hurry.
Thanks in advance for your help,
Federico
test.ly
Description: Text document
- [Help-source-highlight] regexp for scheme blocks in lilypond language,
Federico Bruni <=
- Re: [Help-source-highlight] regexp for scheme blocks in lilypond language, Lorenzo Bettini, 2012/01/18
- Re: [Help-source-highlight] regexp for scheme blocks in lilypond language, Federico Bruni, 2012/01/18
- Re: [Help-source-highlight] regexp for scheme blocks in lilypond language, Lorenzo Bettini, 2012/01/21
- Re: [Help-source-highlight] regexp for scheme blocks in lilypond language, Federico Bruni, 2012/01/22
- Re: [Help-source-highlight] regexp for scheme blocks in lilypond language, Lorenzo Bettini, 2012/01/22
- Re: [Help-source-highlight] regexp for scheme blocks in lilypond language, Federico Bruni, 2012/01/22
- Re: [Help-source-highlight] regexp for scheme blocks in lilypond language, Federico Bruni, 2012/01/22
- Re: [Help-source-highlight] regexp for scheme blocks in lilypond language, Federico Bruni, 2012/01/31
- Re: [Help-source-highlight] regexp for scheme blocks in lilypond language, Lorenzo Bettini, 2012/01/31