Browse Source

Fix bug when cleaning visibility after subtree movement

Bernt Hansen writes:

> ,----[ test.org ]
> |
> | * Main task
> | ** DONE Task 1
> | ** DONE Task 2
> | ** TODO Task 4
> | ** TODO Task 3
> | ** TODO Task 5
> | * Next task
> `----
>
> Put the point on * Main Task
> C-x n s to narrow to subtree
> C-c C-v to show active TODOs
> Put point on TODO Task 4
> M-down arrow
> M-up arrow
>
> generates
>
> Debugger entered--Lisp error: (error "before first heading")
Carsten Dominik 15 years ago
parent
commit
f6b2591412
2 changed files with 8 additions and 1 deletions
  1. 5 0
      lisp/ChangeLog
  2. 3 1
      lisp/org.el

+ 5 - 0
lisp/ChangeLog

@@ -1,3 +1,8 @@
+2009-12-09  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* org.el (org-clean-visibility-after-subtree-move): Only fix
+	entries that are not entirely invisible already.
+
 2009-12-03  Carsten Dominik  <carsten.dominik@gmail.com>
 
 	* org-exp.el (org-export-format-source-code-or-example): Avoid

+ 3 - 1
lisp/org.el

@@ -5481,7 +5481,9 @@ This function is the default value of the hook `org-cycle-hook'."
 	  ;; Properly fold already folded siblings
 	  (goto-char (point-min))
 	  (while (re-search-forward re nil t)
-	    (if (save-excursion (goto-char (point-at-eol)) (org-invisible-p))
+	    (if (and (not (org-invisible-p))
+		     (save-excursion
+		       (goto-char (point-at-eol)) (org-invisible-p)))
 		(hide-entry))))
 	(org-cycle-show-empty-lines 'overview)
 	(org-cycle-hide-drawers 'overview)))))