@@ -305,8 +305,10 @@ If the task has an end part, also demote it."
305305 (add-text-properties (match-beginning 3 ) (match-end 3 )
306306 '(face org-inlinetask font-lock-fontified t )))))
307307
308- (defun org-inlinetask-toggle-visibility ()
309- " Toggle visibility of inline task at point."
308+ (defun org-inlinetask-toggle-visibility (&optional state )
309+ " Toggle visibility of inline task at point.
310+ When optional argument STATE is `fold' , fold unconditionally.
311+ When STATE is `unfold' , unfold unconditionally."
310312 (let ((end (save-excursion
311313 (org-inlinetask-goto-end)
312314 (if (bolp ) (1- (point )) (point ))))
@@ -317,7 +319,9 @@ If the task has an end part, also demote it."
317319 ; ; Nothing to show/hide.
318320 ((= end start))
319321 ; ; Inlinetask was folded: expand it.
320- ((org-fold-get-folding-spec 'headline (1+ start))
322+ ((and (not (eq state 'fold ))
323+ (or (eq state 'unfold )
324+ (org-fold-get-folding-spec 'headline (1+ start))))
321325 (org-fold-region start end nil 'headline ))
322326 (t (org-fold-region start end t 'headline )))))
323327
@@ -330,16 +334,15 @@ This function is meant to be used in `org-cycle-hook'."
330334 (save-excursion
331335 (goto-char (point-min ))
332336 (while (re-search-forward regexp nil t )
333- (org-inlinetask-toggle-visibility)
337+ (org-inlinetask-toggle-visibility 'fold )
334338 (org-inlinetask-goto-end)))))
335339 (`children
336340 (save-excursion
337341 (while
338342 (or (org-inlinetask-at-task-p)
339343 (and (outline-next-heading ) (org-inlinetask-at-task-p)))
340- (org-inlinetask-toggle-visibility)
341- (org-inlinetask-goto-end)
342- (backward-char ))))))
344+ (org-inlinetask-toggle-visibility 'fold )
345+ (org-inlinetask-goto-end))))))
343346
344347(defun org-inlinetask-remove-END-maybe ()
345348 " Remove an END line when present."
0 commit comments