0

I’m looking for an interactive command that would fold / unfold all the :PROPERTIES: drawers in an org file.
I’m sure this command must exist, I just can’t find it – and I’m curious to how you did find it, if you do!

1 Answer 1

1

org-fold-hide-drawer-all will hide all drawers in the buffer (or with an active region, all drawers in the region).

I found it by doing C-h f org-fold--drawer TAB and then doing C-h f <function name> on each of the likely candidates (there were only three of them).

EDIT: My apologies: org-fold-hide-drawer-all was made interactive with commit 13353f1fa34f6f085ffbf142b380af7308f02981 but that change has not been incorporated into the stable releases yet.

In 9.6.151, you'll have to override the function with a copy of the function from the commit above. Add the following to your init file:

(with-eval-after-load 'org-fold
  (defun org-fold-hide-drawer-all (&optional begin end)
    "Fold all drawers in the current buffer or active region BEGIN..END."
    (interactive (list (and (use-region-p) (region-beginning))
                       (and (use-region-p) (region-end))))
    (let ((begin (or begin (point-min)))
          (end (or end (point-max))))
      (org-fold--hide-drawers begin end))))

[1] Actually, in any stable 9.6.x release. The change will probably not be included in any of the 9.6.x series releases: I suspect it will be included in 9.7 and later.

6
  • Thank you for your answer! org-fold-hide-drawer is not an interactive function, is it? I can’t seem to use it with M-x (which is the point). When I do C-h f org-fold--drawer TAB, I have absolutely no suggestion on my Emacs. For reference, I’m on Emacs 29.3 with org-version 9.6.15.
    – kotchwane
    Commented Apr 17 at 15:20
  • You got the name of the function wrong: org-fold-hide-drawer-all is an interactive function (AKA command), so you can call it with M-x.
    – NickD
    Commented Apr 17 at 19:35
  • Are you using standard completion or some third-party completion package? When I do C-h f org-fold-drawer TAB I get a completion buffer with four possibilities (one of which is org-fold-hide-drawer-all.
    – NickD
    Commented Apr 17 at 19:38
  • 1
    See the edited answer: no stable release contains the interactive version of org-fold-hide-drawer-all yet. I provide a workaround in the answer.
    – NickD
    Commented Apr 18 at 1:27
  • Thank you for your answer update and your comments! It works well for folding all properties on a buffer, despite it being slow.  But what about unfolding?
    – kotchwane
    Commented Apr 18 at 15:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.