Re: parser.yy et al: Turn \transpose into a music function, make other music functions use ly:pitch? (issue 4991049)

2011-09-11 Thread dak

Reviewers: Reinhold, J_lowe,

Message:
Made the requested spacing changes and pushed.

Description:
parser.yy et al: Turn \transpose into a music function.

This removes \transpose from its special treatment in the parser.

Please review this at http://codereview.appspot.com/4991049/

Affected files:
  M lily/lily-lexer.cc
  M lily/parser.yy
  M ly/music-functions-init.ly
  M scm/ly-syntax-constructors.scm
  M scm/modal-transforms.scm


Index: lily/lily-lexer.cc
diff --git a/lily/lily-lexer.cc b/lily/lily-lexer.cc
index  
ba6429c3ea2798344702178363f200071c0f73cc..47fd1522dba266d794f86fd502f220d5fcae10e3  
100644

--- a/lily/lily-lexer.cc
+++ b/lily/lily-lexer.cc
@@ -89,7 +89,6 @@ static Keyword_ent the_key_tab[]
   {tempo, TEMPO},
   {time, TIME_T},
   {times, TIMES},
-  {transpose, TRANSPOSE},
   {type, TYPE},
   {unset, UNSET},
   {with, WITH},
Index: lily/parser.yy
diff --git a/lily/parser.yy b/lily/parser.yy
index  
176b4a08777375b8b17332cc8828283f931feb1b..f72b7c0958d44d7610c23dd98d458c591d8b5c72  
100644

--- a/lily/parser.yy
+++ b/lily/parser.yy
@@ -216,7 +216,6 @@ void set_music_properties (Music *p, SCM a);
 %token SKIP \\skip
 %token TEMPO \\tempo
 %token TIMES \\times
-%token TRANSPOSE \\transpose
 %token TYPE \\type
 %token UNSET \\unset
 %token WITH \\with
@@ -1213,12 +1212,6 @@ prefix_composite_music:
 $$ = MAKE_SYNTAX (time-scaled-music, @$, $2, $3);
}
| repeated_music{ $$ = $1; }
-   | TRANSPOSE pitch_also_in_chords pitch_also_in_chords music {
-   Pitch from = *unsmob_pitch ($2);
-   Pitch to = *unsmob_pitch ($3);
-   SCM pitch = pitch_interval (from, to).smobbed_copy ();
-   $$ = MAKE_SYNTAX (transpose-music, @$, pitch, $4);
-   }
| mode_changing_head grouped_music_list {
if ($1 == ly_symbol2scm (chords))
{
Index: ly/music-functions-init.ly
diff --git a/ly/music-functions-init.ly b/ly/music-functions-init.ly
index  
b3a009860753c54d7ab7549617ab4ba6f32d3ae5..a0f232d66136fa6ca1bc088cb55f86ff14ba1fa1  
100644

--- a/ly/music-functions-init.ly
+++ b/ly/music-functions-init.ly
@@ -517,7 +517,7 @@ makeClusters =

 modalInversion =
 #(define-music-function (parser location around to scale music)
-(ly:music? ly:music? ly:music? ly:music?)
+(ly:pitch? ly:pitch? ly:music? ly:music?)
 (_i Invert @var{music} about @var{around} using @var{scale} and
 transpose from @var{around} to @var{to}.)
 (let ((inverter (make-modal-inverter around to scale)))
@@ -526,7 +526,7 @@ transpose from @var{around} to @var{to}.)

 modalTranspose =
 #(define-music-function (parser location from to scale music)
-(ly:music? ly:music? ly:music? ly:music?)
+(ly:pitch? ly:pitch? ly:music? ly:music?)
 (_i Transpose @var{music} from pitch @var{from} to pitch @var{to}
 using @var{scale}.)
 (let ((transposer (make-modal-transposer from to scale)))
@@ -535,7 +535,7 @@ using @var{scale}.)

 inversion =
 #(define-music-function
-   (parser location around to music) (ly:music? ly:music? ly:music?)
+   (parser location around to music) (ly:pitch? ly:pitch? ly:music?)
(_i Invert @var{music} about @var{around} and
 transpose from @var{around} to @var{to}.)
(music-invert around to music))
@@ -570,10 +570,10 @@ markups), or inside a score.)


 octaveCheck =
-#(define-music-function (parser location pitch-note) (ly:music?)
+#(define-music-function (parser location pitch) (ly:pitch?)
(_i Octave check.)
(make-music 'RelativeOctaveCheck
-  'pitch (pitch-of-note pitch-note)))
+  'pitch pitch))

 ottava =
 #(define-music-function (parser location octave) (integer?)
@@ -843,18 +843,13 @@ removeWithTag =
 music))

 resetRelativeOctave =
-#(define-music-function (parser location reference-note) (ly:music?)
+#(define-music-function (parser location pitch) (ly:pitch?)
(_i Set the octave inside a \\relative section.)

-   (let* ((notes (ly:music-property reference-note 'elements))
- (pitch (ly:music-property (car notes) 'pitch)))
-
- (set! (ly:music-property reference-note 'elements) '())
- (set! (ly:music-property reference-note 'to-relative-callback)
-  (lambda (music last-pitch)
-pitch))
-
- reference-note))
+   (make-music 'SequentialMusic
+  'to-relative-callback
+  (lambda (music last-pitch)
+pitch)))

 retrograde =
 #(define-music-function (parser location music)
@@ -875,16 +870,11 @@ rightHandFinger =
 #(define-music-function (parser location finger) (number-or-string?)
(_i Apply @var{finger} as a fingering indication.)

-   (apply make-music
- (append
-  (list
+   (make-music
'StrokeFingerEvent
-   'origin location)
-  (if  (string? finger)
-   (list 'text finger)
-   (list 'digit finger)
-
-
+   'origin location
+   (if (string? finger) 'text 'digit)
+ 

Re: parser.yy et al: Turn \transpose into a music function, make other music functions use ly:pitch? (issue 4991049)

2011-09-10 Thread pkx166h

passes make and reg tests

http://codereview.appspot.com/4991049/

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


parser.yy et al: Turn \transpose into a music function, make other music functions use ly:pitch? (issue 4991049)

2011-09-09 Thread reinhold . kainhofer

LGTM


http://codereview.appspot.com/4991049/diff/2001/ly/music-functions-init.ly
File ly/music-functions-init.ly (right):

http://codereview.appspot.com/4991049/diff/2001/ly/music-functions-init.ly#newcode852
ly/music-functions-init.ly:852: pitch)))
indent (or better, write the whole lambda in one line).

BTW, that's a nice catch that this function can be implemented so easy!

http://codereview.appspot.com/4991049/diff/2001/ly/music-functions-init.ly#newcode876
ly/music-functions-init.ly:876: (if (string? finger) 'text 'digit)
remove tab in the middle of the line;
Use 8 spaces instead of tabs (even if the old code also had tabs. We
want to get away from tabs ASAP).

http://codereview.appspot.com/4991049/

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