- if (ps->safe_)
- {
- static SCM module = SCM_BOOL_F;
- if (module == SCM_BOOL_F)
- {
- SCM function = ly_scheme_function ("make-safe-lilypond-module");
- module = scm_call_0 (function);
- }
- answer = scm_eval (form, module);
- }
+ if (ps->parser_ && !SCM_UNBNDP (ps->parser_->local_environment_))
+ answer = scm_local_eval (form, ps->parser_->local_environment_);
+ else if (ps->safe_)
+ {
+ static SCM module = SCM_BOOL_F;
+ if (module == SCM_BOOL_F)
+ {
+ SCM function = ly_lily_module_constant ("make-safe-lilypond-module");
+ module = scm_call_0 (function);
+ }
+
+ // We define the parser so trusted Scheme functions can
+ // access the real namespace underlying the parser.
+ if (ps->parser_)
+ scm_module_define (module, ly_symbol2scm ("parser"),
+ ps->parser_->self_scm ());
+ answer = scm_eval (form, module);
+ }