On Monday 12 March 2007 7:33 pm, Greg Rundlett wrote: > Way back in the stone age, I used Allaire Homesite to edit HTML. It > was a very good code editor for Windows. In the modern era, circa > 2001 I switched to Linux full-time and became a Quanta user. I've > been thrilled with Quanta. > > One thing I've noted missing however, is the ability to manage large > sets of files (using a graphical IDE) to do Perl-compatible Regular > Expression -based editing of file contents. For example, say I have > 10,000 PHP files, and they all say: > Hello World > // include foo library > include ('foo.inc'); > > Suppose I want to replace that with > > $title='Hello World'; > include ('foo.php'); > > There are multiple replacements with captured backreferences over > multiple lines of 'input'. An obvious job for using the strong regex > abilities of PHP with it's built-in functions like preg_replace(). > > Question 1: Can I create my own Kommander based applications that kick > off classes or functions that I have defined in php? Sure, no problem, but why not just use the KFileReplace plugin? It does it elegantly with multiline replace, backups, directory control, wildcards, saved searches and more. > > Continuing with my example, I have already defined (in a set of PHP > files that I named for lack of a better term 'gregsEditor') a 'doEdit' > function that would take arguments like the following: > > doEdit ($fileRegex, $pathString, $skipFiles, $verbose, $needle, > $replacement, $backup, $test); > > Using the above scenario, the function call would be something like this: > > doEdit ( > '/.*.html$/', > '/var/www/dev.example.com/public_html/', > null, > TRUE, > '|(.*)\n?(^// ?include foo library\n)?( include\(\'foo.inc\'))\n|', > ' > $title=\'$1\'; > include ('foo.php'); > ', > false); > > Question 2: Before I go implement this, is anyone aware of similar > capabilities in code that I should know about rather than dusting off > my old file editor code? > > I know Quanta has KFileReplace plugged in, but it does not handle > multiple lines of source code as the selected source very well if at > all, and it does not allow me fine-grained setting of the various > pattern matching options (imUs) including look-ahead expressions etc. > and lastly I do not know enough about the programmatic access to > scripting the interaction for very specific and complex edits. > > Thanks, > Greg I haven't had to use KFileReplace's more advanced features a lot lately, but unless recent code cleanings have stripped out features it does handle multi line code and I thought it had an elegant way of handling strings and pattern recognition and rewriting. I guess I should go look at it's pattern matching abilities. I'll have to check to see if features got removed in rewrites. You're of course welcome to build a Kommander based tool using PHP and even make it available via KNewStuff. -- Eric Laffoon - Quanta+ Team Leader http://quanta.kdewebdev.org _______________________________________________ Quanta mailing list Quanta@mail.kde.org https://mail.kde.org/mailman/listinfo/quanta