fix(org): don't show parent trees by default
Instead of changing the behavior of the showNlevels startup options, I've added a new set of showNlevels* options to perform the new behavior of unfolding parent trees all the way up to the target level. Ref: https://www.reddit.com/r/emacs/comments/tj0na6/comment/i1laya6/?utm_source=reddit&utm_medium=web2x&context=3
This commit is contained in:
parent
385e60cd26
commit
aed2972d74
1 changed files with 29 additions and 17 deletions
|
@ -685,23 +685,35 @@ mutating hooks on exported output, like formatters."
|
||||||
;; Open help:* links with helpful-* instead of describe-*
|
;; Open help:* links with helpful-* instead of describe-*
|
||||||
(advice-add #'org-link--open-help :around #'doom-use-helpful-a)
|
(advice-add #'org-link--open-help :around #'doom-use-helpful-a)
|
||||||
|
|
||||||
(defadvice! +org--show-parents-a (&optional arg)
|
;; Unlike the stock showNlevels options, these will also show the parents of
|
||||||
"Show all headlines in the buffer, like a table of contents.
|
;; the target level, recursively.
|
||||||
With numerical argument N, show content up to level N."
|
(pushnew! org-startup-options
|
||||||
:override #'org-content
|
'("show2levels*" org-startup-folded show2levels*)
|
||||||
(interactive "p")
|
'("show3levels*" org-startup-folded show3levels*)
|
||||||
|
'("show4levels*" org-startup-folded show4levels*)
|
||||||
|
'("show5levels*" org-startup-folded show5levels*))
|
||||||
|
|
||||||
|
(defadvice! +org--more-startup-folded-options-a ()
|
||||||
|
"Adds support for 'showNlevels*' startup options.
|
||||||
|
Unlike showNlevels, this will also unfold parent trees."
|
||||||
|
:before #'org-set-startup-visibility
|
||||||
|
(when-let (n (pcase org-startup-folded
|
||||||
|
(`show2levels* 2)
|
||||||
|
(`show3levels* 3)
|
||||||
|
(`show4levels* 4)
|
||||||
|
(`show5levels* 5)))
|
||||||
(org-show-all '(headings drawers))
|
(org-show-all '(headings drawers))
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(goto-char (point-max))
|
(goto-char (point-max))
|
||||||
(let ((regexp (if (and (wholenump arg) (> arg 0))
|
(let ((regexp (if (and (wholenump n) (> n 0))
|
||||||
(format "^\\*\\{%d,%d\\} " (1- arg) arg)
|
(format "^\\*\\{%d,%d\\} " (1- n) n)
|
||||||
"^\\*+ "))
|
"^\\*+ "))
|
||||||
(last (point)))
|
(last (point)))
|
||||||
(while (re-search-backward regexp nil t)
|
(while (re-search-backward regexp nil t)
|
||||||
(when (or (not (wholenump arg))
|
(when (or (not (wholenump n))
|
||||||
(= (org-current-level) arg))
|
(= (org-current-level) n))
|
||||||
(org-flag-region (line-end-position) last t 'outline))
|
(org-flag-region (line-end-position) last t 'outline))
|
||||||
(setq last (line-end-position 0))))))
|
(setq last (line-end-position 0)))))))
|
||||||
|
|
||||||
;; Some uses of `org-fix-tags-on-the-fly' occur without a check on
|
;; Some uses of `org-fix-tags-on-the-fly' occur without a check on
|
||||||
;; `org-auto-align-tags', such as in `org-self-insert-command' and
|
;; `org-auto-align-tags', such as in `org-self-insert-command' and
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue