On 2009-Apr-18, at 3:16 AM, Allan Odgaard wrote:
On 16 Apr 2009, at 15:44, Rob McBroom wrote:
I know the words themselves are already available for completion, but it might be more than one "word" or you might want the thing that results from a symbolTransformation instead of the original thing.
Can you give an example of when this is useful?
I thought you might ask that. I'll use the [Puppet][1] syntax as an example.
I've modified the Puppet bundle posted on Git hub and haven't shared my changes with the author yet, so I don't want to include it here, but I can describe the scenario.
If you have a resource like
file { "xyz.conf": # stuff }
you would refer to this resource elsewhere in the file as 'File["xyz.conf"]'. The Puppet bundle on Git hub would list this as "xyz.conf" in the symbols list, but that caused things like Service["postfix"] and Package["postfix"] to both show up as simply "postfix" in the list. I modified the bundle so the symbols list would contain the actual string that you would use to refer to the resource in your file so they could be distinguished from one another.
These things are obviously a bit awkward to type, and it's more common than you might think, so it would be nice if you could just ⎋ to complete them. Let em know if I didn't explain that well enough.
I think this should be handled by a custom completion command, which is already supported (rather than try to make something designed for one purpose somehwat useful in rare cases for another purpose).
I thought of a completion command. It just seems inefficient to redefine the regex that matches the "symbol", redefine the transformation, and re-parse the file on every completion when all of that has been done and the results are sitting right there in the symbols list.
I suppose on modern hardware, scanning the file over and over isn't a big deal, but the fact that a human has to remember to maintain the matching/transformation logic in both the language grammar and the completion command makes me hesitant to go down that road.
[1]: http://reductivelabs.com/trac/puppet