From c589e4055aad93aceefe0ebb3281c008c82a0b46 Mon Sep 17 00:00:00 2001 From: "Paul W. Rankin" Date: Tue, 17 Nov 2020 12:42:47 +1000 Subject: [PATCH 1/2] * lisp/outline.el: better handing of outline overlays when cycling (outline--cycle-state): only consider outline overlays that are on outline headings; when subtree end is point-max, return overlay-end +1 because final subtree overlay only reaches point-max -1. --- lisp/outline.el | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/lisp/outline.el b/lisp/outline.el index 47e6528859..8cc8a3cd89 100644 --- a/lisp/outline.el +++ b/lisp/outline.el @@ -1121,14 +1121,19 @@ outline--cycle-state (setq heading-end (point)) (outline-end-of-subtree) (setq end (point)) - (setq ov-list (cl-remove-if-not - (lambda (o) (eq (overlay-get o 'invisible) 'outline)) - (overlays-in start end))) - (cond ((eq ov-list nil) 'show-all) - ;; (eq (length ov-list) 1) wouldn’t work: what if there is - ;; one folded subheading? - ((and (eq (overlay-end (car ov-list)) end) - (eq (overlay-start (car ov-list)) heading-end)) + (setq ov-list + (seq-filter + (lambda (o) + (and (eq (overlay-get o 'invisible) 'outline) + (save-excursion + (goto-char (overlay-start o)) + (outline-on-heading-p t)))) + (overlays-in start end))) + (cond ((null ov-list) 'show-all) + ((and (or (= end (point-max) + (1+ (overlay-end (car ov-list)))) + (= (overlay-end (car ov-list)) end)) + (= (overlay-start (car ov-list)) heading-end)) 'hide-all) (t 'headings-only))))) -- 2.29.2