Store remember notes under the current clock entry with `C-2 C-c C-c'.

Patch from James TD Smith, but modified.
This commit is contained in:
Carsten Dominik 2008-10-02 18:07:12 +02:00
parent c50a7b312f
commit 2a8dac9f70
5 changed files with 48 additions and 27 deletions

View File

@ -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.

View File

@ -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

View File

@ -1,3 +1,8 @@
2008-10-02 Carsten Dominik <dominik@science.uva.nl>
* 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 <ahktenzero@mohorovi.cc>
* org-remember.el (org-remember-apply-template): Add new

View File

@ -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))

View File

@ -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.