>From b2267d2e4ef40a0d0d6e8c9a789e835b5cde6036 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Sat, 6 Nov 2010 10:10:22 +0100 Subject: [PATCH] Handle inline tasks when marking a subtree * org-inlinetask.el (org-inlinetask-goto-beginning): new function * org-inlinetask.el (org-inlinetask-goto-end): new function * org.el (org-mark-subtree): new command * org.el (org-speed-commands-default, org-mode-map): make use of new command --- lisp/org-inlinetask.el | 24 ++++++++++++++++++++++++ lisp/org.el | 25 ++++++++++++++++++++++++- 2 files changed, 48 insertions(+), 1 deletions(-) diff --git a/lisp/org-inlinetask.el b/lisp/org-inlinetask.el index c000999..fc0d932 100644 --- a/lisp/org-inlinetask.el +++ b/lisp/org-inlinetask.el @@ -147,6 +147,30 @@ If prefix arg NO-STATE is set, ignore `org-inlinetask-default-state'." (and (re-search-forward "^\\*+[ \t]+" nil t) (progn (beginning-of-line) (looking-at task-end-re))))))) +(defun org-inlinetask-goto-beginning () + "Go to the beginning of the inline task at point." + (end-of-line) + (re-search-backward (format "^\\*\\{%d,\\}" org-inlinetask-min-level) nil t) + (when (org-looking-at-p (format "^\\*\\{%d,\\} END" org-inlinetask-min-level)) + (re-search-backward + (format "^\\*\\{%d,\\}" org-inlinetask-min-level) nil t))) + +(defun org-inlinetask-goto-end () + "Go to the end of the inline task at point." + (cond + ((org-looking-at-p (format "^\\*\\{%d,\\} END" org-inlinetask-min-level)) + (forward-line 1)) + ((org-looking-at-p (format "^\\*\\{%d,\\} " org-inlinetask-min-level)) + (forward-line 1) + (when (org-inlinetask-in-task-p) + (re-search-forward + (format "^\\*\\{%d,\\} END" org-inlinetask-min-level) nil t) + (forward-line 1))) + (t + (re-search-forward + (format "^\\*\\{%d,\\} END" org-inlinetask-min-level) nil t) + (forward-line 1)))) + (defvar htmlp) ; dynamically scoped into the next function (defvar latexp) ; dynamically scoped into the next function (defun org-inlinetask-export-handler () diff --git a/lisp/org.el b/lisp/org.el index 201dd87..905fabc 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -16433,6 +16433,7 @@ BEG and END default to the buffer boundaries." (org-defkey org-mode-map "\C-c\C-xf" 'org-footnote-action) (org-defkey org-mode-map "\C-c\C-x\C-mg" 'org-mobile-pull) (org-defkey org-mode-map "\C-c\C-x\C-mp" 'org-mobile-push) +(org-defkey org-mode-map "\C-c@" 'org-mark-subtree) (org-defkey org-mode-map [?\C-c (control ?*)] 'org-list-make-subtree) ;;(org-defkey org-mode-map [?\C-c (control ?-)] 'org-list-make-list-from-subtree) @@ -16506,7 +16507,7 @@ BEG and END default to the buffer boundaries." ("^" . org-sort) ("w" . org-refile) ("a" . org-archive-subtree-default-with-confirmation) - ("." . outline-mark-subtree) + ("." . org-mark-subtree) ("Clock Commands") ("I" . org-clock-in) ("O" . org-clock-out) @@ -18653,6 +18654,28 @@ which make use of the date at the cursor." (message "Entry marked for action; press `k' at desired date in agenda or calendar")) +(defun org-mark-subtree () + "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." + (interactive) + (let ((inline-task-p + (and (featurep 'org-inlinetask) + (org-inlinetask-in-task-p))) + (beg)) + (cond + (inline-task-p (org-inlinetask-goto-beginning)) + ((org-at-heading-p) (beginning-of-line)) + ;; else go back to previous heading + (t (outline-previous-visible-heading 1))) + (setq beg (point)) + (if inline-task-p + (org-inlinetask-goto-end) + (org-end-of-subtree)) + (push-mark (point) nil t) + (goto-char beg))) + ;;; Paragraph filling stuff. ;; We want this to be just right, so use the full arsenal. -- 1.7.3.2