Dear Textmates,
I am currently evaluating Textmate as a substitute for Emacs. My first impression is really good (especially due to the excellent documentation), but now I have encountered a problem that I cannot resolve by myself. I hope you can help me with it.
I mostly work on LaTeX documents. With AucTeX, pressing Meta-q (Reformat) when on line 2 of the following block of text would reformat lines 2 and 3:
\begin{description} \item[Projectivity:] A word and its transitive dependents must form a continuous region of the full sentence. \item[Planarity:] Dependency edges must not cross when drawn above the words of the sentence. \end{description}
The corresponding action in Textmate (Control-Q) produces this:
\begin{description} \item[Projectivity:] A word and its transitive dependents must form a continuous region of the full sentence. \item[Planarity:] Dependency edges must not cross when drawn above the words of the sentence. \end{description}
I wonder if there is any way to tell Textmate that in LaTeX mode, a paragraph should only stretch from the beginning of an \item to the beginning of the next \item (or the \end{...} token), rather than between empty lines? (This is what AucTeX does in the Emacs setting.)
Any help is appreciated.
Best, Marco
Marco, On Jan 8, 2006, at 2:57 PM, Marco Kuhlmann wrote:
Dear Textmates,
I am currently evaluating Textmate as a substitute for Emacs. My first impression is really good (especially due to the excellent documentation), but now I have encountered a problem that I cannot resolve by myself. I hope you can help me with it.
Welcome.
The corresponding action in Textmate (Control-Q) produces this:
This command is for plain text files. You can try the "tidy" command in the LaTeX bundle (bound to ctrl-shift-h I think), though I am not sure it does exactly what you want. I think it will try to tidy the entire document though, which might not be exactly what you need.
In general, the LaTeX and Source bundles are the places to look at for LaTeX related tasks.
I wonder if there is any way to tell Textmate that in LaTeX mode, a paragraph should only stretch from the beginning of an \item to the beginning of the next \item (or the \end{...} token), rather than between empty lines? (This is what AucTeX does in the Emacs setting.)
That's not the way to do this in TextMate, I think. You would probably want to write a command to do what you want, or mess with the tidy command a bit.
Did you create this text in TextMate? If so, would you mind telling me the steps you took? The way I would naturally do it in TM, using the "insert environment..." and "insert item..." commands of the LaTeX bundle, each new item line would be indented by default, so this issue would not arise. If it did arise, as in your case, I would select the rows, switch to columnar editing mode and press tab, thus inserting a tab in each line.
Coming from emacs, you might want to consider altering your workflow a bit to adjust to "the TM way of doing things". Lots of things are exactly the same, others are similar, and others yet are completely different. In particular, there are not many things in common between AUCTeX and TM's LaTeX bundle. Have a look at the bundle's README (available from the bundle through its "help" command) for a description of what you can do.
Feel free to keep on pestering the list with questions, or try the #textmate irc channel as well. Good luck.
Any help is appreciated.
Best, Marco
Haris
Thanks, Haris, for your reply.
Am 09.01.2006 um 00:30 schrieb Charilaos Skiadas:
This command is for plain text files. You can try the "tidy" command in the LaTeX bundle (bound to ctrl-shift-h I think), though I am not sure it does exactly what you want. I think it will try to tidy the entire document though, which might not be exactly what you need.
No, tidy does not really do what I want to achieve here. I also must admit that the LaTeX bundle's authors' idea of tidyness does not really match mine ... ;-)
In general, the LaTeX and Source bundles are the places to look at for LaTeX related tasks.
I browsed through the bundle's help files, but could not find anything that would come close to what I have in mind.
Reformat Paragraph is really close to what I want, and in fact would be exactly what I want, if a paragraph would indeed be a logical LaTeX paragraph (rather than a textual paragraph) for Textmate. (The command even has almost the same key binding as in Emacs!)
So do I get you right that it is not possible for a language definition to specify what it counts as a paragraph?
Thanks, Marco
Marco, On Jan 9, 2006, at 3:59 AM, Marco Kuhlmann wrote:
Thanks, Haris, for your reply.
Am 09.01.2006 um 00:30 schrieb Charilaos Skiadas:
No, tidy does not really do what I want to achieve here. I also must admit that the LaTeX bundle's authors' idea of tidyness does not really match mine ... ;-)
I think Eric Hsu is responsible for the perl script used, and he seems to have it pretty well documented. It resides in Library/ Application Support/TextMate/Bundles/Latex.tmbundle/Support/bin so you could try to toggle it to suit your purposes, it does a lot of stuff that most some people might not like I guess. He is in the mailing list I think, so he might add his input when he gets a chance. I personally have never used the script.
Reformat Paragraph is really close to what I want, and in fact would be exactly what I want, if a paragraph would indeed be a logical LaTeX paragraph (rather than a textual paragraph) for Textmate. (The command even has almost the same key binding as in Emacs!)
So do I get you right that it is not possible for a language definition to specify what it counts as a paragraph?
That is correct, to the best of my knowledge. You could ask it as a feature request, though it will probably have to wait until 2.0 at least.
In the meantime, it would be nice to enhance the tidy script to make it more customizable, maybe, and try to create a "reformat paragraph" script in the bundle. Though for that, enough of us would have to agree on what constitutes a paragraph. :) If you are familiar with some scripting language, you could try porting what emacs is doing... Though of course as things stand, that would require rewriting the reformatting algorithm.
Thanks, Marco
Haris
At 8:16 AM -0600 1/9/06, Charilaos Skiadas wrote:
On Jan 9, 2006, at 3:59 AM, Marco Kuhlmann wrote:
No, tidy does not really do what I want to achieve here. I also must admit that the LaTeX bundle's authors' idea of tidyness does not really match mine ... ;-)
I think Eric Hsu is responsible for the perl script used, and he seems to have it pretty well documented. It resides in Library/Application Support/TextMate/Bundles/Latex.tmbundle/Support/bin so you could try to toggle it to suit your purposes, it does a lot of stuff that most some people might not like I guess. He is in the mailing list I think, so he might add his input when he gets a chance. I personally have never used the script.
Hi. The tidy script is pretty simple and (as I recall) was a hack to tab indent to allow intelligent folding of LaTeX documents. I wrote it in 2004 so it's fuzzy in my mind. Everyone is welcome to improve it.
Reformat Paragraph is really close to what I want, and in fact would be exactly what I want, if a paragraph would indeed be a logical LaTeX paragraph (rather than a textual paragraph) for Textmate.
I don't understand what that means, but I'm not a LaTeX geek. Does that mean that you want a command to remove all line breaks and insert breaks before logical separators, like \item and \section, etc.? How far away is LaTeX Tidy, assuming it could work on a selection?
So do I get you right that it is not possible for a language definition to specify what it counts as a paragraph?
That is correct, to the best of my knowledge. You could ask it as a feature request, though it will probably have to wait until 2.0 at least.
It seems like it would be a straightforward command to write. I would think the fastest thing to do would be to write a little command that inserts line breaks before all the things you don't want broken and then run a macro to Reformat Paragraph and then run your little command.
The insert line break command would be something like (off the cuff)
perl -pe "s/(\item|\section|\subsection)/\n$1/g"
Good luck. If you can't do it, perhaps someone else on the list with some time, or wanting to practice writing a simple TM command could do it... My wonderful 7-month old daughter has reduced my programming productivity...
best, Eric
ps. The LaTeX bundle has changed a lot (in cool ways) since I last worked on it. However, I don't get why there is no built-in way to wrap text in [ ] or ( ), since this is by far the most common move I make. Does anyone have objections to me adding such commands? If so, what is the recommended way of doing this with the existing bundle?
On Jan 10, 2006, at 11:12 AM, Eric Hsu wrote:
ps. The LaTeX bundle has changed a lot (in cool ways) since I last worked on it. However, I don't get why there is no built-in way to wrap text in [ ] or ( ), since this is by far the most
It is probably partly because I never use those two, I use dollar signs instead :). I also tend to do my math by first entering math environment, and not by wrapping the text later. That's my only complain about TextMate at this point, that I can't have smart pairs consisting of more than one characters, so to try and enter math environment immediately is a slight pain. (Yes of course I can write a snippet to do it, but it can't be (yet) set to trigger on [ and the like.
common move I make. Does anyone have objections to me adding such commands? If so, what is the recommended way of doing this with the existing bundle?
By all means please do add them. What shortcuts did you have in mind?
Haris
Am 10.01.2006 um 18:12 schrieb Eric Hsu:
I don't understand what that means, but I'm not a LaTeX geek. Does that mean that you want a command to remove all line breaks and insert breaks before logical separators, like \item and \section, etc.? How far away is LaTeX Tidy, assuming it could work on a selection?
LaTeX tidy does exactly the opposite thing to what I want: it collates several lines into one. While this is a good thing in a Mac world (where a paragraph is text between two newlines), it is a little unfortunate in the LaTeX context (where a paragraph is text between two empty lines).
As an example, the error messages that the LaTeX compiler gives refer to line numbers. Now according to the standard Mac view of things, one line can be a whole, page-long text. Then it is time for a round of Spot the Error on your part.
So what I want is to break a Mac paragraph into several lines, becoming a LaTeX paragraph.
The problem is that the reformatting should stop at certain boundaries, such as \begin and \end or list \items. AucTeX does this for you, and my question was whether I can replicate this with Textmate. It seems now that I cannot.
Thanks, Marco
On Jan 10, 2006, at 5:18 PM, Marco Kuhlmann wrote:
The problem is that the reformatting should stop at certain boundaries, such as \begin and \end or list \items. AucTeX does this for you, and my question was whether I can replicate this with Textmate. It seems now that I cannot.
Of course you can replicate this in Textmate. It's just that you have to write the command that does it, just like someone wrote the AUCTeX command to do it. It just isn't a feature that exists by default, because none of us working on the LaTeX bundle needed this, and hence noone has implemented it yet. You are welcome to write the command yourself, or if you tell us EXACTLY what this command should be doing, maybe one of us will create it when we have the time. TextMate is very customizable.
Haris
Am 11.01.2006 um 00:29 schrieb Charilaos Skiadas:
Of course you can replicate this in Textmate. It's just that you have to write the command that does it, just like someone wrote the AUCTeX command to do it. It just isn't a feature that exists by default, because none of us working on the LaTeX bundle needed this, and hence noone has implemented it yet. You are welcome to write the command yourself, or if you tell us EXACTLY what this command should be doing, maybe one of us will create it when we have the time. TextMate is very customizable.
Sorry, I meant: cannot do this just by altering TextMate's understanding of what constitutes a paragraph. I completely understand that I could write a script that does this. I might even do this as soon as I learn more about the Bundle system. It's just that I got surprised that there was a command called Reformat Paragraph (just as in Emacs), bound to a key that resembled the key binding from Emacs, but doing something completely different.
- Marco
On Jan 10, 2006, at 6:05 PM, Marco Kuhlmann wrote:
I might even do this as soon as I learn more about the Bundle system. It's just
Feel free to ask us any questions you may have, either here or in the irc channel.
that I got surprised that there was a command called Reformat Paragraph (just as in Emacs), bound to a key that resembled the key binding from Emacs, but doing something completely different.
Yes, it would have been great if it worked out of the box. Oh well....
- Marco
Haris
On 10/01/2006, at 18:12, Eric Hsu wrote:
ps. The LaTeX bundle has changed a lot (in cool ways) since I last worked on it. However, I don't get why there is no built-in way to wrap text in [ ] or ( ), since this is by far the most common move I make. Does anyone have objections to me adding such commands? If so, what is the recommended way of doing this with the existing bundle?
I added some commands lately, but apparently the current trend is to keep them small (even though LaTeX is one of the smallest) so they were rolled back. My $$ snippet, which turns into [ ] survived, though. So: $$ <tab> :-).
-- Sune.
At 1:30 AM +0100 1/11/06, Sune Foldager wrote:
I added some commands lately, but apparently the current trend is to keep them small (even though LaTeX is one of the smallest) so they were rolled back. My $$ snippet, which turns into [ ] survived, though. So: $$ <tab> :-).
I noticed that. I tweaked it to include the selected text, so I believe it works the way you expect when $$-tab triggered while it behaves the way I want when key-triggered (which is to wrap [ ] around selected text). I made a parallel one that does ( ), but I also thought about retraining myself to use $ ... $ since that auto-matches so nicely. I'll commit it when I remember to...
best, Eric
On 11/01/2006, at 1:50, Eric Hsu wrote:
I noticed that. I tweaked it to include the selected text, so I believe it works the way you expect when $$-tab triggered while it behaves the way I want when key-triggered
They can be both tab and key triggered?
(which is to wrap [ ] around selected text). I made a parallel one that does ( ), but I also thought about retraining myself to use $ ... $ since that auto-matches so nicely. I'll commit it when I remember to...
Ah.. I didn't even know that ( ) was inline math :-p. I always use $...$
-- Sune.
On Jan 10, 2006, at 8:08 PM, Sune Foldager wrote:
On 11/01/2006, at 1:50, Eric Hsu wrote:
I noticed that. I tweaked it to include the selected text, so I believe it works the way you expect when $$-tab triggered while it behaves the way I want when key-triggered
They can be both tab and key triggered?
Yes, I found that out by accident at some point, when I forgot to remove the key equivalent before putting a tab trigger in :) Really cool.
Haris