unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Transforming Captures in replace-regexp
@ 2007-02-17 10:33 Peter Danenberg
       [not found] ` <mailman.4651.1171710704.2155.help-gnu-emacs@gnu.org>
  2007-02-17 12:12 ` Peter Danenberg
  0 siblings, 2 replies; 6+ messages in thread
From: Peter Danenberg @ 2007-02-17 10:33 UTC (permalink / raw)
  To: help-gnu-emacs

     I'd  like  to  transform captured groups from `replace-
regexp', say, by iterating over the search results  with  an
arbitrary function.

     To take a trivial example, I'd like to run `capitalize-
region' on every \1 resulting from `\(.*\):'.

     Should I be interesting in something like Icicles?*

Best, Peter

-----------
  * http://www.emacswiki.org/cgi-bin/emacs-en/Icicles

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Transforming Captures in replace-regexp
       [not found] ` <mailman.4651.1171710704.2155.help-gnu-emacs@gnu.org>
@ 2007-02-17 12:05   ` David Kastrup
       [not found]     ` <mailman.4655.1171716444.2155.help-gnu-emacs@gnu.org>
  2007-02-17 13:47     ` Peter Danenberg
  0 siblings, 2 replies; 6+ messages in thread
From: David Kastrup @ 2007-02-17 12:05 UTC (permalink / raw)
  To: help-gnu-emacs

Peter Danenberg <pcd@wikitex.org> writes:

>> I'd like to transform captured groups from `replace-regexp', say,
>> by iterating over the search results with an arbitrary function.
>
>
>      The  answer  is  of course to use `\,', following by an
> arbitrary Lisp expression; read the source, Luke!

Works only with Emacs>21, namely pretests or development snapshots of
Emacs 22.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Transforming Captures in replace-regexp
  2007-02-17 10:33 Transforming Captures in replace-regexp Peter Danenberg
       [not found] ` <mailman.4651.1171710704.2155.help-gnu-emacs@gnu.org>
@ 2007-02-17 12:12 ` Peter Danenberg
  2007-02-17 12:23   ` Jim Ottaway
  1 sibling, 1 reply; 6+ messages in thread
From: Peter Danenberg @ 2007-02-17 12:12 UTC (permalink / raw)
  To: help-gnu-emacs

> I'd like to transform captured groups from `replace-regexp', say,
> by iterating over the search results with an arbitrary function.


     The  answer  is  of course to use `\,', following by an
arbitrary Lisp expression; read the source, Luke!

Best, Peter

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Transforming Captures in replace-regexp
  2007-02-17 12:12 ` Peter Danenberg
@ 2007-02-17 12:23   ` Jim Ottaway
  0 siblings, 0 replies; 6+ messages in thread
From: Jim Ottaway @ 2007-02-17 12:23 UTC (permalink / raw)
  To: help-gnu-emacs

On 17 Feb 2007, Peter Danenberg wrote:

>> I'd like to transform captured groups from `replace-regexp', say,
>> by iterating over the search results with an arbitrary function.
>
>
> The  answer  is  of course to use `\,', following by an
> arbitrary Lisp expression; read the source, Luke!

That works as long as you have Emacs 22 [I don't think it is in 21].

And you don't need to read the source

 C-h C-f RET query-replace-regexp 

gives all the details of the usage of \,.

I've found it an extremely useful addition to query-replace-regexp.

Regards,

-- 
Jim Ottaway

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Transforming Captures in replace-regexp
       [not found]     ` <mailman.4655.1171716444.2155.help-gnu-emacs@gnu.org>
@ 2007-02-17 13:12       ` David Kastrup
  0 siblings, 0 replies; 6+ messages in thread
From: David Kastrup @ 2007-02-17 13:12 UTC (permalink / raw)
  To: help-gnu-emacs

Peter Danenberg <pcd@wikitex.org> writes:

>> Works only with Emacs>21, namely pretests or development snapshots
>> of Emacs 22.
>
>
>      I notice from the ChangeLog, David, that you're respon-
> sible for implementing `\,'; thanks: you've saved  at  least
> several hours of my life.

\, does not achieve anything that query-replace-regexp-eval could not
already do previously.  But discovering and using the latter felt, in
my opinion, too awkward for convenience.

You'll find that in the present implementation, \, actually
does nothing that a non-interactive call of query-replace-regexp could
not have achieved: it is implemented merely in the interactive form
collecting the arguments for query-replace-regexp, the actual call of
query-replace-regexp itself occuring with a Lisp form.  You can
look at it by using
C-x M-ESC
after a query-replace-regexp call using \,.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Transforming Captures in replace-regexp
  2007-02-17 12:05   ` David Kastrup
       [not found]     ` <mailman.4655.1171716444.2155.help-gnu-emacs@gnu.org>
@ 2007-02-17 13:47     ` Peter Danenberg
  1 sibling, 0 replies; 6+ messages in thread
From: Peter Danenberg @ 2007-02-17 13:47 UTC (permalink / raw)
  To: help-gnu-emacs

> Works only with Emacs>21, namely pretests or development snapshots
> of Emacs 22.


     I notice from the ChangeLog, David, that you're respon-
sible for implementing `\,'; thanks: you've saved  at  least
several hours of my life.

Best, Peter

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2007-02-17 13:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-02-17 10:33 Transforming Captures in replace-regexp Peter Danenberg
     [not found] ` <mailman.4651.1171710704.2155.help-gnu-emacs@gnu.org>
2007-02-17 12:05   ` David Kastrup
     [not found]     ` <mailman.4655.1171716444.2155.help-gnu-emacs@gnu.org>
2007-02-17 13:12       ` David Kastrup
2007-02-17 13:47     ` Peter Danenberg
2007-02-17 12:12 ` Peter Danenberg
2007-02-17 12:23   ` Jim Ottaway

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).