Closed Pierre-Andre closed 3 months ago
I'm not sure on this. There are many packages for folding things in Emacs, we couldn't deal with all of them.
Also, org-fold-show-context
is not defined in Emacs 28.2 (I guess it's added in Emacs 29). org-show-context
should be used instead.
How about letting the user put their own "unfold" function in citre-after-jump-hook
?
1) About "letting the user put their own "unfold" function in citre-after-jump-hook
":
Yes, but for end-user (like me) an example could be given as a use case of citre-after-jump-hook
2) org-show-context
and org-fold-show-context
:
I didn't pay attention but as I use doom-emacs, org version is (more than) 9.6. In emacs 28.1, org version is 9.5.2. From 9.6 and beyond org-show-context
is replaced by org-fold-show-context
. This is another argument to make citre-after-jump-hook
the solution…
Try this:
(add-hook 'citre-after-jump-hook
(defun citre-org-unfold ()
(when (derived-mode-p 'org-mode)
(org-fold-show-context 'isearch))))
Just in case, the following config for doom-emacs is can be used (to unfold after jump an org file):
package.el
file :
(package! citre)
config.el
file:
(use-package! citre
:init
(add-hook 'citre-after-jump-hook
(lambda ()
(message "org-mode" (derived-mode-p 'org-mode))
(when (derived-mode-p 'org-mode)
(org-fold-show-context 'isearch))))
:config
(map! :map citre-peek-keymap
:localleader
"j" 'citre-peek-next-line
"k" 'citre-peek-prev-line))
(use-package! citre-config
:after citre)
I am reopening this as I've learnt a general unfolding technique that should apply to any folding implemented using overlay.
This technique comes from reveal.el
, which is built-in.
(defun invisible-prop-effective-p (prop)
"If PROP actually means invisible in current buffer, return non-nil.
PROP is the `invisible' property of an overlay."
(pcase buffer-invisibility-spec
('t prop)
(_ (let ((atoms (mapcar (lambda (e) (if (consp e) (car e) e))
buffer-invisibility-spec)))
(if (listp prop)
(cl-intersection prop atoms :test #'eq)
(memq prop atoms))))))
(defun reveal-if-invisible (pt)
"If PT is folded, reveal it."
(let ((ols (overlays-at pt)))
(dolist (ol ols)
(when (invisible-prop-effective-p (overlay-get ol 'invisible))
(delete-overlay ol)))))
A simple test of reveal-if-invisible
in an org file works well. I should test this more and add it to citre-after-jump-hook
by default.
Unfortunately reveal-mode
doesn't work now in org-mode
, maybe due to the changes in org-mode
. So I've added an example in user documentation.
If the org-mode file is folded, jump to TAG go to the tag but the file remain folded (and the point is not visible). A normal behavior would be making the point visible.
For instance in
citre-goto-tag
functioninstead of
could fix the issue, at least for jumping using
citre-goto-tag
, (I don't know if there are other ways to do that)Thanks for all your work on citre !!