]> git.donarmstrong.com Git - lilypond.git/blob - python/convertrules.py
Merge branch 'master' of ssh://kainhofer@git.sv.gnu.org/srv/git/lilypond into dev...
[lilypond.git] / python / convertrules.py
1 # (setq py-indent-offset 4)
2
3
4 import string
5 import re
6 import sys
7 import lilylib
8
9 _ = lilylib._
10
11
12 NOT_SMART = _ ("Not smart enough to convert %s")
13 UPDATE_MANUALLY = _ ("Please refer to the manual for details, and update manually.")
14 FROM_TO = _ ( "%s has been replaced by %s")
15
16
17 class FatalConversionError:
18     pass
19
20 conversions = []
21 stderr_write = lilylib.stderr_write
22
23 def warning (str):
24     stderr_write (_ ("warning: %s") % str)
25
26 def conv(str):
27     if re.search ('\\\\multi', str):
28         stderr_write ('\n')
29         stderr_write (NOT_SMART % "\\multi")
30         stderr_write ('\n')
31     return str
32
33 conversions.append (((0,1,9), conv, _ ('\\header { key = concat + with + operator }')))
34
35
36 def conv (str):
37     if re.search ('\\\\octave', str):
38         stderr_write ('\n')
39         stderr_write (NOT_SMART % "\\octave")
40         stderr_write ('\n')
41         stderr_write (UPDATE_MANUALLY)
42         stderr_write ('\n')
43     #   raise FatalConversionError ()
44
45     return str
46
47 conversions.append ((
48         ((0,1,19), conv, _ ('deprecated %s') % '\\octave')))
49
50
51
52 def conv (str):
53     str = re.sub ('\\\\textstyle([^;]+);',
54                              '\\\\property Lyrics . textstyle = \\1', str)
55     # harmful to current .lys
56     # str = re.sub ('\\\\key([^;]+);', '\\\\accidentals \\1;', str)
57
58     return str
59
60 conversions.append ((
61         ((0,1,20), conv, _ ('deprecated \\textstyle, new \\key syntax'))))
62
63
64
65 def conv (str):
66     str = re.sub ('\\\\musical_pitch', '\\\\musicalpitch',str)
67     str = re.sub ('\\\\meter', '\\\\time',str)
68
69     return str
70
71 conversions.append ((
72         ((0,1,21), conv, '\\musical_pitch -> \\musicalpitch, '+
73          '\\meter -> \\time')))
74
75
76 def conv (str):
77     return str
78
79 conversions.append ((
80         ((1,0,0), conv, _ ("bump version for release"))))
81
82
83
84 def conv (str):
85     str = re.sub ('\\\\accidentals', '\\\\keysignature',str)
86     str = re.sub ('specialaccidentals *= *1', 'keyoctaviation = 0',str)
87     str = re.sub ('specialaccidentals *= *0', 'keyoctaviation = 1',str)
88
89     return str
90
91 conversions.append ((
92         ((1,0,1), conv, '\\accidentals -> \\keysignature, ' +
93          'specialaccidentals -> keyoctaviation')))
94
95
96 def conv(str):
97     if re.search ('\\\\header', str):
98         stderr_write ('\n')
99         stderr_write (NOT_SMART % _ ("new \\header format"))
100         stderr_write ('\n')
101     return str
102
103 conversions.append (((1,0,2), conv, _ ('\\header { key = concat + with + operator }')))
104
105
106 def conv(str):
107     str =  re.sub ('\\\\melodic([^a-zA-Z])', '\\\\notes\\1',str)
108     return str
109
110 conversions.append (((1,0,3), conv, '\\melodic -> \\notes'))
111
112
113 def conv(str):
114     str =  re.sub ('default_paper *=', '',str)
115     str =  re.sub ('default_midi *=', '',str)
116     return str
117
118 conversions.append (((1,0,4), conv, 'default_{paper,midi}'))
119
120
121 def conv(str):
122     str =  re.sub ('ChoireStaff', 'ChoirStaff',str)
123     str =  re.sub ('\\\\output', 'output = ',str)
124
125     return str
126
127 conversions.append (((1,0,5), conv, 'ChoireStaff -> ChoirStaff'))
128
129
130 def conv(str):
131     if re.search ('[a-zA-Z]+ = *\\translator',str):
132         stderr_write ('\n')
133         stderr_write (NOT_SMART % _ ("\\translator syntax"))
134         stderr_write ('\n')
135     #   raise FatalConversionError ()
136     return str
137
138 conversions.append (((1,0,6), conv, 'foo = \\translator {\\type .. } ->\\translator {\\type ..; foo; }'))
139
140
141
142 def conv(str):
143     str =  re.sub ('\\\\lyrics*', '\\\\lyrics',str)
144
145     return str
146
147 conversions.append (((1,0,7), conv, '\\lyric -> \\lyrics'))
148
149
150 def conv(str):
151     str =  re.sub ('\\\\\\[/3+', '\\\\times 2/3 { ',str)
152     str =  re.sub ('\\[/3+', '\\\\times 2/3 { [',str)
153     str =  re.sub ('\\\\\\[([0-9/]+)', '\\\\times \\1 {',str)
154     str =  re.sub ('\\[([0-9/]+)', '\\\\times \\1 { [',str)
155     str =  re.sub ('\\\\\\]([0-9/]+)', '}', str)
156     str =  re.sub ('\\\\\\]', '}',str)
157     str =  re.sub ('\\]([0-9/]+)', '] }', str)
158     return str
159
160 conversions.append (((1,0,10), conv, '[2/3 ]1/1 -> \\times 2/3 '))
161
162
163 def conv(str):
164     return str
165 conversions.append (((1,0,12), conv, 'Chord syntax stuff'))
166
167
168
169 def conv(str):
170
171
172     str =  re.sub ('<([^>~]+)~([^>]*)>','<\\1 \\2> ~', str)
173
174     return str
175
176 conversions.append (((1,0,13), conv, '<a ~ b> c -> <a b> ~ c'))
177
178
179 def conv(str):
180     str =  re.sub ('<\\[','[<', str)
181     str =  re.sub ('\\]>','>]', str)
182
183     return str
184
185 conversions.append (((1,0,14), conv, '<[a b> <a b]>c -> [<a b> <a b>]'))
186
187
188
189 def conv(str):
190     str =  re.sub ('\\\\type([^\n]*engraver)','\\\\TYPE\\1', str)
191     str =  re.sub ('\\\\type([^\n]*performer)','\\\\TYPE\\1', str)
192     str =  re.sub ('\\\\type','\\\\context', str)
193     str =  re.sub ('\\\\TYPE','\\\\type', str)
194     str =  re.sub ('textstyle','textStyle', str)
195
196     return str
197
198 conversions.append (((1,0,16), conv, '\\type -> \\context, textstyle -> textStyle'))
199
200
201
202 def conv(str):
203     if re.search ('\\\\repeat',str):
204         stderr_write ('\n')
205         stderr_write (NOT_SMART % "\\repeat")
206         stderr_write ('\n')
207     #   raise FatalConversionError ()
208     return str
209
210 conversions.append (((1,0,18), conv,
211                      _ ('\\repeat NUM Music Alternative -> \\repeat FOLDSTR Music Alternative')))
212
213
214 def conv(str):
215     str =  re.sub ('SkipBars','skipBars', str)
216     str =  re.sub ('fontsize','fontSize', str)
217     str =  re.sub ('midi_instrument','midiInstrument', str)
218
219     return str
220
221 conversions.append (((1,0,19), conv,
222                      'fontsize -> fontSize, midi_instrument -> midiInstrument, SkipBars -> skipBars'))
223
224
225
226 def conv(str):
227     str =  re.sub ('tieydirection','tieVerticalDirection', str)
228     str =  re.sub ('slurydirection','slurVerticalDirection', str)
229     str =  re.sub ('ydirection','verticalDirection', str)
230
231     return str
232
233 conversions.append (((1,0,20), conv,
234         '{,tie,slur}ydirection -> {v,tieV,slurV}erticalDirection'))
235
236
237
238 def conv(str):
239     str =  re.sub ('hshift','horizontalNoteShift', str)
240
241     return str
242
243 conversions.append (((1,0,21), conv,
244         'hshift -> horizontalNoteShift'))
245
246
247
248 def conv(str):
249     str =  re.sub ('\\\\grouping[^;]*;','', str)
250
251     return str
252
253 conversions.append (((1,1,52), conv,
254         _ ('deprecate %s') % '\\grouping'))
255
256
257
258 def conv(str):
259     str =  re.sub ('\\\\wheel','\\\\coda', str)
260
261     return str
262
263 conversions.append (((1,1,55), conv,
264         '\\wheel -> \\coda'))
265
266
267 def conv(str):
268     str =  re.sub ('keyoctaviation','keyOctaviation', str)
269     str =  re.sub ('slurdash','slurDash', str)
270
271     return str
272
273 conversions.append (((1,1,65), conv,
274         'slurdash -> slurDash, keyoctaviation -> keyOctaviation'))
275
276
277 def conv(str):
278     str =  re.sub ('\\\\repeat *\"?semi\"?','\\\\repeat "volta"', str)
279
280     return str
281
282 conversions.append (((1,1,66), conv,
283         'semi -> volta'))
284
285
286
287 def conv(str):
288     str =  re.sub ('\"?beamAuto\"? *= *\"?0?\"?','noAutoBeaming = "1"', str)
289
290     return str
291
292 conversions.append (((1,1,67), conv,
293         'beamAuto -> noAutoBeaming'))
294
295
296 def conv(str):
297     str =  re.sub ('automaticMelismas', 'automaticMelismata', str)
298
299     return str
300
301 conversions.append (((1,2,0), conv,
302         'automaticMelismas -> automaticMelismata'))
303
304
305 def conv(str):
306     str =  re.sub ('dynamicDir\\b', 'dynamicDirection', str)
307
308     return str
309
310 conversions.append (((1,2,1), conv,
311         'dynamicDir -> dynamicDirection'))
312
313
314 def conv(str):
315     str =  re.sub ('\\\\cadenza *0 *;', '\\\\cadenzaOff', str)
316     str =  re.sub ('\\\\cadenza *1 *;', '\\\\cadenzaOn', str)
317
318     return str
319
320 conversions.append (((1,3,4), conv,
321         '\\cadenza -> \\cadenza{On|Off}'))
322
323
324 def conv (str):
325     str = re.sub ('"?beamAuto([^"=]+)"? *= *"([0-9]+)/([0-9]+)" *;*',
326                   'beamAuto\\1 = #(make-moment \\2 \\3)',
327                   str)
328     return str
329
330 conversions.append (((1,3,5), conv, 'beamAuto moment properties'))
331
332
333 def conv (str):
334     str = re.sub ('stemStyle',
335                   'flagStyle',
336                   str)
337     return str
338
339 conversions.append (((1,3,17), conv, 'stemStyle -> flagStyle'))
340
341
342 def conv (str):
343     str = re.sub ('staffLineLeading',
344                   'staffSpace',
345                   str)
346     return str
347
348 conversions.append (((1,3,18), conv, 'staffLineLeading -> staffSpace'))
349
350
351
352 def conv(str):
353     if re.search ('\\\\repetitions',str):
354         stderr_write ('\n')
355         stderr_write (NOT_SMART % "\\repetitions")
356         stderr_write ('\n')
357     #   raise FatalConversionError ()
358     return str
359
360 conversions.append (((1,3,23), conv,
361         _ ('deprecate %s ') % '\\repetitions'))
362
363
364
365 def conv (str):
366     str = re.sub ('textEmptyDimension *= *##t',
367                   'textNonEmpty = ##f',
368                   str)
369     str = re.sub ('textEmptyDimension *= *##f',
370                   'textNonEmpty = ##t',
371                   str)
372     return str
373
374 conversions.append (((1,3,35), conv, 'textEmptyDimension -> textNonEmpty'))
375
376
377 def conv (str):
378     str = re.sub ("([a-z]+)[ \t]*=[ \t]*\\\\musicalpitch *{([- 0-9]+)} *\n",
379                   "(\\1 . (\\2))\n", str)
380     str = re.sub ("\\\\musicalpitch *{([0-9 -]+)}",
381                   "\\\\musicalpitch #'(\\1)", str)
382     if re.search ('\\\\notenames',str):
383         stderr_write ('\n')
384         stderr_write (NOT_SMART % _ ("new \\notenames format"))
385         stderr_write ('\n')
386     return str
387
388 conversions.append (((1,3,38), conv, '\musicalpitch { a b c } -> #\'(a b c)'))
389
390
391 def conv (str):
392     def replace (match):
393         return '\\key %s;' % match.group (1).lower ()
394
395     str = re.sub ("\\\\key ([^;]+);",  replace, str)
396     return str
397
398 conversions.append (((1,3,39), conv, '\\key A ;  ->\\key a;'))
399
400
401 def conv (str):
402     if re.search ('\\[:',str):
403         stderr_write ('\n')
404         stderr_write (NOT_SMART % _ ("new tremolo format"))
405         stderr_write ('\n')
406     return str
407
408 conversions.append (((1,3,41), conv,
409         '[:16 c4 d4 ] -> \\repeat "tremolo" 2 { c16 d16 }'))
410
411
412 def conv (str):
413     str = re.sub ('Staff_margin_engraver' , 'Instrument_name_engraver', str)
414     return str
415
416 conversions.append (((1,3,42), conv,
417         _ ('Staff_margin_engraver deprecated, use Instrument_name_engraver')))
418
419
420 def conv (str):
421     str = re.sub ('note[hH]eadStyle\\s*=\\s*"?(\\w+)"?' , "noteHeadStyle = #'\\1", str)
422     return str
423
424 conversions.append (((1,3,49), conv,
425         'noteHeadStyle value: string -> symbol'))
426
427
428 def conv (str):
429     if re.search ('\\\\keysignature', str):
430         stderr_write ('\n')
431         stderr_write (NOT_SMART % '\\keysignature')
432         stderr_write ('\n')
433     return str
434
435
436 conversions.append (((1,3,58), conv,
437         'noteHeadStyle value: string -> symbol'))
438
439
440 def conv (str):
441     str = re.sub (r"""\\key *([a-z]+) *;""", r"""\\key \1 \major;""",str);
442     return str
443 conversions.append (((1,3,59), conv,
444         '\key X ; -> \key X major; '))
445
446
447 def conv (str):
448     str = re.sub (r'latexheaders *= *"\\\\input ',
449                   'latexheaders = "',
450                   str)
451     return str
452 conversions.append (((1,3,68), conv, 'latexheaders = "\\input global" -> latexheaders = "global"'))
453
454
455
456
457 # TODO: lots of other syntax change should be done here as well
458
459 def conv (str):
460     str = re.sub ('basicCollisionProperties', 'NoteCollision', str)
461     str = re.sub ('basicVoltaSpannerProperties' , "VoltaBracket", str)
462     str = re.sub ('basicKeyProperties' , "KeySignature", str)
463
464     str = re.sub ('basicClefItemProperties' ,"Clef", str)
465
466
467     str = re.sub ('basicLocalKeyProperties' ,"Accidentals", str)
468     str = re.sub ('basicMarkProperties' ,"Accidentals", str)
469     str = re.sub ('basic([A-Za-z_]+)Properties', '\\1', str)
470
471     str = re.sub ('Repeat_engraver' ,'Volta_engraver', str)
472     return str
473
474 conversions.append (((1,3,92), conv, 'basicXXXProperties -> XXX, Repeat_engraver -> Volta_engraver'))
475
476
477 def conv (str):
478     # Ugh, but meaning of \stemup changed too
479     # maybe we should do \stemup -> \stemUp\slurUp\tieUp ?
480     str = re.sub ('\\\\stemup', '\\\\stemUp', str)
481     str = re.sub ('\\\\stemdown', '\\\\stemDown', str)
482     str = re.sub ('\\\\stemboth', '\\\\stemBoth', str)
483
484     str = re.sub ('\\\\slurup', '\\\\slurUp', str)
485     str = re.sub ('\\\\slurboth', '\\\\slurBoth', str)
486     str = re.sub ('\\\\slurdown', '\\\\slurDown', str)
487     str = re.sub ('\\\\slurdotted', '\\\\slurDotted', str)
488     str = re.sub ('\\\\slurnormal', '\\\\slurNoDots', str)
489
490     str = re.sub ('\\\\shiftoff', '\\\\shiftOff', str)
491     str = re.sub ('\\\\shifton', '\\\\shiftOn', str)
492     str = re.sub ('\\\\shiftonn', '\\\\shiftOnn', str)
493     str = re.sub ('\\\\shiftonnn', '\\\\shiftOnnn', str)
494
495     str = re.sub ('\\\\onevoice', '\\\\oneVoice', str)
496     str = re.sub ('\\\\voiceone', '\\\\voiceOne', str)
497     str = re.sub ('\\\\voicetwo', '\\\\voiceTwo', str)
498     str = re.sub ('\\\\voicethree', '\\\\voiceThree', str)
499     str = re.sub ('\\\\voicefour', '\\\\voiceFour', str)
500
501     # I don't know exactly when these happened...
502     # ugh, we loose context setting here...
503     str = re.sub ('\\\\property *[^ ]*verticalDirection[^=]*= *#?"?(1|(\\\\up))"?', '\\\\stemUp\\\\slurUp\\\\tieUp', str)
504     str = re.sub ('\\\\property *[^ ]*verticalDirection[^=]*= *#?"?((-1)|(\\\\down))"?', '\\\\stemDown\\\\slurDown\\\\tieDown', str)
505     str = re.sub ('\\\\property *[^ ]*verticalDirection[^=]*= *#?"?(0|(\\\\center))"?', '\\\\stemBoth\\\\slurBoth\\\\tieBoth', str)
506
507     str = re.sub ('verticalDirection[^=]*= *#?"?(1|(\\\\up))"?', 'Stem \\\\override #\'direction = #0\nSlur \\\\override #\'direction = #0\n Tie \\\\override #\'direction = #1', str)
508     str = re.sub ('verticalDirection[^=]*= *#?"?((-1)|(\\\\down))"?', 'Stem \\\\override #\'direction = #0\nSlur \\\\override #\'direction = #0\n Tie \\\\override #\'direction = #-1', str)
509     str = re.sub ('verticalDirection[^=]*= *#?"?(0|(\\\\center))"?', 'Stem \\\\override #\'direction = #0\nSlur \\\\override #\'direction = #0\n Tie \\\\override #\'direction = #0', str)
510
511     str = re.sub ('\\\\property *[^ .]*[.]?([a-z]+)VerticalDirection[^=]*= *#?"?(1|(\\\\up))"?', '\\\\\\1Up', str)
512     str = re.sub ('\\\\property *[^ .]*[.]?([a-z]+)VerticalDirection[^=]*= *#?"?((-1)|(\\\\down))"?', '\\\\\\1Down', str)
513     str = re.sub ('\\\\property *[^ .]*[.]?([a-z]+)VerticalDirection[^=]*= *#?"?(0|(\\\\center))"?', '\\\\\\1Both', str)
514
515     # (lacks capitalisation slur -> Slur)
516     str = re.sub ('([a-z]+)VerticalDirection[^=]*= *#?"?(1|(\\\\up))"?', '\\1 \\\\override #\'direction = #1', str)
517     str = re.sub ('([a-z]+)VerticalDirection[^=]*= *#?"?((-1)|(\\\\down))"?', '\\1 \\override #\'direction = #-1', str)
518     str = re.sub ('([a-z]+)VerticalDirection[^=]*= *#?"?(0|(\\\\center))"?', '\\1 \\\\override #\'direction = #0', str)
519
520     ## dynamic..
521     str = re.sub ('\\\\property *[^ .]*[.]?dynamicDirection[^=]*= *#?"?(1|(\\\\up))"?', '\\\\dynamicUp', str)
522     str = re.sub ('\\\\property *[^ .]*[.]?dyn[^=]*= *#?"?((-1)|(\\\\down))"?', '\\\\dynamicDown', str)
523     str = re.sub ('\\\\property *[^ .]*[.]?dyn[^=]*= *#?"?(0|(\\\\center))"?', '\\\\dynamicBoth', str)
524
525     str = re.sub ('\\\\property *[^ .]*[.]?([a-z]+)Dash[^=]*= *#?"?(0|(""))"?', '\\\\\\1NoDots', str)
526     str = re.sub ('\\\\property *[^ .]*[.]?([a-z]+)Dash[^=]*= *#?"?([1-9]+)"?', '\\\\\\1Dotted', str)
527
528     str = re.sub ('\\\\property *[^ .]*[.]?noAutoBeaming[^=]*= *#?"?(0|(""))"?', '\\\\autoBeamOn', str)
529     str = re.sub ('\\\\property *[^ .]*[.]?noAutoBeaming[^=]*= *#?"?([1-9]+)"?', '\\\\autoBeamOff', str)
530
531
532
533     return str
534
535 conversions.append (((1,3,93), conv,
536         _ ('change property definiton case (eg. onevoice -> oneVoice)')))
537
538
539
540 def conv (str):
541     str = re.sub ('ChordNames*', 'ChordNames', str)
542     if re.search ('\\\\textscript "[^"]* *"[^"]*"', str):
543         stderr_write ('\n')
544         stderr_write (NOT_SMART % _ ("new \\textscript markup text"))
545         stderr_write ('\n')
546
547     str = re.sub ('\\textscript +("[^"]*")', '\\textscript #\\1', str)
548
549     return str
550
551 conversions.append (((1,3,97), conv, 'ChordName -> ChordNames'))
552
553
554 # TODO: add lots of these
555
556
557 def conv (str):
558     str = re.sub ('\\\\property *"?Voice"? *[.] *"?textStyle"? *= *"([^"]*)"', '\\\\property Voice.TextScript \\\\set #\'font-style = #\'\\1', str)
559     str = re.sub ('\\\\property *"?Lyrics"? *[.] *"?textStyle"? *= *"([^"]*)"', '\\\\property Lyrics.LyricText \\\\set #\'font-style = #\'\\1', str)
560
561     str = re.sub ('\\\\property *"?([^.]+)"? *[.] *"?timeSignatureStyle"? *= *"([^"]*)"', '\\\\property \\1.TimeSignature \\\\override #\'style = #\'\\2', str)
562
563     str = re.sub ('"?timeSignatureStyle"? *= *#?""', 'TimeSignature \\\\override #\'style = ##f', str)
564
565     str = re.sub ('"?timeSignatureStyle"? *= *#?"([^"]*)"', 'TimeSignature \\\\override #\'style = #\'\\1', str)
566
567     str = re.sub ('#\'style *= #*"([^"])"', '#\'style = #\'\\1', str)
568
569     str = re.sub ('\\\\property *"?([^.]+)"? *[.] *"?horizontalNoteShift"? *= *"?#?([-0-9]+)"?', '\\\\property \\1.NoteColumn \\\\override #\'horizontal-shift = #\\2', str)
570
571     # ugh
572     str = re.sub ('\\\\property *"?([^.]+)"? *[.] *"?flagStyle"? *= *""', '\\\\property \\1.Stem \\\\override #\'flag-style = ##f', str)
573
574     str = re.sub ('\\\\property *"?([^.]+)"? *[.] *"?flagStyle"? *= *"([^"]*)"', '\\\\property \\1.Stem \\\\override #\'flag-style = #\'\\2', str)
575     return str
576
577 conversions.append (((1,3,98), conv, 'CONTEXT.textStyle -> GROB.#font-style '))
578
579
580 def conv (str):
581     str = re.sub ('"?beamAutoEnd_([0-9]*)"? *= *(#\\([^)]*\\))', 'autoBeamSettings \\push #\'(end 1 \\1 * *) = \\2', str)
582     str = re.sub ('"?beamAutoBegin_([0-9]*)"? *= *(#\\([^)]*\))', 'autoBeamSettings \\push #\'(begin 1 \\1 * *) = \\2', str)
583     str = re.sub ('"?beamAutoEnd"? *= *(#\\([^)]*\\))', 'autoBeamSettings \\push #\'(end * * * *) = \\1', str)
584     str = re.sub ('"?beamAutoBegin"? *= *(#\\([^)]*\\))', 'autoBeamSettings \\push #\'(begin * * * *) = \\1', str)
585
586
587     return str
588
589 conversions.append (((1,3,102), conv, 'beamAutoEnd -> autoBeamSettings \\push (end * * * *)'))
590
591
592
593 def conv (str):
594     str = re.sub ('\\\\push', '\\\\override', str)
595     str = re.sub ('\\\\pop', '\\\\revert', str)
596
597     return str
598
599 conversions.append (((1,3,111), conv, '\\push -> \\override, \\pop -> \\revert'))
600
601
602 def conv (str):
603     str = re.sub ('LyricVoice', 'LyricsVoice', str)
604     # old fix
605     str = re.sub ('Chord[Nn]ames*.Chord[Nn]ames*', 'ChordNames.ChordName', str)
606     str = re.sub ('Chord[Nn]ames([ \t\n]+\\\\override)', 'ChordName\\1', str)
607     return str
608
609 conversions.append (((1,3,113), conv, 'LyricVoice -> LyricsVoice'))
610 def regularize_id (str):
611     s = ''
612     lastx = ''
613     for x in str:
614         if x == '_':
615             lastx = x
616             continue
617         elif x in string.digits:
618             x = chr(ord (x) - ord ('0')  +ord ('A'))
619         elif x not in string.letters:
620             x = 'x'
621         elif x in string.lowercase and lastx == '_':
622             x = x.upper ()
623         s = s + x
624         lastx = x
625     return s
626
627 def conv (str):
628
629
630     def regularize_dollar_reference (match):
631         return regularize_id (match.group (1))
632     def regularize_assignment (match):
633         return '\n' + regularize_id (match.group (1)) + ' = '
634     str = re.sub ('\$([^\t\n ]+)', regularize_dollar_reference, str)
635     str = re.sub ('\n([^ \t\n]+)[ \t]*= *', regularize_assignment, str)
636     return str
637
638 conversions.append (((1,3,117), conv, _ ('identifier names: %s') % '$!foo_bar_123 -> xfooBarABC'))
639
640
641
642 def conv (str):
643     def regularize_paper (match):
644         return regularize_id (match.group (1))
645
646     str = re.sub ('(paper_[a-z]+)', regularize_paper, str)
647     str = re.sub ('sustainup', 'sustainUp', str)
648     str = re.sub ('nobreak', 'noBreak', str)
649     str = re.sub ('sustaindown', 'sustainDown', str)
650     str = re.sub ('sostenutoup', 'sostenutoUp', str)
651     str = re.sub ('sostenutodown', 'sostenutoDown', str)
652     str = re.sub ('unachorda', 'unaChorda', str)
653     str = re.sub ('trechorde', 'treChorde', str)
654
655     return str
656
657 conversions.append (((1,3,120), conv, 'paper_xxx -> paperXxxx, pedalup -> pedalUp.'))
658
659
660 def conv (str):
661     str = re.sub ('drarnChords', 'chordChanges', str)
662     str = re.sub ('\\musicalpitch', '\\pitch', str)
663     return str
664
665 conversions.append (((1,3,122), conv, 'drarnChords -> chordChanges, \\musicalpitch -> \\pitch'))
666
667
668 def conv (str):
669     str = re.sub ('ly-([sg])et-elt-property', 'ly-\\1et-grob-property', str)
670     return str
671
672 conversions.append (((1,3,136), conv, 'ly-X-elt-property -> ly-X-grob-property'))
673
674
675 def conv (str):
676     str = re.sub ('point-and-click +#t', 'point-and-click line-column-location', str)
677     return str
678
679 conversions.append (((1,3,138), conv, _ ('point-and-click argument changed to procedure.')))
680
681
682 def conv (str):
683     str = re.sub ('followThread', 'followVoice', str)
684     str = re.sub ('Thread.FollowThread', 'Voice.VoiceFollower', str)
685     str = re.sub ('FollowThread', 'VoiceFollower', str)
686     return str
687
688 conversions.append (((1,3,138), conv, 'followThread -> followVoice.'))
689
690
691 def conv (str):
692     str = re.sub ('font-point-size', 'font-design-size', str)
693     return str
694
695 conversions.append (((1,3,139), conv, 'font-point-size -> font-design-size.'))
696
697
698 def conv (str):
699     str = re.sub ('([a-zA-Z]*)NoDots', '\\1Solid', str)
700     return str
701
702 conversions.append (((1,3,141), conv, 'xNoDots -> xSolid'))
703
704
705 def conv (str):
706     str = re.sub ('([Cc])hord([ea])', '\\1ord\\2', str)
707     return str
708
709 conversions.append (((1,3,144), conv, 'Chorda -> Corda'))
710
711
712
713 def conv (str):
714     str = re.sub ('([A-Za-z]+)MinimumVerticalExtent', 'MinimumV@rticalExtent', str)
715     str = re.sub ('([A-Za-z]+)ExtraVerticalExtent', 'ExtraV@rticalExtent', str)
716     str = re.sub ('([A-Za-z]+)VerticalExtent', 'VerticalExtent', str)
717     str = re.sub ('ExtraV@rticalExtent', 'ExtraVerticalExtent', str)
718     str = re.sub ('MinimumV@rticalExtent', 'MinimumVerticalExtent', str)
719     return str
720
721 conversions.append (((1,3,145), conv,
722 'ContextNameXxxxVerticalExtent -> XxxxVerticalExtent'))
723
724
725 def conv (str):
726     str = re.sub ('\\\\key[ \t]*;', '\\key \\default;', str)
727     str = re.sub ('\\\\mark[ \t]*;', '\\mark \\default;', str)
728
729     # Make sure groups of more than one ; have space before
730     # them, so that non of them gets removed by next rule
731     str = re.sub ("([^ \n\t;]);(;+)", "\\1 ;\\2", str)
732
733     # Only remove ; that are not after spaces, # or ;
734     # Otherwise  we interfere with Scheme comments,
735     # which is badbadbad.
736     str = re.sub ("([^ \t;#]);", "\\1", str)
737
738     return str
739 conversions.append (((1,3,146), conv, _('semicolons removed')))
740
741
742 def conv (str):
743     str = re.sub ('default-neutral-direction', 'neutral-direction',str)
744     return str
745 conversions.append (((1,3,147), conv, 'default-neutral-direction -> neutral-direction'))
746
747
748 def conv (str):
749     str = re.sub ('\(align', '(axis', str)
750     str = re.sub ('\(rows', '(columns', str)
751     return str
752 conversions.append (((1,3,148), conv, '"(align" -> "(axis", "(rows" -> "(columns"'))
753
754
755
756 def conv (str):
757     str = re.sub ('SystemStartDelimiter', 'systemStartDelimiter', str)
758     return str
759 conversions.append (((1,5,33), conv, 'SystemStartDelimiter -> systemStartDelimiter'))
760
761
762 def conv (str):
763     str = re.sub ('arithmetic-multiplier', 'spacing-increment', str)
764     str = re.sub ('arithmetic-basicspace', 'shortest-duration-space', str)
765     return str
766
767 conversions.append (((1,5,38), conv, 'SystemStartDelimiter -> systemStartDelimiter'))
768
769
770
771 def conv (str):
772
773     def func(match):
774         break_dict = {
775         "Instrument_name": "instrument-name",
776         "Left_edge_item": "left-edge",
777         "Span_bar": "span-bar",
778         "Breathing_sign": "breathing-sign",
779         "Staff_bar": "staff-bar",
780         "Clef_item": "clef",
781         "Key_item": "key-signature",
782         "Time_signature": "time-signature",
783         "Custos": "custos"
784         }
785         props =  match.group (1)
786         for (k,v) in break_dict.items():
787             props = re.sub (k, v, props)
788         return  "breakAlignOrder = #'(%s)" % props
789
790     str = re.sub ("breakAlignOrder *= *#'\\(([a-z_\n\tA-Z ]+)\\)",
791                   func, str)
792     return str
793
794 # 40 ?
795 conversions.append (((1,5,40), conv, _ ('%s property names') % 'breakAlignOrder'))
796
797
798
799 def conv (str):
800     str = re.sub ('noAutoBeaming *= *##f', 'autoBeaming = ##t', str)
801     str = re.sub ('noAutoBeaming *= *##t', 'autoBeaming = ##f', str)
802     return str
803
804 conversions.append (((1,5,49), conv, 'noAutoBeaming -> autoBeaming'))
805
806
807 def conv (str):
808     str = re.sub ('tuplet-bracket-visibility', 'bracket-visibility', str)
809     str = re.sub ('tuplet-number-visibility', 'number-visibility', str)
810     return str
811
812 conversions.append (((1,5,52), conv, 'tuplet-X-visibility -> X-visibility'))
813
814
815 def conv (str):
816     str = re.sub ('Pitch::transpose', 'ly-transpose-pitch', str)
817
818     return str
819
820 conversions.append (((1,5,56), conv, 'Pitch::transpose -> ly-transpose-pitch'))
821
822
823 def conv (str):
824     str = re.sub ('textNonEmpty *= *##t', "TextScript \\set #'no-spacing-rods = ##f", str)
825     str = re.sub ('textNonEmpty *= *##f', "TextScript \\set #'no-spacing-rods = ##t", str)
826     return str
827
828 conversions.append (((1,5,58), conv, _ ('deprecate %s') % 'textNonEmpty'))
829
830
831
832 def conv (str):
833     str = re.sub ('MinimumVerticalExtent', 'minimumV@rticalExtent', str)
834     str = re.sub ('minimumVerticalExtent', 'minimumV@rticalExtent', str)
835     str = re.sub ('ExtraVerticalExtent', 'extraV@rticalExtent', str)
836     str = re.sub ('extraVerticalExtent', 'extraV@rticalExtent', str)
837     str = re.sub ('VerticalExtent', 'verticalExtent', str)
838     str = re.sub ('extraV@rticalExtent', 'extraVerticalExtent', str)
839     str = re.sub ('minimumV@rticalExtent', 'minimumVerticalExtent', str)
840     return str
841
842 conversions.append (((1,5,59), conv,
843 'XxxxVerticalExtent -> xxxVerticalExtent'))
844
845
846 def conv (str):
847     str = re.sub ('visibility-lambda', 'break-visibility', str)
848     return str
849
850 conversions.append (((1,5,62), conv,
851 'visibility-lambda -> break-visibility'))
852
853
854
855 def conv (str):
856     if re.search (r'\addlyrics',str) \
857            and re.search ('automaticMelismata', str)  == None:
858         stderr_write ('\n')
859         stderr_write (NOT_SMART % "automaticMelismata; turned on by default since 1.5.67.")
860         stderr_write ('\n')
861         raise FatalConversionError ()
862     return str
863
864 conversions.append (((1,5,67), conv,
865                      _ ('automaticMelismata turned on by default')))
866
867
868 def conv (str):
869     str = re.sub ('ly-set-grob-property([^!])', 'ly-set-grob-property!\1', str)
870     str = re.sub ('ly-set-mus-property([^!])', 'ly-set-mus-property!\1', str)
871     return str
872
873 conversions.append (((1,5,68), conv, 'ly-set-X-property -> ly-set-X-property!'))
874
875
876 def conv (str):
877     str = re.sub ('extent-X', 'X-extent', str)
878     str = re.sub ('extent-Y', 'Y-extent', str)
879     return str
880
881 conversions.append (((1,5,71), conv, 'extent-[XY] -> [XY]-extent'))
882
883
884
885 def conv (str):
886     str = re.sub ("""#\(set! +point-and-click +line-column-location\)""",
887                   """#(set-point-and-click! \'line-column)""", str)
888     str = re.sub ("""#\(set![ \t]+point-and-click +line-location\)""",
889                   '#(set-point-and-click! \'line)', str)
890     str = re.sub ('#\(set! +point-and-click +#f\)',
891                   '#(set-point-and-click! \'none)', str)
892     return str
893
894 conversions.append (((1,5,72), conv, 'set! point-and-click -> set-point-and-click!'))
895
896
897
898 def conv (str):
899     str = re.sub ('flag-style', 'stroke-style', str)
900     str = re.sub (r"""Stem([ ]+)\\override #'style""", r"""Stem \\override #'flag-style""", str);
901     str = re.sub (r"""Stem([ ]+)\\set([ ]+)#'style""", r"""Stem \\set #'flag-style""", str);
902     return str
903
904 conversions.append (((1,6,5), conv, 'Stems: flag-style -> stroke-style; style -> flag-style'))
905
906
907
908 def subst_req_name (match):
909     return "(make-music-by-name \'%sEvent)" % regularize_id (match.group(1))
910
911 def conv (str):
912     str = re.sub ('\\(ly-make-music *\"([A-Z][a-z_]+)_req\"\\)', subst_req_name, str)
913     str = re.sub ('Request_chord', 'EventChord', str)
914     return str
915
916 conversions.append (((1,7,1), conv, 'ly-make-music foo_bar_req -> make-music-by-name FooBarEvent'))
917
918
919
920 spanner_subst ={
921         "text" : 'TextSpanEvent',
922         "decrescendo" : 'DecrescendoEvent',
923         "crescendo" : 'CrescendoEvent',
924         "Sustain" : 'SustainPedalEvent',
925         "slur" : 'SlurEvent',
926         "UnaCorda" : 'UnaCordaEvent',
927         "Sostenuto" : 'SostenutoEvent',
928         }
929 def subst_ev_name (match):
930     stype = 'STOP'
931     if re.search ('start', match.group(1)):
932         stype= 'START'
933
934     mtype = spanner_subst[match.group(2)]
935     return "(make-span-event '%s %s)" % (mtype , stype)
936
937 def subst_definition_ev_name(match):
938     return ' = #%s' % subst_ev_name (match)
939 def subst_inline_ev_name (match):
940     s = subst_ev_name (match)
941     return '#(ly-export %s)' % s
942 def subst_csp_definition (match):
943     return ' = #(make-event-chord (list %s))' % subst_ev_name (match)
944 def subst_csp_inline (match):
945     return '#(ly-export (make-event-chord (list %s)))' % subst_ev_name (match)
946
947 def conv (str):
948     str = re.sub (r' *= *\\spanrequest *([^ ]+) *"([^"]+)"', subst_definition_ev_name, str)
949     str = re.sub (r'\\spanrequest *([^ ]+) *"([^"]+)"', subst_inline_ev_name, str)
950     str = re.sub (r' *= *\\commandspanrequest *([^ ]+) *"([^"]+)"', subst_csp_definition, str)
951     str = re.sub (r'\\commandspanrequest *([^ ]+) *"([^"]+)"', subst_csp_inline, str)
952     str = re.sub (r'ly-id ', 'ly-import ', str)
953
954     str = re.sub (r' *= *\\script "([^"]+)"', ' = #(make-articulation "\\1")', str)
955     str = re.sub (r'\\script "([^"]+)"', '#(ly-export (make-articulation "\\1"))', str)
956     return str
957
958 conversions.append (((1,7,2), conv, '\\spanrequest -> #(make-span-event .. ), \script -> #(make-articulation .. )'))
959
960
961 def conv(str):
962     str = re.sub (r'\(ly-', '(ly:', str)
963
964     changed = [
965             r'duration\?',
966             r'font-metric\?',
967             r'molecule\?',
968             r'moment\?',
969             r'music\?',
970             r'pitch\?',
971             'make-duration',
972             'music-duration-length',
973             'duration-log',
974             'duration-dotcount',
975             'intlog2',
976             'duration-factor',
977             'transpose-key-alist',
978             'get-system',
979             'get-broken-into',
980             'get-original',
981             'set-point-and-click!',
982             'make-moment',
983             'make-pitch',
984             'pitch-octave',
985             'pitch-alteration',
986             'pitch-notename',
987             'pitch-semitones',
988             r'pitch<\?',
989             r'dir\?',
990             'music-duration-compress',
991             'set-point-and-click!'
992             ]
993
994     origre = r'\b(%s)' % '|'.join (changed)
995
996     str = re.sub (origre, r'ly:\1',str)
997     str = re.sub ('set-point-and-click!', 'set-point-and-click', str)
998
999     return str
1000
1001 conversions.append (((1,7,3), conv, 'ly- -> ly:'))
1002
1003
1004 def conv(str):
1005     if re.search ('new-chords-done',str):
1006         return str
1007
1008     str = re.sub (r'<<', '< <', str)
1009     str = re.sub (r'>>', '> >', str)
1010     return str
1011
1012 conversions.append (((1,7,4), conv, '<< >> -> < <  > >'))
1013
1014
1015 def conv(str):
1016     str = re.sub (r"\\transpose", r"\\transpose c'", str)
1017     str = re.sub (r"\\transpose c' *([a-z]+)'", r"\\transpose c \1", str)
1018     return str
1019 conversions.append (((1,7,5), conv, '\\transpose TO -> \\transpose FROM  TO'))
1020
1021
1022 def conv(str):
1023     kws =   ['arpeggio',
1024              'sustainDown',
1025              'sustainUp',
1026              'f',
1027              'p',
1028              'pp',
1029              'ppp',
1030              'fp',
1031              'ff',
1032              'mf',
1033              'mp',
1034              'sfz',
1035              ]
1036
1037     origstr = '|'.join (kws)
1038     str = re.sub (r'([^_^-])\\(%s)\b' % origstr, r'\1-\\\2', str)
1039     return str
1040 conversions.append (((1,7,6), conv, 'note\\script -> note-\script'))
1041
1042
1043
1044 def conv(str):
1045     str = re.sub (r"\\property *ChordNames *\. *ChordName *\\(set|override) *#'style *= *#('[a-z]+)",
1046                   r"#(set-chord-name-style \2)", str)
1047     str = re.sub (r"\\property *ChordNames *\. *ChordName *\\revert *#'style",
1048                   r"", str)
1049     return str
1050 conversions.append (((1,7,10), conv, "\property ChordName #'style -> #(set-chord-name-style 'style)"))
1051
1052
1053
1054
1055 def conv(str):
1056     str = re.sub (r"ly:transpose-pitch", "ly:pitch-transpose", str)
1057
1058     return str
1059 conversions.append (((1,7,11), conv, "transpose-pitch -> pitch-transpose"))
1060
1061
1062 def conv(str):
1063     str = re.sub (r"ly:get-molecule-extent", "ly:molecule-get-extent", str)
1064     str = re.sub (r"ly:set-molecule-extent!", "ly:molecule-set-extent!", str)
1065     str = re.sub (r"ly:add-molecule", "ly:molecule-add", str)
1066     str = re.sub (r"ly:combine-molecule-at-edge", "ly:molecule-combine-at-edge", str)
1067     str = re.sub (r"ly:align-to!", "ly:molecule-align-to!", str)
1068
1069     return str
1070
1071 conversions.append (((1,7,13), conv, "ly:XX-molecule-YY -> ly:molecule-XX-YY"))
1072
1073
1074 def conv(str):
1075     str = re.sub (r"linewidth *= *-[0-9.]+ *(\\mm|\\cm|\\in|\\pt)?", 'raggedright = ##t', str )
1076     return str
1077
1078 conversions.append (((1,7,15), conv, "linewidth = -1 -> raggedright = ##t"))
1079
1080
1081 def conv(str):
1082     str = re.sub ("divisiomaior",
1083                   "divisioMaior", str)
1084     str = re.sub ("divisiominima",
1085                   "divisioMinima", str)
1086     str = re.sub ("divisiomaxima",
1087                   "divisioMaxima", str)
1088     return str
1089
1090 conversions.append (((1,7,16), conv, "divisiomaior -> divisioMaior"))
1091
1092
1093 def conv(str):
1094     str = re.sub ("Skip_req_swallow_translator",
1095                   "Skip_event_swallow_translator", str)
1096     return str
1097
1098 conversions.append (((1,7,17), conv, "Skip_req  -> Skip_event"))
1099
1100
1101 def conv(str):
1102     str = re.sub ("groupOpen",
1103                   "startGroup", str)
1104     str = re.sub ("groupClose",
1105                   "stopGroup", str)
1106     str = re.sub ("#'outer",
1107                   "#'enclose-bounds", str)
1108
1109     return str
1110
1111 conversions.append (((1,7,18), conv,
1112                      """groupOpen/Close  -> start/stopGroup,
1113                      #'outer  -> #'enclose-bounds
1114                      """))
1115
1116
1117 def conv(str):
1118     if re.search( r'\\GraceContext', str):
1119         stderr_write ('\n')
1120         stderr_write (NOT_SMART % "GraceContext")
1121         stderr_write (FROM_TO \
1122                           % ("GraceContext", "#(add-to-grace-init .. )"))
1123         stderr_write ('\n')
1124         stderr_write (UPDATE_MANUALLY)
1125         stderr_write ('\n')
1126         raise FatalConversionError ()
1127
1128     str = re.sub ('HaraKiriStaffContext', 'RemoveEmptyStaffContext', str)
1129     return str
1130
1131 conversions.append (((1,7,19), conv, _ ("remove %s") % "GraceContext"))
1132
1133
1134
1135
1136 def conv(str):
1137     str = re.sub (
1138             r"(set|override|revert) *#'type",
1139             r"\1 #'style",
1140             str)
1141     return str
1142
1143 conversions.append (((1,7,22), conv,"#'type -> #'style"))
1144
1145
1146 def conv(str):
1147     str = re.sub (
1148             "barNonAuto *= *##t",
1149             "automaticBars = ##f",
1150             str)
1151     str = re.sub (
1152             "barNonAuto *= *##f",
1153             "automaticBars = ##t",
1154             str)
1155     return str
1156
1157 conversions.append (((1,7,23), conv,"barNonAuto -> automaticBars"))
1158
1159
1160
1161 def conv(str):
1162     if re.search( r'-(start|stop)Cluster', str):
1163         stderr_write ('\n')
1164         stderr_write (NOT_SMART % _ ("cluster syntax"))
1165         stderr_write ('\n')
1166         stderr_write (UPDATE_MANUALLY)
1167         stderr_write ('\n')
1168
1169         raise FatalConversionError ()
1170
1171     return str
1172
1173 conversions.append (((1,7,24), conv, _ ("cluster syntax")))
1174
1175
1176 def conv(str):
1177     str = re.sub (r"\\property *Staff\.(Sustain|Sostenuto|UnaCorda)Pedal *\\(override|set) *#'pedal-type *",
1178                     r"\property Staff.pedal\1Style ", str)
1179     str = re.sub (r"\\property *Staff\.(Sustain|Sostenuto|UnaCorda)Pedal *\\revert *#'pedal-type", '', str)
1180     return str
1181
1182 conversions.append (((1,7,28), conv, _ ("new Pedal style syntax")))
1183
1184
1185
1186
1187
1188 def sub_chord (m):
1189     str = m.group(1)
1190
1191     origstr =  '<%s>' % str
1192     if re.search (r'\\\\', str):
1193         return origstr
1194
1195     if re.search (r'\\property', str):
1196         return origstr
1197
1198     if re.match (r'^\s*\)?\s*\\[a-zA-Z]+', str):
1199         return origstr
1200
1201     durs = []
1202     def sub_durs (m, durs = durs):
1203         durs.append(m.group(2))
1204         return m.group (1)
1205
1206     str = re.sub (r"([a-z]+[,'!? ]*)([0-9]+\.*)", sub_durs, str)
1207     dur_str = ''
1208
1209     for d in durs:
1210         if dur_str == '':
1211             dur_str = d
1212         if dur_str <> d:
1213             return '<%s>' % m.group (1)
1214
1215     pslur_strs = ['']
1216     dyns = ['']
1217     slur_strs = ['']
1218
1219     last_str = ''
1220     while last_str <> str:
1221         last_str = str
1222
1223         def sub_tremolos (m, slur_strs = slur_strs):
1224             tr = m.group (2)
1225             if tr not in slur_strs:
1226                 slur_strs.append (tr)
1227             return  m.group (1)
1228
1229         str = re.sub (r"([a-z]+[',!? ]*)(:[0-9]+)",
1230                       sub_tremolos, str)
1231
1232         def sub_dyn_end (m, dyns = dyns):
1233             dyns.append (' \!')
1234             return ' ' + m.group(2)
1235
1236         str = re.sub (r'(\\!)\s*([a-z]+)', sub_dyn_end, str)
1237         def sub_slurs(m, slur_strs = slur_strs):
1238             if '-)' not in slur_strs:
1239                 slur_strs.append (')')
1240             return m.group(1)
1241
1242         def sub_p_slurs(m, slur_strs = slur_strs):
1243             if '-\)' not in slur_strs:
1244                 slur_strs.append ('\)')
1245             return m.group(1)
1246
1247         str = re.sub (r"\)[ ]*([a-z]+)", sub_slurs, str)
1248         str = re.sub (r"\\\)[ ]*([a-z]+)", sub_p_slurs, str)
1249         def sub_begin_slurs(m, slur_strs = slur_strs):
1250             if '-(' not in slur_strs:
1251                 slur_strs.append ('(')
1252             return m.group(1)
1253
1254         str = re.sub (r"([a-z]+[,'!?0-9 ]*)\(",
1255                       sub_begin_slurs, str)
1256         def sub_begin_p_slurs(m, slur_strs = slur_strs):
1257             if '-\(' not in slur_strs:
1258                 slur_strs.append ('\(')
1259             return m.group(1)
1260
1261         str = re.sub (r"([a-z]+[,'!?0-9 ]*)\\\(",
1262                 sub_begin_p_slurs, str)
1263
1264         def sub_dyns (m, slur_strs = slur_strs):
1265             s = m.group(0)
1266             if s == '@STARTCRESC@':
1267                 slur_strs.append ("\\<")
1268             elif s == '@STARTDECRESC@':
1269                 slur_strs.append ("\\>")
1270             elif s == r'-?\\!':
1271                 slur_strs.append ('\\!')
1272             return ''
1273
1274         str = re.sub (r'@STARTCRESC@', sub_dyns, str)
1275         str = re.sub (r'-?\\!', sub_dyns, str)
1276
1277         def sub_articulations (m, slur_strs = slur_strs):
1278             a = m.group(1)
1279             if a not in slur_strs:
1280                 slur_strs.append (a)
1281             return ''
1282
1283         str = re.sub (r"([_^-]\@ACCENT\@)", sub_articulations,
1284                       str)
1285         str = re.sub (r"([_^-]\\[a-z]+)", sub_articulations,
1286                       str)
1287         str = re.sub (r"([_^-][>_.+|^-])", sub_articulations,
1288                       str)
1289         str = re.sub (r'([_^-]"[^"]+")', sub_articulations,
1290                       str)
1291
1292         def sub_pslurs(m, slur_strs = slur_strs):
1293             slur_strs.append (' \\)')
1294             return m.group(1)
1295         str = re.sub (r"\\\)[ ]*([a-z]+)", sub_pslurs, str)
1296
1297     ## end of while <>
1298
1299     suffix = ''.join (slur_strs) + ''.join (pslur_strs) \
1300              + ''.join (dyns)
1301
1302     return '@STARTCHORD@%s@ENDCHORD@%s%s' % (str , dur_str, suffix)
1303
1304
1305
1306 def sub_chords (str):
1307     simend = '>'
1308     simstart = '<'
1309     chordstart = '<<'
1310     chordend = '>>'
1311     marker_str = '%% new-chords-done %%'
1312
1313     if re.search (marker_str,str):
1314         return str
1315     str = re.sub ('<<', '@STARTCHORD@', str)
1316     str = re.sub ('>>', '@ENDCHORD@', str)
1317
1318     str = re.sub (r'\\<', '@STARTCRESC@', str)
1319     str = re.sub (r'\\>', '@STARTDECRESC@', str)
1320     str = re.sub (r'([_^-])>', r'\1@ACCENT@', str)
1321     str = re.sub (r'<([^<>{}]+)>', sub_chord, str)
1322
1323     # add dash: -[, so that [<<a b>> c d] becomes
1324     #                      <<a b>>-[ c d]
1325     # and gets skipped by articulation_substitute
1326     str = re.sub (r'\[ *(@STARTCHORD@[^@]+@ENDCHORD@[0-9.]*)',
1327                   r'\1-[', str)
1328     str = re.sub (r'\\! *(@STARTCHORD@[^@]+@ENDCHORD@[0-9.]*)',
1329                   r'\1-\\!', str)
1330
1331     str = re.sub (r'<([^?])', r'%s\1' % simstart, str)
1332     str = re.sub (r'>([^?])', r'%s\1' % simend,  str)
1333     str = re.sub ('@STARTCRESC@', r'\\<', str)
1334     str = re.sub ('@STARTDECRESC@', r'\\>' ,str)
1335     str = re.sub (r'\\context *Voice *@STARTCHORD@',
1336                   '@STARTCHORD@', str)
1337     str = re.sub ('@STARTCHORD@', chordstart, str)
1338     str = re.sub ('@ENDCHORD@', chordend, str)
1339     str = re.sub (r'@ACCENT@', '>', str)
1340     return str
1341
1342 markup_start = re.compile(r"([-^_]|\\mark)\s*(#\s*'\s*)\(")
1343 musicglyph = re.compile(r"\(\s*music\b")
1344 columns = re.compile(r"\(\s*columns\b")
1345 submarkup_start = re.compile(r"\(\s*([a-zA-Z]+)")
1346 leftpar = re.compile(r"\(")
1347 rightpar = re.compile(r"\)")
1348
1349 def text_markup (str):
1350     result = ''
1351     # Find the beginning of each markup:
1352     match = markup_start.search (str)
1353     while match:
1354         result = result + str[:match.end (1)] + " \markup"
1355         str = str[match.end( 2):]
1356         # Count matching parentheses to find the end of the 
1357         # current markup:
1358         nesting_level = 0
1359         pars = re.finditer(r"[()]",str)
1360         for par in pars:
1361             if par.group () == '(':
1362                 nesting_level = nesting_level + 1
1363             else:
1364                 nesting_level = nesting_level - 1
1365             if nesting_level == 0:
1366                 markup_end = par.end ()
1367                 break
1368         # The full markup in old syntax:
1369         markup = str[:markup_end]
1370         # Modify to new syntax:
1371         markup = musicglyph.sub (r"{\\musicglyph", markup)
1372         markup = columns.sub (r"{", markup)
1373         markup = submarkup_start.sub (r"{\\\1", markup)
1374         markup = leftpar.sub ("{", markup)
1375         markup = rightpar.sub ("}", markup)
1376
1377         result = result + markup
1378         # Find next markup
1379         str = str[markup_end:]
1380         match = markup_start.search(str)
1381     result = result + str
1382     return result
1383
1384 def articulation_substitute (str):
1385     str = re.sub (r"""([^-])\[ *(\\?\)?[a-z]+[,']*[!?]?[0-9:]*\.*)""",
1386                   r"\1 \2[", str)
1387     str = re.sub (r"""([^-])\\\) *([a-z]+[,']*[!?]?[0-9:]*\.*)""",
1388                   r"\1 \2\\)", str)
1389     str = re.sub (r"""([^-\\])\) *([a-z]+[,']*[!?]?[0-9:]*\.*)""",
1390                   r"\1 \2)", str)
1391     str = re.sub (r"""([^-])\\! *([a-z]+[,']*[!?]?[0-9:]*\.*)""",
1392                   r"\1 \2\\!", str)
1393     return str
1394
1395 string_or_scheme = re.compile ('("(?:[^"\\\\]|\\\\.)*")|(#\\s*\'?\\s*\\()')
1396
1397 # Only apply articulation_substitute () outside strings and 
1398 # Scheme expressions:
1399 def smarter_articulation_subst (str):
1400     result = ''
1401     # Find the beginning of next string or Scheme expr.:
1402     match = string_or_scheme.search (str)
1403     while match:
1404         # Convert the preceding LilyPond code:
1405         previous_chunk = str[:match.start()]
1406         result = result + articulation_substitute (previous_chunk)
1407         if match.group (1): # Found a string
1408             # Copy the string to output:
1409             result = result + match.group (1)
1410             str = str[match.end(1):]
1411         else: # Found a Scheme expression. Count 
1412             # matching parentheses to find its end
1413             str = str[match.start ():]
1414             nesting_level = 0
1415             pars = re.finditer(r"[()]",str)
1416             for par in pars:
1417                 if par.group () == '(':
1418                     nesting_level = nesting_level + 1
1419                 else:
1420                     nesting_level = nesting_level - 1
1421                 if nesting_level == 0:
1422                     scheme_end = par.end ()
1423                     break
1424             # Copy the Scheme expression to output:
1425             result = result + str[:scheme_end]
1426             str = str[scheme_end:]
1427         # Find next string or Scheme expression:
1428         match = string_or_scheme.search (str)
1429     # Convert the remainder of the file
1430     result = result + articulation_substitute (str)
1431     return result
1432
1433 def conv_relative(str):
1434     if re.search (r"\\relative", str):
1435         str= "#(ly:set-option 'old-relative)\n" + str
1436
1437     return str
1438
1439 def conv (str):
1440     str = re.sub (r"#'\(\)", "@SCM_EOL@", str)
1441     str =  conv_relative (str)
1442     str = sub_chords (str)
1443
1444     str = text_markup (str)
1445     str = smarter_articulation_subst (str)
1446     str = re.sub ("@SCM_EOL@", "#'()", str)
1447
1448     return str
1449
1450 conversions.append (((1,9,0), conv, _ ("""New relative mode,
1451 Postfix articulations, new text markup syntax, new chord syntax.""")))
1452
1453
1454 def conv (str):
1455     if re.search ("font-style",str):
1456         stderr_write ('\n')
1457         stderr_write (NOT_SMART % "font-style")
1458         stderr_write ('\n')
1459         stderr_write (UPDATE_MANUALLY)
1460         stderr_write ('\n')
1461
1462         raise FatalConversionError ()
1463
1464     str = re.sub (r'-\\markup', r'@\\markup', str)
1465     str = re.sub (r'-\\', r'\\', str)
1466     str = re.sub (r'-\)', ')', str)
1467     str = re.sub (r'-\(', '(', str)
1468     str = re.sub ('-\[', '[', str)
1469     str = re.sub ('-\]', ']', str)
1470     str = re.sub ('-~', '~', str)
1471     str = re.sub (r'@\\markup', r'-\\markup', str)
1472     return str
1473
1474 conversions.append (((1,9,1), conv, _ ("""Remove - before articulation""")))
1475
1476 def conv (str):
1477     str = re.sub ('ly:set-context-property',
1478                   'ly:set-context-property!', str)
1479     str = re.sub ('\\\\newcontext', '\\\\new', str)
1480     str = re.sub ('\\\\grace[\t\n ]*([^{ ]+)',
1481                   r'\\grace { \1 }', str)
1482     str = re.sub ("\\\\grace[\t\n ]*{([^}]+)}",
1483                   r"""\\grace {
1484 \\property Voice.Stem \\override #'stroke-style = #"grace"
1485   \1
1486   \\property Voice.Stem \\revert #'stroke-style }
1487 """, str)
1488
1489     return str
1490
1491 conversions.append (((1,9,2), conv, """\\newcontext -> \\new"""))
1492
1493 def conv (str):
1494     str = re.sub ('accacciatura',
1495                   'acciaccatura', str)
1496
1497     if re.search ("context-spec-music", str):
1498         stderr_write ('\n')
1499         stderr_write (NOT_SMART % "context-spec-music")
1500         stderr_write ('\n')
1501         stderr_write (UPDATE_MANUALLY)
1502         stderr_write ('\n')
1503
1504         raise FatalConversionError ()
1505
1506     str = re.sub ('fingerHorizontalDirection *= *#(LEFT|-1)',
1507                   "fingeringOrientations = #'(up down left)", str)
1508     str = re.sub ('fingerHorizontalDirection *= *#(RIGHT|1)',
1509                   "fingeringOrientations = #'(up down right)", str)
1510
1511     return str
1512
1513 conversions.append (((1,9,3), conv,
1514                      (_ ("%s misspelling") % "\\acciaccatura") + \
1515                          ", fingerHorizontalDirection -> fingeringOrientations"))
1516
1517
1518 def conv (str):
1519     if re.search ('\\figures', str):
1520         warning (_ ("attempting automatic \\figures conversion.  Check results!"));
1521
1522
1523     def figures_replace (m):
1524         s = m.group (1)
1525         s = re.sub ('<', '@FIGOPEN@',s)
1526         s = re.sub ('>', '@FIGCLOSE@',s)
1527         return '\\figures { %s }' % s
1528
1529     str = re.sub (r'\\figures[ \t\n]*{([^}]+)}', figures_replace, str)
1530     str = re.sub (r'\\<', '@STARTCRESC@', str)
1531     str = re.sub (r'\\>', '@STARTDECRESC@', str)
1532     str = re.sub (r'([-^_])>', r'\1@ACCENT@', str)
1533     str = re.sub (r'<<', '@STARTCHORD@', str)
1534     str = re.sub (r'>>', '@ENDCHORD@', str)
1535     str = re.sub (r'>', '@ENDSIMUL@', str)
1536     str = re.sub (r'<', '@STARTSIMUL@', str)
1537     str = re.sub ('@STARTDECRESC@', '\\>', str)
1538     str = re.sub ('@STARTCRESC@', '\\<', str)
1539     str = re.sub ('@ACCENT@', '>', str)
1540     str = re.sub ('@ENDCHORD@', '>', str)
1541     str = re.sub ('@STARTCHORD@', '<', str)
1542     str = re.sub ('@STARTSIMUL@', '<<', str)
1543     str = re.sub ('@ENDSIMUL@', '>>', str)
1544     str = re.sub ('@FIGOPEN@', '<', str)
1545     str = re.sub ('@FIGCLOSE@', '>', str)
1546
1547     return str
1548
1549 conversions.append (((1,9,4), conv, _ ('Swap < > and << >>')))
1550
1551
1552 def conv (str):
1553     str = re.sub ('HaraKiriVerticalGroup', 'RemoveEmptyVerticalGroup', str)
1554
1555     return str
1556
1557 conversions.append (((1,9,5), conv, 'HaraKiriVerticalGroup -> RemoveEmptyVerticalGroup'))
1558
1559 def conv (str):
1560     if re.search ("ly:get-font", str) :
1561         stderr_write ('\n')
1562         stderr_write (NOT_SMART % "(ly:-get-font")
1563         stderr_write ('\n')
1564         stderr_write (FROM_TO \
1565                           % ("(ly:paper-get-font (ly:grob-get-paper foo) .. )",
1566                              "(ly:paper-get-font (ly:grob-get-paper foo) .. )"))
1567         stderr_write (UPDATE_MANUALLY)
1568         stderr_write ('\n')
1569         raise FatalConversionError ()
1570
1571     if re.search ("\\pitch *#", str) :
1572         stderr_write ('\n')
1573         stderr_write (NOT_SMART % "\\pitch")
1574         stderr_write ('\n')
1575         stderr_write (_ ("Use Scheme code to construct arbitrary note events."))
1576         stderr_write ('\n')
1577
1578         raise FatalConversionError ()
1579
1580     return str
1581
1582
1583 conversions.append (((1,9,6), conv, _ ('deprecate %s') % 'ly:get-font'))
1584
1585 def conv (str):
1586     def sub_alteration (m):
1587         alt = m.group (3)
1588         alt = {
1589                 '-1': 'FLAT',
1590                 '-2': 'DOUBLE-FLAT',
1591                 '0': 'NATURAL',
1592                 '1': 'SHARP',
1593                 '2': 'DOUBLE-SHARP',
1594                 }[alt]
1595
1596         return '(ly:make-pitch %s %s %s)' % (m.group(1), m.group (2),
1597                                              alt)
1598
1599     str =re.sub ("\\(ly:make-pitch *([0-9-]+) *([0-9-]+) *([0-9-]+) *\\)",
1600                  sub_alteration, str)
1601
1602
1603     str = re.sub ("ly:verbose", "ly:get-option 'verbose", str)
1604
1605     m= re.search ("\\\\outputproperty #([^#]+)[\t\n ]*#'([^ ]+)", str)
1606     if m:
1607         stderr_write (_ (\
1608                 r"""\outputproperty found,
1609 Please hand-edit, using
1610
1611   \applyoutput #(outputproperty-compatibility %s '%s <GROB PROPERTY VALUE>)
1612
1613 as a substitution text.""") % (m.group (1), m.group (2)) )
1614         raise FatalConversionError ()
1615
1616     if re.search ("ly:(make-pitch|pitch-alteration)", str) \
1617            or re.search ("keySignature", str):
1618         stderr_write ('\n')
1619         stderr_write (NOT_SMART % "pitches")
1620         stderr_write ('\n')
1621         stderr_write (
1622             _ ("""The alteration field of Scheme pitches was multiplied by 2
1623 to support quarter tone accidentals.  You must update the following constructs manually:
1624
1625 * calls of ly:make-pitch and ly:pitch-alteration
1626 * keySignature settings made with \property
1627 """))
1628         raise FatalConversionError ()
1629
1630     return str
1631 conversions.append (((1,9,7), conv,
1632                      _ ('''use symbolic constants for alterations,
1633 remove \\outputproperty, move ly:verbose into ly:get-option''')))
1634
1635
1636 def conv (str):
1637     if re.search ("dash-length",str):
1638         stderr_write ('\n')
1639         stderr_write (NOT_SMART % "dash-length")
1640         stderr_write ('\n')
1641         stderr_write (FROM_TO % ("dash-length", "dash-fraction"))
1642         stderr_write ('\n')
1643         stderr_write (UPDATE_MANUALLY)
1644         stderr_write ('\n')
1645         raise FatalConversionError ()
1646     return str
1647
1648 conversions.append (((1,9,8), conv, """dash-length -> dash-fraction"""))
1649
1650
1651 def conv (str):
1652     def func(match):
1653         return "#'font-size = #%d" % (2*int (match.group (1)))
1654
1655     str =re.sub (r"#'font-relative-size\s*=\s*#\+?([0-9-]+)", func, str)
1656     str =re.sub (r"#'font-family\s*=\s*#'ancient",
1657                  r"#'font-family = #'music", str)
1658
1659     return str
1660
1661 conversions.append (((2,1,1), conv, """font-relative-size -> font-size"""))
1662
1663 def conv (str):
1664     str =re.sub (r"ly:get-music-length", "ly:music-length", str)
1665     return str
1666
1667 conversions.append (((2,1,2), conv, """ly:get-music-length -> ly:music-length"""))
1668
1669 def conv (str):
1670     str =re.sub (r"\.\s+stz=", ". instr ", str)
1671     return str
1672
1673 conversions.append (((2,1,3), conv, """stanza -> instrument"""))
1674
1675 def conv (str):
1676     def func (match):
1677         c = match.group (1)
1678         b = match.group (2)
1679
1680         if b == 't':
1681             if c == 'Score':
1682                 return ''
1683             else:
1684                 return r" \property %s.melismaBusyProperties \unset"  % c
1685         elif b == 'f':
1686             return r"\property %s.melismaBusyProperties = #'(melismaBusy)"  % c
1687
1688     str = re.sub (r"\\property ([a-zA-Z]+)\s*\.\s*automaticMelismata\s*=\s*##([ft])", func, str)
1689     return str
1690
1691 conversions.append (((2,1,4), conv, _ ("""removal of automaticMelismata; use melismaBusyProperties instead.""")))
1692
1693
1694
1695 def conv (str):
1696     str =re.sub (r"\\translator\s+([a-zA-Z]+)", r"\\change \1", str)
1697     return str
1698
1699 conversions.append (((2,1,7), conv, """\\translator Staff -> \\change Staff"""))
1700
1701 def conv (str):
1702     str =re.sub (r"\\newaddlyrics", r"\\lyricsto", str)
1703     return str
1704
1705 conversions.append (((2,1,10), conv, """\\newaddlyrics -> \\lyricsto"""))
1706
1707 def conv (str):
1708     str = re.sub (r'\\include\s*"paper([0-9]+)(-init)?.ly"',
1709                   r"#(set-staff-size \1)", str)
1710
1711     def sub_note (match):
1712         dur = ''
1713         log = int (match.group (1))
1714         dots = int (match.group (2))
1715
1716         if log >= 0:
1717             dur = '%d' % (1 << log)
1718         else:
1719             dur = { -1 : 'breve',
1720                     -2 : 'longa',
1721                     -3 : 'maxima'}[log]
1722
1723         dur += ('.' * dots)
1724
1725         return r'\note #"%s" #%s' % (dur, match.group (3))
1726
1727     str = re.sub (r'\\note\s+#([0-9-]+)\s+#([0-9]+)\s+#([0-9.-]+)',
1728                   sub_note, str)
1729     return str
1730
1731 conversions.append (((2,1,11), conv, """\\include "paper16.ly" -> #(set-staff-size 16)
1732 \\note #3 #1 #1 -> \\note #"8." #1
1733 """))
1734
1735
1736 def conv (str):
1737     str =re.sub (r"OttavaSpanner", r"OttavaBracket", str)
1738     return str
1739
1740 conversions.append (((2,1,12), conv, """OttavaSpanner -> OttavaBracket"""))
1741
1742
1743 def conv (str):
1744     str =re.sub (r"\(set-staff-size ", r"(set-global-staff-size ", str)
1745     return str
1746
1747 conversions.append (((2,1,13), conv, """set-staff-size -> set-global-staff-size"""))
1748
1749 def conv (str):
1750     str =re.sub (r"#'style\s*=\s*#'dotted-line",
1751                  r"#'dash-fraction = #0.0 ", str)
1752     return str
1753
1754 conversions.append (((2,1,14), conv, """style = dotted -> dash-fraction = 0"""))
1755
1756 def conv (str):
1757     str =re.sub (r'LyricsVoice\s*\.\s*instrument\s*=\s*("[^"]*")',
1758                  r'LyricsVoice . vocalName = \1', str)
1759
1760     str =re.sub (r'LyricsVoice\s*\.\s*instr\s*=\s*("[^"]*")',
1761                  r'LyricsVoice . vocNam = \1', str)
1762     return str
1763
1764 conversions.append (((2,1,15), conv, """LyricsVoice . instr(ument) -> vocalName"""))
1765
1766 def conv (str):
1767     def sub_acc (m):
1768         d = {
1769         '4': 'doublesharp',
1770         '3': 'threeqsharp',
1771         '2': 'sharp',
1772         '1': 'semisharp',
1773         '0': 'natural',
1774         '-1': 'semiflat',
1775         '-2': 'flat',
1776         '-3': 'threeqflat',
1777         '-4': 'doubleflat'}
1778         return '\\%s' %  d[m.group (1)]
1779
1780     str = re.sub (r'\\musicglyph\s*#"accidentals-([0-9-]+)"',
1781                   sub_acc, str)
1782     return str
1783
1784 conversions.append (((2,1,16), conv, """\\musicglyph #"accidentals-NUM" -> \\sharp/flat/etc."""))
1785
1786
1787 def conv (str):
1788
1789     if re.search (r'\\partcombine', str):
1790         stderr_write ('\n')
1791         stderr_write (NOT_SMART % "\\partcombine")
1792         stderr_write ('\n')
1793         stderr_write (UPDATE_MANUALLY)
1794         stderr_write ('\n')
1795         raise FatalConversionError ()
1796
1797     # this rule doesn't really work,
1798     # too lazy to figure out why.
1799     str = re.sub (r'\\context\s+Voice\s*=\s*one\s*\\partcombine\s+Voice\s*\\context\s+Thread\s*=\s*one(.*)\s*'
1800                   + r'\\context\s+Thread\s*=\s*two',
1801                   '\\\\newpartcombine\n\\1\n', str)
1802
1803
1804     return str
1805
1806 conversions.append (((2,1,17), conv, _ ("\\partcombine syntax change to \\newpartcombine")))
1807
1808
1809 def conv (str):
1810     str = re.sub (r'\\newpartcombine', r'\\partcombine', str)
1811     str = re.sub (r'\\autochange\s+Staff', r'\\autochange ', str)
1812     return str
1813
1814 conversions.append (((2,1,18), conv, """\\newpartcombine -> \\partcombine,
1815 \\autochange Staff -> \\autochange
1816 """))
1817
1818
1819
1820
1821 def conv (str):
1822     if re.search ('include "drumpitch', str):
1823         stderr_write (_ ("Drums found. Enclose drum notes in \\drummode"))
1824
1825     str = re.sub (r'\\include "drumpitch-init.ly"','', str)
1826
1827     str = re.sub (r'\\pitchnames ','pitchnames = ', str)
1828     str = re.sub (r'\\chordmodifiers ','chordmodifiers = ', str)
1829     str = re.sub (r'\bdrums\b\s*=','drumContents = ', str)
1830     str = re.sub (r'\\drums\b','\\drumContents ', str)
1831
1832
1833     if re.search ('drums->paper', str):
1834         stderr_write (_ ("\n%s found. Check file manually!\n") % _("Drum notation"))
1835
1836     str = re.sub (r"""\\apply\s+#\(drums->paper\s+'([a-z]+)\)""",
1837                   r"""\property DrumStaff.drumStyleTable = #\1-style""",
1838                   str)
1839
1840     if re.search ('Thread', str):
1841         stderr_write (_ ("\n%s found. Check file manually!\n") % "Thread");
1842
1843     str = re.sub (r"""(\\once\s*)?\\property\s+Thread\s*\.\s*NoteHead\s*"""
1844                   + r"""\\(set|override)\s*#'style\s*=\s*#'harmonic"""
1845                   + r"""\s+([a-z]+[,'=]*)([0-9]*\.*)"""
1846                   ,r"""<\3\\harmonic>\4""", str)
1847
1848     str = re.sub (r"""\\new Thread""", """\context Voice""", str)
1849     str = re.sub (r"""Thread""", """Voice""", str)
1850
1851     if re.search ('\bLyrics\b', str):
1852         stderr_write (_ ("\n%s found. Check file manually!\n") % "Lyrics");
1853
1854     str = re.sub (r"""LyricsVoice""", r"""L@ricsVoice""", str)
1855     str = re.sub (r"""\bLyrics\b""", r"""LyricsVoice""", str)
1856     str = re.sub (r"""LyricsContext""", r"""LyricsVoiceContext""", str)
1857     str = re.sub (r"""L@ricsVoice""", r"""LyricsVoice""",str)
1858
1859
1860     return str
1861
1862 conversions.append (((2,1,19), conv, _ ("""Drum notation changes, Removing \\chordmodifiers, \\notenames.
1863 Harmonic notes. Thread context removed. Lyrics context removed.""")))
1864
1865 def conv (str):
1866     str = re.sub (r'nonevent-skip', 'skip-music', str)
1867     return str
1868
1869 conversions.append (((2,1,20), conv, """nonevent-skip -> skip-music""" ))
1870
1871 def conv (str):
1872     str = re.sub (r'molecule-callback', 'print-function', str)
1873     str = re.sub (r'brew_molecule', 'print', str)
1874     str = re.sub (r'brew-new-markup-molecule', 'Text_item::print', str)
1875     str = re.sub (r'LyricsVoice', 'Lyrics', str)
1876     str = re.sub (r'tupletInvisible',
1877                   r"TupletBracket \\set #'transparent", str)
1878 #       str = re.sub (r'molecule', 'collage', str)
1879 #molecule -> collage
1880     str = re.sub (r"\\property\s+[a-zA-Z]+\s*\.\s*[a-zA-Z]+\s*"
1881                   + r"\\set\s*#'X-extent-callback\s*=\s*#Grob::preset_extent",
1882                   "", str)
1883
1884     return str
1885
1886 conversions.append (((2,1,21), conv, """molecule-callback -> print-function,
1887 brew_molecule -> print
1888 brew-new-markup-molecule -> Text_item::print
1889 LyricsVoice -> Lyrics
1890 tupletInvisible -> TupletBracket \set #'transparent
1891 %s.
1892 """ % (_ ("remove %s") % "Grob::preset_extent")))
1893
1894
1895 def conv (str):
1896     str = re.sub (r'(\\property[^=]+)=\s*([-0-9]+)',
1897                   r'\1= #\2', str)
1898     str = re.sub (r'\\property\s+([^. ]+)\s*\.\s*([^\\=]+)\s*\\(set|override)',
1899                   r"\\overrid@ \1.\2 ", str)
1900     str = re.sub (r'\\property\s+([^. ]+)\s*\.\s*([^\\= ]+)\s*=\s*',
1901                   r'\\s@t \1.\2 = ', str)
1902     str = re.sub (r'\\property\s+([^. ]+)\s*\.\s*([^\\= ]+)\s*\\unset',
1903                   r'\\uns@t \1.\2 ', str)
1904     str = re.sub (r'\\property\s+([^. ]+)\s*\.\s*([^\\= ]+)\s*\\revert'
1905                   + r"\s*#'([-a-z0-9_]+)",
1906                   r"\\rev@rt \1.\2 #'\3", str)
1907     str = re.sub (r'Voice\.', '', str)
1908     str = re.sub (r'Lyrics\.', '', str)
1909     str = re.sub (r'ChordNames\.', '', str)
1910
1911     str = re.sub ('rev@rt', 'revert',str)
1912     str = re.sub ('s@t', 'set',str)
1913     str = re.sub ('overrid@', 'override',str)
1914
1915     str = re.sub ('molecule', 'stencil', str)
1916     str = re.sub ('Molecule', 'Stencil', str)
1917     return str
1918
1919 conversions.append (((2,1,22), conv, """%s
1920         \\set A.B = #C , \\unset A.B
1921         \\override A.B #C = #D, \\revert A.B #C
1922
1923 """ % _ ("new syntax for property settings:")))
1924
1925 def conv (str):
1926     def subst_in_trans (match):
1927         s = match.group (0)
1928         s = re.sub (r'\s([a-zA-Z]+)\s*\\override',
1929                       r' \\override \1', s)
1930         s = re.sub (r'\s([a-zA-Z]+)\s*\\set',
1931                       r' \\override \1', s)
1932         s = re.sub (r'\s([a-zA-Z]+)\s*\\revert',
1933                       r' \\revert \1', s)
1934         return s
1935     str = re.sub (r'\\(translator|with)\s*{[^}]+}',  subst_in_trans, str)
1936
1937     def sub_abs (m):
1938
1939         context = m.group ('context')
1940         d = m.groupdict ()
1941         if context:
1942             context = " '%s" % context[:-1] # -1: remove .
1943         else:
1944             context = ''
1945
1946         d['context'] = context
1947
1948         return r"""#(override-auto-beam-setting %(prop)s %(num)s %(den)s%(context)s)""" % d
1949
1950     str = re.sub (r"""\\override\s*(?P<context>[a-zA-Z]+\s*\.\s*)?autoBeamSettings"""
1951                   +r"""\s*#(?P<prop>[^=]+)\s*=\s*#\(ly:make-moment\s+(?P<num>\d+)\s+(?P<den>\d)\s*\)""",
1952                   sub_abs, str)
1953
1954     return str
1955
1956 conversions.append (((2,1,23), conv, _ ("Property setting syntax in \\translator{ }")))
1957
1958 def conv (str):
1959     str = re.sub (r'music-list\?', 'ly:music-list?', str)
1960     str = re.sub (r'\|\s*~', '~ |', str)
1961     return str
1962
1963 conversions.append (((2,1,24), conv, """music-list? -> ly:music-list?"""))
1964
1965 def conv (str):
1966     str = re.sub (r'ly:get-spanner-bound', 'ly:spanner-get-bound', str)
1967     str = re.sub (r'ly:get-extent', 'ly:grob-extent', str)
1968     str = re.sub (r'ly:get-system', 'ly:grob-system', str)
1969     str = re.sub (r'ly:get-original', 'ly:grob-original', str)
1970     str = re.sub (r'ly:get-parent', 'ly:grob-parent', str)
1971     str = re.sub (r'ly:get-broken-into', 'ly:spanner-broken-into', str)
1972     str = re.sub (r'Melisma_engraver', 'Melisma_translator', str)
1973     if re.search ("ly:get-paper-variable", str):
1974         stderr_write ('\n')
1975         stderr_write (NOT_SMART % "ly:paper-get-variable")
1976         stderr_write ('\n')
1977         stderr_write (_ ('use %s') % '(ly:paper-lookup (ly:grob-paper ))')
1978         stderr_write ('\n')
1979         raise FatalConversionError ()
1980
1981     str = re.sub (r'\\defaultAccidentals', "#(set-accidental-style 'default)", str)
1982     str = re.sub (r'\\voiceAccidentals', "#(set-accidental-style 'voice)", str)
1983     str = re.sub (r'\\modernAccidentals', "#(set-accidental-style 'modern)", str)
1984     str = re.sub (r'\\modernCautionaries', "#(set-accidental-style 'modern-cautionary)", str)
1985     str = re.sub (r'\\modernVoiceAccidental', "#(set-accidental-style 'modern-voice)", str)
1986     str = re.sub (r'\\modernVoiceCautionaries', "#(set-accidental-style 'modern-voice-cautionary)", str)
1987     str = re.sub (r'\\pianoAccidentals', "#(set-accidental-style 'piano)", str)
1988     str = re.sub (r'\\pianoCautionaries', "#(set-accidental-style 'piano-cautionary)", str)
1989     str = re.sub (r'\\forgetAccidentals', "#(set-accidental-style 'forget)", str)
1990     str = re.sub (r'\\noResetKey', "#(set-accidental-style 'no-reset)", str)
1991
1992     return str
1993
1994 conversions.append (((2,1,25), conv, _ ("Scheme grob function renaming")))
1995
1996
1997 def conv (str):
1998     str = re.sub ('ly:set-grob-property!', 'ly:grob-set-property!',str)
1999     str = re.sub ('ly:set-mus-property!', 'ly:music-set-property!',str)
2000     str = re.sub ('ly:set-context-property!', 'ly:context-set-property!', str)
2001     str = re.sub ('ly:get-grob-property', 'ly:grob-property',str)
2002     str = re.sub ('ly:get-mus-property', 'ly:music-property',str)
2003     str = re.sub ('ly:get-context-property', 'ly:context-property',str)
2004
2005     return str
2006
2007 conversions.append (((2,1,26), conv, _ ("More Scheme function renaming")))
2008
2009 def conv (str):
2010     def subst (m):
2011         g = int (m.group (2))
2012         o = g / 12
2013         g -= o * 12
2014         if g <  0:
2015             g += 12
2016             o -= 1
2017
2018
2019         lower_pitches = filter (lambda x : x <= g, [0, 2, 4, 5, 7, 9, 11, 12])
2020         s = len (lower_pitches) -1
2021         a = g - lower_pitches [-1]
2022
2023
2024         print s , lower_pitches, g, a, s
2025         str = 'cdefgab' [s]
2026         str += ['eses', 'es', '', 'is', 'isis'][a + 2]
2027         if o < 0:
2028             str += ',' * (-o - 1)
2029         elif o >= 0:
2030             str += "'" * (o + 1)
2031
2032         return '\\transposition %s ' % str
2033
2034
2035     str = re.sub (r"\\set ([A-Za-z]+\s*\.\s*)?transposing\s*=\s*#([-0-9]+)",
2036                   subst, str)
2037     return str
2038
2039 conversions.append (((2,1,27), conv, """property transposing -> tuning"""))
2040
2041 def conv (str):
2042     str = re.sub (r'make-music-by-name', 'make-music', str)
2043     str = re.sub (r"\\override\s+.*Arpeggio\s+#.print-function\s+=\s+\\arpeggioBracket", r"\\arpeggioBracket", str)
2044     return str
2045
2046 conversions.append (((2,1,28), conv,
2047                      """make-music-by-name -> make-music,
2048 new syntax for setting \\arpeggioBracket"""))
2049
2050 def conv (str):
2051     str = re.sub (r'\\center([^-])', '\\center-align\\1', str)
2052     str = re.sub (r'\\translator', '\\context', str)
2053     return str
2054
2055 conversions.append (((2,1,29), conv,
2056                      '\\center -> \\center-align, \\translator -> \\context'))
2057
2058
2059 def conv (str):
2060     str = re.sub (r'\\threeq(flat|sharp)', r'\\sesqui\1', str)
2061     str = re.sub (r'ly:stencil-get-extent',
2062                   'ly:stencil-extent', str)
2063     str = re.sub (r'ly:translator-find',
2064                   'ly:context-find', str)
2065     str = re.sub ('ly:unset-context-property','ly:context-unset-property',
2066                   str)
2067
2068     str = re.sub (r'ly:get-mutable-properties',
2069                   'ly:mutable-music-properties',str)
2070     str = re.sub (r'centralCPosition',
2071                   'middleCPosition',str)
2072     return str
2073
2074 conversions.append (((2,1,30), conv,
2075                      '''\\threeq{flat,sharp} -> \\sesqui{flat,sharp}
2076 ly:get-mutable-properties -> ly:mutable-music-properties
2077 centralCPosition -> middleCPosition
2078 ly:unset-context-property -> ly:context-unset-property
2079 ly:translator-find -> ly:context-find
2080 ly:get-stencil-extent -> ly:stencil-extent
2081 '''))
2082
2083
2084 def conv (str):
2085     str = re.sub (r'\\alias\s*"?Timing"?', '', str)
2086     return str
2087
2088 conversions.append (((2,1,31), conv,
2089                      '''remove \\alias Timing'''))
2090
2091 def conv (str):
2092     str = re.sub (r"(\\set\s+)?(?P<context>(Score\.)?)breakAlignOrder\s*=\s*#'(?P<list>[^\)]+)",
2093                   r"\n\\override \g<context>BreakAlignment #'break-align-orders = "
2094                   + "#(make-vector 3 '\g<list>)", str)
2095
2096     return str
2097
2098 conversions.append (((2,1,33), conv,
2099                      '''breakAlignOrder -> break-align-orders.'''))
2100
2101 def conv (str):
2102     str = re.sub (r"\(set-paper-size",
2103                   "(set-default-paper-size",str)
2104     return str
2105
2106 conversions.append (((2,1,34), conv,
2107                      '''set-paper-size -> set-default-paper-size.'''))
2108
2109 def conv (str):
2110     str = re.sub (r"ly:mutable-music-properties",
2111                   "ly:music-mutable-properties", str)
2112     return str
2113
2114 conversions.append (((2,1, 36), conv,
2115                      '''ly:mutable-music-properties -> ly:music-mutable-properties'''))
2116
2117
2118
2119 def conv (str):
2120     return str
2121
2122 conversions.append (((2, 2, 0), conv,
2123                      _ ("bump version for release")))
2124
2125 def conv (str):
2126     return re.sub (r'\\apply\b', r'\\applymusic', str)
2127
2128 conversions.append (((2, 3, 1), conv,
2129                      '''\\apply -> \\applymusic'''))
2130
2131 def conv (str):
2132     if re.search ('textheight', str):
2133         stderr_write ('\n')
2134         stderr_write (NOT_SMART % "textheight")
2135         stderr_write ('\n')
2136         stderr_write (UPDATE_MANUALLY)
2137         stderr_write ('\n')
2138         stderr_write (
2139 _ ("""Page layout has been changed, using paper size and margins.
2140 textheight is no longer used.
2141 """))
2142     str = re.sub (r'\\OrchestralScoreContext', '\\Score', str)
2143     def func(m):
2144         if m.group(1) not in ['RemoveEmptyStaff',
2145                               'AncientRemoveEmptyStaffContext',
2146                               'EasyNotation']:
2147             return '\\' + m.group (1)
2148         else:
2149             return m.group (0)
2150
2151
2152     str = re.sub (r'\\([a-zA-Z]+)Context\b', func, str)
2153     str = re.sub ('ly:paper-lookup', 'ly:output-def-lookup', str)
2154     return str
2155
2156 conversions.append (((2, 3, 2), conv,
2157                      '''\\FooContext -> \\Foo'''))
2158
2159 def conv (str):
2160     str = re.sub (r'\\notes\b', '', str)
2161
2162     return str
2163
2164 conversions.append (((2, 3, 4), conv,
2165                      _ ('remove %s') % '\\notes'))
2166
2167
2168
2169 def conv (str):
2170     str = re.sub (r'lastpagefill\s*=\s*"?1"', 'raggedlastbottom = ##t', str)
2171     return str
2172
2173 conversions.append (((2, 3, 6), conv,
2174                      '''lastpagefill -> raggedlastbottom'''))
2175
2176
2177
2178 def conv (str):
2179     str = re.sub (r'\\consistsend', '\\consists', str)
2180     str = re.sub (r'\\lyricsto\s+("?[a-zA-Z]+"?)(\s*\\new Lyrics\s*)?\\lyrics',
2181                   r'\\lyricsto \1 \2', str)
2182     return str
2183
2184 conversions.append (((2, 3, 8), conv,
2185                      '''remove \\consistsend, strip \\lyrics from \\lyricsto.'''))
2186
2187 def conv (str):
2188     str = re.sub (r'neo_mensural', 'neomensural', str)
2189     str = re.sub (r'if-text-padding', 'bound-padding', str)
2190     return str
2191
2192 conversions.append (((2, 3, 9), conv,
2193                      '''neo_mensural -> neomensural, if-text-padding -> bound-padding'''))
2194
2195
2196
2197 def conv (str):
2198     str = re.sub (r'\\addlyrics', r'\\oldaddlyrics', str)
2199     str = re.sub (r'\\newlyrics', r'\\addlyrics', str)
2200     if re.search (r"\\override\s*TextSpanner", str):
2201         stderr_write ("\nWarning: TextSpanner has been split into DynamicTextSpanner and TextSpanner\n")
2202     return str
2203
2204 conversions.append (((2, 3, 10), conv,
2205                      '''\\addlyrics -> \\oldaddlyrics, \\newlyrics -> \\addlyrics'''))
2206
2207 def conv (str):
2208     str = re.sub (r'\\setMmRestFermata\s+(R[0-9.*/]*)',
2209                   r'\1^\\fermataMarkup', str)
2210     return str
2211
2212 conversions.append (((2, 3, 11), conv,
2213                      '''\\setMmRestFermata -> ^\\fermataMarkup'''))
2214
2215 def conv (str):
2216     str = re.sub (r'\\newpage', r'\\pageBreak', str)
2217     str = re.sub (r'\\scriptUp', r"""{
2218 \\override TextScript  #'direction = #1
2219 \\override Script  #'direction = #1
2220 }""", str)
2221     str = re.sub (r'\\scriptDown', r"""{
2222   \\override TextScript  #'direction = #-1
2223   \\override Script  #'direction = #-1
2224 }""", str)
2225     str = re.sub (r'\\scriptBoth', r"""{
2226   \\revert TextScript  #'direction
2227   \\revert Script  #'direction
2228 }""", str)
2229     str = re.sub ('soloADue', 'printPartCombineTexts', str)
2230     str = re.sub (r'\\applymusic\s*#notes-to-clusters',
2231                       '\\makeClusters', str)
2232     
2233     str = re.sub (r'pagenumber\s*=', 'firstpagenumber = ', str)
2234     return str
2235
2236 conversions.append (((2, 3, 12), conv,
2237                      '''\\newpage -> \\pageBreak, junk \\script{up,down,both},
2238 soloADue -> printPartCombineTexts, #notes-to-clusters -> \\makeClusters
2239 '''))
2240
2241
2242 def conv (str):
2243     str = re.sub (r'\\chords\b', r'\\chordmode', str)
2244     str = re.sub (r'\\lyrics\b', r'\\lyricmode', str)
2245     str = re.sub (r'\\figures\b', r'\\figuremode', str)
2246     str = re.sub (r'\\notes\b', r'\\notemode', str)
2247     str = re.sub (r'\\drums\b', r'\\drummode', str)
2248     str = re.sub (r'\\chordmode\s*\\new ChordNames', r'\\chords', str)
2249     str = re.sub (r'\\new ChordNames\s*\\chordmode', r'\\chords', str)
2250     str = re.sub (r'\\new FiguredBass\s*\\figuremode', r'\\figures', str)
2251     str = re.sub (r'\\figuremode\s*\new FiguredBass', r'\\figures', str)
2252     str = re.sub (r'\\new DrumStaff\s*\\drummode', r'\\drums', str)
2253     str = re.sub (r'\\drummode\s*\\new DrumStaff', r'\\drums', str)
2254
2255     return str
2256
2257 conversions.append (((2, 3, 16), conv,
2258                      _ ('''\\foo -> \\foomode (for chords, notes, etc.)
2259 fold \\new FooContext \\foomode into \\foo.''')))
2260
2261 def conv (str):
2262     str = re.sub (r'(slur|stem|phrasingSlur|tie|dynamic|dots|tuplet|arpeggio|)Both', r'\1Neutral', str)
2263     str = re.sub (r"\\applymusic\s*#\(remove-tag\s*'([a-z-0-9]+)\)",
2264                   r"\\removeWithTag #'\1", str)
2265     return str
2266
2267 conversions.append (((2, 3, 17), conv,
2268                      '''slurBoth -> slurNeutral, stemBoth -> stemNeutral, etc.
2269 \\applymusic #(remove-tag 'foo) -> \\removeWithTag 'foo'''))
2270
2271
2272 def conv (str):
2273     str = re.sub (r'Text_item', 'Text_interface', str)
2274     return str
2275
2276 conversions.append (((2, 3, 18),
2277                      conv,
2278                      '''Text_item -> Text_interface''' ))
2279
2280 def conv (str):
2281     str = re.sub (r'\\paper', r'\\layout', str)
2282     str = re.sub (r'\\bookpaper', r'\\paper', str)
2283     if re.search ('paper-set-staff-size', str):
2284         warning (_ ('''staff size should be changed at top-level
2285 with
2286
2287   #(set-global-staff-size <STAFF-HEIGHT-IN-POINT>)
2288
2289 '''))
2290
2291
2292     str = re.sub (r'#\(paper-set-staff-size', '%Use set-global-staff-size at toplevel\n% #(layout-set-staff-size', str)
2293     return str
2294     
2295 conversions.append (((2, 3, 22),
2296                      conv,
2297                      '''paper -> layout, bookpaper -> paper''' ))
2298
2299
2300 def conv (str):
2301     str = re.sub (r'\\context\s+([a-zA-Z]+)\s*=\s*([a-z]+)\s',
2302                   r'\\context \1 = "\2" ',
2303                   str )
2304     return str
2305
2306 conversions.append (((2, 3, 23),
2307                      conv,
2308                      '''\context Foo = NOTENAME -> \context Foo = "NOTENAME"'''))
2309
2310 def conv (str):
2311     def sub(m):
2312         return regularize_id (m.group (1))
2313     str = re.sub (r'(maintainer_email|maintainer_web|midi_stuff|gourlay_maxmeasures)',
2314                   sub, str)
2315     return str
2316
2317 conversions.append (((2, 3, 24),
2318                      conv,
2319                      _ ('''regularize other identifiers''')))
2320
2321 def conv (str):
2322     str = re.sub ('petrucci_c1', 'petrucci-c1', str)
2323     str = re.sub ('1style', 'single-digit', str)
2324     return str
2325
2326 conversions.append (((2, 3, 25),
2327                      conv,
2328                      '''petrucci_c1 -> petrucci-c1, 1style -> single-digit'''))
2329
2330
2331 def conv (str):
2332     return str
2333
2334 conversions.append (((2, 4, 0),
2335                      conv,
2336                      _ ("bump version for release")))
2337
2338
2339 def conv (str):
2340     str = re.sub (r'\\quote\s+"?([a-zA-Z0-9]+)"?\s+([0-9.*/]+)',
2341                   r'\\quoteDuring #"\1" { \skip \2 }',
2342                   str)
2343     return str
2344
2345 conversions.append (((2, 5, 0),
2346                      conv,
2347                      '\\quote -> \\quoteDuring'))
2348
2349
2350 def conv (str):
2351     str = re.sub (r'ly:import-module',
2352                   r'ly:module-copy', str)
2353     return str
2354
2355 conversions.append (((2, 5, 1),
2356                      conv,
2357                      'ly:import-module -> ly:module-copy'))
2358
2359 def conv (str):
2360     str = re.sub (r'\\(column|fill-line|dir-column|center-align|right-align|left-align|bracketed-y-column)\s*<(([^>]|<[^>]*>)*)>',
2361                   r'\\\1 {\2}', str)
2362     str = re.sub (r'\\(column|fill-line|dir-column|center-align|right-align|left-align|bracketed-y-column)\s*<(([^>]|<[^>]*>)*)>',
2363                   r'\\\1 {\2}', str)
2364     str = re.sub (r'\\(column|fill-line|dir-column|center-align|right-align|left-align|bracketed-y-column)\s*<(([^>]|<[^>]*>)*)>',
2365                   r'\\\1 {\2}', str)
2366     def get_markup (m):
2367         s = m.group (0)
2368         s = re.sub (r'''((\\"|})\s*){''', '\2 \\line {', s)
2369         return s
2370     str = re.sub (r'\\markup\s*{([^}]|{[^}]*})*}', get_markup, str)
2371     return str
2372
2373 conversions.append (((2, 5, 2),
2374                      conv,
2375                      '\markup .. < .. > .. -> \markup .. { .. } ..'))
2376
2377 def conv (str):
2378     str = re.sub ('ly:find-glyph-by-name', 'ly:font-get-glyph', str)
2379     str = re.sub ('"(scripts|clefs|accidentals)-', r'"\1.', str)
2380     str = re.sub ("'hufnagel-do-fa", "'hufnagel.do.fa", str)
2381     str = re.sub ("'(vaticana|hufnagel|medicaea|petrucci|neomensural|mensural)-", r"'\1.", str)
2382     return str
2383
2384 conversions.append (((2, 5, 3),
2385                      conv,
2386                      'ly:find-glyph-by-name -> ly:font-get-glyph, remove - from glyphnames.'))
2387
2388
2389 def conv (str):
2390     str = re.sub (r"\\override\s+(Voice\.)?Slur #'dashed\s*=\s*#\d*(\.\d+)?",
2391                   r"\\slurDashed", str)
2392     return str
2393
2394 conversions.append (((2, 5, 12),
2395                      conv,
2396                      '\set Slur #\'dashed = #X -> \slurDashed'))
2397
2398 def conv (str):
2399     input_encoding = 'latin1'
2400     def func (match):
2401         encoding = match.group (1)
2402
2403         # FIXME: automatic recoding of other than latin1?
2404         if encoding == 'latin1':
2405             return match.group (2)
2406
2407         stderr_write ('\n')
2408         stderr_write (NOT_SMART % ("\\encoding: %s" % encoding))
2409         stderr_write ('\n')
2410         stderr_write (_ ("LilyPond source must be UTF-8"))
2411         stderr_write ('\n')
2412         if encoding == 'TeX':
2413             stderr_write (_ ("Try the texstrings backend"))
2414             stderr_write ('\n')
2415         else:
2416             stderr_write ( _("Do something like: %s") % \
2417                                ("recode %s..utf-8 FILE" % encoding))
2418             stderr_write ('\n')
2419         stderr_write (_ ("Or save as UTF-8 in your editor"))
2420         stderr_write ('\n')
2421         raise FatalConversionError ()
2422
2423         return match.group (0)
2424
2425     str = re.sub (r'\\encoding\s+"?([a-zA-Z0-9]+)"?(\s+)', func, str)
2426
2427     import codecs
2428     de_ascii = codecs.getdecoder ('ascii')
2429     de_utf_8 = codecs.getdecoder ('utf_8')
2430     de_input = codecs.getdecoder (input_encoding)
2431     en_utf_8 = codecs.getencoder ('utf_8')
2432     try:
2433         de_ascii (str)
2434     # only in python >= 2.3
2435     # except UnicodeDecodeError:
2436     except UnicodeError:
2437         # do not re-recode UTF-8 input
2438         try:
2439             de_utf_8 (str)
2440         #except UnicodeDecodeError:
2441         except UnicodeError:
2442             str = en_utf_8 (de_input (str)[0])[0]
2443
2444
2445
2446     str = re.sub (r"#\(ly:set-point-and-click '[a-z-]+\)", '', str)
2447     return str
2448
2449 conversions.append (((2, 5, 13),
2450                      conv,
2451                      _ ('\\encoding: smart recode latin1..utf-8. Remove ly:point-and-click')))
2452
2453
2454 def conv (str):
2455     if re.search ("ly:stencil-set-extent!", str):
2456         stderr_write ('\n')
2457         stderr_write (NOT_SMART % "ly:stencil-set-extent!")
2458         stderr_write ('\n')
2459         stderr_write ('use (set! VAR (ly:make-stencil (ly:stencil-expr VAR) X-EXT Y-EXT))\n')
2460         raise FatalConversionError ()
2461     if re.search ("ly:stencil-align-to!", str):
2462         stderr_write ('\n')
2463         stderr_write (NOT_SMART % "ly:stencil-align-to!")
2464         stderr_write ('\n')
2465         stderr_write ('use (set! VAR (ly:stencil-aligned-to VAR AXIS DIR))\n')
2466         raise FatalConversionError ()
2467     return str
2468
2469 conversions.append (((2, 5, 17),
2470                      conv,
2471                      _ ('remove %s') % 'ly:stencil-set-extent!'))
2472
2473 def conv (str):
2474     str = re.sub (r"ly:warn\b", 'ly:warning', str)
2475     return str
2476
2477 conversions.append (((2, 5, 18),
2478                      conv,
2479                      'ly:warn -> ly:warning'))
2480 def conv (str):
2481     if re.search ("(override-|revert-)auto-beam-setting", str)\
2482        or re.search ("autoBeamSettings", str):
2483         stderr_write ('\n')
2484         stderr_write (NOT_SMART % _ ("auto beam settings"))
2485         stderr_write ('\n')
2486         stderr_write (_ ('''
2487 Auto beam settings must now specify each interesting moment in a measure
2488 explicitely; 1/4 is no longer multiplied to cover moments 1/2 and 3/4 too.
2489 '''))
2490         stderr_write (UPDATE_MANUALLY)
2491         stderr_write ('\n')
2492         raise FatalConversionError ()
2493     return str
2494
2495 conversions.append (((2, 5, 21),
2496                      conv,
2497                      _ ('warn about auto beam settings')))
2498
2499 def conv (str):
2500     str = re.sub (r"unfoldrepeats", 'unfoldRepeats', str)
2501     str = re.sub (r"compressmusic", 'compressMusic', str)
2502     return str
2503
2504 conversions.append (((2, 5, 25), conv,
2505              'unfoldrepeats -> unfoldRepeats, compressmusic -> compressMusic'))
2506
2507 def conv (str):
2508     return str
2509
2510 conversions.append (((2, 6, 0), conv,
2511                      _ ("bump version for release")))
2512
2513
2514
2515 def conv (str):
2516     return re.sub('ly:get-default-font', 'ly:grob-default-font', str) 
2517
2518 conversions.append (((2, 7, 0), conv,
2519                      'ly:get-default-font -> ly:grob-default-font'))
2520
2521 def conv (str):
2522     str = re.sub('ly:parser-define', 'ly:parser-define!', str)
2523     str = re.sub('excentricity', 'eccentricity', str)
2524     str = re.sub(r'\\(consists|remove) *"?Timing_engraver"?',
2525                  r'\\\1 "Timing_translator" \\\1 "Default_bar_line_engraver"',
2526                  str)
2527     return str
2528
2529 conversions.append (((2, 7, 1), conv,
2530                      '''ly:parser-define -> ly:parser-define!
2531 excentricity -> eccentricity
2532 Timing_engraver -> Timing_translator + Default_bar_line_engraver
2533 '''))
2534
2535
2536 def conv (str):
2537     str = re.sub('ly:(add|mul|mod|div)-moment', r'ly:moment-\1', str)
2538     return str
2539
2540 conversions.append (((2, 7, 2), conv,
2541                      '''ly:X-moment -> ly:moment-X'''))
2542
2543
2544 def conv (str):
2545     str = re.sub('keyAccidentalOrder', 'keyAlterationOrder', str)
2546     return str
2547
2548 conversions.append (((2, 7, 4), conv,
2549                      '''keyAccidentalOrder -> keyAlterationOrder'''))
2550
2551
2552
2553 def conv (str):
2554     str = re.sub('Performer_group_performer', 'Performer_group', str)
2555     str = re.sub('Engraver_group_engraver', 'Engraver_group', str)
2556     str = re.sub (r"#'inside-slur\s*=\s*##t *",
2557                   r"#'avoid-slur = #'inside ", str)
2558     str = re.sub (r"#'inside-slur\s*=\s*##f *",
2559                   r"#'avoid-slur = #'around ", str)
2560     str = re.sub (r"#'inside-slur",
2561                   r"#'avoid-slur", str)
2562     return str
2563
2564 conversions.append (((2, 7, 6), conv,
2565                      '''Performer_group_performer -> Performer_group, Engraver_group_engraver -> Engraver_group,
2566 inside-slur -> avoid-slur'''))
2567
2568
2569
2570 def conv (str):
2571     str = re.sub(r'\\applyoutput', r'\\applyOutput', str)
2572     str = re.sub(r'\\applycontext', r'\\applyContext', str)
2573     str = re.sub(r'\\applymusic',  r'\\applyMusic', str)
2574     str = re.sub(r'ly:grob-suicide', 'ly:grob-suicide!', str)
2575     return str
2576
2577 conversions.append (((2, 7, 10), conv,
2578                      '''\\applyxxx -> \\applyXxx'''))
2579
2580
2581
2582 def conv (str):
2583     str = re.sub(r'\"tabloid\"', '"11x17"', str)
2584     return str
2585
2586 conversions.append (((2, 7, 11), conv,
2587                      '''\"tabloid\" -> \"11x17\"'''))
2588
2589 def conv (str):
2590     str = re.sub(r'outputProperty' , 'overrideProperty', str)
2591     return str
2592
2593 conversions.append (((2, 7, 12), conv,
2594                      '''outputProperty -> overrideProperty'''))
2595
2596
2597 def conv (str):
2598     def subber (match):
2599         newkey = {'spacing-procedure': 'springs-and-rods',
2600                   'after-line-breaking-callback' : 'after-line-breaking',
2601                   'before-line-breaking-callback' : 'before-line-breaking',
2602                   'print-function' : 'stencil'} [match.group(3)]
2603         what = match.group (1)
2604         grob = match.group (2)
2605
2606         if what == 'revert':
2607             return "revert %s #'callbacks %% %s\n" % (grob, newkey)
2608         elif what == 'override':
2609             return "override %s #'callbacks #'%s" % (grob, newkey)
2610         else:
2611             raise 'urg'
2612             return ''
2613
2614     str = re.sub(r"(override|revert)\s*([a-zA-Z.]+)\s*#'(spacing-procedure|after-line-breaking-callback"
2615                 + r"|before-line-breaking-callback|print-function)",
2616                 subber, str)
2617
2618     if re.search ('bar-size-procedure', str):
2619         stderr_write (NOT_SMART % "bar-size-procedure")
2620     if re.search ('space-function', str):
2621         stderr_write (NOT_SMART % "space-function")
2622     if re.search ('verticalAlignmentChildCallback', str):
2623         stderr_write (_ ('verticalAlignmentChildCallback has been deprecated'))
2624     return str
2625
2626 conversions.append (((2, 7, 13), conv,
2627                      '''layout engine refactoring [FIXME]'''))
2628
2629
2630
2631 def conv (str):
2632     str = re.sub (r"\\override +([A-Z.a-z]+) #'callbacks",
2633                   r"\\override \1", str)
2634     str = re.sub (r"\\revert ([A-Z.a-z]+) #'callbacks % ([a-zA-Z]+)",
2635                   r"\\revert \1 #'\2", str)
2636     str = re.sub (r"([XY]-extent)-callback", r'\1', str)
2637     str = re.sub (r"RemoveEmptyVerticalGroup", "VerticalAxisGroup", str)
2638     str = re.sub (r"\\set ([a-zA-Z]*\.?)minimumVerticalExtent",
2639                   r"\\override \1VerticalAxisGroup #'minimum-Y-extent",
2640                   str)
2641     str = re.sub (r"minimumVerticalExtent",
2642                   r"\\override VerticalAxisGroup #'minimum-Y-extent",
2643                   str)
2644     str = re.sub (r"\\set ([a-zA-Z]*\.?)extraVerticalExtent",
2645                   r"\\override \1VerticalAxisGroup #'extra-Y-extent", str)
2646     str = re.sub (r"\\set ([a-zA-Z]*\.?)verticalExtent",
2647                   r"\\override \1VerticalAxisGroup #'Y-extent", str)
2648     return str
2649
2650 conversions.append (((2, 7, 14), conv,
2651                      _ ('Remove callbacks property, deprecate XY-extent-callback.')))
2652
2653
2654 def conv (str):
2655     if re.search ('[XY]-offset-callbacks', str):
2656         stderr_write (NOT_SMART % "[XY]-offset-callbacks")
2657     if re.search ('position-callbacks', str):
2658         stderr_write (NOT_SMART % "position-callbacks")
2659     return str
2660
2661 conversions.append (((2, 7, 15), conv,
2662                      _ ('Use grob closures iso. XY-offset-callbacks.')))
2663
2664
2665 def conv (str):
2666     def sub_syms (m):
2667         syms =  m.group (1).split ()
2668         tags = ["\\tag #'%s" % s for s in syms]
2669         return ' '.join (tags)
2670
2671     str = re.sub (r"\\tag #'\(([^)]+)\)",  sub_syms, str)
2672     return str
2673
2674 conversions.append (((2, 7, 22), conv,
2675                      """\tag #'(a b) -> \tag #'a \tag #'b""" ))
2676
2677 def conv (str):
2678     str = re.sub (r"#'number-visibility",
2679                   "#'number-visibility % number-visibility is deprecated. Tune the TupletNumber instead\n",
2680                   str)
2681     return str
2682
2683 conversions.append (((2, 7, 24), conv,
2684                      _ ('deprecate %s') % 'number-visibility')) 
2685
2686 def conv (str):
2687     str = re.sub (r"ly:spanner-get-bound", "ly:spanner-bound", str)
2688     return str
2689
2690 conversions.append (((2, 7, 28), conv,
2691                      """ly:spanner-get-bound -> ly:spanner-bound"""))
2692
2693 def conv (str):
2694     for a in ['beamed-lengths', 'beamed-minimum-free-lengths',
2695               'lengths',
2696               'beamed-extreme-minimum-free-lengths']:
2697         str = re.sub (r"\\override\s+Stem\s+#'%s" % a,
2698                       r"\\override Stem #'details #'%s" % a,
2699                       str)
2700     return str
2701
2702 conversions.append (((2, 7, 29), conv,
2703                      """override Stem #'beamed-* -> #'details #'beamed-*"""))
2704
2705 def conv (str):
2706     str = re.sub (r'\\epsfile *#"', r'\\epsfile #X #10 #"', str)
2707     return str
2708
2709 conversions.append (((2, 7, 30), conv,
2710                      """\\epsfile"""))
2711
2712
2713 def conv (str):
2714     def sub_cxx_id (m):
2715         str = m.group(1)
2716         return 'ly:' + str.lower ().replace ('_','-')
2717
2718     str = re.sub (r'([A-Z][a-z_0-9]+::[a-z_0-9]+)',
2719                   sub_cxx_id, str)
2720     return str
2721
2722 conversions.append (((2, 7, 31), conv,
2723                      """Foo_bar::bla_bla -> ly:foo-bar::bla-bla"""))
2724
2725
2726 def conv (str):
2727     identifier_subs = [
2728             ('inputencoding', 'input-encoding'),
2729             ('printpagenumber', 'print-page-number'),
2730             ('outputscale', 'output-scale'),
2731             ('betweensystemspace', 'between-system-space'),
2732             ('betweensystempadding', 'between-system-padding'),
2733             ('pagetopspace', 'page-top-space'),
2734             ('raggedlastbottom', 'ragged-last-bottom'),
2735             ('raggedright', 'ragged-right'),
2736             ('raggedlast', 'ragged-last'),
2737             ('raggedbottom', 'ragged-bottom'),
2738             ('aftertitlespace', 'after-title-space'),
2739             ('beforetitlespace', 'before-title-space'),
2740             ('betweentitlespace', 'between-title-space'),
2741             ('topmargin', 'top-margin'),
2742             ('bottommargin', 'bottom-margin'),
2743             ('headsep', 'head-separation'),
2744             ('footsep', 'foot-separation'),
2745             ('rightmargin', 'right-margin'),
2746             ('leftmargin', 'left-margin'),
2747             ('printfirstpagenumber', 'print-first-page-number'),
2748             ('firstpagenumber', 'first-page-number'),
2749             ('hsize', 'paper-width'),
2750             ('vsize', 'paper-height'),
2751             ('horizontalshift', 'horizontal-shift'),
2752             ('staffspace', 'staff-space'),
2753             ('linethickness', 'line-thickness'),
2754             ('ledgerlinethickness', 'ledger-line-thickness'),
2755             ('blotdiameter', 'blot-diameter'),
2756             ('staffheight', 'staff-height'),
2757             ('linewidth', 'line-width'),
2758             ('annotatespacing', 'annotate-spacing')
2759             ]
2760
2761     for (a,b)  in identifier_subs:
2762         ### for C++:
2763         ## str = re.sub ('"%s"' % a, '"%s"' b, str)
2764
2765         str = re.sub (a, b, str)
2766     return str
2767
2768 conversions.append (((2, 7, 32), conv,
2769                      _ ("foobar -> foo-bar for \paper, \layout")))
2770
2771 def conv (str):
2772     str = re.sub ('debug-beam-quanting', 'debug-beam-scoring', str)
2773     return str
2774
2775 conversions.append (((2, 7, 32), conv,
2776                      """debug-beam-quanting -> debug-beam-scoring"""))
2777
2778 def conv (str):
2779     str = re.sub ('def-music-function', 'define-music-function', str)
2780     str = re.sub ('def-markup-command', 'define-markup-command', str)
2781     return str
2782
2783 conversions.append (((2, 7, 36), conv,
2784                     """def-(music-function|markup-command) -> define-(music-function|markup-command)"""))
2785
2786
2787
2788 def conv (str):
2789     str = re.sub (r'\\set\s+Score\s*\.\s*barNumberAlignSymbol\s*=',
2790                   r"\\override Score.BarNumber #'break-align-symbol = ", str)
2791     str = re.sub (r'\\set\s*Score\s*\.\s*rehearsalMarkAlignSymbol\s*=',
2792                   r"\\override Score.RehearsalMark #'break-align-symbol = ", str)
2793     return str
2794
2795 conversions.append (((2, 7, 40), conv,
2796                     "rehearsalMarkAlignSymbol/barNumberAlignSymbol -> break-align-symbol"))
2797
2798
2799 def conv (str):
2800     str = re.sub ('page-penalty', 'page-break-penalty', str)
2801     str = re.sub ('([^-])penalty', '\1break-penalty', str)
2802     return str
2803
2804 conversions.append (((2, 9, 4), conv, """(page-)penalty -> (page-)break-penalty"""))
2805
2806 def conv (str):
2807     str = re.sub (r'\\context\s+\"?([a-zA-Z]+)\"?\s*\\applyOutput', r"\\applyOutput #'\1", str)
2808     return str
2809
2810 conversions.append (((2, 9, 6), conv, """\context Foo \\applyOutput #bla -> \\applyOutput #'Foo #bla """))
2811
2812
2813 def conv (str):
2814     str = re.sub ('annotatepage', 'annotate-page', str)
2815     str = re.sub ('annotateheaders', 'annotate-headers', str)
2816     str = re.sub ('annotatesystems', 'annotate-systems', str)
2817     return str
2818
2819 conversions.append (((2, 9, 9), conv, """annotatefoo -> annotate-foo"""))
2820
2821
2822 def conv (str):
2823     str = re.sub (r"""(\\set\s)?(?P<context>[a-zA-Z]*.?)tupletNumberFormatFunction\s*=\s*#denominator-tuplet-formatter""",
2824                   r"""\\override \g<context>TupletNumber #'text = #tuplet-number::calc-denominator-text""", str)
2825
2826     str = re.sub (r"""(\\set\s+)?(?P<context>[a-zA-Z]*.?)tupletNumberFormatFunction\s*=\s*#fraction-tuplet-formatter""",
2827                   r"""\\override \g<context>TupletNumber #'text = #tuplet-number::calc-fraction-text""", str)
2828
2829     if re.search ('tupletNumberFormatFunction', str):
2830         stderr_write ("\n")
2831         stderr_write ("tupletNumberFormatFunction has been removed. Use #'text property on TupletNumber")
2832         stderr_write ("\n")
2833         
2834     return str
2835
2836 conversions.append (((2, 9, 11), conv, """\\set tupletNumberFormatFunction -> \\override #'text = """))
2837
2838
2839 def conv (str):
2840     str = re.sub ('vocNam', 'shortVocalName', str)
2841     str = re.sub (r'\.instr\s*=', r'.shortInstrumentName =', str)
2842     str = re.sub (r'\.instrument\s*=', r'.instrumentName =', str)
2843     return str
2844
2845 conversions.append (((2, 9, 13), conv, """instrument -> instrumentName, instr -> shortInstrumentName, vocNam -> shortVocalName"""))
2846
2847
2848 def conv (str):
2849
2850     def sub_tempo (m):
2851         dur = int (m.group (1))
2852         dots = len (m.group (2))
2853         count = int (m.group (3))
2854
2855         log2 = 0
2856         while dur > 1 :
2857             dur /= 2
2858             log2 += 1
2859         
2860         den = (1 << dots) * (1 << log2)
2861         num = ((1 << (dots+1))  - 1)
2862
2863         return  """
2864   \midi {
2865     \context {
2866       \Score
2867       tempoWholesPerMinute = #(ly:make-moment %d %d)
2868       }
2869     }
2870
2871 """ % (num*count, den)
2872     
2873     str = re.sub (r'\\midi\s*{\s*\\tempo ([0-9]+)\s*([.]*)\s*=\s*([0-9]+)\s*}', sub_tempo, str)
2874     return str
2875
2876 conversions.append (((2, 9, 16), conv, _ ("deprecate \\tempo in \\midi")))
2877
2878 def conv (str):
2879     str = re.sub ('printfirst-page-number', 'print-first-page-number', str)
2880     return str
2881
2882 conversions.append (((2, 9, 19), conv, """printfirst-page-number -> print-first-page-number"""))
2883
2884
2885 def conv (str):
2886     return str
2887
2888 conversions.append (((2, 10, 0), conv, _ ("bump version for release")))
2889
2890
2891 def conv (str):
2892     return re.sub ('ly:clone-parser',
2893                    'ly:parser-clone', str)
2894
2895 conversions.append (((2, 11, 2), conv, """ly:clone-parser -> ly:parser-clone"""))
2896
2897
2898
2899 def conv (str):
2900     str = re.sub ("Accidental\s*#'cautionary-style\s*=\s*#'smaller",
2901                    "AccidentalCautionary #'font-size = #-2", str)
2902     str = re.sub ("Accidental\s*#'cautionary-style\s*=\s*#'parentheses",
2903                    "AccidentalCautionary #'parenthesized = ##t", str)
2904     str = re.sub ("([A-Za-z]+)\s*#'cautionary-style\s*=\s*#'parentheses",
2905                    r"\1 #'parenthesized = ##t", str)
2906     str = re.sub ("([A-Za-z]+)\s*#'cautionary-style\s*=\s*#'smaller",
2907                    r"\1 #'font-size = #-2", str)
2908     
2909     return str
2910
2911 conversions.append (((2, 11, 5), conv, _ ("deprecate cautionary-style. Use AccidentalCautionary properties")))
2912
2913                     
2914
2915
2916 def conv (str):
2917     
2918     def sub_acc_name (m):
2919         idx = int (m.group (1).replace ('M','-'))
2920         
2921         return ["accidentals.doublesharp",
2922                 "accidentals.sharp.slashslash.stemstemstem",
2923                 "accidentals.sharp",
2924                 "accidentals.sharp.slashslash.stem",
2925                 "accidentals.natural",
2926                 "accidentals.mirroredflat",
2927                 "accidentals.flat",
2928                 "accidentals.mirroredflat.flat",
2929                 "accidentals.flatflat"][4-idx]
2930
2931     str = re.sub (r"accidentals[.](M?[-0-9]+)",
2932                   sub_acc_name, str) 
2933     str = re.sub (r"(KeySignature|Accidental[A-Za-z]*)\s*#'style\s*=\s*#'([a-z]+)",
2934                   r"\1 #'glyph-name-alist = #alteration-\2-glyph-name-alist", str)
2935     ## FIXME: standard vs default, alteration-FOO vs FOO-alteration
2936     str = str.replace ('alteration-default-glyph-name-alist',
2937                        'standard-alteration-glyph-name-alist')
2938     return str
2939
2940 conversions.append (((2, 11, 6), conv, _ ("Rename accidental glyphs, use glyph-name-alist.")))
2941
2942
2943 def conv (str):
2944     str = re.sub (r'(\\set\s+)?([A-Z][a-zA-Z]+\s*\.\s*)allowBeamBreak',
2945                   r"\override \2Beam #'breakable", str)
2946     str = re.sub (r'(\\set\s+)?allowBeamBreak',
2947                   r"\override Beam #'breakable", str)
2948     str = re.sub (r'addquote' , 'addQuote', str)
2949     if re.search ("Span_dynamic_performer", str):
2950         stderr_write ("Span_dynamic_performer has been merged into Dynamic_performer")
2951
2952     return str
2953
2954 conversions.append (((2, 11, 10), conv, """allowBeamBreak -> Beam #'breakable = ##t
2955 addquote -> addQuote
2956 """))
2957
2958 def conv (str):
2959     str = re.sub (r'\(layout-set-staff-size \(\*\s*([0-9.]+)\s*(pt|mm|cm)\)\)',
2960                   r'(layout-set-absolute-staff-size (* \1 \2))', str)
2961     return str
2962
2963 conversions.append (((2, 11, 11), conv, """layout-set-staff-size -> layout-set-absolute-staff-size"""))
2964
2965
2966 def conv (str):
2967     str = re.sub (r"\\override\s*([a-zA-Z.]+)\s*#'arrow\s*=\s*##t",
2968                   r"\\override \1 #'bound-details #'right #'arrow = ##t",
2969                   str)
2970
2971     if re.search ('edge-text', str):
2972         stderr_write (NOT_SMART % _ ("edge-text settings for TextSpanner."))
2973         stderr_write (_ ("Use\n\n%s") %
2974                           "\t\\override TextSpanner #'bound-details #'right #'text = <right-text>\n"
2975                           "\t\\override TextSpanner #'bound-details #'left #'text = <left-text>\n")
2976
2977         
2978     return str
2979
2980 conversions.append (((2, 11, 13), conv, """#'arrow = ##t -> #'bound-details #'right #'arrow = ##t"""))
2981
2982 def conv (str):
2983     def sub_edge_height (m):
2984         s = ''
2985         for (var, h) in [('left', m.group (3)),
2986                          ('right', m.group (4))]:
2987
2988             if h and float (h):
2989                 once = m.group(1)
2990                 if not once:
2991                     once = ''
2992                     
2993                 s += (r"%s \override %s #'bound-details #'%s #'text = \markup { \draw-line #'(0 . %s) }"
2994                       % (once, m.group (2), var, h))
2995
2996                 s += '\n'
2997             
2998         return s
2999     
3000                   
3001     str = re.sub (r"(\\once)?\s*\\override\s*([a-zA-Z.]+)\s*#'edge-height\s*=\s*#'\(([0-9.-]+)\s+[.]\s+([0-9.-]+)\)",
3002                   sub_edge_height, str)
3003     return str
3004
3005 conversions.append (((2, 11, 15), conv, """#'edge-height -> #'bound-details #'right/left #'text = ..."""))
3006
3007 def conv (str):
3008     str = re.sub (r"\\override\s*([a-zA-Z.]+)\s*#'break-align-symbol\s*=\s*#'([a-z-]+)",
3009                   r"\\override \1 #'break-align-symbols = #'(\2)", str)
3010     return str
3011
3012 conversions.append (((2, 11, 23), conv, """#'break-align-symbol -> #'break-align-symbols"""))
3013
3014 def conv (str):
3015     str = re.sub (r"scripts\.caesura",
3016                   r"scripts.caesura.curved", str)
3017
3018     if re.search ('dash-fraction', str):
3019         stderr_write (NOT_SMART % _ ("all settings related to dashed lines.\n"))
3020         stderr_write (_ ("Use \\override ... #'style = #'line for solid lines and\n"))
3021         stderr_write (_ ("\t\\override ... #'style = #'dashed-line for dashed lines."))
3022
3023     return str
3024
3025 conversions.append (((2, 11, 35), conv, """scripts.caesura -> scripts.caesura.curved.
3026 """ + _ ("Use #'style not #'dash-fraction to select solid/dashed lines.")))
3027
3028 def conv (str):
3029     str = re.sub (r"setEasyHeads", r"easyHeadsOn", str)
3030     str = re.sub (r"fatText", r"textLengthOn", str)
3031     str = re.sub (r"emptyText", r"textLengthOff", str)
3032     return str
3033
3034 conversions.append (((2, 11, 38), conv, """\\setEasyHeads -> \\easyHeadsOn, \\fatText -> \\textLengthOn,
3035 \\emptyText -> \\textLengthOff"""))
3036
3037 def conv (str):
3038     str = re.sub (r"\\set\s+([a-zA-Z]+)\s*.\s*hairpinToBarline\s*=\s*##([tf]+)",
3039                   r"\\override \1.Hairpin #'to-barline = ##\2", str)
3040     str = re.sub (r"\\set\s+hairpinToBarline\s*=\s*##([tf]+)",
3041                   r"\\override Hairpin #'to-barline = ##\1", str)
3042     str = re.sub (r"\\unset\s+([a-zA-Z]+)\s*.\s*hairpinToBarline",
3043                   r"\\revert \1.Hairpin #'to-barline", str)
3044     str = re.sub (r"\\unset\s+hairpinToBarline",
3045                   r"\\revert Hairpin #'to-barline", str)
3046     str = re.sub (r"hairpinToBarline\s*=\s*##([tf]+)",
3047                   r"\\override Hairpin #'to-barline = ##\1", str)
3048     return str
3049
3050 conversions.append (((2, 11, 46), conv, """\\set hairpinToBarline -> \\override Hairpin #'to-barline"""))