Fix zr, zm, zR & zM vimmish folding in org-mode
Fixes the following keybinds for evil users: z r open next level of headings buffer-wide z m close next level of headings buffer-wide z R open all folded headings z M close all folded headings [N] z R open all headings at level N and above [N] z M close all headings at level N and below
This commit is contained in:
parent
7bbb52f17c
commit
a10c157d87
2 changed files with 22 additions and 9 deletions
|
@ -306,6 +306,20 @@ the prefix ARG changes this command's behavior."
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defalias #'+org/close-fold #'outline-hide-subtree)
|
(defalias #'+org/close-fold #'outline-hide-subtree)
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun +org/close-all-folds (&optional level)
|
||||||
|
"Close all folds in the buffer (or below LEVEL)."
|
||||||
|
(interactive "p")
|
||||||
|
(outline-hide-sublevels (or level 1)))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun +org/open-all-folds (&optional level)
|
||||||
|
"Open all folds in the buffer (or up to LEVEL)."
|
||||||
|
(interactive "P")
|
||||||
|
(if (integerp level)
|
||||||
|
(outline-hide-sublevels level)
|
||||||
|
(outline-show-all)))
|
||||||
|
|
||||||
(defun +org--get-foldlevel ()
|
(defun +org--get-foldlevel ()
|
||||||
(let ((max 1))
|
(let ((max 1))
|
||||||
(save-restriction
|
(save-restriction
|
||||||
|
@ -321,22 +335,20 @@ the prefix ARG changes this command's behavior."
|
||||||
max)))
|
max)))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun +org/show-next-fold-level ()
|
(defun +org/show-next-fold-level (&optional count)
|
||||||
"Decrease the fold-level of the visible area of the buffer. This unfolds
|
"Decrease the fold-level of the visible area of the buffer. This unfolds
|
||||||
another level of headings on each invocation."
|
another level of headings on each invocation."
|
||||||
(interactive)
|
(interactive "p")
|
||||||
(let* ((current-level (+org--get-foldlevel))
|
(let ((new-level (+ (+org--get-foldlevel) (or count 1))))
|
||||||
(new-level (1+ current-level)))
|
|
||||||
(outline-hide-sublevels new-level)
|
(outline-hide-sublevels new-level)
|
||||||
(message "Folded to level %s" new-level)))
|
(message "Folded to level %s" new-level)))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun +org/hide-next-fold-level ()
|
(defun +org/hide-next-fold-level (&optional count)
|
||||||
"Increase the global fold-level of the visible area of the buffer. This folds
|
"Increase the global fold-level of the visible area of the buffer. This folds
|
||||||
another level of headings on each invocation."
|
another level of headings on each invocation."
|
||||||
(interactive)
|
(interactive "p")
|
||||||
(let* ((current-level (+org--get-foldlevel))
|
(let ((new-level (max 1 (- (+org--get-foldlevel) (or count 1)))))
|
||||||
(new-level (max 1 (1- current-level))))
|
|
||||||
(outline-hide-sublevels new-level)
|
(outline-hide-sublevels new-level)
|
||||||
(message "Folded to level %s" new-level)))
|
(message "Folded to level %s" new-level)))
|
||||||
|
|
||||||
|
|
|
@ -907,11 +907,12 @@ compelling reason, so..."
|
||||||
:n "zc" #'+org/close-fold
|
:n "zc" #'+org/close-fold
|
||||||
:n "zC" #'outline-hide-subtree
|
:n "zC" #'outline-hide-subtree
|
||||||
:n "zm" #'+org/hide-next-fold-level
|
:n "zm" #'+org/hide-next-fold-level
|
||||||
|
:n "zM" #'+org/close-all-folds
|
||||||
:n "zn" #'org-tree-to-indirect-buffer
|
:n "zn" #'org-tree-to-indirect-buffer
|
||||||
:n "zo" #'+org/open-fold
|
:n "zo" #'+org/open-fold
|
||||||
:n "zO" #'outline-show-subtree
|
:n "zO" #'outline-show-subtree
|
||||||
:n "zr" #'+org/show-next-fold-level
|
:n "zr" #'+org/show-next-fold-level
|
||||||
:n "zR" #'outline-show-all
|
:n "zR" #'+org/open-all-folds
|
||||||
:n "zi" #'org-toggle-inline-images
|
:n "zi" #'org-toggle-inline-images
|
||||||
|
|
||||||
:map org-read-date-minibuffer-local-map
|
:map org-read-date-minibuffer-local-map
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue