The above example shows how to @q{export} music expressions from the
input to the Scheme interpreter. The opposite is also possible. By
-wrapping a Scheme value in the function @code{ly:export}, a Scheme
+placing it after @code{$}, a Scheme
value is interpreted as if it were entered in LilyPond syntax.
Instead of defining @code{\twice}, the example above could also have
been written as
@{ $(make-sequential-music (list newLa)) @}
@end example
+You can use @code{$} with a Scheme expression anywhere you could use
+@code{\@var{name}} after assigning the Scheme expression to a variable
+@var{name}. This replacement happens in the @q{Lexer}, so Lilypond is
+not even aware of the difference.
+
Scheme code is evaluated as soon as the parser encounters it. To
define some Scheme code in a macro (to be called later), use
@ref{Void scheme functions}, or
+++ /dev/null
-/*
- This file is part of LilyPond, the GNU music typesetter.
-
- Copyright (C) 2002--2011 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
- LilyPond is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- LilyPond is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "identifier-smob.hh"
-
-scm_t_bits package_tag;
-
-static int
-print_box (SCM b, SCM port, scm_print_state *)
-{
- SCM value = SCM_CELL_OBJECT_1 (b);
-
- scm_puts ("#<packaged object ", port);
- scm_write (value, port);
- scm_puts (">", port);
-
- /* Non-zero means success. */
- return 1;
-}
-
-/* This defines the primitve `make-box', which returns a new smob of
- type `box', initialized to `#f'. */
-LY_DEFINE (ly_export, "ly:export",
- 1, 0, 0, (SCM arg),
- "Export a Scheme object to the parser"
- " so it is treated as an identifier.")
-{
- SCM_RETURN_NEWSMOB (package_tag, arg);
-}
-
-SCM
-unpack_identifier (SCM box)
-{
- if (SCM_IMP (box) || SCM_CELL_TYPE (box) != package_tag)
- return SCM_UNDEFINED;
-
- return SCM_CELL_OBJECT_1 (box);
-}
-
-static void
-init_box_type (void)
-{
- package_tag = scm_make_smob_type ("box", 0);
- scm_set_smob_mark (package_tag, scm_markcdr);
- scm_set_smob_print (package_tag, print_box);
-}
-
-ADD_SCM_INIT_FUNC (package, init_box_type);
+++ /dev/null
-/*
- This file is part of LilyPond, the GNU music typesetter.
-
- Copyright (C) 2002--2011 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
- LilyPond is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- LilyPond is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef IDENTIFIER_SMOB_HH
-#define IDENTIFIER_SMOB_HH
-
-#include "lily-guile.hh"
-
-SCM package_identifier (SCM);
-bool identifier_smob_p (SCM);
-SCM unpack_identifier (SCM);
-
-#endif /* IDENTIFIER_SMOB_HH */
-
#include "context-def.hh"
#include "duration.hh"
-#include "identifier-smob.hh"
#include "international.hh"
#include "interval.hh"
#include "lily-guile.hh"
}
char_count_stack_.back () += n;
- if (unpack_identifier (sval) != SCM_UNDEFINED)
- {
- yylval.scm = unpack_identifier(sval);
- return identifier_type (yylval.scm);
- }
-
for (size_t i = 0; i < pending_string_includes_.size (); i++)
new_input ("<included string>", pending_string_includes_[i],
parser_->sources_);
(use-modules (ice-9 receive))
-(defmacro*-public markup* (#:rest body)
- "Same as `markup', for use in a \\notes block."
- `(ly:export (markup ,@body)))
-
-
(define (compile-all-markup-expressions expr)
"Return a list of canonical markups expressions, e.g.:
(#:COMMAND1 arg11 arg12 #:COMMAND2 arg21 arg22 arg23)
(markup \"foo\"
#:raise 0.2 #:hbracket #:bold \"bar\"
#:override '(baseline-skip . 4)
- #:bracket #:column (\"baz\" \"bazr\" \"bla\"))
-Use `markup*' in a \\notemode context."
+ #:bracket #:column (\"baz\" \"bazr\" \"bla\"))"
(car (compile-all-markup-expressions `(#:line ,body))))
ly:duration<?
ly:duration?
ly:error
- ly:export
ly:font-get-glyph
ly:font-design-size
ly:font-file-name