emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@posteo.net>
To: Cassio Koshikumo <ckoshikumo@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: [FR] Make org-occur highlights always visible, even upon folding (was: Bug or expected behavior? org-sparse-tree visibility toggling)
Date: Fri, 24 Mar 2023 12:16:15 +0000	[thread overview]
Message-ID: <87v8iqwdio.fsf@localhost> (raw)
In-Reply-To: <CAJP-4jOBA5gb871vtta2BXufyyieuki07mj6DJ-0tvD+7veBow@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 839 bytes --]

Cassio Koshikumo <ckoshikumo@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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-highlight-new-match-Make-highlights-always-visib.patch --]
[-- Type: text/x-patch, Size: 1420 bytes --]

From d3e8d0a9fc235b025f005158cc51f21e5e2ec8ee Mon Sep 17 00:00:00 2001
Message-Id: <d3e8d0a9fc235b025f005158cc51f21e5e2ec8ee.1679659944.git.yantar92@posteo.net>
From: Ihor Radchenko <yantar92@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


[-- Attachment #3: Type: text/plain, Size: 224 bytes --]


-- 
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>

      reply	other threads:[~2023-03-24 15:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-24 21:57 Bug or expected behavior? org-sparse-tree visibility toggling Cassio Koshikumo
2023-02-26 11:53 ` Ihor Radchenko
2023-02-27 20:12   ` Cassio Koshikumo
2023-03-24 12:16     ` Ihor Radchenko [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87v8iqwdio.fsf@localhost \
    --to=yantar92@posteo.net \
    --cc=ckoshikumo@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).