[prev in list] [next in list] [prev in thread] [next in thread] 

List:       quanta
Subject:    [Quanta] multi-file, multi-line PCRE (regex) editing support
From:       "Greg Rundlett" <greg () freephile ! com>
Date:       2007-03-13 3:33:57
Message-ID: 5e2aaca40703122033l16071717n2ffdba79287fb8c1 () mail ! gmail ! com
[Download RAW message or body]

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:
<title>Hello World</title>
<?
// include foo library
include ('foo.inc');

Suppose I want to replace that with

<?php
$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?

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,
  '|<title>(.*)</title>\n?(^// ?include foo library\n)?(<?\w
include\(\'foo.inc\'))\n|',
  '
  <?php
  $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
_______________________________________________
Quanta mailing list
Quanta@mail.kde.org
https://mail.kde.org/mailman/listinfo/quanta
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic