help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: re-builder vs replace-regexp


From: Eric Abrahamsen
Subject: Re: re-builder vs replace-regexp
Date: Fri, 25 Nov 2011 17:22:18 +0800
User-agent: Gnus/5.110018 (No Gnus v0.18) Emacs/24.0.91 (gnu/linux)

On Fri, Nov 25 2011, Андрей Парамонов wrote:

> Re-Builder is a great tool. It allows interactive search with
> incredibly handy highlight, subexpression mode, etc. However, one
> often needs not just search by regexp, but also perform regexp
> replace. I thought reb-copy command would help me to pass my regexp to
> replace-regexp. But replace-regexp doesn't understand the result of
> reb-copy, i.e. for default *scratch* buffer the following regexp works
> in Re-Builder:
>
> "\\(file\\)"
>
> but to make it suitable for search-forward-regexp/replace-regexp I
> need to manually adjust it to
>
> \(file\)
>
> I find it really inconvenient (the larger regexp the more
> inconvenient). Should I report a bug, or I'm missing something basic?
> I'm running GNU Emacs 23.3.1.

Try the library re-builder+, at
http://www.emacswiki.org/emacs/re-builder+.el

It provides `reb+-replace-regexp' which is something like what you want.
Personally, I think a nice solution would be a function bound to a key
in re-builder mode that takes the present regexp, modifies it to work
with replace-regexp and family, and then places it on the re search
history. You hit the key, go to do your search or replace or whatever,
and then hit M-p to call up that regexp. That sort of thing wouldn't be
too hard to cobble together if you look at the code in re-builder+
(this is basically a note to self).

Eric

-- 
GNU Emacs 24.0.91.1 (i686-pc-linux-gnu, GTK+ Version 2.24.6)
 of 2011-11-07 on pellet




reply via email to

[Prev in Thread] Current Thread [Next in Thread]