2009/6/16 Mark Polesky <markpole...@yahoo.com>:

> I wish there were a similar way to suppress the printing of the
> accidental from within the NoteEvent expression.
>
> Something like 'suppress-accidental that would fit right where
> 'force-accidental goes in the scheme expression. Is that
> possible? Would it be difficult to implement?

It's quite simple to do.

Attached is a patch which uses an ampersand to hide accidentals.

Regards,
Neil
From 86eeeb51725d3f1752c0a75b7e024a93dca03927 Mon Sep 17 00:00:00 2001
From: Neil Puttock <n.putt...@gmail.com>
Date: Tue, 16 Jun 2009 22:39:43 +0100
Subject: [PATCH] Allow accidentals to be hidden using ampersand.

---
 lily/accidental-engraver.cc |    3 ++-
 lily/parser.yy              |   34 ++++++++++++++++++++++------------
 2 files changed, 24 insertions(+), 13 deletions(-)

diff --git a/lily/accidental-engraver.cc b/lily/accidental-engraver.cc
index f84e281..57905bd 100644
--- a/lily/accidental-engraver.cc
+++ b/lily/accidental-engraver.cc
@@ -436,7 +436,8 @@ Accidental_engraver::acknowledge_rhythmic_head (Grob_info info)
   Stream_event *note = info.event_cause ();
   if (note
       && (note->in_event_class ("note-event")
-	  || note->in_event_class ("trill-span-event")))
+	  || note->in_event_class ("trill-span-event"))
+      && !to_boolean (note->get_property ("hide-accidental")))
     {
       /*
 	string harmonics usually don't have accidentals.
diff --git a/lily/parser.yy b/lily/parser.yy
index 462a58d..992a717 100644
--- a/lily/parser.yy
+++ b/lily/parser.yy
@@ -312,6 +312,7 @@ If we give names, Bison complains.
 
 %type <i> bare_unsigned
 %type <scm> figured_bass_alteration
+%type <i> ampersands
 %type <i> dots
 %type <i> exclamations
 %type <i> optional_rest
@@ -1443,15 +1444,18 @@ chord_body_elements:
 	;
 
 chord_body_element:
-	pitch exclamations questions octave_check post_events
+	pitch ampersands exclamations questions octave_check post_events
 	{
-		int q = $3;
-		int ex = $2;
-		SCM check = $4;
-		SCM post = $5;
+		int amp = $2;
+		int q = $4;
+		int ex = $3;
+		SCM check = $5;
+		SCM post = $6;
 
 		Music *n = MY_MAKE_MUSIC ("NoteEvent", @$);
 		n->set_property ("pitch", $1);
+		if (amp % 2)
+		   	n->set_property ("hide-accidental", SCM_BOOL_T);
 		if (q % 2)
 			n->set_property ("cautionary", SCM_BOOL_T);
 		if (ex % 2 || q % 2)
@@ -2050,28 +2054,30 @@ optional_rest:
 	;
 
 simple_element:
-	pitch exclamations questions octave_check optional_notemode_duration optional_rest {
+	pitch ampersands exclamations questions octave_check optional_notemode_duration optional_rest {
 		if (!PARSER->lexer_->is_note_state ())
 			PARSER->parser_error (@1, _ ("have to be in Note mode for notes"));
 
 		Music *n = 0;
-		if ($6)
+		if ($7)
 			n = MY_MAKE_MUSIC ("RestEvent", @$);
 		else
 			n = MY_MAKE_MUSIC ("NoteEvent", @$);
 		
 		n->set_property ("pitch", $1);
-		n->set_property ("duration", $5);
+		n->set_property ("duration", $6);
 
-		if (scm_is_number ($4))
+		if (scm_is_number ($5))
 		{
-			int q = scm_to_int ($4);
+			int q = scm_to_int ($5);
 			n->set_property ("absolute-octave", scm_from_int (q-1));
 		}
 
-		if ($3 % 2)
+		if ($2 % 2)
+			n->set_property ("hide-accidental", SCM_BOOL_T);
+		if ($4 % 2)
 			n->set_property ("cautionary", SCM_BOOL_T);
-		if ($2 % 2 || $3 % 2)
+		if ($3 % 2 || $4 % 2)
 			n->set_property ("force-accidental", SCM_BOOL_T);
 
 		$$ = n->unprotect ();
@@ -2270,6 +2276,10 @@ unsigned_number:
 	}
 	;
 	
+ampersands:
+		{ $$ = 0; }
+	| ampersands '&'	{ $$ ++; }
+	;
 
 exclamations:
 		{ $$ = 0; }
-- 
1.6.0.4

_______________________________________________
lilypond-devel mailing list
lilypond-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-devel

Reply via email to