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.
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
On 11/4/07, Peter Gerdes truepath@infiniteinjury.org wrote:
On Nov 4, 2007, at 11:23 PM, Peter Gerdes wrote:
This is a big one. Frequently I will type a long paragraph filled with many many math commands and my powerbook G4 1Ghz
Duh, I don't know what I was thinking I meant 1.5Ghz (and I have plenty of ram)
This particular problem could be due to spell checking. Try turning off the "Check Spelling While you Type" feature. This is related to the line length. Search the list for more discussion if this issue.
HTH
Peter
On Nov 5, 2007, at 12:09 AM, Peter Cowan wrote:
On 11/4/07, Peter Gerdes truepath@infiniteinjury.org wrote:
On Nov 4, 2007, at 11:23 PM, Peter Gerdes wrote:
This is a big one. Frequently I will type a long paragraph filled with many many math commands and my powerbook G4 1Ghz
This particular problem could be due to spell checking. Try turning off the "Check Spelling While you Type" feature. This is related to the line length. Search the list for more discussion if this issue.
HTH
Peter
Yah, I've already seen that and did turn off spell checking but for really long paragraphs with lots of math and commands in them it wasn't enough.
Peter
Hi Peter, On Nov 5, 2007, at 2:23 AM, Peter Gerdes wrote:
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. <PyTexdoc.py.patch> Note that this is patched from the tree updated earlier today.
Thanks, I'll let Brad have a look at this, since he is our Python expert.
Now for some harder issues that I can only gesture at solving.
Useability Issues:
- 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.
Have you tried using the "Insert Symbol based on Current Word" command? For instance, instead of typing \ followed by Gamma, you type: G and then press cmd-\ in my case, and it becomes \Gamma.
Of course it won't work for other commands, but for most of those (those you use frequently that is) you can set them up for the shortcuts in the "Insert Label Based On Current Word" command. For instance already typing: "ds" followed by cmd-shift-[ leads to "\displaystyle".
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.
As you say, it would be quite controversial to replace this, especially thinking of people working with collaborators or on old latex files. I personally have made a set of three commands, kept in a separate grammar, that help me with this:
a) "Inline Math", a command bound to the key equivalent $, with scope selector text.tex.latex and doing an Insert Snippet with command text:
#!/usr/bin/env ruby require ENV['TM_SUPPORT_PATH'] + '/lib/escape.rb' if ENV['TM_SELECTED_TEXT'].nil? then print "\( $1 \)" else print "\( #{e_sn ENV['TM_SELECTED_TEXT']} \)" end
b) "Move out of Math", a macro bound to the key equivalent $ but with scope selector "text.tex.latex string.other.math.latex", that effectively does a search for a ) or ] and takes you right after it. This is particularly nice, since it will take me out of the environment regardless of whether I am at its end or not, and regardless of whether I'm doing a new math equation or revisiting an old one (at which point the smart pair is not active anyway).
c) "Insert dollar sign", a snippet bound to ctrl-4 that simply inserts an escaped dollar sign: "\$".
I've attached the three commands if you want to give them a try (hope the files go through).
I think these should alleviate most of the problems mentioned below. I have often thought of making these part of the official bundle, but keep on thinking of the people who would have issues with it, and haven't found a nice way to cause them less problems.
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.
- 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.
- 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.
If you use the above commands, that should not be a problem I don't think.
On the other hand probably anyone who knows textmate well enough will see how to do this in an elegant fashion.
- 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.
That would probably work in fact. I am puzzled however. This should be slowing you down only if you have many begin-end blocks on the same line, and I don't tend to see that often. What begin-end blocks are you using? If you use the "Insert Environment Based On Current Word" command to generate them, then they will span multiple lines instead.
Still before I keep screwing with this I figured I would toss this out there and see if it was a well known problem.
Haris Skiadas Department of Mathematics and Computer Science Hanover College
On Nov 5, 2007, at 3:52 AM, Charilaos Skiadas wrote:
Often I will be editing an existing tex file and need to add something like $\Gamma_{\alpha+1}(\sigma)\concat\tau$. This
Have you tried using the "Insert Symbol based on Current Word" command? For instance, instead of typing \ followed by Gamma, you type: G and then press cmd-\ in my case, and it becomes \Gamma.
I make quite heavy use of custom commands that I've defined making it pretty hard to keep all of them as snippets. Besides I find that when I'm typing it's a HUGE slowdown if I have to take stop touch typing and press a control sequence. I could use tab completion but since I tend to create new commands for common functions in particular files this would mean changing snippets for every file (this would be a nice feature but I don't have the time to implement it).
The latex mode should really just work. I should be able to type in textmate the same way I do in a plain tex editor and have it work well and if I can help make that the case I'd like to help..
As you say, it would be quite controversial to replace this, especially thinking of people working with collaborators or on old latex files. I personally have made a set of three commands, kept in a separate grammar, that help me with this:
Great, thanks. These are helpful.
That would probably work in fact. I am puzzled however. This should be slowing you down only if you have many begin-end blocks on the same line, and I don't tend to see that often. What begin-end blocks are you using? If you use the "Insert Environment Based On Current Word" command to generate them, then they will span multiple lines instead.
I'm not using any begin end blocks on most lines (though I do jump in and out of math mode several times and use a bunch of custom commands, often with nested arguments). The reason I felt that these matches would be problematic is that even if they don't actually match ruby (or whatever regex engine is being used) has to check them for a match. Maybe the difference isn't enough to be noticeable but my thinking was that by pinning the begin end statements to the begining of the line we wouldn't be forcing the regex engine to start a new attempted match whenever it encounters a space (and with multiple spaces it might even start backtracking if it doesn't compile down to a DFA).
Anyway thanks for the commands.
Peter
On Nov 5, 2007, at 1:23 AM, Peter Gerdes wrote:
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.<PyTexdoc.py.patch> Note that this is patched from the tree updated earlier today.
Peter,
Thanks for the patch. Can you tell me more about what you had in mind for this? I can't really see how your patch helps, given that PyTexdoc already manually searches all the TEXMF paths and finds way more documentation than your kpsewhich package does.
As long as we are discussing this program, I've been thinking for some time now that I could speed up day to day use of this command drastically by pickling the dictionaries created when I manually crawl the latex hierarchy. Given that most people don't update their tex installation all that frequently I think this would be a real win. The question becomes when to go back and recrawl? * After some number of days? * Provide a command to rebuild the index manually? * Look for some other marker in the tex heirarchy that indicates that LaTeX has been updated... Is there a file or a kpse sort of command that would give me an installation last updated date?
Other ideas or comments welcome...
Thanks,
Brad
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate
As long as we are discussing this program, I've been thinking for some time now that I could speed up day to day use of this command drastically by pickling the dictionaries created when I manually crawl the latex hierarchy. Given that most people don't update their tex installation all that frequently I think this would be a real win. The question becomes when to go back and recrawl?
- After some number of days?
- Provide a command to rebuild the index manually?
- Look for some other marker in the tex heirarchy that indicates
that LaTeX has been updated... Is there a file or a kpse sort of command that would give me an installation last updated date?
I think that a command to rebuild the index manually is a good idea that need not compete with, say, rebuilding after a fixed time period. Just my two cents.
Brad Miller wrote:
As long as we are discussing this program, I've been thinking for some time now that I could speed up day to day use of this command drastically by pickling the dictionaries created when I manually crawl the latex hierarchy. Given that most people don't update their tex installation all that frequently I think this would be a real win. The question becomes when to go back and recrawl?
- After some number of days?
- Provide a command to rebuild the index manually?
- Look for some other marker in the tex heirarchy that indicates that
LaTeX has been updated... Is there a file or a kpse sort of command that would give me an installation last updated date?
Other ideas or comments welcome...
What about using that FSEvents stuff in Leopard? (e.g. from PyObjC)
-Jacob
Sorry to take so long to reply, school stuff stole my attention for awhile.
On Nov 5, 2007, at 6:16 AM, Brad Miller wrote:
Thanks for the patch. Can you tell me more about what you had in mind for this? I can't really see how your patch helps, given that PyTexdoc already manually searches all the TEXMF paths and finds way more documentation than your kpsewhich package does.
This isn't to find more documentation but to find files that have been \input into the current document. It's quite possible that there is a better way to do this but at least for me the program would complain when my header had a line like
\input{notation.tex}
where this file wasn't in the same directory but kept in my local texmf tree so I could include it in whatever program I wanted.
As long as we are discussing this program, I've been thinking for some time now that I could speed up day to day use of this command drastically by pickling the dictionaries created when I manually crawl the latex hierarchy. Given that most people don't update their tex installation all that frequently I think this would be a real win. The question becomes when to go back and recrawl?
- After some number of days?
- Provide a command to rebuild the index manually?
- Look for some other marker in the tex heirarchy that indicates
that LaTeX has been updated... Is there a file or a kpse sort of command that would give me an installation last updated date?
Other ideas or comments welcome...
Thanks,
Brad
Could you somehow bootstrap off the ls-R files?
Peter