4

Org capture is a great tool for capturing notes and task when doing other things inside Emacs. The captured item is stored in a specified file for later review, and the point jumps back to the file it was in when you got the idea. Practical. However, I am also using capture to make tasks when working deliberately in my task file. In this case it would be much more handy if the task template saved the new task at point whichever file I am in, and not to a predefined capture file. After the task is produced I would like point to stay in the headerline of this new task. Is this possible?

Here is a capture template I use for producing task items:

(setq org-capture-templates '((
         "t"                                            ; key
         "Todo"                                         ; description
         entry                                          ; type
         (file+headline "C:/.../privat.org" "tasks")    ; target
         "* TODO [#B] %^{Todo} \nSCHEDULED: %t \n\n%?"  ; template
         :prepend t                                     ; properties
)))

It stores the produced task to the file "C:/.../privat.org" under the heading "tasks", and the "prepend" property makes the new task to be placed as the first subheading under "task".

How can I make the new task be stored at point in whatever file I work in?

3
  • 2
    It looks like the original poster may want (file+function "path/to/file" function-finding-location) [A function to find the right location in the file.] The custom function doesn't need to really do anything -- e.g., (lambda () (message "hello-world")) -- since the original poster is already at the desired location -- i.e., nothing to do.
    – lawlist
    Jul 29, 2015 at 20:32
  • Thanks ! ok so I do not need any "function-finding-location", right? But the target-file will not be the same each time I will use this capture. Can I skip the path or what?
    – myotis
    Jul 29, 2015 at 20:37
  • 2
    Then, in that case you may want to try using: (function function-finding-location) [Most general way, write your own function to find both file and location.] -- and something like: (function (lambda () (message "You have already arrived at your destination.")))
    – lawlist
    Jul 29, 2015 at 20:43

1 Answer 1

6

From the org-capture help:

When called with a ‘C-0’ (zero) prefix, insert a template at point.

So C-0 C-c c does what want (assuming C-c c is bound to org-capture).

6
  • Thanks! that works :) but could this functionality be buildt into the capture code instead of in the call?
    – myotis
    Jul 30, 2015 at 7:37
  • Yes, using a custom location finding function in the template as @lawlist suggested.
    – erikstokes
    Jul 30, 2015 at 12:37
  • Thanks :) I am sure that a custom local finding function is a great advice, but I have absolutely no idea of how to make it, or how it would look like inside my code. Where to put @lawlist 's code (function (lambda () (message "You have already arrived at your destination."))) inside my code? and how would the "target' line in my cod look like?
    – myotis
    Jul 30, 2015 at 12:49
  • 1
    Use @lawlist's code to replace the (file+headline "..."). That's the part of the template the decides where the capture goes.
    – erikstokes
    Jul 30, 2015 at 12:55
  • Fantastic, it works :)) thanks to both of you!
    – myotis
    Jul 30, 2015 at 13:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.