On Thu, 19 Aug 2010 16:20:47 -0500 "Edward K. Ream" <[email protected]> wrote:
> On Thu, Aug 19, 2010 at 4:12 PM, Matt Wilkie <[email protected]> wrote: > > I'm attempting to refactor several python files with numerous of > > copy-n-paste duplicated functions into a module. Is there some way Leo > > can search through node trees of "@file foo.py" and "@file bar.py" and > > make the duplicated functions clones of each other? > > That would be bad (Python) style. Create a module to hold common code > and import that module. > > I have often said that using clones to share code is an anti-pattern > (bad Leo style), except for languages like html for which there is no > alternative. I suspect Matt just wanted the clones as a way of visualizing the duplicate functions that have already been created by copy-n-paste (by someone else, no doubt :-). A script could build a dictionary mapping some hash of the body text to lists of the gnxs of nodes where that body text occurs, and then insert clones of the first occurrence after each subsequence occurrence, and delete the none-clone occurrences. Cheers -Terry -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/leo-editor?hl=en.
