From 03e81f0d240271d072fd155d41e59b6b353abaa9 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Thu, 2 Apr 2015 00:06:49 +0200 Subject: [PATCH] Fix cycling ARCHIVE trees with inline tasks loaded * lisp/org-inlinetask.el (org-inlinetask-hide-tasks): New function. * lisp/org.el (org-cycle-hide-inline-tasks): Remove function. (org-cycle-hook): Apply removal. Reported-by: "Francesco Pizzolante" --- lisp/org-inlinetask.el | 21 +++++++++++++++++++-- lisp/org.el | 16 ---------------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/lisp/org-inlinetask.el b/lisp/org-inlinetask.el index 9e0aadb31..887f75ea6 100644 --- a/lisp/org-inlinetask.el +++ b/lisp/org-inlinetask.el @@ -319,14 +319,31 @@ If the task has an end part, also demote it." (org-cycle-hide-drawers 'children)) (t (outline-flag-region start end t))))) +(defun org-inlinetask-hide-tasks (state) + "Hide inline tasks in buffer when STATE is `contents' or `children'. +This function is meant to be used in `org-cycle-hook'." + (case state + (contents + (let ((regexp (org-inlinetask-outline-regexp))) + (save-excursion + (goto-char (point-min)) + (while (re-search-forward regexp nil t) + (org-inlinetask-toggle-visibility) + (org-inlinetask-goto-end))))) + (children + (save-excursion + (while (and (outline-next-heading) (org-inlinetask-at-task-p)) + (org-inlinetask-toggle-visibility) + (org-inlinetask-goto-end)))))) + (defun org-inlinetask-remove-END-maybe () "Remove an END line when present." (when (looking-at (format "\\([ \t]*\n\\)*\\*\\{%d,\\}[ \t]+END[ \t]*$" org-inlinetask-min-level)) (replace-match ""))) -(eval-after-load "org" - '(add-hook 'org-font-lock-hook 'org-inlinetask-fontify)) +(add-hook 'org-font-lock-hook 'org-inlinetask-fontify) +(add-hook 'org-cycle-hook 'org-inlinetask-hide-tasks) (provide 'org-inlinetask) diff --git a/lisp/org.el b/lisp/org.el index 6bb0ddf05..d3f7d85ae 100755 --- a/lisp/org.el +++ b/lisp/org.el @@ -1420,7 +1420,6 @@ the values `folded', `children', or `subtree'." (defcustom org-cycle-hook '(org-cycle-hide-archived-subtrees org-cycle-hide-drawers - org-cycle-hide-inline-tasks org-cycle-show-empty-lines org-optimize-window-after-visibility-change) "Hook that is run after `org-cycle' has changed the buffer visibility. @@ -7217,21 +7216,6 @@ specifying which drawers should not be hidden." ;; `org-drawer-regexp'. (goto-char (org-element-property :end drawer)))))))))) -(defun org-cycle-hide-inline-tasks (state) - "Re-hide inline tasks when switching to 'contents or 'children -visibility state." - (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) - (save-excursion - (while (and (outline-next-heading) - (org-inlinetask-at-task-p)) - (org-inlinetask-toggle-visibility) - (org-inlinetask-goto-end))))))) - (defun org-flag-drawer (flag &optional element) "When FLAG is non-nil, hide the drawer we are at. Otherwise make it visible. When optional argument ELEMENT is -- 2.11.4.GIT