From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Xah Lee Newsgroups: gmane.emacs.help Subject: Re: regexp/emacs selective replace Date: Thu, 26 Nov 2009 11:20:34 -0800 (PST) Organization: http://groups.google.com Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1259307202 16253 80.91.229.12 (27 Nov 2009 07:33:22 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 27 Nov 2009 07:33:22 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Nov 27 08:33:16 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1NDvKN-0005WW-K0 for geh-help-gnu-emacs@m.gmane.org; Fri, 27 Nov 2009 08:33:15 +0100 Original-Received: from localhost ([127.0.0.1]:47599 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NDvKN-0006lY-6n for geh-help-gnu-emacs@m.gmane.org; Fri, 27 Nov 2009 02:33:15 -0500 Original-Path: news.stanford.edu!usenet.stanford.edu!postnews.google.com!h14g2000pri.googlegroups.com!not-for-mail Original-Newsgroups: comp.emacs,gnu.emacs.help Original-Lines: 55 Original-NNTP-Posting-Host: 76.102.12.87 Original-X-Trace: posting.google.com 1259263234 2446 127.0.0.1 (26 Nov 2009 19:20:34 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Thu, 26 Nov 2009 19:20:34 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: h14g2000pri.googlegroups.com; posting-host=76.102.12.87; posting-account=bRPKjQoAAACxZsR8_VPXCX27T2YcsyMA User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/532.0 (KHTML, like Gecko) Chrome/3.0.195.33 Safari/532.0, gzip(gfe), gzip(gfe) Original-Xref: news.stanford.edu comp.emacs:99445 gnu.emacs.help:175086 X-Mailman-Approved-At: Fri, 27 Nov 2009 02:21:06 -0500 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:70173 Archived-At: On Nov 23, 5:41 am, m121212 wrote: > Hi, > > I have a tricky problem that I'm not sure how to solve. I have a latex > document with several figure environments that look like this: > > \begin{figure} > \includegraphics{blah.ps} > \end{figure} > > but need to look like this: > > \begin{figure} > \begin{center} \includegraphics{blah.ps} \end{center} > \end{figure} > > Some of the figure environments already have this however, and I don't wa= nt > to end up with something like this: > > \begin{figure} > \begin{center}\begin{center} \includegraphics{blah.ps} > \end{center}\end{center} > \end{figure} This page answers your question exactly: =E2=80=A2 Elisp Lesson: Repeated Find Replace http://xahlee.org/emacs/elisp_repeat_replace.html if you prefer emacs to ask you for each case, perhaps just to be sure your regex didn't find a bad match, see: =E2=80=A2 Lisp Lesson: Regex Replace with a Function http://xahlee.org/emacs/lisp_regex_replace_func.html > Any ideas? Also, is there a way Emacs can just wrap any selection with > custom, predefined tags? (defun wrap-markup () "Insert a markup around a region." (interactive) (goto-char (region-end)) (insert "") (goto-char (region-beginning)) (insert "") ) the above is from a collection of simple elisp examples at =E2=80=A2 Emacs Lisp Examples http://xahlee.org/emacs/elisp_examples.html Xah =E2=88=91 http://xahlee.org/ =E2=98=84