Преглед изворни кода

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 пре 13 година
родитељ
комит
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
 the end.  If a numeric prefix UP is given, move up into the
 hierarchy of headlines by UP levels before marking the subtree."
 hierarchy of headlines by UP levels before marking the subtree."
   (interactive "P")
   (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))
   (org-element-mark-element))
 
 
 ;;; Indentation
 ;;; 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)
       (progn (transient-mark-mode 1)
 	     (forward-line 2)
 	     (forward-line 2)
 	     (org-mark-subtree 1)
 	     (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
 ;;; test-org.el ends here