On 30-Mar-08, at 3:18 PM, Thomas Aylott - subtleGradient wrote:
On Mar 29, 2008, at 10:37 PM, Alain O'Dea wrote:
I would find it incredibly useful if I could do a
that I could reliably rename symbols like variables and function
names. I envision that this would be based on scopes and that it
would constrain Find/Replace to exact matches of entire scopes. In
Erlang this would enable me to rename variables by doing a Find/
Replace of exact scope match for variable.other.erlang.
Actually, search and replace is more powerful than the scope
matching in language grammars.
Find and replace regex can match multiple lines.
What you could do is look at the language definition file and find
out the regex that's used to scope variables and then modify it to
search and replace the specific variables you're looking for.
Maybe this could be automated in a command somehow. But, currently
TextMate wouldn't be able to do what you're asking in any but the
currently open document, since it doesn't even parse any files that
it doesn't have open, and a command isn't capable of accessing the
parsed version of any but the frontmost document anyway.
Maybe you could do something with a ruby script that parses all the
files in the project or something similar and asks you what
variables you want to replace.
Personally, I wouldn't touch something like this because of the pain
that it would take to debug it.
I see how your suggestion would work for Erlang, where variables are
lexically distinct from other symbols. However, just grabbing the
regex for variables from the language file won't suffice because it
loses the state/context in which that regex validly extracts variables
from the stream of text. Even in Erlang, this is a problem because
capitalized words (which Erlang's variables must be) can appear in
comments, strings, and other contexts where they are not logically
You mentioned by that a command isn't capable of accessing the parsed
version of any of the frontmost document. Does that mean that the
parsed version of the frontmost document is somehow accessible to
commands? That would be immensely useful to me for a variety of