Flams, drags and ruffs

Writing a flam, drag, or ruff is pretty easy, but it's just too much typing for such a common ornament. Because the notation of the ornament depends on the note it is attached to, you can't just write it as a simple variable, you need a function. This snippet provides four functions and an example of using them: \flam, \drag,\ruff and the more generic \graceRepeat, also, a improved version of add-grace-property, thanks to David Kastrup.

Just write \flam, \drag, or \ruff, followed by the note you want to attach it to. If you pass it a chord, then the first note in the chord will get the flam. They are typeset as grace notes internally, so if you want to change their appearance, use the usual grace note tweaks.

The more generic \graceRepeat offers the possibility to get grace chords and to specify which number of grace notes you want.