+IMPLEMENT_TRANSLATOR_LISTENER (Bar_number_engraver, alternative);
+void
+Bar_number_engraver::listen_alternative (Stream_event *ev)
+{
+ if (alternative_event_)
+ return;
+
+ alternative_event_ = ev;
+ int current_barnumber = robust_scm2int (get_property ("currentBarNumber"), 0);
+ Direction alternative_dir = robust_scm2dir (ev->get_property ("alternative-dir"), CENTER);
+ bool make_alternative = scm_is_eq (get_property ("alternativeNumberingStyle"),
+ ly_symbol2scm ("numbers"))
+ || scm_is_eq (get_property ("alternativeNumberingStyle"),
+ ly_symbol2scm ("numbers-with-letters"));
+ if (make_alternative)
+ {
+ /*
+ if we're starting the first alternative, we set the starting
+ bar number to the current bar number
+ */
+ if (alternative_dir == LEFT)
+ alternative_starting_bar_number_ = current_barnumber;
+
+ /*
+ if the alternative is not the last one, we send the
+ current bar number back to the alternative bar number.
+ */
+ if (alternative_dir < RIGHT)
+ current_barnumber = alternative_starting_bar_number_;
+
+ context ()->set_property ("currentBarNumber", scm_from_int (current_barnumber));
+ }
+}
+