GNU bug report logs -
#74307
30.0.92; emacs-lisp font-locking word regexp
Previous Next
Reported by: Roland Winkler <winkler <at> gnu.org>
Date: Mon, 11 Nov 2024 06:30:02 UTC
Severity: normal
Merged with 74308
Found in version 30.0.92
Done: Eli Zaretskii <eliz <at> gnu.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
>> The problem is that this removes highlighting from the last character
>> because it doesn't get into the group:
>>
>> (rx (seq "[" (group-n 1 lisp-mode-symbol) (not "\\") "]"))
>> => "\\[\\(?1:\\(?:\\w\\|\\s_\\|\\\\.\\)+\\)[^\\]]"
>>
>> A possible solution is to move (not "\\") inside the group:
>>
>> (rx (seq "[" (group-n 1 (seq lisp-mode-symbol (not "\\"))) "]"))
>> => "\\[\\(?1:\\(?:\\w\\|\\s_\\|\\\\.\\)+[^\\]\\)]"
>>
>> But this removes highlighting completely from the reported case of
>> (setq foo "\\<foo\\>"). However, I guess it should not have highlighting
>> anyway because this is an incorrect syntax of `substitute-command-keys'
>> that should match only \\[], \\<>, \\{} or \\`' without the second \\
>
> Sorry, I don't understand: the change which was supposed to fix this
> was already installed.
Ah, so (setq foo "\\<foo\\>") should not be highlighted. Ok, then
indeed (not "\\") should be inside the group.
> If you are saying it caused regressions, could you please show
> a recipe for reproducing those regressions?
A recipe is to put the following two lines into a buffer with
emacs-lisp-mode:
(setq foo "\\<foo\\>")
(setq foo "\\<foo>")
The first foo should not be highlighted, the second currently is
highlighted partially without the last character. Here is the fix:
diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el
index 99980a44ddf..95fbae48bb6 100644
--- a/lisp/emacs-lisp/lisp-mode.el
+++ b/lisp/emacs-lisp/lisp-mode.el
@@ -491,16 +491,16 @@ lisp-mode--search-key
;; Words inside \\[], \\<>, \\{} or \\`' tend to be for
;; `substitute-command-keys'.
(,(rx "\\\\" (or (seq "["
- (group-n 1 lisp-mode-symbol) (not "\\") "]")
+ (group-n 1 (seq lisp-mode-symbol (not "\\"))) "]")
(seq "`" (group-n 1
;; allow multiple words, e.g. "C-x a"
lisp-mode-symbol (* " " lisp-mode-symbol))
"'")))
(1 font-lock-constant-face prepend))
(,(rx "\\\\" (or (seq "<"
- (group-n 1 lisp-mode-symbol) (not "\\") ">")
+ (group-n 1 (seq lisp-mode-symbol (not "\\"))) ">")
(seq "{"
- (group-n 1 lisp-mode-symbol) (not "\\") "}")))
+ (group-n 1 (seq lisp-mode-symbol) (not "\\")) "}")))
(1 font-lock-variable-name-face prepend))
;; Ineffective backslashes (typically in need of doubling).
("\\(\\\\\\)\\([^\"\\]\\)"
This bug report was last modified 262 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.