Subject: RE: bug#13755: 24.3.50; regression: incorrect font-lock highlighting

From: "Drew Adams" <[email-masked]>
Date: Sat, 9 Mar 2013 09:16:25 -0800

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