lang/org: augment org-cycle, rather than replace it
This removes +org/toggle-fold in favor of a more compatible alternative: a org-tab-first-hook function that forces org-cycle only to toggle the current subtree, and not cycle through all visibility states.
This commit is contained in:
parent
5d3f247a7f
commit
bc91c55acc
|
@ -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))))
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user