bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Matthias Meulien
Subject: bug#51809: 29.0.50; [PATCH] Support for outline default state in Diff buffers
Date: Sun, 26 Dec 2021 21:55:30 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

Matthias Meulien <orontee@gmail.com> writes:

> I am now back to the origin of this bug report (toggling visibility of
> some diff hunks depending on long lines, chunks size, or file names) and
> I see there's a major drawback with the outline mode default visibility
> state approach: When outline minor mode is set through diff-mode-hook,
> the buffer is emtpy and applying the default state visibility is a
> no-op; It's a side-effect of the buffer content being generated
> asynchronously...

I fixed it using an advice to `vc-diff-finish', but wondering whether
there's a clean way to achieve the same...

For posterity, here is a sample configuration for *vc-diff* buffers to
hide hunks with long lines, long hunks or matching some regexp.

(add-hook 'diff-mode-hook #'(lambda ()
                              (setq diff-font-lock-prettify t
                                    outline-default-state 1
                                    outline-default-state-subtree-visibility
                                    '(subtree-is-long
                                      subtree-has-long-lines
                                      (match-regexp . "NEWS\\|test")))
                              (outline-minor-mode)))

(defadvice vc-diff-finish (after ensure-outline-apply-default-state activate)
  (when outline-minor-mode
    (outline-apply-default-state)))





reply via email to

[Prev in Thread] Current Thread [Next in Thread]