Skip to content

Commit a0b8b73

Browse files
committed
org-inlinetask: Fix infinite loop caused by 5f184b5
* lisp/org-inlinetask.el (org-inlinetask-toggle-visibility): Accept optional argument forcing folding/unfolding. (org-inlinetask-hide-tasks): Do not use `backward-char' since it can cause infinite loop. Force folding instead. Fixes https://orgmode.org/list/CAKJdtO8+bh4G-Mzhp7k1x9SGfjo9PxdmncdHcUJKCk6PbK9d=g@mail.gmail.com
1 parent 8eb3f93 commit a0b8b73

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

lisp/org-inlinetask.el

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)