[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] [PATCH] hide inline-tasks in 'children visibility state

From: Jonas Hörsch
Subject: Re: [O] [PATCH] hide inline-tasks in 'children visibility state
Date: Mon, 04 Nov 2013 09:52:53 +0100
User-agent: Notmuch/0.15.2 (http://notmuchmail.org) Emacs/24.3.1 (x86_64-unknown-linux-gnu)


On Thu, Oct 31 2013, Nicolas Goaziou wrote:

> address@hidden (Jonas Hörsch) writes:
>> +  (cond ((eq state 'contents)
> I suggest to use `case' here, but it's really a matter of style.

fine with me. i wasn't sure about the usage convention for cl. i
switched to the namespaced cl-case variant, for now.

>> +       (hide-sublevels (1- org-inlinetask-min-level))))
>> +         (while (and (outline-next-heading)
>> +                     (org-inlinetask-at-task-p))
> I think it is more efficient to directly look for inlinetasks since you
> can use `org-inlinetask-outline-regexp'.

hmm ... i'm not so sure. as you can see in the attached patch, now i
have to perform an extra search on each headline to find the boundary
for the inline task search. it feels to me like this would be faster for
a situation with more than one inline task per headline in the mean?
(which i don't think is the likely situation).

well, what do you think?

From 763f4d8c8daa0c09809a677c8cd8358476336f24 Mon Sep 17 00:00:00 2001
From: Jonas Hoersch <address@hidden>
Date: Wed, 30 Oct 2013 15:39:33 +0100
Subject: [PATCH] org-inlinetask: Hide inline tasks in 'children visibility

* lisp/org.el (org-cycle-hide-inline-tasks): Re-hide inline tasks when
  switching to 'children visibility state.

 lisp/org.el | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index 4f3bf4b..c94e2ee 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -7074,11 +7074,23 @@ open and agenda-wise Org files."
          (org-flag-drawer t))))))
 (defun org-cycle-hide-inline-tasks (state)
-  "Re-hide inline task when switching to 'contents visibility state."
-  (when (and (eq state 'contents)
-            (boundp 'org-inlinetask-min-level)
-            org-inlinetask-min-level)
-    (hide-sublevels (1- org-inlinetask-min-level))))
+  "Re-hide inline tasks when switching to 'contents or 'children
+visibility state."
+  (cl-case state
+    (contents
+     (when (org-bound-and-true-p org-inlinetask-min-level)
+       (hide-sublevels (1- org-inlinetask-min-level))))
+    (children
+     (when (featurep 'org-inlinetask)
+       (let ((end (save-excursion
+                   (if (re-search-forward
+                        (concat "[\r\n]\\(" org-outline-regexp "\\)") nil t)
+                       (match-beginning 1)
+                     (point-max)))))
+        (save-excursion
+          (while (re-search-forward (org-inlinetask-outline-regexp) end t)
+            (org-inlinetask-toggle-visibility)
+            (org-inlinetask-goto-end))))))))
 (defun org-flag-drawer (flag)
   "When FLAG is non-nil, hide the drawer we are within.

p.s.: for some weird reason, i was convinced i submitted this mail a
few days ago ... but my mail program says otherwise.

Attachment: pgpJg82OlbZ3q.pgp
Description: PGP signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]