Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Interactively enter headline under which to place an entry using capture

Tags:

emacs

org-mode

Using capture templates like the one below, I can add entries to different headlines in a file. How can I manually enter a headline during capture, instead of setting up each headline to a key in the .emacs file like I am now doing?

(setq org-capture-templates
      '(
      ("l" "Log" entry
     (file+headline "c:/Org/log.org" "Log")
     "\n\n** %?\n<%<%Y-%m-%d %a %T>>"
     :empty-lines 1))
like image 464
Nathan Fowler Avatar asked Jan 25 '12 16:01

Nathan Fowler


1 Answers

It looks like, in newer versions of org at least, that custom functions can be used in capture templates to do this.

Instead of:

entry
(file+headline "~/Work/work.org" "Refile")

You can use:

entry
(file+function "~/Work/work.org" function-finding-location)

Where 'function-finding-location' is a custom function you have written yourself, which could easily prompt you for a headline.

Or, you can go even farther, and define a custom function which will prompt for both file name and headline name (or anything else you can dream up):

entry
(function function-finding-location)

I don't really know enough elisp to write these functions myself, but this looks like the place to start. It'd be nice if someone else could offer up some code. The relevant documentation is here:

http://orgmode.org/manual/Template-elements.html

like image 95
Jones Avatar answered Oct 19 '22 19:10

Jones