mathed's lexer has some really stupid hacks in it. Following TeX on what is a
macro makes the code *much* simpler and would eliminate even more if I could
rebuild math_hash.C (the CVS sources seem to lack to input to gperf). All the
change required is to put the first character after the \ in the macro name
before checking whether it is a letter (just like TeX does). Doing this allows
the special cases handling things like \, to be nuked and , to be placed in
math_hash.C's list instead.
It is presumably not too hard to handle catcode magic with this change in
place, just assuming anyone works up the enthusiasm to do so. This seems unlike
as 99.99% of documents leave the catcodes alone---the main exception is
setting something like @ to be an active character and defining it as an
abreviation for something. (zed-csp.cls does turns @ is a solid circle, for
example).
Evil halign, valign, and other stuff the lexer can not cope with is easy
enough to handle too... all it takes is noticing these constructs and playing
{ and } counting to skip the argument (which currently causes mathed much
grief by feeding it & signs when it was not expecting them). This stuff should
be fed to the (TeXnical) user as a piece of plain TeX mode. [halign is really
useful for fancy matrices where you want entries spanning multiple columns.]
It might be feasable to imagine understanding alignments to some extent but
that would require some basic understanding of non-math mode to handle the
general case, so presumably this should wait for the support for using TeX as
a source document format everywhere (given the proper design halign and valign
could use the same layout engine as more standard stuff). Given the current
non existence of a TeX based rendering engine I do not know how hard it would
be to make it support halign and valign---maybe an alignment extension should
be factored into the design when that happens.
Also on my personal hit list is understanding \def to some extent---given the
support for \newcommand and \renewcommand this should not be too hard for 99%
understanding. The other 1% that uses the heavy delimited argument stuff,
which I know from personal experience can be really useful occasionally, can
be ignored provided it does not crash LyX. (Am I the only person that does a
quick \def for stuff that turns up all over everything in the next bit?).
--
Duncan (-:
"software industry, the: unique industry where selling substandard goods is
legal and you can charge extra for fixing the problems."