diff --git a/users/crumb/programs/emacs/modules/syd-org.el b/users/crumb/programs/emacs/modules/syd-org.el index 1814517..689bef0 100755 --- a/users/crumb/programs/emacs/modules/syd-org.el +++ b/users/crumb/programs/emacs/modules/syd-org.el @@ -2,6 +2,38 @@ (require 'syd-prose) +(with-eval-after-load 'org + (syd-add-hook 'org-tab-first-hook + (defun syd-org-cycle-only-current-subtree-h (&optional arg) + "Toggle the local fold at the point, and no deeper. +`org-cycle's standard behavior is to cycle between three levels: collapsed, +subtree and whole document. This is slow, especially in larger org buffer. Most +of the time I just want to peek into the current subtree -- at most, expand +*only* the current subtree. + +All my (performant) foldings needs are met between this and `org-show-subtree' +(on zO for evil users), and `org-cycle' on shift-TAB if I need it." + (interactive "P") + (unless (or (eq this-command 'org-shifttab) + (and (bound-and-true-p org-cdlatex-mode) + (or (org-inside-LaTeX-fragment-p) + (org-inside-latex-macro-p)))) + (save-excursion + (org-beginning-of-line) + (let (invisible-p) + (when (and (org-at-heading-p) + (or org-cycle-open-archived-trees + (not (member org-archive-tag (org-get-tags)))) + (or (not arg) + (setq invisible-p + (memq (get-char-property (line-end-position) + 'invisible) + '(outline org-fold-outline))))) + (unless invisible-p + (setq org-cycle-subtree-status 'subtree)) + (org-cycle-internal-local) + t))))))) + (defun syd-org--init-hacks-h () ;; Open file links in current window, rather than new ones (setf (alist-get 'file org-link-frame-setup) #'find-file)