From 61993bc4bf86769ef37573c5b7db40feebb34d53 Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Mon, 31 Dec 2012 11:06:55 +0100 Subject: [PATCH] org.el (org-cycle-internal-local): Don't run hooks when cycling a plain list before first headline * org.el (org-cycle-internal-local): Don't run hooks when cycling a plain list before first headline. --- lisp/org.el | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 2139c5214..a780fa392 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -6285,7 +6285,8 @@ in special contexts. (cond ((= eos eoh) ;; Nothing is hidden behind this heading - (run-hook-with-args 'org-pre-cycle-hook 'empty) + (unless (org-before-first-heading-p) + (run-hook-with-args 'org-pre-cycle-hook 'empty)) (message "EMPTY ENTRY") (setq org-cycle-subtree-status nil) (save-excursion @@ -6298,7 +6299,8 @@ in special contexts. (not (setq children-skipped org-cycle-skip-children-state-if-no-children)))) ;; Entire subtree is hidden in one line: children view - (run-hook-with-args 'org-pre-cycle-hook 'children) + (unless (org-before-first-heading-p) + (run-hook-with-args 'org-pre-cycle-hook 'children)) (if (org-at-item-p) (org-list-set-item-visibility (point-at-bol) struct 'children) (org-show-entry) @@ -6326,24 +6328,28 @@ in special contexts. (outline-next-heading) (if (outline-invisible-p) (org-flag-heading nil))) (setq org-cycle-subtree-status 'children) - (run-hook-with-args 'org-cycle-hook 'children)) + (unless (org-before-first-heading-p) + (run-hook-with-args 'org-cycle-hook 'children))) ((or children-skipped (and (eq last-command this-command) (eq org-cycle-subtree-status 'children))) ;; We just showed the children, or no children are there, ;; now show everything. - (run-hook-with-args 'org-pre-cycle-hook 'subtree) + (unless (org-before-first-heading-p) + (run-hook-with-args 'org-pre-cycle-hook 'subtree)) (outline-flag-region eoh eos nil) (message (if children-skipped "SUBTREE (NO CHILDREN)" "SUBTREE")) (setq org-cycle-subtree-status 'subtree) - (run-hook-with-args 'org-cycle-hook 'subtree)) + (unless (org-before-first-heading-p) + (run-hook-with-args 'org-cycle-hook 'subtree))) (t ;; Default action: hide the subtree. (run-hook-with-args 'org-pre-cycle-hook 'folded) (outline-flag-region eoh eos t) (message "FOLDED") (setq org-cycle-subtree-status 'folded) - (run-hook-with-args 'org-cycle-hook 'folded))))) + (unless (org-before-first-heading-p) + (run-hook-with-args 'org-cycle-hook 'folded)))))) ;;;###autoload (defun org-global-cycle (&optional arg) -- 2.11.4.GIT