diff --git a/modules/lang/org/autoload/org.el b/modules/lang/org/autoload/org.el index 29529b762..4b3f60909 100644 --- a/modules/lang/org/autoload/org.el +++ b/modules/lang/org/autoload/org.el @@ -256,27 +256,6 @@ wrong places)." (interactive) (org-toggle-checkbox '(4))) -;;;###autoload -(defun +org/toggle-fold () - "Toggle the local fold at the point (as opposed to cycling through all levels -with `org-cycle'). Also: - - + If in a babel block, removes result blocks. - + If in a table, realign it, if necessary." - (interactive) - (save-excursion - (org-beginning-of-line) - (cond ((org-at-table-p) - (org-table-align)) - ((org-at-heading-p) - (outline-toggle-children)) - ((org-in-src-block-p) - (org-babel-remove-result)) - ((org-at-item-p) - (let ((window-beg (window-start))) - (org-cycle) - (set-window-start nil window-beg)))))) - ;; ;; Hooks @@ -349,3 +328,19 @@ with `org-cycle'). Also: (yas--templates-for-key-at-point)) (call-interactively #'yas-expand) t)) + +;;;###autoload +(defun +org|toggle-only-current-fold () + "Toggle the local fold at the point (as opposed to cycling through all levels +with `org-cycle')." + (interactive) + (save-excursion + (org-beginning-of-line) + (cond ((org-at-heading-p) + (outline-toggle-children) + (unless (outline-invisible-p (line-end-position)) + (org-cycle-hide-drawers 'subtree)) + t) + ((org-in-src-block-p) + (org-babel-remove-result) + t)))) diff --git a/modules/lang/org/config.el b/modules/lang/org/config.el index a74d3f362..8de5312da 100644 --- a/modules/lang/org/config.el +++ b/modules/lang/org/config.el @@ -251,6 +251,9 @@ between the two." (defun +org|setup-evil () (require 'evil-org) + + (add-hook 'org-tab-first-hook #'+org|toggle-only-current-fold) + (map! :map outline-mode-map :n "^" nil :n [backtab] nil @@ -267,8 +270,6 @@ between the two." :ni "C-S-h" #'+org/table-prepend-field-or-shift-left :ni "C-S-k" #'org-metaup :ni "C-S-j" #'org-metadown - ;; toggle local fold, instead of all children - :n [tab] #'+org/toggle-fold ;; more intuitive RET keybinds :i "RET" #'org-return-indent :n "RET" #'+org/dwim-at-point