I have a bunch of C macros in files, stuff like NEXT( pL ) which is expanded to ( ( pL ) -> next )
I want to remove most of them because they're unnecessary.
What I would like to do, is get the text inside the parentheses in the macro, pL. I want the replacing regexp to use that text for the rewriting. For example, in Perl I could do something like /NEXT\(\s*(.+)\s*) (may be a little incorrect) and then output something like $1->next, which should turn a line
if ( NEXT( pL ) != NULL ) {
into
if ( pL->next != NULL ) {
In Emacs, I would like to use match groups in an emacs replace-regexp on a file by file basis. I'm not entirely sure how to do this in Emacs.
M-x c-macro-expansionorM-x c-macro-expandcould be used. But what you ask for looks like it will need a new function around theM-x c-macro-expansionto work on a whole file or buffer.