Try:
English text \sethebrew [Hebrew text] \unsethebrew more
English text \sethebrew
[more Hebrew text] \unsethebrew final English text.
It goes wrong in interesting ways.
I believe the fix is very simple: in the definition of
\noextrashebrew, simply c
hange \beginL to \endR: \noextras<language> is meant to
undo the settings of \ex
tras<language>; \endR unsets \beginR whereas \beginL
begins another level of und
esired directional grouping. This fixes the problem.
With this fix, it is then
not clear to me why the \ifinner test is required in
\(no)extrashebrew; maybe i
t is no longer required.
Note that this fix (which follows Babel's conventions
of language blocks being i
ndependent of each other) does mean that if Hebrew is
required to be embedded in
a sequence:
\beginR heb \beginL eng \beginR heb \endR end \endL heb
\endR then the commands
used would have to be:
\sethebrew heb \L{eng \R{heb} eng} heb \unsethebrew
but that's OK.