emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nicolas Goaziou <n.goaziou@gmail.com>
To: "Sébastien Vauban" <wxhgmqzgwmuf@spammotel.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: [Bug?] Mark subtrees and inline tasks
Date: Sat, 06 Nov 2010 11:15:10 +0100	[thread overview]
Message-ID: <877hgqdahd.wl%n.goaziou@gmail.com> (raw)
In-Reply-To: <80vd4vq445.fsf@mundaneum.com>

[-- Attachment #1: Type: text/plain, Size: 648 bytes --]

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


[-- Attachment #2: 0001-Handle-inline-tasks-when-marking-a-subtree.patch --]
[-- Type: text/plain, Size: 3924 bytes --]

From b2267d2e4ef40a0d0d6e8c9a789e835b5cde6036 Mon Sep 17 00:00:00 2001
From: Nicolas Goaziou <n.goaziou@gmail.com>
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


[-- Attachment #3: Type: text/plain, Size: 201 bytes --]

_______________________________________________
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

  reply	other threads:[~2010-11-06 10:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-21  9:36 [Bug?] Mark subtrees and inline tasks Sébastien Vauban
2010-11-06 10:15 ` Nicolas Goaziou [this message]
2010-11-06 10:28   ` Nicolas Goaziou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=877hgqdahd.wl%n.goaziou@gmail.com \
    --to=n.goaziou@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=wxhgmqzgwmuf@spammotel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).