I'm using the following functions to speed up some regexps
replacements I frequently use.
jc-replace-regexp-in-region can be
called by several functions like
jc-dollar-to-paren. At the moment,
when one of those functions completes, the region is deactivated and I
have to reactivate it to execute another replace-regexp.
query-replace-regexp doesn't seem to offer an option to save the
activation of the mark, and the function jc-replace-regexp-in-region
explicitly sets the dectivate-mark (I don't actually know why, I
didn't write it).
Ideally I'd like to be able to chain several replace-regexp on the same region without having to mark the region between each one. How can it be done ?
(defun jc-replace-regexp-in-region (Begin End from to) "Replace from by to in the selected region" (interactive "r") (let (deactivate-mark) (query-replace-regexp from to nil Begin End))) (defun jc-dollar-to-paren (Begin End) "Replace $toto$ by \\(toto\\) in selected region" (interactive "r") (jc-replace-regexp-in-region Begin End "\\$\\([\n\t [:nonascii:][:ascii:]]+?\\)\\$" "\\\\\(\\1\\\\\)"))