From: Heime <heimeborgia@protonmail.com>
To: tomas@tuxteam.de
Cc: help-gnu-emacs@gnu.org
Subject: Re: Special hilighting for comments
Date: Sun, 11 Dec 2022 07:52:53 +0000 [thread overview]
Message-ID: <l0EHxvAQS9v6ecrY3jnKmvpHm0P-AS_APYB4m4NuS386U4ScqziVNcKFIyWOzwfYbQVyhPKZVdSl1gQjkwRfaINo-NlFcOT_7ZnD4gG6JX8=@protonmail.com> (raw)
In-Reply-To: <Y5WK9hgla4IMONpk@tuxteam.de>
------- Original Message -------
On Sunday, December 11th, 2022 at 7:47 AM, tomas@tuxteam.de <tomas@tuxteam.de> wrote:
> On Sun, Dec 11, 2022 at 07:33:19AM +0000, Heime wrote:
>
> > ------- Original Message -------
> > On Sunday, December 11th, 2022 at 7:24 AM, tomas@tuxteam.de tomas@tuxteam.de wrote:
> >
> > > On Sun, Dec 11, 2022 at 06:59:32AM +0000, Heime wrote:
> > >
> > > > ------- Original Message -------
> > > > On Sunday, December 11th, 2022 at 6:54 AM, tomas@tuxteam.de tomas@tuxteam.de wrote:
> > > >
> > > > > On Sun, Dec 11, 2022 at 02:37:38AM +0000, Heime wrote:
> > > > >
> > > > > > Would you know the problem with the following regexp
> > > > > >
> > > > > > "^;; \\[.+\\].*$"
> > > > > >
> > > > > > It fails to match
> > > > > >
> > > > > > ;; [something] other things
> > > > >
> > > > > Worksforme. At least if the first semicolon is actually at the
> > > > > start of a line, that is.
> > > > >
> > > > > Cheers
> > > > > --
> > > > > t
> > > >
> > > > Yes it works. I am trying to use subexp in highlight-regexp.
> > > > To match "^;; \\[.+\\].*$" but highlight only the "\\[.+\\]" part.
> > >
> > > Aha. Read again the documentation string of `hightlight-regexp'.
> > > Is there any part in there you don't understand? What about
> > > SUBEXP?
> >
> > Right. Have done
> >
> > (highlight-regexp "^;; \\[.+\\].*$" 'elf-face "\\[.+\\]")
> >
> > which does not get the highlighting.
>
>
> [...]
>
> Ah. There's your misunderstanding. Read the section about
> "grouping constructs" in regular expressions. The short
> version is that this argument SUBGROUP refers to the count
> number of that subexpression, starting with 1.
>
> So you need to group the part you are interested in in
> your regexp (the subexpression) with \(...\) (don't forget
> the extra backslash for the string syntax) like so:
>
> "^;; \\(\\[.+\\]\\).$"
>
> Now this is the first subgroup in your regexp (actually, the
> only one). You refer to it with 1. This might work
>
> (highlight-regexp "^;; \\(\\[.+\\]\\).$" 'elf-face 1)
>
> Now read the section on "\( ... \)" in the chapter "Backslash
> constructs in Regular Expressions". The others are useful,
> too :)
Success. Thank you so very much. I now understand how it works.
next prev parent reply other threads:[~2022-12-11 7:52 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-10 2:42 Special hilighting for comments Heime
2022-12-10 6:12 ` Marcin Borkowski
2022-12-10 6:23 ` Heime
2022-12-10 8:13 ` Eli Zaretskii
2022-12-10 8:14 ` Eli Zaretskii
2022-12-10 8:30 ` Heime
2022-12-10 8:49 ` Eli Zaretskii
2022-12-10 10:53 ` Heime
2022-12-10 11:15 ` Eli Zaretskii
2022-12-10 11:26 ` Heime
2022-12-10 14:21 ` Eli Zaretskii
2022-12-10 14:28 ` Heime
2022-12-10 15:52 ` Jean Louis
2022-12-10 17:11 ` Heime
2022-12-10 17:16 ` Eli Zaretskii
2022-12-10 17:39 ` Heime
2022-12-10 17:57 ` Thibaut Verron
2022-12-10 18:32 ` Eli Zaretskii
2022-12-12 0:59 ` Heime
2022-12-10 19:44 ` Jean Louis
2022-12-11 2:10 ` Heime
2022-12-11 2:37 ` Heime
2022-12-11 4:23 ` Jean Louis
2022-12-11 5:06 ` Heime
2022-12-11 9:06 ` Jean Louis
2022-12-11 6:54 ` tomas
2022-12-11 6:59 ` Heime
2022-12-11 7:24 ` tomas
2022-12-11 7:33 ` Heime
2022-12-11 7:47 ` tomas
2022-12-11 7:52 ` Heime [this message]
2022-12-11 8:55 ` tomas
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='l0EHxvAQS9v6ecrY3jnKmvpHm0P-AS_APYB4m4NuS386U4ScqziVNcKFIyWOzwfYbQVyhPKZVdSl1gQjkwRfaINo-NlFcOT_7ZnD4gG6JX8=@protonmail.com' \
--to=heimeborgia@protonmail.com \
--cc=help-gnu-emacs@gnu.org \
--cc=tomas@tuxteam.de \
/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).