diff options
author | Nicolas Goaziou <n.goaziou@gmail.com> | 2012-08-08 11:43:39 +0200 |
---|---|---|
committer | Nicolas Goaziou <n.goaziou@gmail.com> | 2012-08-08 11:50:09 +0200 |
commit | 694a8585068cb3b84867f49b4c6d552518621ea6 (patch) | |
tree | faa0c6d89c69c29bd7ef63e25ee94d6dd23f28c0 | |
parent | 06c8457f0c4d8d603395fc8d71330c0de57677d6 (diff) | |
download | org-mode-694a8585068cb3b84867f49b4c6d552518621ea6.tar.gz |
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.
-rw-r--r-- | lisp/org.el | 10 | ||||
-rw-r--r-- | testing/lisp/test-org.el | 17 |
2 files changed, 18 insertions, 9 deletions
diff --git a/lisp/org.el b/lisp/org.el index e42f6c4..94b3fee 100644 --- a/lisp/org.el +++ b/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 diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el index 38e4a70..3d37e4e 100644 --- a/testing/lisp/test-org.el +++ b/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 |