From 42ae401deb7c39a72c6e24bd899abab9c10a687c Mon Sep 17 00:00:00 2001 From: 45mg <45mm.cartridge421@slmail.me> Date: Mon, 20 May 2024 18:09:54 +0000 Subject: [PATCH] fix(fold): +fold/next: actually support outlines The docstring says that this function will move to the next folded outline heading, but this had not been implemented. --- modules/editor/fold/autoload/fold.el | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/modules/editor/fold/autoload/fold.el b/modules/editor/fold/autoload/fold.el index 290958a78..ff668d9f9 100644 --- a/modules/editor/fold/autoload/fold.el +++ b/modules/editor/fold/autoload/fold.el @@ -219,7 +219,8 @@ Targets `vimmish-fold', `hideshow', `ts-fold' and `outline' folds." ;;;###autoload (defun +fold/next (count) - "Jump to the next vimish fold, outline heading or folded region." + "Jump to the next vimish fold, folded outline heading or folded +region." (interactive "p") (cl-loop with orig-pt = (point) for fn @@ -233,6 +234,24 @@ Targets `vimmish-fold', `hideshow', `ts-fold' and `outline' folds." (dotimes (_ count) (vimish-fold-previous-fold (- count))))) (if (/= (point) orig-pt) (point))) + (lambda () + (when (or (bound-and-true-p outline-minor-mode) + (derived-mode-p 'outline-mode)) + (cl-destructuring-bind + (count fn bound-fn) + (if (> count 0) + (list count + #'outline-next-visible-heading #'eobp) + (list (- count) + #'outline-previous-visible-heading #'bobp)) + (dotimes (_ count) + (funcall fn 1) + (outline-end-of-heading) + (while (and (not (funcall bound-fn)) + (not (outline-invisible-p))) + (funcall fn 1) + (outline-end-of-heading)))) + (point))) (lambda () ;; ts-fold does not define movement functions so we need to do it ourselves (when (+fold--ts-fold-p)