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.
This commit is contained in:
Nicolas Goaziou 2012-08-08 11:43:39 +02:00
parent 06c8457f0c
commit 694a858506
2 changed files with 16 additions and 7 deletions

View File

@ -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

View File

@ -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)))))))
(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)
(provide 'test-org))
;;; test-org.el ends here