From: Neil Puttock <n.puttock@gmail.com>
Date: Thu, 12 Nov 2009 21:28:24 +0000 (+0000)
Subject: Allow music functions to recognize strings as markup.
X-Git-Tag: release/2.13.8-1~41
X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=071453b302c30541d28c7397e1dd335366961eaa;p=lilypond.git

Allow music functions to recognize strings as markup.

Though strings count as markup according to the type predicate `markup?',
passing a string to a music function is currently only possible if the
type predicate is `string?' or `scm?'

This patch adds parser rules which support strings passed as markup, thus
making it easier to define music functions which default to using strings
unless extra formatting is required.
---

diff --git a/input/regression/music-function-string-markup.ly b/input/regression/music-function-string-markup.ly
new file mode 100644
index 0000000000..e3a80358be
--- /dev/null
+++ b/input/regression/music-function-string-markup.ly
@@ -0,0 +1,17 @@
+\version "2.13.8"
+
+\header {
+  texidoc = "Music functions accept strings as markup arguments
+when using the type predicate @code{markup?}
+"
+}
+
+testFunc =
+#(define-music-function (parser location text music) (markup? ly:music?)
+   ;; dummy function, does nothing
+   music)
+
+\relative c' {
+  \testFunc "test string"
+  c2 <c \testFunc "test string" e>
+}
diff --git a/lily/parser.yy b/lily/parser.yy
index f4fa5f4e2b..584b6e7853 100644
--- a/lily/parser.yy
+++ b/lily/parser.yy
@@ -1053,6 +1053,9 @@ function_arglist_nonmusic_last:
 	EXPECT_MARKUP function_arglist full_markup {
 		$$ = scm_cons ($3, $2);
 	}
+	| EXPECT_MARKUP function_arglist simple_string {
+		$$ = scm_cons ($3, $2);
+	}
 	| EXPECT_SCM function_arglist function_scm_argument {
 		$$ = scm_cons ($3, $2);
 	}
@@ -1064,6 +1067,9 @@ function_arglist_nonmusic: EXPECT_NO_MORE_ARGS {
 	| EXPECT_MARKUP function_arglist_nonmusic full_markup {
 		$$ = scm_cons ($3, $2);
 	}
+	| EXPECT_MARKUP function_arglist_nonmusic simple_string {
+		$$ = scm_cons ($3, $2);
+	}
 	| EXPECT_SCM function_arglist_nonmusic function_scm_argument {
 		$$ = scm_cons ($3, $2);
 	}