Hiya,
Is it possible for a bundle command to accept a single selection and return multiple selections (or just carets)?
Here’s an example (brackets indicate selection, | is a caret );
Stage 1: state: …class="|dark-theme"… action: select "dark-theme"
Stage 2: state: …class="[dark-theme]"… action: [Hypothetical caret split command]
Stage 3a: state: …class="[dark]-[theme]"…
or
Stage 3b: state: …class="|dark-|theme"…
Then I’d press command T to switch from "dark-theme" to "theme-dark".
Im not sure what the logic would be in the bundle, my use would be served by simply returning the caret at the beginning and end of my selection (then command + w to select the word).
I’m also curious how Filter Through Command’s behavior could be reproduced in a bundle command, where the commands results are distributed to each line.
Thanks everyone!
Graham P Heath
ps: I’ve got some serious love for multiple carets ♥️♥️♥️
On 29 Apr 2015, at 23:23, Graham P Heath wrote:
Is it possible for a bundle command to accept a single selection and return multiple selections (or just carets)?
It can return a snippet where subsets can be selected, but I don’t think this is useful for your example.
Here’s an example (brackets indicate selection, | is a caret ); […] Then I’d press command T to switch from "dark-theme" to "theme-dark".
I am not sure I follow your example. If you mean control T (rather than command T) then this will transform “dark-theme” into “theme-dark” if the entire thing is selected, so here there is no need to “split” the selection into left/right carets, or to select only the first word (on the contrary).
Though when there are multiple selections, control T changes from acting on each selection, to acting on all selections, and will transpose them (swap them around).
So I think I understand what feature you want, but the example isn’t the best, and also, if you get multiple carets, they sort of all act on the actions you do, e.g. move left/right etc., so “splitting” a selection into a left/right caret would be very hard to subsequently work with, as I don’t think there are many actions that would be able follow this.
Im not sure what the logic would be in the bundle, my use would be served by simply returning the caret at the beginning and end of my selection (then command + w to select the word).
Here I assume you mean control W. The end result could be achieved by selecting the “dark-theme” instances, then do a (regexp) “Find All” for \b\w+\b, although I don’t know step would follow this; if the goal is to swap them around, it might be simplest to do a search and replace, though leaving out the find dialog, I would probably have selected “dark-” and used control W to select consecutive matches, then ⌘X, ⌥→, -, ⌘V, ⌫ to “swap” the order of all the instances.
I’m also curious how Filter Through Command’s behavior could be reproduced in a bundle command, where the commands results are distributed to each line.
Do you mean “each caret” (rather than “each line”)?
If the input/output option of the command is selection/replace input, then it should act the same as Filter Through Command (which is really just an ad hoc command).
Thank you for your clarification, and I’m sorry for my command/control confusion (how embarrassing!).
I had no idea that Control + T would respect a hyphen as a separator. That is awesome and is a perfect example to my use case, so thanks for that.
And that would settle it, except you peaked my interest with your last sentence:
Filter Through Command (which is really just an ad hoc command).
Would you mind sharing the code for that command, or point me to a similar one?
Thanks much,
Graham P Heath
On May 3, 2015 at 10:31:51 AM, Allan Odgaard (mailinglist@textmate.org) wrote:
On 29 Apr 2015, at 23:23, Graham P Heath wrote:
Is it possible for a bundle command to accept a single selection and return multiple selections (or just carets)?
It can return a snippet where subsets can be selected, but I don’t think this is useful for your example.
Here’s an example (brackets indicate selection, | is a caret ); […] Then I’d press command T to switch from "dark-theme" to "theme-dark".
I am not sure I follow your example. If you mean control T (rather than command T) then this will transform “dark-theme” into “theme-dark” if the entire thing is selected, so here there is no need to “split” the selection into left/right carets, or to select only the first word (on the contrary).
Though when there are multiple selections, control T changes from acting on each selection, to acting on all selections, and will transpose them (swap them around).
So I think I understand what feature you want, but the example isn’t the best, and also, if you get multiple carets, they sort of all act on the actions you do, e.g. move left/right etc., so “splitting” a selection into a left/right caret would be very hard to subsequently work with, as I don’t think there are many actions that would be able follow this.
Im not sure what the logic would be in the bundle, my use would be served by simply returning the caret at the beginning and end of my selection (then command + w to select the word).
Here I assume you mean control W. The end result could be achieved by selecting the “dark-theme” instances, then do a (regexp) “Find All” for \b\w+\b, although I don’t know step would follow this; if the goal is to swap them around, it might be simplest to do a search and replace, though leaving out the find dialog, I would probably have selected “dark-” and used control W to select consecutive matches, then ⌘X, ⌥→, -, ⌘V, ⌫ to “swap” the order of all the instances.
I’m also curious how Filter Through Command’s behavior could be reproduced in a bundle command, where the commands results are distributed to each line.
Do you mean “each caret” (rather than “each line”)?
If the input/output option of the command is selection/replace input, then it should act the same as Filter Through Command (which is really just an ad hoc command).
_______________________________________________ textmate mailing list textmate@lists.macromates.com http://lists.macromates.com/listinfo/textmate
On 4 May 2015, at 17:00, Graham P Heath wrote:
And that would settle it, except you peaked my interest with your last sentence:
Filter Through Command (which is really just an ad hoc command).
Would you mind sharing the code for that command, or point me to a similar one?
What I mean is that internally TextMate treats it similar to any other command, so there is nothing special about the handling of its output, i.e. a regular command can do the same, the closest current command would be the Execute Line in the Shell Script bundle, in theory this one could show a dialog like Filter Through Command… via the DIALOG system and dynamically change its output option via its exit code.