Subject: bug#51809: 29.0.50; [PATCH] Support for outline default state in Diff buffers

From: Matthias Meulien <[email-masked]>
Date: Sat, 13 Nov 2021 19:08:04 +0100

Juri Linkov <[email-masked]> writes:

> (...) I'm using outline-minor-mode in diff buffers all the time with
> (add-hook 'diff-mode-hook 'outline-minor-mode) and would like to
> understand how your patch improves this.
>
> Could the above hook be replaced with customization of
> diff-outline-default-state?

It was supposed to. But I am also using outline-minor-mode in diff
buffers all the time with the same hook as you, and I must confess I've
not tested until you asked: `diff-outline-apply-default-state' is
supposed to automatically turn on `outline-minor-mode' but I forgot to
autoload the later resulting in "Symbol’s value as variable is void:
outline-minor-mode". I'll fix this.

>
>> +;; - Support outlining files by name (eg to skip automatically
>> +;;   generated files like package-lock.json in Javascript projects).
>>…
>> +(defcustom diff-file-outline-threshold 50
>> +  "Number of lines of hunks for a file to be outlined.
>
> Often the files that need to be hidden contain just one very long line
> without newlines such as in compiled assets, etc. and eventually make
> Emacs unresponsive.  This is a big problem.  Would it be possible
> in your patch to check the size of the hunk counting characters
> instead of lines?

Good point. I guess counting characters can be achieved by:
  (- (overlay-end overlay) (overlay-start overlay))
thus it looks feasible.

Wouldn't it better to add a new choice "Outline hunks with long lines"
and allow multiple choices in `diff-outline-default-state'
customization?

It would allow to implement one more usefull choice (from my pov),
"Outline files by name" to hide automatically generated files (like
package-lock.json in Javascript projects using NPM)...

Does it looks reasonnable to you?
-- 
Matthias