Thorsten Jolitz <tjol...@gmail.com> writes: > Matt Price <mopto...@gmail.com> writes: > >> Is there a command to fold all drawers in a buffer (all property >> drawers would be enough, actually)? Or a suggestion for how to do >> this? Thanks! > > They might exist (with me unaware of them), but the following pair of > commands does the job, at least with this minimal test org snippet: > > * A > :PROPERTIES: > :CUSTOM_ID: a1 > :END: > * B > :PROPERTIES: > :CUSTOM_ID: B1 > :END: > > #+begin_src emacs-lisp > (defun org-show-drawers () > "Unfold all drawers in buffer" > (interactive) > (save-excursion > (goto-char (point-min)) > (while (not (eobp)) > (and (org-at-drawer-p) > (org-element-property :hiddenp (org-element-at-point)) > (org-cycle)) > (forward-char)))) > > (defun org-hide-drawers () > "Fold all drawers in buffer" > (interactive) > (save-excursion > (goto-char (point-min)) > (while (not (eobp)) > (and (org-at-drawer-p) > (not (org-element-property :hiddenp (org-element-at-point))) > (org-cycle)) > (forward-char)))) > #+end_src > > #+results: > : org-hide-drawers
I tested the above functions with a big org file - way to slow. These versions perfom better, but only on property drawers: #+begin_src emacs-lisp (defun org-show-drawers () "Unfold all drawers in buffer" (interactive) (save-excursion (goto-char (point-min)) (while (re-search-forward org-property-start-re nil 'NOERROR) (and (org-element-property :hiddenp (org-element-at-point)) (org-cycle))))) (defun org-hide-drawers () "Unfold all drawers in buffer" (interactive) (save-excursion (goto-char (point-min)) (while (re-search-forward org-property-start-re nil 'NOERROR) (and (not (org-element-property :hiddenp (org-element-at-point))) (org-cycle))))) #+end_src -- cheers, Thorsten