From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: [Bug?] Mark subtrees and inline tasks Date: Sat, 06 Nov 2010 11:15:10 +0100 Message-ID: <877hgqdahd.wl%n.goaziou@gmail.com> References: <80vd4vq445.fsf@mundaneum.com> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: multipart/mixed; boundary="Multipart_Sat_Nov__6_11:15:10_2010-1" Content-Transfer-Encoding: 8bit Return-path: Received: from [140.186.70.92] (port=45082 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PEfnk-0007pA-AQ for emacs-orgmode@gnu.org; Sat, 06 Nov 2010 06:15:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PEfnj-0005Hy-1H for emacs-orgmode@gnu.org; Sat, 06 Nov 2010 06:15:12 -0400 Received: from mail-wy0-f169.google.com ([74.125.82.169]:63213) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PEfni-0005Hs-Os for emacs-orgmode@gnu.org; Sat, 06 Nov 2010 06:15:10 -0400 Received: by wyf23 with SMTP id 23so4384628wyf.0 for ; Sat, 06 Nov 2010 03:15:09 -0700 (PDT) In-Reply-To: <80vd4vq445.fsf@mundaneum.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: =?UTF-8?B?U8OpYmFzdGllbg==?= Vauban Cc: emacs-orgmode@gnu.org --Multipart_Sat_Nov__6_11:15:10_2010-1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hello, >>>>> Sébastien Vauban writes: > To select this subtree, I use =C-c @=. > It does its job, except that it never selects the last line. OK; > just C-x C-x, add a line, and that's it. Feature? Bug? Feature. If you want to grab the last line too, use (org-end-of-subtree nil t) > Same problem, though more problematic IMHO, with the inline tasks. > *************** Check how the selection works > I'd expect the END line to be selected as well. It's not. > *************** END Here is a suggestion of patch creating a new function org-mark-subtree (and not using the outline one). Tell me if it works for you. Regards, -- Nicolas --Multipart_Sat_Nov__6_11:15:10_2010-1 Content-Type: text/plain; type=patch; charset=US-ASCII Content-Disposition: attachment; filename="0001-Handle-inline-tasks-when-marking-a-subtree.patch" Content-Transfer-Encoding: 7bit >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 --Multipart_Sat_Nov__6_11:15:10_2010-1 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode --Multipart_Sat_Nov__6_11:15:10_2010-1--