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).