[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: replace-regexp from A to B?
From: |
Rodolfo Medina |
Subject: |
Re: replace-regexp from A to B? |
Date: |
Sun, 26 Aug 2018 19:54:12 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) |
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
- Re: replace-regexp from A to B?, Emanuel Berg, 2018/08/26
- Re: replace-regexp from A to B?,
Rodolfo Medina <=
- Message not available
- Re: replace-regexp from A to B?, Emanuel Berg, 2018/08/26
- mixing argument types (was: Re: replace-regexp from A to B?), Emanuel Berg, 2018/08/26
- Re: mixing argument types, Stefan Monnier, 2018/08/26
- Message not available
- Re: mixing argument types, Emanuel Berg, 2018/08/26
- Re: mixing argument types, Rodolfo Medina, 2018/08/27
- Message not available
- Re: mixing argument types, Emanuel Berg, 2018/08/27
- Message not available
- Re: mixing argument types, Emanuel Berg, 2018/08/27
- Re: mixing argument types, Rodolfo Medina, 2018/08/28