From mboxrd@z Thu Jan 1 00:00:00 1970 From: James TD Smith Subject: [PATCH 7/9] Add some new interaction between remember and clocked tasks Date: Sat, 20 Sep 2008 22:09:16 +0100 Message-ID: <20080920210916.19759.93188.stgit@nyarlathotep.internal.mohorovi.cc> References: <20080920210101.19759.15959.stgit@nyarlathotep.internal.mohorovi.cc> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Kh9hg-0004FA-Is for emacs-orgmode@gnu.org; Sat, 20 Sep 2008 17:09:20 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Kh9hf-0004En-VX for emacs-orgmode@gnu.org; Sat, 20 Sep 2008 17:09:20 -0400 Received: from [199.232.76.173] (port=60170 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Kh9hf-0004Ei-Lx for emacs-orgmode@gnu.org; Sat, 20 Sep 2008 17:09:19 -0400 Received: from 81-86-40-42.dsl.pipex.com ([81.86.40.42]:63558 helo=yog-sothoth.mohorovi.cc) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Kh9hf-0002Ar-1D for emacs-orgmode@gnu.org; Sat, 20 Sep 2008 17:09:19 -0400 Received: from nyarlathotep.internal.mohorovi.cc (Debian-exim@nyarlathotep.internal.mohorovi.cc [10.0.0.5]) by yog-sothoth.mohorovi.cc (8.14.2/8.14.2) with ESMTP id m8KL9Hkb017676 for ; Sat, 20 Sep 2008 22:09:17 +0100 (BST) (envelope-from ahktenzero@mohorovi.cc) Received: from [127.0.0.1] (helo=nyarlathotep.internal.mohorovi.cc ident=ahktenzero) by nyarlathotep.internal.mohorovi.cc with esmtp (Exim 4.69) (envelope-from ) id 1Kh9hd-0005qz-08 for emacs-orgmode@gnu.org; Sat, 20 Sep 2008 22:09:17 +0100 In-Reply-To: <20080920210101.19759.15959.stgit@nyarlathotep.internal.mohorovi.cc> 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: emacs-orgmode@gnu.org Add %< expansion. This tells org-remember to add the item to the currently clocked task. Often while I'm working on something I find other related things which need to be done and this makes it possible to use a remember template to add a TODO item in the right place. Add %l expansion for the current clock string. Add %L expansion for a link to the currently clocked task. --- lisp/ChangeLog | 5 +++++ lisp/org-remember.el | 38 ++++++++++++++++++++++++++++++++++---- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 1753881..0b40a6e 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,10 @@ 2008-09-20 James TD Smith + * org-remember.el (org-remember-apply-template): Add new + expansions: %k, %K for currently clocked task and a link to the + currently clocked task, and %< to file notes in the currently + clocked task. + * org.el (org-get-refile-targets): Replace links with their descriptions (org-imenu-get-tree): Replace links with their descriptions diff --git a/lisp/org-remember.el b/lisp/org-remember.el index c1828e6..5a2c69b 100644 --- a/lisp/org-remember.el +++ b/lisp/org-remember.el @@ -135,11 +135,15 @@ Furthermore, the following %-escapes will be replaced with content: %^L Like %^C, but insert as link %^g prompt for tags, with completion on tags in target file %^G prompt for tags, with completion all tags in all agenda files + %k currently clocked task + %K link to currently clocked task + %:keyword specific information for certain link types, see below %[pathname] insert the contents of the file given by `pathname' %(sexp) evaluate elisp `(sexp)' and replace with the result %! Store this note immediately after filling the template %& Visit note immediately after storing it + %< file note under currently clocked task %? After completing the template, position cursor here. @@ -354,6 +358,13 @@ to be run from that hook to function properly." (replace-match "[\\1[%^{Link description}]]" nil nil v-a) v-a)) (v-n user-full-name) + (v-k (if (marker-buffer org-clock-marker) + (substring-no-properties org-clock-heading))) + (v-K (if (marker-buffer org-clock-marker) + (org-make-link-string + (buffer-file-name (marker-buffer org-clock-marker)) + org-clock-heading))) + v-I (org-startup-folded nil) (org-inhibit-startup t) org-time-was-given org-end-time-was-given x @@ -363,6 +374,21 @@ to be run from that hook to function properly." (setq file (funcall file))) (when (and file (not (file-name-absolute-p file))) (setq file (expand-file-name file org-directory))) + + ;;handle the %^K file to clocked task indicator + (if (and v-k (string-match "%<" tpl)) + (setq file (buffer-file-name (marker-buffer org-clock-marker)) + headline (with-current-buffer + (get-buffer (marker-buffer org-clock-marker)) + (goto-char (marker-position org-clock-marker)) + (org-back-to-heading t) + (if (looking-at org-complex-heading-regexp) + (concat (match-string 2) + (if (match-string 2) " ") + (match-string 3) + (if (match-string 3) " ") + (match-string 4)))))) + (setq org-store-link-plist (append (list :annotation v-a :initial v-i) org-store-link-plist)) @@ -382,9 +408,14 @@ to be run from that hook to function properly." (or headline "") (or (car org-remember-previous-location) "???") (or (cdr org-remember-previous-location) "???")))) - (insert tpl) (goto-char (point-min)) + (insert tpl) + (goto-char (point-min)) + ;;Get rid of %< if present + (while (re-search-forward "%<" nil t) + (replace-match "")) + (goto-char (point-min)) ;; Simple %-escapes - (while (re-search-forward "%\\([tTuUaiAcx]\\)" nil t) + (while (re-search-forward "%\\([tTuUaiAcxkKI]\\)" nil t) (when (and initial (equal (match-string 0) "%i")) (save-match-data (let* ((lead (buffer-substring @@ -393,8 +424,7 @@ to be run from that hook to function properly." (org-split-string initial "\n") (concat "\n" lead)))))) (replace-match - (or (eval (intern (concat "v-" (match-string 1)))) "") - t t)) + (or (eval (intern (concat "v-" (match-string 1)))) "") t t)) ;; %[] Insert contents of a file. (goto-char (point-min))