Re: Newbie question on renaming

From: Alan Shutko (ats_at_acm.org)
Date: 05/07/04


Date: Thu, 06 May 2004 18:24:14 -0500

William Bland <news@abstractnonsense.com> writes:

> I guess this is the kind of thing that "refactoring browsers" are meant to
> do (guessing because I've never used one). I wonder how hard it would be
> to get Emacs to rename a variable, taking into account scope?

I like it! You should write it and incorporate it into SLIME!

But I don't frequently find it a problem. Most of my variables exist
in a very limited scope, inside a function or in a let body. If it
doesn't, it has a *nice-long-name* which is unique across files or
directories. So, when changing most variables, I have to change it
across two or three place only.

What you could do, for cases that are more involved than it, are to
use Emacs' mark-defun (C-M-h) or mark-sexp (C-M-SPC) commands, narrow
to the region (C-x n n), then C-M-% to replace things. You probably
don't reuse a variable for different things within the same scope, right?
I've used this to good effect in many languages.

-- 
Alan Shutko <ats@acm.org> - I am the rocks.
I just need enough to tide me over until I need more.


Relevant Pages

  • Re: Two Small Suggestions
    ... The reason it works as it does is because if you rename at any other ... preserving refactoring. ... safer to rename at global scope (ignoring external dependencies such as ...
    (comp.lang.smalltalk.dolphin)
  • Re: Two Small Suggestions
    ... Global is probably my least favourable option as well - ... The reason it works as it does is because if you rename at any other scope ... Contrary to intuition it should actually be safer to rename at ...
    (comp.lang.smalltalk.dolphin)
  • Re: Returning address of local variable
    ... (I think it depends on whether you mean lexical or dynamic scope.) ... nowhere in the Standard. ... I'm guessing most people reading this group aren't intimately acquainted with Concepts VI:2:1. ...
    (comp.lang.c)
  • Re: Scope for .22 Rifle
    ... # I also noticed that the scope rings come in medium and high. ... I'm guessing I should get the medium, ... You want the scope as low as possible. ...
    (rec.guns)
  • Re: Roland HP-860 electronic piano has HUM
    ... facts. ... guessing. ... understand - and check each of the rails for ripple with your 'scope ... ... Arfa ...
    (sci.electronics.repair)