assign penalty to one discretionary (not all paragraph)
Using the test release of luatex 0.85 I get from
\tracingoutput1
\tracingonline1
\showboxdepth1000
\showboxbreadth1000
abc\begingroup\hyphenpenalty -10001\discretionary{d}{e}{f}\endgroup
ghi\begingroup\hyphenpenalty 10001\discretionary{d}{e}{f}\endgroup
\bye
and a log
Completed box being shipped out [1]
\vbox(667.20255+0.0)x469.75499, direction TLT
.\vbox(0.0+0.0)x469.75499, glue set 14.0fil, direction TLT
..\glue -22.5
..\hbox(8.5+0.0)x469.75499, glue set 469.755fil, direction TLT
...\vbox(8.5+0.0)x0.0, direction TLT
...\glue 0.0 plus 1.0fil
..\glue 0.0 plus 1.0fil minus 1.0fil
.\vbox(643.20255+0.0)x469.75499, glue set 619.25812fill, direction TLT
..\glue(\topskip) 3.05556
..\hbox(6.94444+0.0)x469.75499, direction TLT
...\localpar
....\localinterlinepenalty=0
....\localbrokenpenalty=0
....\localleftbox=null
....\localrightbox=null
...\hbox(0.0+0.0)x20.0, direction TLT
...\tenrm a
...\tenrm b
...\kern0.27779
...\tenrm c
...\tenrm d
...\discretionary-10001|
...\glue(\rightskip) 0.0
..\penalty 400
..\glue(\baselineskip) 5.05556
..\hbox(6.94444+1.94444)x469.75499, glue set 448.9216fil, direction TLT
...\tenrm e
...\tenrm g
...\tenrm h
...\tenrm i
...\discretionary10001| replacing
....\tenrm f
....\tenrm d
...|\tenrm e
...\penalty 10000
...\glue(\parfillskip) 0.0 plus 1.0fil
...\glue(\rightskip) 0.0
..\glue 0.0 plus 1.0fill
.\glue(\baselineskip) 17.55556
.\hbox(6.44444+0.0)x469.75499, glue set 232.37749fil, direction TLT
..\glue 0.0 plus 1.0fil minus 1.0fil
..\tenrm 1
..\glue 0.0 plus 1.0fil minus 1.0fil
Showing that each of the discretionary nodes has recorded its local value of \hyphenpenalty
So, as egreg wrote earlier you cannot assign different penalties to different discretionaries within a paragraph.
Thus, the answer to your question is “no”.
From The TeXbook, p. 101:
“TeX looks at the parameters that affect line breaking only when it is breaking lines.”
So, after TeX has read the paragraph, it starts its line breaking task. Potential breakpoints are rated upon their associated penalty. The penalties associated with discretionary breakpoints are the values for \hyphenpenalty
respectively \exhyphenpenalty
which are in force at the end of the paragraph.
By stating \penalty
p you are inserting a potential breakpoint with an assoctiated penalty p. If p ≤ -10000 TeX will always break at this breakpoint.
Thus, if you input abc\penalty-10001\discretionary{d}{e}{f}ghi
to TeX, you force a break at the \penalty
and while TeX is choosing the remaining breakpoints, the potential breakpoint you inserted by \discretionary{d}{e}{f}
is (still) taken into account with a penalty of the value of \hyphenpenalty
that was current at the end of the paragraph.