浏览代码

Fix bug when marking subtree with point on an inlinetask

* lisp/org.el (org-mark-subtree): Fix bug when marking subtree with
  point on an inlinetask.  Refactor code.
* testing/lisp/test-org.el: Add test.
Nicolas Goaziou 12 年之前
父节点
当前提交
694a858506
共有 2 个文件被更改,包括 18 次插入9 次删除
  1. 5 5
      lisp/org.el
  2. 13 4
      testing/lisp/test-org.el

+ 5 - 5
lisp/org.el

@@ -20682,11 +20682,11 @@ This puts point at the start of the current subtree, and mark at
 the end.  If a numeric prefix UP is given, move up into the
 hierarchy of headlines by UP levels before marking the subtree."
   (interactive "P")
-  (when (org-with-limited-levels (org-before-first-heading-p))
-    (error "Not currently in a subtree"))
-  (if (org-at-heading-p) (beginning-of-line)
-    (org-with-limited-levels (outline-previous-visible-heading 1)))
-  (when up (dotimes (c (abs up)) (ignore-errors (org-element-up))))
+  (org-with-limited-levels
+   (cond ((org-at-heading-p) (beginning-of-line))
+	 ((org-before-first-heading-p) (error "Not in a subtree"))
+	 (t (outline-previous-visible-heading 1))))
+  (when up (while (and (> up 0) (org-up-heading-safe)) (decf up)))
   (org-element-mark-element))
 
 ;;; Indentation

+ 13 - 4
testing/lisp/test-org.el

@@ -363,9 +363,18 @@ http://article.gmane.org/gmane.emacs.orgmode/21459/"
       (progn (transient-mark-mode 1)
 	     (forward-line 2)
 	     (org-mark-subtree 1)
-	     (list (region-beginning) (region-end)))))))
-
-
-(provide 'test-org)
+	     (list (region-beginning) (region-end))))))
+  ;; Do not get fooled with inlinetasks.
+  (when (featurep 'org-inlinetask)
+    (should
+     (= 1
+	(org-test-with-temp-text "* Headline\n*************** Task\nContents"
+	  (progn (transient-mark-mode 1)
+		 (forward-line 1)
+		 (let ((org-inlinetask-min-level 15)) (org-mark-subtree))
+		 (region-beginning))))))
+
+
+  (provide 'test-org))
 
 ;;; test-org.el ends here