From: Heime <heimeborgia@protonmail.com>
To: Thibaut Verron <thibaut.verron@gmail.com>
Cc: Jean Louis <bugs@gnu.support>, help-gnu-emacs@gnu.org
Subject: Re: Introducing face in comments for various modes
Date: Tue, 13 Dec 2022 15:00:54 +0000 [thread overview]
Message-ID: <C_SdRDPrgaKGBolL0VlnLaenDYA21AxMvdhsZ-jaxwF5tJuIGZdz5bxbQTlVDDZ1T2AYABNnF_zDxGPYvM4XYRNzQ1KDNMhXu0WL3g4SbM0=@protonmail.com> (raw)
In-Reply-To: <4c2ec873-8ca6-34b3-dc6b-dab47c03291d@gmail.com>
------- Original Message -------
On Tuesday, December 13th, 2022 at 10:45 AM, Thibaut Verron <thibaut.verron@gmail.com> wrote:
> On 13/12/2022 11:40, Heime wrote:
>
> > ------- Original Message -------
> > On Tuesday, December 13th, 2022 at 10:05 AM, Thibaut Verron thibaut.verron@gmail.com wrote:
> >
> > > On 13/12/2022 10:46, Heime wrote:
> > >
> > > > ------- Original Message -------
> > > > On Tuesday, December 13th, 2022 at 9:35 AM, Thibaut Verron thibaut.verron@gmail.com wrote:
> > > >
> > > > > On 13/12/2022 09:30, Heime wrote:
> > > > >
> > > > > > ------- Original Message -------
> > > > > > On Tuesday, December 13th, 2022 at 8:04 AM, Heime heimeborgia@protonmail.com wrote:
> > > > > >
> > > > > > > ------- Original Message -------
> > > > > > > On Tuesday, December 13th, 2022 at 7:52 AM, Jean Louis bugs@gnu.support wrote:
> > > > > > >
> > > > > > > > Heime, I like the idea of highlighting comments, though I do it this
> > > > > > > > way to specify (syntax comment-start) as that works for multiple
> > > > > > > > modes.
> > > > > > > >
> > > > > > > > ; one
> > > > > > > > ;; two
> > > > > > > > ;;; three
> > > > > > > > ;;;; and more
> > > > > > > >
> > > > > > > > ;;; Highlighting comments
> > > > > > > >
> > > > > > > > (setq rcd-regexp-comment (rx line-start
> > > > > > > > (one-or-more (syntax comment-start))
> > > > > > > > (one-or-more space)
> > > > > > > > (group (one-or-more not-newline))
> > > > > > > > line-end))
> > > > > > > >
> > > > > > > > ;; (highlight-regexp regexp nil 1)
> > > > > > > > ;; (unhighlight-regexp regexp)
> > > > > > > >
> > > > > > > > Jean
> > > > > > > > I would like to introduce (syntax comment-start) in place
> > > > > > > > of ";;" in "^;;\s+\\[.+\\].*$".
> > > > > > > > It's not something you can "introduce" in your regexp, it only makes
> > > > > > > > sense within the context of a regexp built with rx:
> > > > > > > > https://www.gnu.org/software/emacs/manual/html_node/elisp/Rx-Notation.html
> > > > >
> > > > > Rewriting your regexp as an rx regexp would not be too difficult if you
> > > > > want to go that route, Jean's example is a good template.
> > > > >
> > > > > Otherwise, as an approximation of that feature, you could built your
> > > > > regex string using the value of the variable comment-start ( ";" in
> > > > > emacs-lisp-mode) instead of hardcoding ;; .
> > > > > How can one specify two comment characters next to each other?
> > >
> > > Using the variable, the same way you would normally do for a regexp, by
> > > putting \{2\} after the matched regexp.
> > >
> > > E.g.
> > >
> > > ELISP> (format "\\(%s\\)\\{2\\}" comment-start)
> > >
> > > "\\(;\\)\\{2\\}"
> > >
> > > (don't trust me for the number of escape characters)
> > >
> > > But I don't think it's really what you want: for example, in a mode
> > > where comment-start is "# " (e.g. org or python), this will match "# # "
> > > but not "##".
> > > Let's disregard org and python at this time.
I do not think "python" comment character should be "# ", it is "#". At least from what I have read about python.
> Even then, avoiding the need to carefully count string expansions for
> backslashes would be enough reason to use syntax tables for me.
>
> > > Using the syntax table is better here, as the character # alone has the
> > > syntax of a comment-start.
> > >
> > > I had forgotten about the simplest option, that is the regexp equivalent
> > > of the rx syntax: \s< in a regexp will match exactly a character with
> > > the syntax of a comment-start.
> > >
> > > So: "\s<\{2\}" should be exactly what you want (at least in languages
> > > where comments start with a single character).
next prev parent reply other threads:[~2022-12-13 15:00 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-11 15:35 Introducing face in comments for various modes Heime
2022-12-11 17:40 ` Stefan Monnier via Users list for the GNU Emacs text editor
2022-12-12 2:24 ` Heime
2022-12-12 3:00 ` Heime
2022-12-12 8:49 ` Thibaut Verron
2022-12-12 9:21 ` Heime via Users list for the GNU Emacs text editor
2022-12-12 9:58 ` Thibaut Verron
2022-12-12 10:20 ` Heime
2022-12-12 10:50 ` Thibaut Verron
2022-12-12 11:55 ` Heime
2022-12-12 12:17 ` Thibaut Verron
2022-12-12 14:46 ` Heime
2022-12-12 15:22 ` Yuri Khan
2022-12-12 15:38 ` Thibaut Verron
2022-12-12 15:55 ` Christopher Dimech
2022-12-12 16:07 ` Christopher Dimech
2022-12-12 17:44 ` Stefan Monnier
2022-12-13 5:20 ` Christopher Dimech
2022-12-12 15:22 ` Stefan Monnier
2022-12-13 7:52 ` Jean Louis
2022-12-13 8:04 ` Heime
2022-12-13 8:30 ` Heime
2022-12-13 9:35 ` Thibaut Verron
2022-12-13 9:46 ` Heime
2022-12-13 10:05 ` Thibaut Verron
2022-12-13 10:24 ` Christopher Dimech
2022-12-13 10:40 ` Heime
2022-12-13 10:45 ` Thibaut Verron
2022-12-13 10:49 ` Heime
2022-12-13 15:00 ` Heime [this message]
2022-12-13 12:37 ` Jean Louis
2022-12-13 14:00 ` Heime
2022-12-13 12:36 ` Jean Louis
2022-12-13 13:46 ` Heime
2022-12-13 12:35 ` Jean Louis
2022-12-13 8:17 ` Christopher Dimech
2022-12-13 19:19 ` Jean Louis
2022-12-12 15:20 ` Stefan Monnier
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='C_SdRDPrgaKGBolL0VlnLaenDYA21AxMvdhsZ-jaxwF5tJuIGZdz5bxbQTlVDDZ1T2AYABNnF_zDxGPYvM4XYRNzQ1KDNMhXu0WL3g4SbM0=@protonmail.com' \
--to=heimeborgia@protonmail.com \
--cc=bugs@gnu.support \
--cc=help-gnu-emacs@gnu.org \
--cc=thibaut.verron@gmail.com \
/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).