Hi suppose the caret is somewhere inside a scope meta.myscope delimited by two keywords beginmyscope and endmyscope. I need to capture all the text in the region between beginmyscope and endmyscope. I thought the Input type "Selected Text or Scope" might do exactly this, but I'm seeing something different: only the text from the line where the caret is to endmyscope is captured. Is this the intended behaviour, or I'm doing something wrong? I think the scope is defined correctly since ctr-shift-P shows that the entire region between beginmyscope and endmyscope is correctly parsed as meta.myscope. What's wrong?
Thanks Piero
On 26 Oct 2008, at 01:25, Piero D'Ancona wrote:
suppose the caret is somewhere inside a scope meta.myscope delimited by two keywords beginmyscope and endmyscope. I need to capture all the text in the region between beginmyscope and endmyscope. I thought the Input type "Selected Text or Scope" might do exactly this, but I'm seeing something different [...]
It should do exactly that, yes (and a few default commands use it, like e.g. the toggle string quotes).
The scope selector of the command though must be the scope you want as input.
If you can’t make it work, post the involved grammar rules, document etc.
Allan Odgaard <mailinglist@...> writes:
If you can’t make it work, post the involved grammar rules, document etc.
After I read your message I tried to isolate an example but everything works as intended now... I hate computers. Problem vanished, not sure how that happened.
But I have an additional question. My trivial routine to get the text is
def get_test_in_scope(the_scope) TextMate.exit_discard unless ENV["TM_SCOPE"].split(" ")\ .include?(the_scope) the_text = STDIN.read return the_text end
(no comments on my coding style please. I know). What if two nested scopes are applicable in the same caret position and I need to capture all the text belonging to the larger scope? I guess I'm out of luck then, since STDIN.read has no way to get the larger area.
Thanks, Piero
On 26 Oct 2008, at 10:05, Piero D'Ancona wrote:
[...] I have an additional question. My trivial routine to get the text is
def get_test_in_scope(the_scope) TextMate.exit_discard unless ENV["TM_SCOPE"].split(" ")\ .include?(the_scope) the_text = STDIN.read return the_text end
If the goal is to act only when the fallback (of scope) is given as input, it is more robust to do something like:
TextMate.exit_discard if ENV.has_key?('TM_SELECTED_TEXT')
What if two nested scopes are applicable in the same caret position and I need to capture all the text belonging to the larger scope?
When selecting a scope, TM applies the scope selector to the scopes to the left/right of the caret, and stos as soon as the scope selector does not match.
So for nested scopes, you get all the scopes, which sounds like what you want.