On Sun, 18 Jan 2009 02:17:42 +0100, spir denis.spir@free.fr wrote:
-3- I would add a "replace all in current scope" function that I dream of for years already ;-) where 'scope' means closest nesting func, class, or whatever.
Hmm, not sure. Could be done but adds yet another button, yet another thing you need to sort out when you do a quick search/replace. (this is not a 'no', just a 'I won't work on it')
[...]
"In Scope" sounds interesting, but I think it would be too complicated practically to be added alongside the other find/replace modes. My misgivings:
- Would it work reliably/predictably, even in cases of complex C++
code and the like?
- What, exactly, does "scope" mean? Body of the current
function/method? (Would it include the signature line, so you can find/replace the formal parameters too?)
Yes, I meant that. Precisely, as a formal parameter (name) is a local variable (name), I find practicle to be able to "replace all" in the scope of the name life. Namely (sic!) a namespace is imo the proper scope of a "replace all" feature in many cases, if not most. So that when writing "in scope" I rather meant "in the extent of the current code section that defines a namespace". What about just the current curly-brace block, which
would also have a claim to the term "scope?" Or the current class? Would there be a preference to decide between these, or would it be something set by the language syntax driver?
The note above basically excludes lower level code blocks such as loops or ifs. Anyway, this seems mostly useful for funcs/methods and it would apply on a whole class only when one points at a line at class top-level. An alternative may be to define this at per-language level inside language specific config files, so that there would be both a geany default and possible user preference.
Hmm, first this is going a bit off-topic and far beyond the original request. I don't think we need this in the core of Geany, could be done as a plugin, maybe. But per filetype scope settings just for 'Replace All' sounds heavy to me, sorry.
Anyway, we already have some code to find the scope at the cursor position and the found scope is displayed in the statusbar. Anyway, it's known that this value is not always accurate and not that reliable. Especially for PHP files and maybe others.
Regards, Enrico