[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Match <div and </div>
From: |
Benno Schulenberg |
Subject: |
Re: Match <div and </div> |
Date: |
Tue, 24 Jan 2023 12:55:54 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 |
Op 24-01-2023 om 06:52 schreef Seb:
One detail for other readers of the list: I didn't see any "tortoise bracket" in
your email. But there were question marks.
Then your mailer seems not to support UTF-8. Apparently you are one of
the few people that still stick to ISO-8859-*. The tortoise brackets
appear fine for me in the archive:
https://lists.gnu.org/archive/html/help-nano/2023-01/msg00013.html
The way you solved the problem indicates that the same technique would work for
other pairs, such as <form or <p. But I don't want to assign a keystroke to each.
I tried to modify the line by replacing the first "div" with "(\w+)" and the
following ones with "\1", as I would in a Perl regexp. It's not working.
The correspondence between "(...)" in a search string and "\x" in the
replacement string is valid only within a single replace command: a \x
does not carry over into subsequent replace commands. In other words:
each replace command stands on its own.
(Also: even if the \x would have carried over, the keystroke would have
failed to work wherever a HTML document contains an non-paired tag, like
<br>.)
If you want to be able to jump not just between <div> and </div> but
also between other pairs of tags, then you have to add the relevant
replace commands for each tag to the key binding, and use a different
replacement for each tag. For example:
bind M-B "{replace}<div{enter}^Q{enter}A
{replace}</div{enter}^R{enter}A
{replace}<form{enter}^S{enter}A
{replace}</form{enter}^T{enter}A
{findbracket}
{replace}^T{enter}</form{enter}A
{replace}^S{enter}<form{enter}A
{replace}^R{enter}</div{enter}A
{replace}^Q{enter}<div{enter}A
{left}{right}" main
In this case, instead of rare code points, I have used control codes
that are very unlikely to occur in any document. Enter each one by
preceding the keystroke with M-V.
Benno
OpenPGP_signature
Description: OpenPGP digital signature