- send_stream_event (get_outlet (), "SetProperty", get_music ()->origin (),
- ly_symbol2scm ("symbol"), get_music ()->get_property ("symbol"),
- ly_symbol2scm ("value"), get_music ()->get_property ("value"));
-
- Simple_music_iterator::process (m);
+ Context *o = get_outlet ();
+ Music *m = get_music ();
+ bool once = to_boolean (m->get_property ("once"));
+ SCM symbol = m->get_property ("symbol");
+ SCM previous_value = SCM_UNDEFINED;
+ if (once)
+ o->here_defined (symbol, &previous_value);
+
+ send_stream_event (o, "SetProperty", m->origin (),
+ ly_symbol2scm ("symbol"), symbol,
+ ly_symbol2scm ("value"), m->get_property ("value"));
+
+ /* For \once \set install a finalization hook to reset the property to the
+ * previous value after the timestep */
+ if (once)
+ {
+ Global_context *tg = get_outlet ()->get_global_context ();
+ tg->add_finalization (scm_list_4 (once_finalization_proc,
+ o->self_scm (), m->self_scm (),
+ previous_value));
+ }
+
+ Simple_music_iterator::process (mom);