Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!caip!rutgers!sri-spam!wohler From: wohler@sri-spam.istc.sri.com (Bill Wohler) Newsgroups: net.emacs Subject: Re: regular expressions and operations other than replace Message-ID: <8356@sri-spam.istc.sri.com> Date: Sat, 18-Oct-86 17:23:03 EDT Article-I.D.: sri-spam.8356 Posted: Sat Oct 18 17:23:03 1986 Date-Received: Tue, 21-Oct-86 20:55:46 EDT References: <1168@peregrine.UUCP> Reply-To: wohler@sri-spam.UUCP (Bill Wohler) Organization: SRI International, Menlo Park Lines: 34 mike, i had the same problem you did when i switch to gnuemacs, but, since gnuemacs is fully extensible, i wrote my first lisp function (no laughter from the peanut gallery, please). in addition, emacs offers a richer regular expression set than vi does. check it out! anyway, here's the function that will get you started. load it in and bind it to a key if you wish. currently you have to set the region around the section of text that you want to massage and then set your point at the beginning of the region. therefore, if you wanted to do the whole file, you could use C-x h to select the whole buffer. it works fine, but could be more elegant. for instance, it should work on the region even if you aren't at the beginning of it. if any of you can improve on it, please be sure to share your findings with us. thanks! --bw ----- 8< re-relace-region follows ----- (defun re-replace-region () nil (interactive) (setq old (read-input "Replace string: " nil)) (setq new (read-input "with: " nil)) (while (< (dot) (mark)) (re-search-forward old (+ (mark) 1) nil) (setq end (dot)) (re-search-backward old) (delete-region (dot) end) (insert new) ) )