emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: James TD Smith <ahktenzero@mohorovi.cc>
To: emacs-orgmode@gnu.org
Subject: [PATCH 7/7] Add some new interaction between remember and clocked tasks
Date: Fri, 25 Jul 2008 00:46:39 +0100	[thread overview]
Message-ID: <20080724234639.23478.94799.stgit@nyarlathotep.internal.mohorovi.cc> (raw)
In-Reply-To: <20080724234608.23478.48564.stgit@nyarlathotep.internal.mohorovi.cc>

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       |    7 ++++++-
 lisp/org-remember.el |   38 ++++++++++++++++++++++++++++++++++----
 2 files changed, 40 insertions(+), 5 deletions(-)

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index d072d40..b591f32 100755
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,10 @@
 2008-07-25  James TD Smith  <ahktenzero@mohorovi.cc>
 
+	* 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
@@ -18,7 +23,7 @@
 	set-text-properties to remove text properties from the clipboard
 	value.
 
-	* lisp/org-clock.el (org-update-mode-line): Support limiting the
+	* org-clock.el (org-update-mode-line): Support limiting the
 	modeline clock string, and display the full todo value in the
 	tooltip. Set a local keymap so mouse-3 on the clock string goes to
 	the currently clocked task.
diff --git a/lisp/org-remember.el b/lisp/org-remember.el
index 8399f3d..80b5896 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.
 
@@ -346,11 +350,33 @@ 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-time-was-given org-end-time-was-given x
 	     prompt completions char time pos default histvar)
 	(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))
@@ -369,9 +395,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
@@ -380,8 +411,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))

      parent reply	other threads:[~2008-07-24 23:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-24 23:46 [PATCH 1/7] Some improvements to the modeline clock display James TD Smith
2008-07-24 23:46 ` [PATCH 2/7] Fix X clipboard handling in emacs21 James TD Smith
2008-07-24 23:46 ` [PATCH 3/7] Show durations of clocked times in timeline James TD Smith
2008-07-24 23:46 ` [PATCH 4/7] Fix link display in imenus and the refile interface James TD Smith
2008-07-24 23:46 ` [PATCH 5/7] Fix note insertion in entries with drawers James TD Smith
2008-07-24 23:46 ` [PATCH 6/7] Add some functions for handling checklists James TD Smith
2008-07-24 23:46 ` James TD Smith [this message]

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=20080724234639.23478.94799.stgit@nyarlathotep.internal.mohorovi.cc \
    --to=ahktenzero@mohorovi.cc \
    --cc=emacs-orgmode@gnu.org \
    /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).