diff options
author | Nicolas Goaziou <n.goaziou@gmail.com> | 2012-08-07 13:30:09 +0200 |
---|---|---|
committer | Nicolas Goaziou <n.goaziou@gmail.com> | 2012-08-07 13:38:32 +0200 |
commit | d70f965486fc890af199d3dd8c9ed9a8fb88f16b (patch) | |
tree | ca65bb6491825c7a0c4d058e059eeb611745ffc8 | |
parent | 7bc9b2242e318afacd6450682e100f0144073977 (diff) | |
download | org-mode-d70f965486fc890af199d3dd8c9ed9a8fb88f16b.tar.gz |
Do not make a special case for inlinetasks when marking a subtree
* lisp/org.el (org-mark-subtree): Do not make a special case for
inlinetasks when marking a subtree. These are handled by
`org-element-mark-element'.
* testing/lisp/test-org.el: Add test.
-rw-r--r-- | lisp/org.el | 30 | ||||
-rw-r--r-- | testing/lisp/test-org.el | 30 |
2 files changed, 38 insertions, 22 deletions
diff --git a/lisp/org.el b/lisp/org.el index e948d8f..3c25c46 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -20679,29 +20679,15 @@ which make use of the date at the cursor." (defun org-mark-subtree (&optional up) "Mark the current subtree. This puts point at the start of the current subtree, and mark at -the end. If point is in an inline task, mark that task instead. -If a numeric prefix UP is given, move up into the hierarchy of -headlines by UP levels before marking the subtree." +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") - (let ((inline-task-p - (and (featurep 'org-inlinetask) - (org-inlinetask-in-task-p))) - (beg)) - ;; Get beginning of subtree - (cond - (inline-task-p (org-inlinetask-goto-beginning)) - ((org-at-heading-p) (beginning-of-line)) - (t (org-with-limited-levels (outline-previous-visible-heading 1)))) - ;; Move up - (when up (dotimes (c (abs up)) (ignore-errors (org-element-up)))) - (setq beg (point)) - ;; Get end of it - (if inline-task-p - (org-inlinetask-goto-end) - (org-end-of-subtree)) - ;; Mark zone - (push-mark (point) nil t) - (goto-char beg))) + (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-element-mark-element)) ;;; Indentation diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el index 489da24..cb48524 100644 --- a/testing/lisp/test-org.el +++ b/testing/lisp/test-org.el @@ -327,6 +327,36 @@ http://article.gmane.org/gmane.emacs.orgmode/21459/" (buffer-string)))))) + +;;; Mark region + +(ert-deftest test-org/mark-subtree () + "Test `org-mark-subtree' specifications." + ;; Error when point is before first headline. + (should-error + (org-test-with-temp-text "Paragraph\n* Headline\nBody" + (progn (transient-mark-mode 1) + (org-mark-subtree)))) + ;; Without argument, mark current subtree. + (should + (equal + '(12 32) + (org-test-with-temp-text "* Headline\n** Sub-headline\nBody" + (progn (transient-mark-mode 1) + (forward-line 2) + (org-mark-subtree) + (list (region-beginning) (region-end)))))) + ;; With an argument, move ARG up. + (should + (equal + '(1 32) + (org-test-with-temp-text "* Headline\n** Sub-headline\nBody" + (progn (transient-mark-mode 1) + (forward-line 2) + (org-mark-subtree 1) + (list (region-beginning) (region-end))))))) + + (provide 'test-org) ;;; test-org.el ends here |