All pastes #707673 Raw Edit

Something

public text v1 · immutable
#707673 ·published 2007-09-23 04:53 UTC
rendered paste body
[21:29] <jtbandes> allan: what I really need is a way to put tab stops in format strings. This needs to put a new tab stop after "bar.":  ${1:foo}${1/(^foo$)/(?1:bar.$2)/}
[21:31] <jtbandes> Of course, that would kinda interfere with regexps, you'd have to do \$2.
[21:31] <allan> also there is a whole bunch of problems related to how to enumerate the tab stops
[21:32] <allan> i.e. if this is going to be useful, you’d have to insert more than just one tab stop dynamically
[21:32] <jtbandes> Why?  ${1:foo}${3:bar} doesn't cause problems.
[21:32] <jtbandes> Example.
[21:32] <jtbandes> <div${1/(^.+$)|/(?1: )/}${1:i}${1/(^i$)|(^c$)|(^s$)|.+/(?1:d:(?2:lass:(?3:tyle)))/}${1/(^.+?)|/(?1:="A$2")/}>$3</div>$0
[21:32] <allan> jtbandes: not sure what you’re aiming for
[21:32] <jtbandes> I want (?1:="A$2") to actually put a tab stop in ="|||"
[21:33] <allan> maybe try switch language to C then type printf⇥ and enter e.g. %s in the string
[21:33] <allan> and notice how a new argument appear
[21:33] <allan> if that is all you want, maybe your simple suggestion will work, but not really give us much more
[21:33] <allan> what I want is to have multiple dynamic tab stops inserted based on what the user type
[21:34] <jtbandes> It looks like the C one is faked, kidna..
[21:34] <jtbandes> *kinda
[21:36] * loincloth (n=loinclot@c-67-174-220-109.hsd1.ca.comcast.net) has joined ##textmate
[21:37] <jtbandes> What I'm aiming for in mine is that div⇥ does <div id=""></div> with the 'i' in id as the selection, then the part with the 'd' is 'lass' if you type c, 'tyle' if you type s, or nothing if you type something else. The space before the attribute doesn't exist if you delete the contents of the tab stop. However, if you do delete the attribute, there's an extra stop which I don't want.
[21:39] <jtbandes> (the extra tab stop is where between the "" would be, if there were quotes)
[21:40] <jtbandes> allan: am I missing something, or is there no way to do that at this point?
[21:42] <allan> no, you can’t do dynamic tab stops
[21:42] <jtbandes> And that's what I want for christmas :)
[21:43] <allan> yes, what I was saying is that your case has rather limited use — I want to fully control the insertion of them, as there are many more use cases for that, but it is not straight
[21:43] <allan> +forward
[21:43] <jtbandes> What do you mean by fully control?
[21:44] <allan> well, say you enter the printf format string and you put in "%s: is %d" then I want the argument part to become », ${2:string}, ${3:int}«
[21:45] <allan> so I don’t just want to either insert $2 or not, as in your case
[21:45] <allan> I want to insert multiple tab stops, with place holder text under my control
[21:45] <jtbandes> Well, but with my suggestion, couldn't you do that?
[21:45] <allan> no
[21:45] <allan> not without further thoughts
[21:45] <jtbandes> I mean, I could put "${2:string}" instead of "$2"..
[21:45] <allan> yes, and how would you get the next argument to 3?
[21:45] <jtbandes> That is, inside the last section of ${1/(^.+?)|/(?1:="A$2")/}
[21:45] <allan> (instead of 2)
[21:46] <jtbandes> You would hard-code it as 3?
[21:46] <jtbandes> That doesn't create any problems.. unless you want unlimited tab stop creation. that's what you're saying, isn't it. >_<
[21:46] <allan> ehm… but I want to run a /g replace on the user string and insert a tab stop in each replacement
[21:46] <jtbandes> Yes, then that creates problems :)
[21:47] <allan> yes, as I said “fully control”
[21:47] <allan> I don’t just want a binary tab stop
[21:47] <jtbandes> You could have some magic thing like ${%:whatever} that would put the next available stop in place of $.
[21:47] <jtbandes> s/\$/%/
[21:47] <allan> yes, and then what if you want to actually insert a tab stop with a mirror, so not increase the count?
[21:47] <jtbandes> Tough?
[21:47] <jtbandes> :P
[21:48] <jtbandes> There doesn't seem to be a perfect solution... but better is better.
[21:48] <allan> anyway, I was just saying that there are more considerations to your request than just implementing it…
[21:48] <jtbandes> Unless you had a GUI snippet editor. Then you might have a chance at doing that.
[21:48] <allan> surely a language (which snippets are) can convey more than a GUI
[21:49] <jtbandes> If you can think of a way to give that much control through a legible snippet language, go for it.
[21:49] * chendo has quit (Connection timed out)
[21:51] <allan> yeah, I think I can :)
[21:51] <allan> but it won’t be for christmas… ;)
[21:51] * dmitrig01 has quit ()
[21:51] <jtbandes> I'll give you another month. How about my birthday? :P