emacs-orgmode
[Top][All Lists]
Advanced

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

Re: Visibility cycling with inline tasks 2


From: Ihor Radchenko
Subject: Re: Visibility cycling with inline tasks 2
Date: Fri, 01 Oct 2021 14:17:28 +0800

No Wayman <iarchivedmywholelife@gmail.com> writes:

> I can confirm the issue you've outlined on latest 'main'.
> To me it looks like the problem is in `org-inline-hide-tasks'.
> I don't use inline tasks, so I'm not sure what the exact expected 
> behavior is,
> but that function uses a `while' during `org-cycle-hook' to 
> iterate through all of the headings.
> My intuition is that it's overshooting a boundary and toggling 
> visibility on more than it should.
>
> Does the attached patch behave more in line with what you expect? 

Your patch will fail with the following counterexample (when there is a
subheading containing an inlinetask inside current heading):

* Example
** heading 1
xxxxx
** heading 2
*************** TODO Test access with provided credentials
xxxxx
*************** END
*** subheading
*************** TODO State "high value" targets
:@CB:
xxxxx
*************** END
** heading 3
xxxxx

The recepy is same with original:

1. emacs -Q
2. paste the following snipped (right into the scratch buffer)
3. execute the two commands at the end C-x C-e for each
4. collapse all (TAB TAB)
5. expand Example (TAB)
5. go to heading 2 and expand it (TAB)

I propose an alternative patch. See the attached.

Best,
Ihor

>From ec78cbc00b4e2abf201149b76ce41df87869627f Mon Sep 17 00:00:00 2001
Message-Id: 
<ec78cbc00b4e2abf201149b76ce41df87869627f.1633068903.git.yantar92@gmail.com>
From: Ihor Radchenko <yantar92@gmail.com>
Date: Fri, 1 Oct 2021 14:03:47 +0800
Subject: [PATCH] org-inlinetask.el: Fix visibility cycling for inlinetasks

* lisp/org-inlinetask.el (org-inlinetask-hide-tasks): Make sure that
we loop over inlinetasks inside current section only.
`org-inlinetask-goto-end' moves point to the end of the inlinetask
element.  If an inlinetask is followed by a heading, the function
logic will treat the heading as the beginning of another inline task.
Prevent it by moving the point at the end of the END line of the
inlinetask.

Fixes
https://list.orgmode.org/orgmode/CAP7OBx+rs-7v4jstEFYC4u0=0NZ3xJKfb3CNrWeDvjmwRTvgxw@mail.gmail.com/
---
 lisp/org-inlinetask.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lisp/org-inlinetask.el b/lisp/org-inlinetask.el
index 3379a2e46..6320be12b 100644
--- a/lisp/org-inlinetask.el
+++ b/lisp/org-inlinetask.el
@@ -338,7 +338,8 @@ (defun org-inlinetask-hide-tasks (state)
           (or (org-inlinetask-at-task-p)
               (and (outline-next-heading) (org-inlinetask-at-task-p)))
         (org-inlinetask-toggle-visibility)
-        (org-inlinetask-goto-end))))))
+        (org-inlinetask-goto-end)
+         (backward-char))))))
 
 (defun org-inlinetask-remove-END-maybe ()
   "Remove an END line when present."
-- 
2.32.0


reply via email to

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