[Gllug] Emacs macro to do a replace-regexp

Mark Preston mark at markpreston.co.uk
Wed Feb 15 05:14:47 UTC 2006


*Hi,
What about using emacs' query replace command (Alt-%)?
To suspend the query replace session (if you spot another error which 
needs adjusting) **use Ctrl-r
To resume the query replace **use Ctrl-Alt-c.
Regards,
Mark
*

On Mon, 13 Feb 2006, J. F. wrote

Hello

I'm new to Emacs and I'm trying to set up a quick way of doing a search & replace for a word beginning with &# and ending with a semi-colon (ie an HTML entity) in Emacs. But I want to be asked everytime whether the search string should be deleted or replaced with something else.

I tried to set up a keyboard macro for the command replace-regexp, searching for '\&\#[^;];' (without the quotes). I stopped recording it when it asks what it should be replaced with, but this didn't work... when running the keyboard macro it goes ahead and replaces everything without asking. This is the macro in my .emacs:

(fset 'findentities
   [?\M-x ?r ?e ?p ?l ?a ?c ?e ?- ?r ?e ?g ?e ?x ?p return ?\\ ?& ?\\ ?# ?[ ?^ ?\; ?] ?* ?\;])

Is there a way of running this keyboard macro interactively, where it asks what the search string should be replace with? Or should I look into LISP?

Thanks

-- 



-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list