From 2a8dac9f706d635b23a330f6a6e0b8b9bec0b596 Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Thu, 2 Oct 2008 18:07:12 +0200 Subject: [PATCH] Store remember notes under the current clock entry with `C-2 C-c C-c'. Patch from James TD Smith, but modified. --- ORGWEBPAGE/Changes.org | 13 ++++++++++++- doc/org.texi | 4 ++++ lisp/ChangeLog | 5 +++++ lisp/org-clock.el | 5 +++++ lisp/org-remember.el | 48 ++++++++++++++++++++++-------------------------- 5 files changed, 48 insertions(+), 27 deletions(-) diff --git a/ORGWEBPAGE/Changes.org b/ORGWEBPAGE/Changes.org index c7bd35bef..d862370d3 100644 --- a/ORGWEBPAGE/Changes.org +++ b/ORGWEBPAGE/Changes.org @@ -47,7 +47,18 @@ Thanks to John Wiegley who contributed this fantastic new concept and wrote org-attach.el to implement it. -*** New remember template escape to add a property +*** New remember template escapes + + : %^{prop}p to insert a property + : %k the heading of the item currently being clocked + : %K a link to the heading of the item currently being clocked + + Also, when you exit remember with =C-2 C-c C-c=, the item + will be filed as a child of the item currently being + clocked. So the idea is, if you are working on something and + think of a new task related to this or a new note to be + added, you can use this to quickly add information to that + task. Thanks to James TD Smith for a patch to this effect. diff --git a/doc/org.texi b/doc/org.texi index b842f998e..e58c89c44 100644 --- a/doc/org.texi +++ b/doc/org.texi @@ -5022,6 +5022,8 @@ insertion of content: %^C @r{Interactive selection of which kill or clip to use.} %^L @r{Like @code{%^C}, but insert as link.} %^g @r{prompt for tags, with completion on tags in target file.} +%k @r{title of currently clocked task} +%K @r{link to currently clocked task} %^G @r{prompt for tags, with completion all tags in all agenda files.} %^@{prop@}p @r{Prompt the user for a value for property @code{prop}} %:keyword @r{specific information for certain link types, see below} @@ -5082,6 +5084,8 @@ The window configuration will be restored, sending you back to the working context before the call to @code{remember}. To re-use the location found during the last call to @code{remember}, exit the remember buffer with @kbd{C-0 C-c C-c}, i.e. specify a zero prefix argument to @kbd{C-c C-c}. +Another special case is @kbd{C-2 C-c C-c} which files the note as a child of +the currently clocked item. If you want to store the note directly to a different place, use @kbd{C-1 C-c C-c} instead to exit remember@footnote{Configure the diff --git a/lisp/ChangeLog b/lisp/ChangeLog index a7e78eb7e..cff1c7115 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2008-10-02 Carsten Dominik + + * org-clock.el (org-clock-heading-for-remember): New variable. + (org-clock-in): Set `org-clock-heading-for-remember'. + 2008-10-01 James TD Smith * org-remember.el (org-remember-apply-template): Add new diff --git a/lisp/org-clock.el b/lisp/org-clock.el index 51613f554..286f7d7be 100644 --- a/lisp/org-clock.el +++ b/lisp/org-clock.el @@ -98,6 +98,7 @@ The function is called with point at the beginning of the headline." (defvar org-mode-line-timer nil) (defvar org-clock-heading "") +(defvar org-clock-heading-for-remember "") (defvar org-clock-start-time "") (defvar org-clock-history nil @@ -269,6 +270,10 @@ the clocking selection, associated with the letter `d'." org-clock-in-switch-to-state "\\>")))) (org-todo org-clock-in-switch-to-state)) + (setq org-clock-heading-for-remember + (and (looking-at org-complex-heading-regexp) + (match-end 4) + (org-trim (buffer-substring (match-end 1) (match-end 4))))) (setq org-clock-heading (cond ((and org-clock-heading-function (functionp org-clock-heading-function)) diff --git a/lisp/org-remember.el b/lisp/org-remember.el index 08dee31cd..5a53fbb66 100644 --- a/lisp/org-remember.el +++ b/lisp/org-remember.el @@ -43,6 +43,8 @@ (defvar remember-buffer) (defvar remember-handler-functions) (defvar remember-annotation-functions) +(defvar org-clock-heading) +(defvar org-clock-heading-for-remember) (defgroup org-remember nil "Options concerning interaction with remember.el." @@ -133,17 +135,16 @@ Furthermore, the following %-escapes will be replaced with content: %x content of the X clipboard %^C Interactive selection of which kill or clip to use %^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 title of currently clocked task %K link to currently clocked task + %^g prompt for tags, with completion on tags in target file + %^G prompt for tags, with completion all tags in all agenda files %^{prop}p Prompt the user for a value for property `prop' %: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 as child of currently clocked task %? After completing the template, position cursor here. @@ -375,19 +376,6 @@ to be run from that hook to function properly." (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) @@ -396,24 +384,20 @@ to be run from that hook to function properly." (erase-buffer) (insert (substitute-command-keys (format -"## Filing location: Select interactively, default, or last used: -## %s to select file and header location interactively. -## %s \"%s\" -> \"* %s\" -## C-0 C-c C-c \"%s\" -> \"* %s\" +"## %s \"%s\" -> \"* %s\" ## C-u C-c C-c like C-c C-c, and immediately visit note at target location +## C-0 C-c C-c \"%s\" -> \"* %s\" +## %s to select file and header location interactively. +## C-2 C-c C-c as child of the currently clocked item ## To switch templates, use `\\[org-remember]'. To abort use `C-c C-k'.\n\n" - (if org-remember-store-without-prompt "C-1 C-c C-c" " C-c C-c") (if org-remember-store-without-prompt " C-c C-c" " C-1 C-c C-c") (abbreviate-file-name (or file org-default-notes-file)) (or headline "") (or (car org-remember-previous-location) "???") - (or (cdr org-remember-previous-location) "???")))) + (or (cdr org-remember-previous-location) "???") + (if org-remember-store-without-prompt "C-1 C-c C-c" " C-c C-c")))) (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 "%\\([tTuUaiAcxkKI]\\)" nil t) @@ -690,6 +674,10 @@ process is used to select the target location. When the prefix is 0 (i.e. when remember is exited with `C-0 C-c C-c'), the entry is filed to the same location as the previous note. +When the prefix is 2 (i.e. when remember is exited with `C-2 C-c C-c'), +the entry is fild as a subentry of the entry where the clock is +currently running. + When `C-u' has been used as prefix argument, the note is stored and emacs moves point to the new location of the note, so that editing can be continued there (smilar to inserting \"%&\" into the tempate). @@ -704,6 +692,9 @@ also indented so that it starts in the same column as the headline \(i.e. after the stars). See also the variable `org-reverse-note-order'." + (when (and (equal current-prefix-arg 2) + (not (marker-buffer org-clock-marker))) + (error "No runing clock")) (when (org-bound-and-true-p org-jump-to-target-location) (let* ((end (min (point-max) (1+ (point)))) (beg (point))) @@ -722,6 +713,7 @@ See also the variable `org-reverse-note-order'." (let* ((visitp (org-bound-and-true-p org-jump-to-target-location)) (previousp (and (member current-prefix-arg '((16) 0)) org-remember-previous-location)) + (clockp (equal current-prefix-arg 2)) (fastp (org-xor (equal current-prefix-arg 1) org-remember-store-without-prompt)) (file (cond @@ -743,6 +735,10 @@ See also the variable `org-reverse-note-order'." (setq file (car org-remember-previous-location) heading (cdr org-remember-previous-location) fastp t)) + (when clockp + (setq file (buffer-file-name (marker-buffer org-clock-marker)) + heading org-clock-heading-for-remember + fastp t)) (setq current-prefix-arg nil) ;; Modify text so that it becomes a nice subtree which can be inserted ;; into an org tree. -- 2.11.4.GIT