As far as I know this is currently not possible. You can trick MM rests to allow for such an behaviour, like this:
\version "2.22"
#(define (slash height slope thickness)
(let* ((wid (/ height slope))
(adjthick (/ thickness (sqrt (+ (* slope slope) 1))))
(x0 0)
(y0 0)
(x1 (+ 0 adjthick))
(y1 0)
(x2 (+ wid adjthick))
(y2 height)
(x3 wid)
(y3 height))
(make-path-stencil
`(moveto ,x0 ,y0 lineto ,x1 ,y1 lineto ,x2 ,y2 lineto ,x3 ,y3 lineto ,x0 ,y0)
0.01
1
1
#t)))
#(define-markup-command (slash layout props height slope thickness) (number? number? number?)
(slash height slope thickness))
perc = \markup\concat{
\raise #0.5 \musicglyph #"dots.dot"
\hspace #-0.75
\lower #1 \slash #2 #1 #0.98
\hspace #-0.75
\lower #0.5 \musicglyph #"dots.dot"
}
compress = \compressMMRests\etc
repeatWholeMeasure =
#(define-music-function (dur n) (ly:duration? number?)
#{
\temporary\override Staff.MultiMeasureRest.stencil =
#(grob-transformer 'stencil
(lambda (grob orig)
(let* ((text (ly:text-interface::print grob))
(ext-x (ly:stencil-extent orig X))
(mid (interval-center ext-x))
(t-ext-x (ly:stencil-extent text X))
(mid2 (interval-center t-ext-x)))
(ly:stencil-translate-axis text (- mid mid2) X))))
\temporary\override Staff.MultiMeasureRest.text = \perc
\temporary\override Staff.MultiMeasureRest.spacing-pair.break-alignment = #'staff-bar
\temporary\override Staff.MultiMeasureRest.bound-padding = #'()
\temporary\override Staff.MultiMeasureRest.space-increment = #'()
\temporary\override Staff.MultiMeasureRestNumber.padding = #1.5
R $dur * $n
\revert Staff.MultiMeasureRest.stencil
\revert Staff.MultiMeasureRest.text
\revert Staff.MultiMeasureRest.spacing-pair.break-alignment
\revert Staff.MultiMeasureRest.bound-padding
\revert Staff.MultiMeasureRest.space-increment
\revert Staff.MultiMeasureRestNumber.padding
#})
\new RhythmicStaff {
4 8 8 8 8 4
\compress \repeatWholeMeasure 1 5
}
% Advantage of this approach:
<<
\new RhythmicStaff {
4 8 8 8 8 4
\compress \repeatWholeMeasure 1 5
}
\new RhythmicStaff {
8 8 4 4 8 8 |
4 4 8 8 8 8 |
4 8 8 4 8 8 |
4 4 4 4 |
8 8 8 8 8 8 4 |
4 2 8 8
}
>>
but there is not really a way to collapse percent repeats. It would be most certainly doable if there is enough reason to have percent repeats compressable.