all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* fold all drawers in a buffer?
@ 2013-11-01 13:46 Matt Price
  2013-11-01 15:52 ` Thorsten Jolitz
  0 siblings, 1 reply; 5+ messages in thread
From: Matt Price @ 2013-11-01 13:46 UTC (permalink / raw)
  To: Org Mode

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!
Matt

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: fold all drawers in a buffer?
  2013-11-01 13:46 fold all drawers in a buffer? Matt Price
@ 2013-11-01 15:52 ` Thorsten Jolitz
  2013-11-01 16:43   ` Thorsten Jolitz
  0 siblings, 1 reply; 5+ messages in thread
From: Thorsten Jolitz @ 2013-11-01 15:52 UTC (permalink / raw)
  To: emacs-orgmode

Matt Price <moptop99@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

-- 
cheers,
Thorsten

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: fold all drawers in a buffer?
  2013-11-01 15:52 ` Thorsten Jolitz
@ 2013-11-01 16:43   ` Thorsten Jolitz
  2013-11-01 18:34     ` Aaron Ecay
  0 siblings, 1 reply; 5+ messages in thread
From: Thorsten Jolitz @ 2013-11-01 16:43 UTC (permalink / raw)
  To: emacs-orgmode

Thorsten Jolitz <tjolitz@gmail.com> writes:

> Matt Price <moptop99@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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: fold all drawers in a buffer?
  2013-11-01 16:43   ` Thorsten Jolitz
@ 2013-11-01 18:34     ` Aaron Ecay
  2013-11-01 19:28       ` Thorsten Jolitz
  0 siblings, 1 reply; 5+ messages in thread
From: Aaron Ecay @ 2013-11-01 18:34 UTC (permalink / raw)
  To: Thorsten Jolitz, emacs-orgmode

Hi Thorsten,

2013ko azaroak 1an, Thorsten Jolitz-ek idatzi zuen:
> 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

This will work on recent versions of org, but the :hiddenp properties
were taken out of the parser by the following git commit (not yet in any
released version of org AFAIK):

commit fe27ca9906f1d6c48a93f463d85850925687b825
Author: Nicolas Goaziou <n.goaziou@gmail.com>
Date:   Thu Oct 3 22:57:02 2013 +0200

For forward compatibility you can skip the visibility check and use
‘(org-flag-drawer nil)’ unconditionally, I think.

-- 
Aaron Ecay

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: fold all drawers in a buffer?
  2013-11-01 18:34     ` Aaron Ecay
@ 2013-11-01 19:28       ` Thorsten Jolitz
  0 siblings, 0 replies; 5+ messages in thread
From: Thorsten Jolitz @ 2013-11-01 19:28 UTC (permalink / raw)
  To: emacs-orgmode

Aaron Ecay <aaronecay@gmail.com> writes:

Hi Aaron,

> 2013ko azaroak 1an, Thorsten Jolitz-ek idatzi zuen:
>> 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
>
> This will work on recent versions of org, but the :hiddenp properties
> were taken out of the parser by the following git commit (not yet in any
> released version of org AFAIK):
>
> commit fe27ca9906f1d6c48a93f463d85850925687b825
> Author: Nicolas Goaziou <n.goaziou@gmail.com>
> Date:   Thu Oct 3 22:57:02 2013 +0200
>
> For forward compatibility you can skip the visibility check and use
> ‘(org-flag-drawer nil)’ unconditionally, I think.

I see, thanks for the tip. I did not know about the fate of 'hiddenp' or
about the useful 'org-flag-XXX' functions.

-- 
cheers,
Thorsten

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-11-01 19:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-01 13:46 fold all drawers in a buffer? Matt Price
2013-11-01 15:52 ` Thorsten Jolitz
2013-11-01 16:43   ` Thorsten Jolitz
2013-11-01 18:34     ` Aaron Ecay
2013-11-01 19:28       ` Thorsten Jolitz

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.