GNU bug report logs - #68318
30.0.50; Fontification of \{m\} and \{m,n\} in a regexp

Previous Next

Package: emacs;

Reported by: Arash Esbati <arash <at> gnu.org>

Date: Mon, 8 Jan 2024 09:27:02 UTC

Severity: minor

Found in version 30.0.50

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 68318 in the body.
You can then email your comments to 68318 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#68318; Package emacs. (Mon, 08 Jan 2024 09:27:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Arash Esbati <arash <at> gnu.org>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 08 Jan 2024 09:27:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Arash Esbati <arash <at> gnu.org>
To: "emacs-bugs" <bug-gnu-emacs <at> gnu.org>
Subject: 30.0.50; Fontification of \{m\} and \{m,n\} in a regexp
Date: Mon, 08 Jan 2024 10:26:16 +0100
[Message part 1 (text/plain, inline)]
Hi all,

to reproduce, start 'emacs -Q' and paste the following lines into
scratch:

(re-search-forward "a\\{7\\}")

(re-search-forward "a\\{7,\\}")

(re-search-forward "a\\{,7\\}")

For me, it looks like this:
[string.png (image/png, inline)]
[Message part 3 (text/plain, inline)]
Hitting 'C-u C-x =' on the first 7 and the backslashes says:

  There are text properties here:
    face                 (font-lock-variable-name-face font-lock-string-face)
    fontified            t

On the next two forms, I get:

  There are text properties here:
    face                 font-lock-string-face
    fontified            t

Is this difference on purpose?

Best, Arash

In GNU Emacs 30.0.50 (build 1, aarch64-apple-darwin23.2.0, NS
 appkit-2487.30 Version 14.2.1 (Build 23C71)) of 2024-01-07 built on
 MacMutant.fritz.box
Repository revision: f866c85ac4e32df8061b285b6b44b15346994f3d
Repository branch: master
Windowing system distributor 'Apple', version 10.3.2487
System Description:  macOS 14.2.1

Configured using:
 'configure --with-ns --without-pop --without-mailutils --with-threads
 --with-modules --with-native-compilation --without-compress-install
 'CFLAGS=-O2 -g0 -pipe'
 'CPPFLAGS=-I/opt/homebrew/Cellar/gcc/13.2.0/include
 -I/opt/homebrew/Cellar/libgccjit/13.2.0/include
 -I/opt/homebrew/Cellar/gmp/6.3.0/include'
 'LDFLAGS=-L/opt/homebrew/Cellar/gcc/13.2.0/lib/gcc/current
 -L/opt/homebrew/Cellar/gmp/6.3.0/lib''

Configured features:
ACL GLIB GMP GNUTLS JSON LCMS2 LIBXML2 MODULES NATIVE_COMP NOTIFY KQUEUE
NS PDUMPER PNG RSVG SQLITE3 THREADS TOOLKIT_SCROLL_BARS TREE_SITTER WEBP
XIM ZLIB

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#68318; Package emacs. (Mon, 08 Jan 2024 11:09:02 GMT) Full text and rfc822 format available.

Message #8 received at 68318 <at> debbugs.gnu.org (full text, mbox):

From: Andreas Schwab <schwab <at> linux-m68k.org>
To: Arash Esbati <arash <at> gnu.org>
Cc: 68318 <at> debbugs.gnu.org
Subject: Re: bug#68318: 30.0.50; Fontification of \{m\} and \{m,n\} in a regexp
Date: Mon, 08 Jan 2024 12:07:50 +0100
See lisp-el-font-lock-keywords-2 in lisp-mode.el:

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

-- 
Andreas Schwab, schwab <at> linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."




Severity set to 'minor' from 'normal' Request was from Stefan Kangas <stefankangas <at> gmail.com> to control <at> debbugs.gnu.org. (Wed, 10 Jan 2024 17:31:01 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#68318; Package emacs. (Thu, 11 Jan 2024 15:52:01 GMT) Full text and rfc822 format available.

Message #13 received at 68318 <at> debbugs.gnu.org (full text, mbox):

From: Arash Esbati <arash <at> gnu.org>
To: Andreas Schwab <schwab <at> linux-m68k.org>
Cc: 68318 <at> debbugs.gnu.org
Subject: Re: bug#68318: 30.0.50; Fontification of \{m\} and \{m,n\} in a regexp
Date: Thu, 11 Jan 2024 16:51:16 +0100
Andreas Schwab <schwab <at> linux-m68k.org> writes:

> See lisp-el-font-lock-keywords-2 in lisp-mode.el:
>
>          ;; Words inside \\[], \\<>, \\{} or \\`' tend to be for
>          ;; `substitute-command-keys'.

Thanks for the pointer.  I'm not familiar with the code, but IIUC, the
lines 499-500 are relevant, where the condense is:

  (rx "\\\\" (seq "{" (group-n 1 lisp-mode-symbol) "}"))

which returns:

  "\\\\\\\\{\\(?1:\\(?:\\w\\|\\s_\\|\\\\.\\)+\\)}"

Since we're talking about \\{\\} and not \\{}, I wonder if some
variation like:

  "\\\\\\\\{\\(?1:\\(?:\\w\\|\\s_\\|\\\\.\\)*?[^\\]\\)}"

would fix this issue?  Not sure if it does TRT reg. the "\\\\." part.

Best, Arash




Reply sent to Eli Zaretskii <eliz <at> gnu.org>:
You have taken responsibility. (Sun, 17 Nov 2024 06:23:02 GMT) Full text and rfc822 format available.

Notification sent to Arash Esbati <arash <at> gnu.org>:
bug acknowledged by developer. (Sun, 17 Nov 2024 06:23:02 GMT) Full text and rfc822 format available.

Message #18 received at 68318-done <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Arash Esbati <arash <at> gnu.org>
Cc: 68318-done <at> debbugs.gnu.org, winkler <at> gnu.org, 74308 <at> debbugs.gnu.org
Subject: Re: bug#74308: 30.0.92; emacs-lisp font-locking word regexp
Date: Sun, 17 Nov 2024 08:22:23 +0200
> From: Arash Esbati <arash <at> gnu.org>
> Cc: Roland Winkler <winkler <at> gnu.org>,  74308 <at> debbugs.gnu.org
> Date: Sat, 16 Nov 2024 22:33:55 +0100
> 
> Eli Zaretskii <eliz <at> gnu.org> writes:
> 
> > merge 74308 74307
> > thanks
> >
> >> From: Roland Winkler <winkler <at> gnu.org>
> >> Date: Mon, 11 Nov 2024 00:30:46 -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.
> >
> > This is an exact duplicate of bug#74307 that you submitted just 2
> > minutes earlier, so I'm merging them.
> 
> I think bug#68318 is also about the same issue; it can be merged into
> this one as well.

Thanks.  Since this bug was already closed, I'm therefore closing
bug#68318 as well.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 15 Dec 2024 12:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 188 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.