Cassio Koshikumo <ckoshik...@gmail.com> writes: > Hm. It makes sense that TAB is not affected... Somehow I hadn't really > considered that. > > What I expected to happen (and now I realize it was not a justified > expectation) was to have the visibility of the sparse-tree kept while > tabbing. So I could expand a tree, then collapse it again, all the > while keeping the sparse-tree "filter" applied. But I guess it doesn't > make much sense. > > Well, I guess I could leave it as a suggestion for new functionality, > but I don't even know if it's feasible.
It is not very hard to do, actually. See the attached patch. However, I am not sure if it is something of interest for other Org users. If there is more support, I can convert the patch into proper new Org feature, adding customization and necessary ORG-NEWS announcement.
>From d3e8d0a9fc235b025f005158cc51f21e5e2ec8ee Mon Sep 17 00:00:00 2001 Message-Id: <d3e8d0a9fc235b025f005158cc51f21e5e2ec8ee.1679659944.git.yanta...@posteo.net> From: Ihor Radchenko <yanta...@posteo.net> Date: Fri, 24 Mar 2023 13:10:37 +0100 Subject: [PATCH] org-highlight-new-match: Make highlights always visible * lisp/org.el (org-highlight-new-match): Make highlights always visible, even upon folding. --- lisp/org.el | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 20e6ea6d9..1834eadbc 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -10762,10 +10762,15 @@ (defun org-occur-next-match (&optional n _reset) (defun org-highlight-new-match (beg end) "Highlight from BEG to END and mark the highlight is an occur headline." - (let ((ov (make-overlay beg end))) + (let ((ov (make-overlay beg end)) + (ov-line (make-overlay + (org-with-point-at beg (max (point-min) (1- (pos-bol)))) + (org-with-point-at end (pos-eol))))) (overlay-put ov 'face 'secondary-selection) (overlay-put ov 'org-type 'org-occur) - (push ov org-occur-highlights))) + (overlay-put ov-line 'invisible 'org-occur) + (push ov org-occur-highlights) + (push ov-line org-occur-highlights))) (defun org-remove-occur-highlights (&optional _beg _end noremove) "Remove the occur highlights from the buffer. -- 2.39.1
-- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at <https://orgmode.org/>. Support Org development at <https://liberapay.com/org-mode>, or support my work at <https://liberapay.com/yantar92>