Path: utzoo!utgpu!water!watmath!clyde!rutgers!sri-spam!wohler From: wohler@spam.istc.sri.com (Bill Wohler) Newsgroups: comp.emacs Subject: Re: Need mlisp for "prefix-region" Message-ID: <11305@sri-spam.istc.sri.com> Date: 2 Feb 88 07:10:26 GMT References: <3910015@nucsrl.UUCP> Sender: nobody@sri-spam.istc.sri.com Reply-To: wohler@spam.istc.sri.com (Bill Wohler) Organization: SRI International Lines: 20 while the prefix-region function that people have been posting is nice, this function that i wrote (with your help) last year is more general. to perform a prefix-region, you would say, "M-x re-replace-region RET ^ RET whatever RET". (defun re-replace-region (begin end old new) "Replace occurrences of REGEXP with TO-STRING in region." (interactive "*r\nsReplace string: \nswith: ") (save-excursion (save-restriction (narrow-to-region begin end) (goto-char (point-min)) (while (re-search-forward old (point-max) t) (replace-match new t t))))) this has a feature of combining all the changes so that one undo will undo all of them. --bw