From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Emanuel Berg Newsgroups: gmane.emacs.help Subject: Re: replace-regexp from A to B? Date: Sun, 26 Aug 2018 18:02:20 +0200 Organization: Aioe.org NNTP Server Message-ID: <86tvnhktf7.fsf@zoho.com> References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1535299421 15444 195.159.176.226 (26 Aug 2018 16:03:41 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 26 Aug 2018 16:03:41 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Aug 26 18:03:36 2018 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ftxVo-0003wO-Nc for geh-help-gnu-emacs@m.gmane.org; Sun, 26 Aug 2018 18:03:36 +0200 Original-Received: from localhost ([::1]:49592 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ftxXv-0004Ho-2i for geh-help-gnu-emacs@m.gmane.org; Sun, 26 Aug 2018 12:05:47 -0400 X-Received: by 2002:a1c:7a10:: with SMTP id v16-v6mr579049wmc.11.1535299342106; Sun, 26 Aug 2018 09:02:22 -0700 (PDT) Original-Path: usenet.stanford.edu!143-v6no4857772wmm.0!news-out.google.com!a22-v6ni16885wmg.0!nntp.google.com!proxad.net!feeder1-2.proxad.net!news.mixmin.net!aioe.org!.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 42 Original-NNTP-Posting-Host: onLrbz09yV+MU3RaxdbMkg.user.gioia.aioe.org Original-X-Complaints-To: abuse@aioe.org Mail-Copies-To: never X-Notice: Filtered by postfilter v. 0.8.3 Cancel-Lock: sha1:ojJ9F91Rk+xsGweGZlB/rVNvG1g= Original-Xref: usenet.stanford.edu gnu.emacs.help:223626 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:117751 Archived-At: Rodolfo Medina wrote: > Is it possible, and how?, to perform > a replace-regexp from a certain point, e.g. > the current one, or from a certain > word/expression, up to the next occurrence of > a certain other word/expression...? In my > case, with MusiXTeX documents, the starting > point should be the TeX command `\startpiece' > and the final one `\Endpiece'. So I could > replace strings/expressions within a single > musical piece without going out of it. You can set the region manually and then use a function with (goto-char START) (while (re-search-forward REGEXP STOP t) (replace-match TO-STRING nil nil)) where START is (region-beginning) and STOP is (region-end). First check if there is a region with (use-region-p) ! Or if you want it fully automated make a search for "\startpiece" and set START, then make a search for "\Endpiece" and set STOP. Do this in Elisp as well. But then you'd have to supply them (the delimitators) as arguments so it won't necessarily be faster because you'd have to type them each time rather than to set the region. If they (the delimitators) are always the same you could hard-code them, of course. Then it'll be very fast to invoke :) -- underground experts united http://user.it.uu.se/~embe8573