GNU bug report logs -
#13755
24.3.50; regression: incorrect font-lock highlighting
Previous Next
Reported by: "Drew Adams" <drew.adams <at> oracle.com>
Date: Mon, 18 Feb 2013 22:41:02 UTC
Severity: minor
Tags: notabug
Found in version 24.3.50
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
Full log
Message #21 received at 13755 <at> debbugs.gnu.org (full text, mbox):
> > (font-lock-add-keywords
> > 'emacs-lisp-mode
> > `((,(concat "(" (regexp-opt
> > '("icicle-define-add-to-alist-command"
> > "icicle-define-command"
> > "icicle-define-file-command"
> > "icicle-define-sort-command")
> > t)
> > "\\>[ \t'\(]*\\(\\sw+\\)?")
> ^^^
> There's your bug: you should use \\_>.
Interesting. I'm surprised that Emacs has for so long (decades) matched only a
word-end here and not a symbol-end.
Be that as it may, changing from \\> to \\_> here does NOT fix the bug.
Here is the relevant entry from `font-lock-keywords' in Emacs-Lisp mode:
("(\\(icicle-define-\\(?:\\(?:\\(?:add-to-alist\\|file\\|sort\\)-\\)?command\\)\
\)\\_>[ '(]*\\(\\sw+\\)?"
(1 font-lock-keyword-face)
(2 font-lock-function-name-face nil t))
The problem is not the highlighting of `icicle-define-command', which is
correctly in `font-lock-keyword-face' (when using either \\> or \\_>, for that
matter).
The problem is the highlighting of the command name that follows keyword
`icicle-define-command'. The command name should all be in
`font-lock-function-name-face'. But only its first word is highlighted now, as
shown in the screenshots I sent with the bug report. That is the regression.
It's as if Emacs is not counting regexp groups the same way as before.
Here is the code again (but with your suggested \\_> this time):
(font-lock-add-keywords
'emacs-lisp-mode
`((,(concat
"("
(regexp-opt
'("icicle-define-add-to-alist-command"
"icicle-define-command"
"icicle-define-file-command"
"icicle-define-sort-command")
t)
"\\_>[ \t'\(]*\\(\\sw+\\)?")
(1 font-lock-keyword-face)
;; Index (2 or 3) depends on whether or not
;; shy groups are supported.
,(list (if (string-match "\\(?:\\)" "") 2 3)
'font-lock-function-name-face nil t))
("(\\(icicle-condition-case-no-debug\\)\\_>"
1 font-lock-keyword-face)
("(\\(icicle-user-error\\)\\_>"
1 font-lock-warning-face)))
> > ("(\\(icicle-condition-case-no-debug\\)\\>"
> ^^^
> Same here.
No. That highlights correctly. Again, there is no problem with
`font-lock-keyword-face' highlighting.
Similarly, all the other uses of \\> in Emacs-Lisp mode `font-lock-keywords'
(and there are several, in emacs -Q) also fontify correctly.
AFAICT, you mistook the problem. Please take another look.
This bug report was last modified 9 years and 84 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.