[TxMt] Fwd: Latex Bundle Useability (and patch)
Peter Gerdes
truepath at infiniteinjury.org
Mon Nov 5 07:23:25 UTC 2007
So I'm working on writing up my (mathematical logic) thesis and I've
been using textmate to do it. Unfortunately I've ran into some
serious usability issues with the latex bundle in textmate and
unsurprisingly have been wasting time trying to fix them. I figured
I would post the issues to this list along with some of the hacks
that seem to help for me and see if people who know more about the
textmate stuff can help make this bundle more useable for intense
mathematics.
First of all I'm attaching a simple patch for PyTeXdoc.py so it
queries kpsewhich to look for included/inputed files if it fails to
find them. Since I keep some general purpose includes in my tex
directory this makes a difference.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PyTexdoc.py.patch
Type: application/octet-stream
Size: 3175 bytes
Desc: not available
URL: <http://lists.macromates.com/textmate/attachments/20071104/3ceee181/attachment.patch>
-------------- next part --------------
Note that this is patched from the tree updated earlier today.
Now for some harder issues that I can only gesture at solving.
Useability Issues:
1) Typing commands inside $$ causes wacky highlighting flip-flops.
Often I will be editing an existing tex file and need to add
something like $\Gamma_{\alpha+1}(\sigma)\concat\tau$. This causes
issues since you have to pass through $$ $\$, $\Gamma_{\}$ and $
\Gamma_{\alpha+1}(\sigma)\concat\$ on the way each of which flips the
syntax highlighting for the ENTIRE rest of the document. Not only is
this annoying it causes unacceptable slowdowns as the rest of the doc
is rehighlighted.
My personal collection of hacks to deal with this problem is as
follows (some of these are old so i apologize if it was fixed in the
bundle and I missed it):
a) Elimate the $$ $$ notation for display math. It is considered
bad form to use the old $$ $$ approach rather than the new \[ \]
notation. I realize doing something like this would be controversial
in the default language grammar but I'd rather have the right way of
doing things be useable rather than correctly hightlighting the wrong
way. But maybe there is another way to deal with the issue.
b) Require $ to be escaped as {\$}. Once again not a good general
solution but for me this works since I rarely use a real dolsign.
Perhaps a better trick would be to require this weird special
escaping only when in math mode. Once again I'm puzzled about how to
do this correctly but as it stands it causes serious problems.
c) I used to have problems with $\Gamma_{\}$ letting the braces spill
over but it is either fixed now I or I changed something locally I
don't remember.
2) Typing { when the caret is before a slash causes smart typing
pairs to insert {\} instead of {} because it thinks we are trying to
escape the {. This can be fixed by changing the match for
constant.character.escape.tex to start with a positive backref of (?<=
\\) instead of just (\\). It seems weird to me that having a caret
in front of the string causes it to be grabbed but go figure.
3) Often I need to insert math inside an already written paragraph.
So I start with a line like
If $x$ is a blah then blah2
and need to fix it to
If $x$ is a blah and $math stuff$ then blah2
which one naturally does by simply putting the caret in front of the
t in then and starting to type. Unfortunately the smart typing pairs
for $ fail to activate when you are in front of a character. I have
no idea why this is (seems to work for {) but the best fix I could
come up with was a hack to define meta.in-front-of-char.latex and
create a snippet for this situation assigning it to $. If I knew how
to insert true smart typing pairs from a snippet (or command) a
general purpose solution that works could be found.
On the other hand probably anyone who knows textmate well enough will
see how to do this in an elegant fashion.
4) SPEED
This is a big one. Frequently I will type a long paragraph filled
with many many math commands and my powerbook G4 1Ghz will slow
enough to make typing difficult if I am inserting anything inside the
paragraph. If I actually hard wrap the lines this stops happening
but since textmate doesn't support hard wrapping well this isn't
really an option.
I noticed in the language definition there are many syntax elements
(like meta.function.embedded.java.latex) whose matches begin with
something like: (?:\s*)((\\)begin) ..... I can't figure out what
sense this makes at all. Why match the spaces if they can just
happen anywhere in the line? Maybe I am just missing something
obvious and I'm deluding myself but when I changed these all to (?:^
\s*)((\\)begin) .... everything seemed to keep working and things
seemed to speed up considerably. Then again maybe it was an
unrelated bundle update.
Still before I keep screwing with this I figured I would toss this
out there and see if it was a well known problem.
------------------
Sorry to describe the changes I made rather than giving a bunch of
patches but the normal bundle development model just won't work for
me. I change a bunch of stuff for my personal use (like some of the
hacks above) so I need to keep the ~/Library/Application Support/
Textmate directory for my own personal modifications. If someone
could tell me an easy way to produce a diff of the changes I've made
here with the actual bundle maybe I could be more helpful.
Anyway thanks to the author(s) of the latex bundle for all the work
they've put in so far. Hopefully this was helpful an not just
useless bitching.
Peter
More information about the textmate
mailing list