Subject: bug#74156: 29.4; Incorrect face with outline-minor-mode-highlight in lisp-mode

From: Juri Linkov <[email-masked]>
Date: Sat, 02 Nov 2024 19:14:02 +0200

> Take this example Elisp file:
>
> ;;; xxx -- OK: face is outline-1
> ;;;; xxx -- OK: face is outline-2
> (defun test ()) ; WRONG: face is outline-8
>
> ;; Local Variables:
> ;; outline-minor-mode-highlight: override
> ;; eval: (outline-minor-mode 1)
> ;; End:
>
> After loading this file into Emacs you will see that the function
> definition
> is displayed incorrectly in face outline-8.
>
> I guess this is due to the definition of outline-regexp in lisp-mode.el:
>
> ";;;;* [^ \t\n]\\|(\\|\\(^;;;###\\(\\([-[:alnum:]]+?\\)-\\)?\\
> (autoload\\)\\)"
>
> Notice the opening parenthesis in the regular expression that causes
> the function definition to be recognized as an outline heading.
>
> I removed the opening parenthesis and now the face of the function
> definition
> is correct. This is fine for me. But note that you loose the ability to
> move
> to top-level expressions, like this function definition, with
> (outline-next-visible-heading) and (outline-previous-visible-heading).

Isn't the face 'outline-8' because 'lisp-outline-level' returns
the level 1000 for the opening parenthesis in 'lisp-outline-level':

  (defun lisp-outline-level ()
    (let ((len (- (match-end 0) (match-beginning 0))))
      (cond ((or (looking-at-p "(")
                 (looking-at-p lisp-mode-autoload-regexp))
             1000)

The level 1000 corresponds to outline-8:

Level    1 - outline-1
Level    2 - outline-2
Level    3 - outline-3
Level    4 - outline-4
Level    5 - outline-5
Level    6 - outline-6
Level    7 - outline-7
Level    8 - outline-8
Level    9 - outline-1
Level   10 - outline-2
Level   11 - outline-3
...
Level  998 - outline-6
Level  999 - outline-7
Level 1000 - outline-8