unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#74307: 30.0.92; emacs-lisp font-locking word regexp
@ 2024-11-11  6:28 Roland Winkler
  2024-11-14  8:11 ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: Roland Winkler @ 2024-11-11  6:28 UTC (permalink / raw)
  To: 74307

Starting from emacs -Q, put the following into a buffer with
emacs-lisp-mode

  (setq foo "\\<foo\\>")

The part "foo\\" of the string "\\<foo\\>" will get
font-lock-variable-name-face, which looks odd.

I believe, this is due to a clause in lisp-mode.el that says

         ;; Words inside \\[], \\<>, \\{} or \\`' tend to be for
         ;; `substitute-command-keys'.

But this assumption is not always correct, in particular if ">" is
preceded by "\\", which happens when constructing regexps.





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#74307: 30.0.92; emacs-lisp font-locking word regexp
  2024-11-11  6:28 bug#74307: 30.0.92; emacs-lisp font-locking word regexp Roland Winkler
@ 2024-11-14  8:11 ` Eli Zaretskii
  2024-11-14 16:24   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-11-14 16:49   ` Roland Winkler
  0 siblings, 2 replies; 4+ messages in thread
From: Eli Zaretskii @ 2024-11-14  8:11 UTC (permalink / raw)
  To: Roland Winkler, Stefan Monnier; +Cc: 74307

> From: Roland Winkler <winkler@gnu.org>
> Date: Mon, 11 Nov 2024 00:28:34 -0600
> 
> Starting from emacs -Q, put the following into a buffer with
> emacs-lisp-mode
> 
>   (setq foo "\\<foo\\>")
> 
> The part "foo\\" of the string "\\<foo\\>" will get
> font-lock-variable-name-face, which looks odd.
> 
> I believe, this is due to a clause in lisp-mode.el that says
> 
>          ;; Words inside \\[], \\<>, \\{} or \\`' tend to be for
>          ;; `substitute-command-keys'.
> 
> But this assumption is not always correct, in particular if ">" is
> preceded by "\\", which happens when constructing regexps.

I believe you are saying that in

         (,(rx "\\\\" (or (seq "<" (group-n 1 lisp-mode-symbol) ">")
                          (seq "{" (group-n 1 lisp-mode-symbol) "}")))
          (1 font-lock-variable-name-face prepend))

we should use something like the below instead?

     (,(rx "\\\\" (or (seq "<" (group-n 1 lisp-mode-symbol) (not "\\\\") ">")
                      (seq "{" (group-n 1 lisp-mode-symbol) (not "\\\\") "}"))

And similarly for \\[] etc.?





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#74307: 30.0.92; emacs-lisp font-locking word regexp
  2024-11-14  8:11 ` Eli Zaretskii
@ 2024-11-14 16:24   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-11-14 16:49   ` Roland Winkler
  1 sibling, 0 replies; 4+ messages in thread
From: Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-11-14 16:24 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 74307, Roland Winkler

> I believe you are saying that in
>
>          (,(rx "\\\\" (or (seq "<" (group-n 1 lisp-mode-symbol) ">")
>                           (seq "{" (group-n 1 lisp-mode-symbol) "}")))
>           (1 font-lock-variable-name-face prepend))
>
> we should use something like the below instead?
>
>      (,(rx "\\\\" (or (seq "<" (group-n 1 lisp-mode-symbol) (not "\\\\") ">")
>                       (seq "{" (group-n 1 lisp-mode-symbol) (not "\\\\") "}"))
>
> And similarly for \\[] etc.?

Sounds good to me.


        Stefan






^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#74307: 30.0.92; emacs-lisp font-locking word regexp
  2024-11-14  8:11 ` Eli Zaretskii
  2024-11-14 16:24   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-11-14 16:49   ` Roland Winkler
  1 sibling, 0 replies; 4+ messages in thread
From: Roland Winkler @ 2024-11-14 16:49 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 74307, Stefan Monnier

On Thu, Nov 14 2024, Eli Zaretskii wrote:
> we should use something like the below instead?
>
>      (,(rx "\\\\" (or (seq "<" (group-n 1 lisp-mode-symbol) (not "\\\\") ">")
>                       (seq "{" (group-n 1 lisp-mode-symbol) (not "\\\\") "q}"))

Yes, thanks.  (This is my first real-world encounter with rx.  Otherwise
I would have proposed it myself.)

> And similarly for \\[] etc.?

I do not know in what context backslash-quoted right square brackets may
appear in regexps.  But certainly, they do not make sense in the context
of substitute-command-keys either.  So excluding here backslash-quoted
right square brackets is probably for the better, too.





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-11-14 16:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-11  6:28 bug#74307: 30.0.92; emacs-lisp font-locking word regexp Roland Winkler
2024-11-14  8:11 ` Eli Zaretskii
2024-11-14 16:24   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-14 16:49   ` Roland Winkler

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).