;KeepOnlySelection
	(let ((selection (d-GetSelection)))
		(if selection
				(let ((movement (d-GetMovement))
						(startstaff (list-ref (car selection) 1))
						(endstaff (list-ref (cdr selection) 1))
						(startbar (list-ref (car selection) 2))
						(endbar (list-ref (cdr selection) 2)))
						(d-GoToPosition #f endstaff endbar 1)
						(if (d-MoveToMeasureRight)
							(d-DeleteFromCursorToEnd 'all))
						(while (d-MoveToStaffDown)
							(d-DeleteStaff)
							(d-GoToPosition #f endstaff endbar 1))
						(d-GoToPosition #f startstaff startbar 1)
						(d-DeleteMeasuresBeforeCursor 'all)
						(while (d-MoveToStaffUp)
							(d-DeleteStaff))
						(if (d-NextMovement)
								(begin
									(d-DeleteMovement)
									(while (> (d-GetMovement) movement)
										(d-DeleteMovement))))
						(while (d-PreviousMovement)
								(d-DeleteMovement)))
					(d-WarningDialog (_ "No Selection"))))
