From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thorsten Jolitz Subject: Re: fold all drawers in a buffer? Date: Fri, 01 Nov 2013 17:43:15 +0100 Message-ID: <87d2mkkr8c.fsf@gmail.com> References: <87ppqkktky.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:38482) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VcHow-0001aG-3W for emacs-orgmode@gnu.org; Fri, 01 Nov 2013 12:43:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VcHoo-0006nt-Pm for emacs-orgmode@gnu.org; Fri, 01 Nov 2013 12:43:38 -0400 Received: from plane.gmane.org ([80.91.229.3]:58672) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VcHoo-0006nh-Io for emacs-orgmode@gnu.org; Fri, 01 Nov 2013 12:43:30 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1VcHon-00038F-4i for emacs-orgmode@gnu.org; Fri, 01 Nov 2013 17:43:29 +0100 Received: from g231108014.adsl.alicedsl.de ([92.231.108.14]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 01 Nov 2013 17:43:29 +0100 Received: from tjolitz by g231108014.adsl.alicedsl.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 01 Nov 2013 17:43:29 +0100 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Thorsten Jolitz writes: > Matt Price 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