benma / visual-regexp.el

A regexp/replace command for Emacs with interactive visual feedback
396 stars 28 forks source link

Eval in regex #2

Closed kototama closed 11 years ago

kototama commented 11 years ago

First let me tell you that what you have done is really great :-)

It would be even cooler if it was possible to do something like that (as it is possible currently with replace-regexp) and have direct feedback :

Replace regexp: (\w+) Replace regexp with: \,(capitalize \1)

benma commented 11 years ago

Thanks!

This feature needs more time than I thought, but it is coming. Please be patient :)

In the meantime, check out the steroids package. If you have Python installed, you can use Python expressions (C-c C-c to toggle). Your example replace string would then be \0.upper().

benma commented 11 years ago

Okay, version 0.2 of visual-regexp features lisp expressions, working just as in replace-regexp. Should be on melpa soon. Please report back if everything works. Thanks!

kototama commented 11 years ago

It seems to work fine on the few examples I tried.

Really great! It's a nice addition for my Emacs propaganda ;-). It's also helpful for code refactoring, file renaming etc!

benma commented 11 years ago

Cool, I'm glad it worked out. I also found it extremely useful for file renaming, which is why I put up this example in the readme ;)

Protip: I use C-c p a lot do see the replacements completely inline before applying it. I wonder if things like are known to users without tutorials.

kototama commented 11 years ago

Ok you closed the ticket but I think I found a bug, it's not possible to replace with this pattern:

\1\,(capitalize \1)

benma commented 11 years ago

Indeed! Is it better now? (You may have to wait for the package upgrade on melpa for a while)

kototama commented 11 years ago

It's working fine. It's great :-)

benma commented 11 years ago

Nice! Thanks for reporting this.