From: David Kastrup Date: Sun, 30 Oct 2011 07:09:57 +0000 (+0100) Subject: Replace \key with music function X-Git-Tag: release/2.15.17-1~8 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=1abee28bcf158a15477f570819ddfe36d4e51302;p=lilypond.git Replace \key with music function --- diff --git a/lily/lily-lexer.cc b/lily/lily-lexer.cc index b19639b579..6383ab9a94 100644 --- a/lily/lily-lexer.cc +++ b/lily/lily-lexer.cc @@ -60,7 +60,6 @@ static Keyword_ent the_key_tab[] {"figures", FIGURES}, {"grobdescriptions", GROBDESCRIPTIONS}, {"header", HEADER}, - {"key", KEY}, {"layout", LAYOUT}, {"lyricmode", LYRICMODE}, {"lyrics", LYRICS}, diff --git a/lily/parser.yy b/lily/parser.yy index a60fdefacb..799b662a51 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -236,7 +236,6 @@ void set_music_properties (Music *p, SCM a); %token GROBDESCRIPTIONS "\\grobdescriptions" %token HEADER "\\header" %token INVALID "\\version-error" -%token KEY "\\key" %token LAYOUT "\\layout" %token LYRICMODE "\\lyricmode" %token LYRICS "\\lyrics" @@ -2021,24 +2020,6 @@ command_event: | tempo_event { $$ = $1; } - | KEY DEFAULT { - Music *key = MY_MAKE_MUSIC ("KeyChangeEvent", @$); - $$ = key->unprotect (); - } - | KEY NOTENAME_PITCH SCM_IDENTIFIER { - - Music *key = MY_MAKE_MUSIC ("KeyChangeEvent", @$); - if (scm_ilength ($3) > 0) - { - key->set_property ("pitch-alist", $3); - key->set_property ("tonic", Pitch (0, 0, 0).smobbed_copy ()); - key->transpose (* unsmob_pitch ($2)); - } else { - PARSER->parser_error (@3, _ ("second argument must be pitch list")); - } - - $$ = key->unprotect (); - } ; diff --git a/ly/music-functions-init.ly b/ly/music-functions-init.ly index c0c9378830..834166131b 100644 --- a/ly/music-functions-init.ly +++ b/ly/music-functions-init.ly @@ -469,6 +469,23 @@ keepWithTag = res))) music)) +key = +#(define-music-function (parser location tonic pitch-alist) + ((ly:pitch? '()) (list? '())) + (_i "Set key to @var{tonic} and scale @var{pitch-alist}. +If both are null, just generate @code{KeyChangeEvent}.") + (cond ((null? tonic) (make-music 'KeyChangeEvent)) + ((null? pitch-alist) + (ly:parser-error parser (_ "second argument must be pitch list") + location) + (make-music 'SequentialMusic 'void #t)) + (else + (ly:music-transpose + (make-music 'KeyChangeEvent + 'tonic (ly:make-pitch 0 0 0) + 'pitch-alist pitch-alist) + tonic)))) + killCues = #(define-music-function (parser location music) (ly:music?) (_i "Remove cue notes from @var{music}.")