From: Rodolfo Medina <rodolfo.medina@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: replace-regexp from A to B?
Date: Sun, 26 Aug 2018 19:54:12 +0200 [thread overview]
Message-ID: <87lg8thv3v.fsf@gmail.com> (raw)
In-Reply-To: 86tvnhktf7.fsf@zoho.com
Emanuel Berg <moasen@zoho.com> writes:
> 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 :)
Thanks, Yuri and Emanuel... I've seen that a single MusiXTeX piece can be
considered as a tex paragraph, because no blank line should be inserted into
it... So I can perform my replace-regexp with the `M-h' prefix so applying it
only to the current paragraph/piece...
Rodolfo
next prev parent reply other threads:[~2018-08-26 17:54 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.5556.1535294433.1292.help-gnu-emacs@gnu.org>
2018-08-26 16:02 ` replace-regexp from A to B? Emanuel Berg
2018-08-26 17:54 ` Rodolfo Medina [this message]
[not found] ` <mailman.5566.1535306070.1292.help-gnu-emacs@gnu.org>
2018-08-26 19:35 ` Emanuel Berg
2018-08-26 19:42 ` mixing argument types (was: Re: replace-regexp from A to B?) Emanuel Berg
2018-08-26 20:23 ` mixing argument types Stefan Monnier
[not found] ` <mailman.5572.1535315139.1292.help-gnu-emacs@gnu.org>
2018-08-26 21:09 ` Emanuel Berg
2018-08-27 13:06 ` Rodolfo Medina
[not found] ` <mailman.5588.1535375213.1292.help-gnu-emacs@gnu.org>
2018-08-27 19:08 ` Emanuel Berg
2018-08-27 20:07 ` Emanuel Berg
2018-08-28 7:29 ` Rodolfo Medina
2018-08-26 14:40 replace-regexp from A to B? Rodolfo Medina
2018-08-26 15:50 ` Yuri Khan
2018-08-28 7:13 ` Rodolfo Medina
[not found] ` <87wosd0yoe.fsf@himinbjorg.adminart.net>
2018-08-28 7:15 ` Rodolfo Medina
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87lg8thv3v.fsf@gmail.com \
--to=rodolfo.medina@gmail.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).