GNU bug report logs -
#51809
29.0.50; [PATCH] Support for outline default state in Diff buffers
Previous Next
Reported by: Matthias Meulien <orontee <at> gmail.com>
Date: Sat, 13 Nov 2021 13:10:02 UTC
Severity: normal
Tags: fixed, patch
Fixed in version 29.0.50
Done: Juri Linkov <juri <at> linkov.net>
Bug is archived. No further changes may be made.
Full log
Message #20 received at 51809 <at> debbugs.gnu.org (full text, mbox):
>>> (...) Could the above hook be replaced with customization of
>>> diff-outline-default-state?
>
> With the attached patch, Outline minor mode is automatically enabled
> when `diff-outline-default-state' is customized. Tested within "emacs
> -q". That said, I am not a proficient elisper and my use of the
> autoload, declare-function, eval-when-compile machinery may not be
> standard. Sorry for this.
> +(autoload 'outline-minor-mode "outline")
Actually, outline-minor-mode is already autoloaded, so no special
handling is needed for it.
But the problem is that too many outline functions are used in
diff-mode.el in your patch. This is a clear indication that
some part should be moved to outline.el.
Note that the following function has no diff-specific code, so it could
be refactored and some generalized function added to outline.el. Such
function could be like `outline-map-region' to accept arguments `beg', `end'
and a predicate function that defines whether to hide or show the body.
> + (when outline-minor-mode
> + (save-excursion
> + (let* (outline-view-change-hook
> + (beg (progn
> + (goto-char (point-min))
> + ;; Skip the prelude, if any.
> + (unless (outline-on-heading-p t) (outline-next-heading))
> + (point)))
> + (end (progn
> + (goto-char (point-max))
> + ;; Keep empty last line, if available.
> + (if (bolp) (1- (point)) (point)))))
> + (if (< end beg)
> + (setq beg (prog1 end (setq end beg))))
> + ;; First hide sublevels
> + (outline-hide-sublevels 1)
> + ;; Then unhide short subtrees
> + (outline-map-region
> + (lambda ()
> + (when (= (funcall outline-level) 1)
> + (goto-char (match-end 0))
> + (let ((overlays (overlays-at (point))))
> + (while overlays
> + (let ((overlay (car overlays)))
> + (progn
> + (when (eq (overlay-get overlay 'invisible) 'outline)
> + (let ((size (count-lines
> + (overlay-end overlay)
> + (overlay-start overlay))))
> + (goto-char (match-beginning 0))
> + (if (< size diff-file-outline-threshold)
> + (outline-show-subtree)
> + (outline-show-branches))))
> + (setq overlays (cdr overlays))))))))
> + beg end)))))
This bug report was last modified 3 years and 91 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.