Subject: bug#48724: Code collapsing and outline headings for elisp

From: Christopher Dimech <[email-masked]>
Date: Wed, 2 Jun 2021 02:07:40 +0200

> Sent: Wednesday, June 02, 2021 at 8:44 AM
> From: "Juri Linkov" <[email-masked]>
> To: "Christopher Dimech" <[email-masked]>
> Cc: [email-masked]
> Subject: Re: bug#48724: Code collapsing and outline headings for elisp

> I suggest that emacs-lisp-mode does code collapse (show/hide) by default.
> Then outline-minor-mode does additional headings in the form
>
> ;;; Heading 1
> ;;;; SubHeading
> ;;;;; SubSubHeading
>
> ;;; Heading 2
>
> outline-minor-mode would then be made to collapse sections of code between
> headlines.
>
> This means that a headline hide could hide a number of variable and function
> definitions that belong together.

Recently we changed the outlines of emacs-lisp-mode in https://debbugs.gnu.org/46878
So this is already fixed.

Have been discussing all this together with Protesilaos Stavrou.  Could you have a read
to see if we actually got to something?

> Sent: Wednesday, June 02, 2021 at 1:46 AM
> From: "Protesilaos Stavrou" <[email-masked]>
> To: "Christopher Dimech" <[email-masked]>
> Subject: Re: modus-themes and headlines
>
> On 2021-06-01, 14:42 +0200, Christopher Dimech <[email-masked]> wrote:
>
> > I send you a file to see how doing "Hide Body" looks like after enabling
> > outline-minor-mode.
> >
> > For headings, you seem to change the font.  Anyway, I have seen that the colours
> > for headings staring with comments (;;; ;;;; ;;;;; ...) are basically indistinguisable
> > from code headlines ("(defvar", "(defun"),  Almost same colour but not the same.
> >
> > Don't you play with contrast ratio between headings starting with ;;; and those starting
> > with code?
>
> Just rebuilt Emacs and checked with the file you sent.  Long story
> short: this is the same as we discussed the other day, namely, that the
> problem is with outline.el and how it chooses to fontify forms that are
> not explicitly defined as headings (defvar, defun...).
>
> To the defun, defvar etc. it applies the outline-8 face, whereas the
> real headings (starting with comments that have three delimiters: ;;;)
> are styled with outline-1 and then incremented for each extra comment
> delimiter.
>
> This happens regardless of theme.  It just is that the generic theme
> inherits from font-lock, so the problem is not obvious even though it is
> still there: try it with and without outline-minor-mode to see the
> difference.
>
> Here is what I did (screenshots attached):
>
> - emacs -Q and find-file gungadin.el (screenshot 1)
>
> - M-x outline-minor-mode (screenshot 2)
>
> - M-x load-theme RET modus-operandi RET (screenshot 3)
>
> - M-: (setq-default outline-minor-mode-highlight 'override) RET
>   and then M-x outline-minor-mode twice to re-enable the mode
>   (screenshot 4)
>
> - M-x disable-theme RET modus-operandi RET (screenshot 5)
>
> - M-x outline-minor-mode (screenshot 6)
>
> Just comparing the last two screenshots you can see that the problem is
> there.
>
> As for the style of the headings for the modus-themes (screenshot 4),
> you can use the variable 'modus-themes-headings' as we mentioned before.
>
> I suggest we bring this issue upstream.  Ask them whether the
> defvar,defun etc. can retain their styles and only for explicit headings
> to be fontified.
>
> --
> Protesilaos Stavrou
> https://protesilaos.com
>