Skip to content

Commit

Permalink
org-inlinetask: Fix infinite loop caused by 5f184b5
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
yantar92 committed Aug 20, 2022
1 parent 8eb3f93 commit a0b8b73
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions lisp/org-inlinetask.el
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,10 @@ If the task has an end part, also demote it."
(add-text-properties (match-beginning 3) (match-end 3)
'(face org-inlinetask font-lock-fontified t)))))

(defun org-inlinetask-toggle-visibility ()
"Toggle visibility of inline task at point."
(defun org-inlinetask-toggle-visibility (&optional state)
"Toggle visibility of inline task at point.
When optional argument STATE is `fold', fold unconditionally.
When STATE is `unfold', unfold unconditionally."
(let ((end (save-excursion
(org-inlinetask-goto-end)
(if (bolp) (1- (point)) (point))))
Expand All @@ -317,7 +319,9 @@ If the task has an end part, also demote it."
;; Nothing to show/hide.
((= end start))
;; Inlinetask was folded: expand it.
((org-fold-get-folding-spec 'headline (1+ start))
((and (not (eq state 'fold))
(or (eq state 'unfold)
(org-fold-get-folding-spec 'headline (1+ start))))
(org-fold-region start end nil 'headline))
(t (org-fold-region start end t 'headline)))))

Expand All @@ -330,16 +334,15 @@ This function is meant to be used in `org-cycle-hook'."
(save-excursion
(goto-char (point-min))
(while (re-search-forward regexp nil t)
(org-inlinetask-toggle-visibility)
(org-inlinetask-toggle-visibility 'fold)
(org-inlinetask-goto-end)))))
(`children
(save-excursion
(while
(or (org-inlinetask-at-task-p)
(and (outline-next-heading) (org-inlinetask-at-task-p)))
(org-inlinetask-toggle-visibility)
(org-inlinetask-goto-end)
(backward-char))))))
(org-inlinetask-toggle-visibility 'fold)
(org-inlinetask-goto-end))))))

(defun org-inlinetask-remove-END-maybe ()
"Remove an END line when present."
Expand Down

0 comments on commit a0b8b73

Please sign in to comment.