<?xml version="1.0"?>
<Denemo>
  <merge>
    <title>A Denemo Keymap</title>
    <author>AT, JRR, RTS</author>
    <map>
      <row>
        <action>ShortMeasure</action>
        <scheme>;;;;;;;;;;ShortMeasure-amended with DW's Rebar functions
(let ((duration 0)(TupletScaleFactor 1))
	(define (GetNoteBeat )	;get duration of a note as a fraction of a whole note, e.g. dotted quarter = 3/8
		(let ((note 0) (len 0 ) (DotIndex 0) (NumDots 0) (NoteBeat 0))
			(begin		
			(if (Tupletopen?) ;FIXME-no support for nested tuplets.
				(set! TupletScaleFactor (string-&gt;number (d-GetTuplet))))

	                ;(d-DirectiveDelete-standalone "ShortMeasure")	;delete the old ShortMeasure
			
			(if (Tupletclose?) (set! TupletScaleFactor 1))
			(if (Music?)
				(if (not (d-ToggleGrace "query="))	;if it's not a grace, continue; otherwise, leave it as 0.
					(begin
						(set! note (d-GetNoteDuration))
						(set! len (string-length note) )
						(set! DotIndex (string-index note #\.) )
						( if DotIndex (begin		;if DotIndex is a valid number...
							(set! NumDots (- len DotIndex) )
							(set! note (substring note 0 DotIndex) )  ;trim off dots
						) )
						(set! note (string-&gt;number note))
						(set! NoteBeat ( / 1 note))
						;now modify base NoteBeat by (2-2^(-NumDots))
						(set! NoteBeat (* NoteBeat (- 2 (expt 2 (* -1 NumDots)))))				
					)
				)
			)
			(* TupletScaleFactor NoteBeat)	;return NoteBeat--modified by TupletScale Factor.
			)
		)
	);GetNoteBeat
	(define (LoopThroughBar)   ;stops once we've run out of new notes.
		(if (d-NextObjectInMeasure)	;as long as there's more stuff to process...
			(begin
				(set! duration (+ duration (GetNoteBeat)) )	;we increment the measure's duration,
				(LoopThroughBar)	;and keep going until done with the bar.				
			)
		)
	)
	  (define (GoToMeasureBegin)
	  (while (d-PrevObjectInMeasure))
	  )
	  (d-PushPosition)
	  (GoToMeasureBegin)	
	  (set! duration (GetNoteBeat))
	  (LoopThroughBar)	;run through bar adding up all durations.
	  (GoToMeasureBegin)
	  (set! duration (* duration 128))	;number of 128ths in duration
	  (if (equal? 0 duration)
	  (begin
	  (d-WarningDialog "No notes/rests in this measure."))
	  (if (integer? duration)
	  (begin
	  (d-DirectivePut-standalone  "ShortMeasure")
	  (d-DirectivePut-standalone-postfix "ShortMeasure" (string-append "\\partial 128*" (number-&gt;string duration) " " ))
	  (d-DirectivePut-standalone-minpixels "ShortMeasure" 60)
	  (d-DirectivePut-standalone-display "ShortMeasure" "Short")
	  (d-RefreshDisplay)
	  )
	  (d-WarningDialog "This measure's duration is too complex for this script.\nSimplify or insert the required lilypond manually.")
	  )
	  )
	(d-PopPosition)
)</scheme>
        <label>Short Measure</label>
        <tooltip>Allow too few notes/rests in this measure. This measure will print out (in all staffs) with the short duration given by notes already present when this command was issued.</tooltip>
      </row>
    </map>
  </merge>
</Denemo>
