Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Folding with outline-minor-mode #197

Open
tpeacock19 opened this issue May 19, 2021 · 4 comments
Open

Folding with outline-minor-mode #197

tpeacock19 opened this issue May 19, 2021 · 4 comments
Assignees

Comments

@tpeacock19
Copy link

I just posted this on reddit but thought it may be useful to include in the README as an alternative to using origami to auto-fold.

(use-package outline
  :after org-super-agenda
  :general (:keymaps org-super-agenda-header-map
            "TAB" #'outline-cycle)
  :config
  (defvar org-super-agenda-auto-fold-groups '("Stuck Tasks" "Other items" "Notice"))

  ;; function borrowed from new fork of origami.el https://github.com/emacs-origami/origami.el/blob/master/origami.el#L1024
  (defun outline-auto-agenda (pattern-or-patterns function)
    "Search buffer and apply the FUNCTION on each line.
PATTERN-OR-PATTERNS is a string or a list of strings to search"
    (interactive)
    (let ((patterns (if (listp pattern-or-patterns) pattern-or-patterns (list pattern-or-patterns))))
      (save-excursion
        (dolist (pattern patterns)
          (goto-char (point-min))
          (while (re-search-forward pattern nil t 1)
            (unless (outline-invisible-p)
              (funcall function)))))))

  (defun outline-agenda-setup ()
    (setq-local outline-regexp org-super-agenda-header-prefix)
    (setq-local outline-level #'outline-level)
    (setq-local outline-heading-alist
                `((,org-super-agenda-header-prefix . 1)))
    (outline-auto-agenda org-super-agenda-auto-fold-groups #'outline-hide-subtree))

  :hook ((org-agenda-mode . outline-minor-mode)
         (org-agenda-finalize . outline-agenda-setup)))
@alphapapa alphapapa self-assigned this Jun 3, 2021
@alphapapa
Copy link
Owner

Hi, thanks, that's very cool. It never occurred to me to use outline-minor-mode for that. I'll add it to the docs sometime... :)

@alphapapa
Copy link
Owner

alphapapa commented Jul 5, 2021

Why did you close this? I intend to add it to the docs eventually, but there are a lot of other issues on my Emacs-related to-do lists. It does no harm to leave the issue open until it's done.

@alphapapa alphapapa reopened this Jul 5, 2021
@tpeacock19
Copy link
Author

oh sorry i was cleaning up my notifications and thought this may have just been noise for you.

@alphapapa
Copy link
Owner

No problem. I lean towards Debian's philosophy of bug tracking: If it still needs to be done, the issue should remain open. If there's noise, it means the bug tracker software needs to do a better job of helping the user filter it. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants