From mboxrd@z Thu Jan 1 00:00:00 1970 From: Noah Slater Subject: Re: Sorting nodes by clocked time Date: Thu, 17 Apr 2014 14:20:57 +0200 Message-ID: References: <87zjjk5p9q.fsf@bzg.ath.cx> <87ioq82pk9.fsf@bzg.ath.cx> <87a9bk2pbc.fsf@bzg.ath.cx> <87lhv442xy.fsf@bzg.ath.cx> <87mwfkb26u.fsf@bzg.ath.cx> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=20cf303f6a44bd22c704f73c1029 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:52050) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WalJg-0004mp-Ak for emacs-orgmode@gnu.org; Thu, 17 Apr 2014 08:21:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WalJK-0000LL-Kh for emacs-orgmode@gnu.org; Thu, 17 Apr 2014 08:21:20 -0400 Received: from mail-yh0-x234.google.com ([2607:f8b0:4002:c01::234]:52711) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WalJK-0000Kq-DE for emacs-orgmode@gnu.org; Thu, 17 Apr 2014 08:20:58 -0400 Received: by mail-yh0-f52.google.com with SMTP id c41so256215yho.39 for ; Thu, 17 Apr 2014 05:20:57 -0700 (PDT) In-Reply-To: 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: Bastien Cc: emacs-orgmode@gnu.org --20cf303f6a44bd22c704f73c1029 Content-Type: text/plain; charset=ISO-8859-1 Actually. What I want, I think, is a function that sorts the whole buffer and then collapses all nodes. I think your my-hide-all-drawers-in-current-subtree thing will take care of collapsing all nodes. But I'm now on StackOverflow trying to work out how to sort the whole buffer. On 17 April 2014 14:02, Noah Slater wrote: > Okay, wow. Thanks for writing that. Do you have a Gittip or something? I > would love to support your OSS work in some way or otherwise show my > gratitude beyond words in an email! > > Anyway. I tried your function and it works. But afterwards, the node is > completely folded. So I added (org-cycle) to the sequence of functions > inside save-restriction. That seems to work, but I'm no elisp/Org pro. Is > this how you would have done it? > > > On 17 April 2014 13:55, Bastien wrote: > >> Noah Slater writes: >> >> > Okay, that seem to work. >> > >> > But I'm not able to get this work: >> > >> > (add-hook 'org-after-sorting-entries-or-items-hook >> > (lambda() (org-cycle-hide-drawers 'children))) >> > >> > After running the sort, all the LOGBOOK draws are still open. >> >> Try this: >> >> (defun my-hide-all-drawers-in-current-subtree () >> "Hide all drawers in the current subtree." >> (save-restriction >> (org-narrow-to-subtree) >> (org-cycle-hide-drawers 'all) >> (org-cycle-internal-local))) >> >> (add-hook 'org-after-sorting-entries-or-items-hook >> 'my-hide-all-drawers-in-current-subtree) >> >> > I'm also thinking: even if this closes the logbook draws, all the >> > nodes will be unfolded. But my node tree is quite large. Is it be >> > possible to refold all the nodes after n-levels? >> > >> > So let's say I have: >> > >> > * Level 1 >> > ** Level 2 >> > *** Level 3 >> > >> > If I move the point to Level 1 and sort, I'd like it fold all Level 2 >> > items, but leave Level 1 unfolded. >> >> You can fix the cycling through the hook above. >> >> HTH, >> >> -- >> Bastien >> > > --20cf303f6a44bd22c704f73c1029 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Actually. What I want, I think, is a function that sorts t= he whole buffer and then collapses all nodes.

I think yo= ur=A0my-hide-all-drawers-in-current-subtree thing will take care of collaps= ing all nodes. But I'm now on StackOverflow trying to work out how to s= ort the whole buffer.


On 17 A= pril 2014 14:02, Noah Slater <nslater@tumbolia.org> wrote= :
Okay, wow. Thanks for writing that. Do you have a Gittip o= r something? I would love to support your OSS work in some way or otherwise= show my gratitude beyond words in an email!

Anyway. I t= ried your function and it works. But afterwards, the node is completely fol= ded. So I added (org-cycle) to the sequence of functions inside=A0save-rest= riction. That seems to work, but I'm no elisp/Org pro. Is this how you = would have done it?

On 17 April 2014 13:55, Bastien <bzg@gnu.org> wrote:
Noah Slater <nslater@tumbolia.org> writes:

> Okay, that seem to work.
>
> But I'm not able to get this work:
>
> (add-hook 'org-after-sorting-entries-or-items-hook
> =A0 =A0 =A0 =A0 =A0 (lambda() (org-cycle-hide-drawers 'children)))=
>
> After running the sort, all the LOGBOOK draws are still open.

Try this:

(defun my-hide-all-drawers-in-current-subtree ()
=A0 "Hide all drawers in the current subtree."
=A0 (save-restriction
=A0 =A0 (org-narrow-to-subtree)
=A0 =A0 (org-cycle-hide-drawers 'all)
=A0 =A0 (org-cycle-internal-local)))

(add-hook 'org-after-sorting-entries-or-items-hook
=A0 =A0 =A0 =A0 =A0 'my-hide-all-drawers-in-current-subtree)

> I'm also thinking: even if this closes the logbook draws, all the<= br> > nodes will be unfolded. But my node tree is quite large. Is it be
> possible to refold all the nodes after n-levels?
>
> So let's say I have:
>
> * Level 1
> ** Level 2
> *** Level 3
>
> If I move the point to Level 1 and sort, I'd like it fold all Leve= l 2
> items, but leave Level 1 unfolded.

You can fix the cycling through the hook above.

HTH,

--
=A0Bastien


--20cf303f6a44bd22c704f73c1029--