[Gllug] Emacs macro to do a replace-regexp

Mark Preston mark at markpreston.co.uk
Fri Feb 17 02:46:35 UTC 2006


Hi Nix,
 I didn't realize you'd added mind reading to your extensive skills.
Without a reply from the mysterious JF I guess we'll never know for sure
precisely what he was thinking. He does say he is new to Emacs, not that he's a
hardened hacker with too many neurones to rub together. 
In an ideal world I'd have you as my next door neighbour on one side and Tethys 
on the other side and I'm sure all my computering problems would be solved. I'd 
just need to supply the coffee, plastic blow up dolls, or whatever else was 
required for the odd favour. In the meantime I'll have to make do with 
eavesdropping on your postings to GLLUG :-).
Regards,
Mark

Late On Wed, 15 Feb 2006 Nix hypothesised,
>I think that's what he's trying to *avoid* :)

On Wed, 15 Feb 2006, Mark Preston whispered secretively:
>/ 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.

/On Mon, 13 Feb 2006, J. F. announced authoritatively:
>/ 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?/

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




More information about the GLLUG mailing list