Suppose you have two snippets, like: \begin{${1:name}} $2 \end{${1:name}}
and
\emph{${1:emphasized text...}}
and suppose we want to insert the second snippet while editing $2 of the first snippet. Then the snippet will not expand. On the other hand, working only with the first snippet, once we are done editing $2 and press tab, we will conveniently move out of the snippet. One the other hand, we could have the first snippet as: \begin{${1:name}} $0 \end{${1:name}}
This has the advantage that the second snippet will work while editing $0, but the disadvantage that tabbing will no longer take us out of the first snippet. Questions: 1) Is there a workaround to make both things possible? 2) More generally is it possible, or planned in the future, to support activating a new snippet while in the process of completing another snippet? 3) If there is no workaround, do people have a preference on which of the two situations is more useful?
thanks, Haris
On May 20, 2005, at 0:35, Charilaos Skiadas wrote:
- Is there a workaround to make both things possible?
No
- More generally is it possible, or planned in the future, to
support activating a new snippet while in the process of completing another snippet?
It's planned.
- If there is no workaround, do people have a preference on which
of the two situations is more useful?
Probably depends on the situation ;)
On May 19, 2005, at 9:30 PM, Allan Odgaard wrote:
- If there is no workaround, do people have a preference on which of
the two situations is more useful?
Probably depends on the situation ;)
It's just that the snippets in the LaTeX bundle are not consistent, some of them are one way and some the other. I guess in hindsight it makes sense the way they are now. The equation snippet usually contains a line or two, so probably no other snippet will be used in there. The general begin-end snippet is designed more for environments, and there are more things going in there usually, so it makes sense to allow other snippets in there.
Btw, I have some more snippets for common environments, like theorem, lemma, definition etc, but since these are user defined environments and the users might want to name their theorem environments differently, I have not included them in the bundle. If you want/are not opposed to, I could add them, and the user can edit them to their liking later on. Sure they can use the generic begin-end snippet, but I find I use them so often that I'd much rather have snippets for them anyway. Also, my personal preference is to automatically add labels to them as well.
Haris
On 20/05/2005, at 4.43, Charilaos Skiadas wrote:
Btw, I have some more snippets for common environments, like theorem, lemma, definition etc, but since these are user defined environments and the users might want to name their theorem environments differently, I have not included them in the bundle. If you want/are not opposed to, I could add them, and the user can edit them to their liking later on. Sure they can use the generic begin-end snippet, but I find I use them so often that I'd much rather have snippets for them anyway. Also, my personal preference is to automatically add labels to them as well.
I have snippets for those too, with labels, but like you say their names are custom so I don't know if it's a good idea to add them. I use names def, lem thm and cor myself.
-- Sune.
Haris,
I find that I rarely make it through a multi-part snippet without doing something that breaks me out of snippet-tab-mode. Then I fill in the rest of the snippet template by navigating to the pieces in the usual way. Maybe I just have an unusually short attention span, or I am an exceptionally erratic typist, not sure. Anyway, usually by the end of the first template variable I've managed to get it so that tabs are just tabs.
I think that in a \begin \end environment like the one in your example, the $0 between the begin/end is the way to go. Usually people are going to do a fair amount of typing in between.
I think its important to remember that Snippets help two completely different classes of user.
1. Novices -- advanced beginners: Snippets help them create basic language constructs that they otherwise don't know how to do without spending time in the manual. How do I make a table? How do I insert a figure? etc. These users are most likely going to select snippets from the menu.
To this end, I'd like to see Allan add the ability to create categories and subcategories of snippets that result in menus/ submenus if snippets. IMHO the snippets menu is useless for languages like Actionscript and OCaml because there are too many entries (screens of them)
2. language power users : These users already know the syntax for creating a table, the snippet is just helping this class of users go faster. These users are going to use tab completion. These users are going to be most annoyed when things don't behave logically. (at least as far as they understand the workings of things)
Here's the one that annoys me the most: (and I've just now figured out how to fix it since I've been writing this email :-) )
\begin{itemize} \item ${1:premier item} $0 \end{itemize}
Here's my typical use pattern with the above:
itemize<tab> type in first item, <return> item<tab> At this point I end up on the next line with the word item on a line by itself crap, why does this do this? - Why isn't TM smart enough to read my mind and understand when I'm ready to move on to a new snippet? - Why aren't I smart enough to understand TM's rules for deciding I'm not in snippet-tab-mode anymore.
Personally, I think <return> ought to do it.
Now, I've modified my copy of itemize to be: \begin{itemize} \item ${0:premier item} \end{itemize}
Now things behave like I would like them to. I think I'll commit this new itemize, and fix up the other list making environments as well.
As to your other question about theorems and definitions, I say add them so that they are there to help people get better with Latex.
Brad
On May 19, 2005, at 9:30 PM, Allan Odgaard wrote:
On May 20, 2005, at 0:35, Charilaos Skiadas wrote:
- If there is no workaround, do people have a preference on which
of the two situations is more useful?
Probably depends on the situation ;)
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
On May 20, 2005, at 8:17 AM, Brad Miller wrote:
Haris,
I find that I rarely make it through a multi-part snippet without doing something that breaks me out of snippet-tab-mode. Then I fill in the rest of the snippet template by navigating to the pieces in the usual way. Maybe I just have an unusually short attention span, or I am an exceptionally erratic typist, not sure.
I also cannot work with a snippet that has more than two tabs, and that's already too much :-)
Anyway, usually by the end of the first template variable I've managed to get it so that tabs are just tabs.
I think that in a \begin \end environment like the one in your example, the $0 between the begin/end is the way to go. Usually people are going to do a fair amount of typing in between.
I think its important to remember that Snippets help two completely different classes of user.
- Novices -- advanced beginners: Snippets help them create basic
language constructs that they otherwise don't know how to do without spending time in the manual. How do I make a table? How do I insert a figure? etc. These users are most likely going to select snippets from the menu.
To this end, I'd like to see Allan add the ability to create categories and subcategories of snippets that result in menus/submenus if snippets. IMHO the snippets menu is useless for languages like Actionscript and OCaml because there are too many entries (screens of them)
I think this is a great idea. The way things are, I'm afraid to add too many snippets so as not to overload the menu. Btw, how much of a concern is the size of the bundle? Does adding a lot of snippets affect performance? If not, then I could try to add as many LaTeX commands as snippets as possible, or at least commands I think are likely to be often used.
- language power users : These users already know the syntax for
creating a table, the snippet is just helping this class of users go faster. These users are going to use tab completion. These users are going to be most annoyed when things don't behave logically. (at least as far as they understand the workings of things)
Here's the one that annoys me the most: (and I've just now figured out how to fix it since I've been writing this email :-) )
[snip]
Now, I've modified my copy of itemize to be: \begin{itemize} \item ${0:premier item} \end{itemize}
Now things behave like I would like them to. I think I'll commit this new itemize, and fix up the other list making environments as well.
This sounds more appropriate to me too. I can't remember if I edited it, or if someone else did, but I would guess whoever did it might have had the html lists in mind, where a simple return would not cut it. But I guess Command-return takes care of that now and is pretty intuitive. (btw, command-return is bound to <br /> in html. Do we really want that?)
As to your other question about theorems and definitions, I say add them so that they are there to help people get better with Latex.
Great, I'll edit them a bit and add them to the bundle, and people can adjust them as they see fit. On this respect, it might make sense to create a template for amsart, with these definitions included. Maybe a project for me for the weekend...
Brad
Haris
On May 21, 2005, at 2:04, Charilaos Skiadas wrote:
I find that I rarely make it through a multi-part snippet without doing something that breaks me out of snippet-tab-mode. Then I fill in the rest of the snippet template by navigating to the pieces in the usual way. Maybe I just have an unusually short attention span, or I am an exceptionally erratic typist, not sure.
I also cannot work with a snippet that has more than two tabs, and that's already too much :-)
Yeah, I also think for those 3+ argument snippets, it's often easier to collect the information first, and then say: make the proper boilerplate given this stuff I just collected for you! I've seen a few snippets with a non-linear flow through the snippet, that stuff throws me off ;)
To this end, I'd like to see Allan add the ability to create categories and subcategories of snippets that result in menus/ submenus if snippets. IMHO the snippets menu is useless for languages like Actionscript and OCaml because there are too many entries (screens of them)
OCaml turns out (after sorting) that this is completions for a lot of known functions for most objects, so here you'd never use the menu. But eventually I do plan to provide a way to structure these things into groups etc.
I think this is a great idea. The way things are, I'm afraid to add too many snippets so as not to overload the menu.
The important thing IMHO is to choose tab triggers in a way that makes them easy to remember, that way the menu really shouldn't be used. Often this means going with the full word of what to insert rather than some abbreviation, because the former is easy to remember (afterall, that's what the user wants to insert), where the latter is rather arbitrary (so only for stuff that's used a lot, should that be used, and since how to abbreviate is a personal preference, it probably makes sense to leave this to the user to do, when he starts to get confident with using snippets).
It also makes sense to try to use the same tab triggers accross languages, of course this does require some coordination, but going into a new language and being able to simply type function<tab> to get the proper way to define a function in that language would be a nice help :)
Btw, how much of a concern is the size of the bundle? Does adding a lot of snippets affect performance? If not, then I could try to add as many LaTeX commands as snippets as possible, or at least commands I think are likely to be often used.
After I started to load bundle items in a separate thread, I think the performance considurations are negligible (also, I'll probably switch to lazy loading using a cache of scope+activation per item in the future, so that I won't have to do any loading before the item is called upon).
So the main concern is perceived complexity.
Here's the one that annoys me the most: (and I've just now figured out how to fix it since I've been writing this email :-) )
[snip]
Now, I've modified my copy of itemize to be: \begin{itemize} \item ${0:premier item} \end{itemize}
Now things behave like I would like them to. I think I'll commit this new itemize, and fix up the other list making environments as well.
This sounds more appropriate to me too.
I've been bitten by that as well! :) I'm not entirely sure I want return to leave a snippet/placeholder -- when I do support nested snippets, it will work as expected even in the first form, so that might be the better workaround.
(btw, command-return is bound to <br /> in html. Do we really want that?)
No -- I've changed it to control-return now, which is consistant with control-space to make a tag pair. I've also added a control-return snippet for the source scope which inserts “\n”.
On 21/05/2005, at 2.04, Charilaos Skiadas wrote:
On May 20, 2005, at 8:17 AM, Brad Miller wrote:
As to your other question about theorems and definitions, I say add them so that they are there to help people get better with Latex.
Great, I'll edit them a bit and add them to the bundle, and people can adjust them as they see fit. On this respect, it might make sense to create a template for amsart, with these definitions included. Maybe a project for me for the weekend...
I think most people who use amsmath already have templates (I even use a custom class) for that, since ams is really mostly needed for the more advanced features, but... *shrug*. And again, the names might differ although I guess 'thm', 'lem', 'def', 'exa' and 'cor' are quite common.
-- Sune.
On May 21, 2005, at 2:23 AM, Sune Foldager wrote:
I think most people who use amsmath already have templates (I even use a custom class) for that, since ams is really mostly needed for the more advanced features, but...
You are probably right. While thinking what to put in it, I realized there's no way to make it work well for everyone.
*shrug*. And again, the names might differ although I guess 'thm', 'lem', 'def', 'exa' and 'cor' are quite common.
I figure these are probably more or less standard. I set those up as snippets with those triggers, and environment names as I would call them, and I guess if people call their environments differently, then they can just change the names in the snippets, easier than writing the snippets in the first place.
-- Sune.
Haris