mf schrieb am 11.12.2019 um 15:31:
This is a good-enough solution to my problem:
\setupalign[stretch]
\starttext
\def\Text{This is the text of an index term, that is normally justified, but I'd like the page numbers to be flushed to the right from their second line}
\def\Pages{34, 57, 101-104, 276, 345, 401, 403, 512.}
\type{\PlaceIndexTerm} has 6 parameters: \startitemize[n] \item the main text \item the pages' numbers \item the text width \item the left margin of the lines made only of page numbers \item the width of the separator (an hbox) before the first page number, when there's room in the last line of the text \item the minimum accepted space left at the end of the last line of text, to put a page number \stopitemize
\def\PlaceIndexTerm#1#2#3#4#5#6{% \newdimen\TextWidth \TextWidth=#3 \newdimen\SBPN \SBPN=#5 % space before page numbers \newdimen\PagesIndentation \PagesIndentation=#4 \newdimen\MSLLL \MSLLL=#6 % minimum space left on last line \parshape 1 0pt \TextWidth #1\par \newdimen\LLW \LLW=\lastlinewidth \page[no] \ifdim \dimexpr\TextWidth-\LLW-\SBPN > \MSLLL \blank[-\the\lineheight,fixed]\fi \startalignment[flushright,stretch] \ifdim \dimexpr\TextWidth-\LLW-\SBPN > \MSLLL \parshape 2 \LLW \dimexpr \TextWidth - \LLW \PagesIndentation \dimexpr \TextWidth - \PagesIndentation \red \else \parshape 1 \PagesIndentation \dimexpr \TextWidth - \PagesIndentation \darkgreen \fi \noindent\ifdim \dimexpr\TextWidth-\LLW-\SBPN > \MSLLL\hbox to \SBPN{}\fi #2\par \stopalignment}
\starttext \startbuffer This is the text of an index term, that is normally justified, but I'd like the page numbers to be flushed to the right from their second line\par \startalignment[flushright] \ifdim\dimexpr\hsize-\lastlinewidth\relax>2\emwidth \blank[overlay] % simple solution but doesn't indent the numbers on the following lines % \hskip\dimexpr\lastlinewidth+\emwidth\relax \parshape 2 \dimexpr\lastlinewidth+\emwidth\relax \dimexpr\hsize-\lastlinewidth-\emwidth\relax \emwidth \dimexpr\hsize-\emwidth\relax \else \parshape 1 \emwidth \dimexpr\hsize-\emwidth\relax \fi 34, 57, 101-104, 276, 345, 401, 403, 512. \stopalignment \stopbuffer \dorecurse {10} {\hsize\dimexpr.75\textwidth-#1\emwidth\relax \getbuffer \page} \stoptext Wolfgang