Hi folks,

I'm trying to figure out the proper use of the 'file+function' target. The documentation indicates the entry will be a child of the target entry, but I'm not finding that to be the case for all cases.

As far as I can tell, the function is expected to put the point where the entry should go and return t.

Here's my org-capture templates:

(setq org-capture-templates
     ("x" "Test")
     ("x1" "Test function" entry
      (file+function
       "~/test.org"
       (lambda ()
         (goto-char (org-find-olp (list "Top" "A" "A1") t))
         t))
      "* Test A1"
      )

     ("x2" "Test function" entry
      (file+function
       "~/test.org"
       (lambda ()
         (goto-char (org-find-olp (list "Top" "A" "A1" "A1x") t))
         t))
      "* Test A1x")

     ("x3" "Test function" entry
      (file+function
       "~/test.org"
       (lambda ()
         (goto-char (org-find-olp (list "Top" "A" "A1" "A1x" "A1xx") t))
         t))
      "* Test A1xx")))

Start with this as a test.org:

* Top
** A
*** A1
**** A1x
***** A1xx
**** A1y
** B
*** B1
**** B1x

Then call org-capture for x1, then x2, then x3, and you get:

* Top
** A
*** Test A1
*** A1
**** Test A1x
**** A1x
***** Test A1xx
***** A1xx
**** A1y
** B
*** B1
**** B1x

I expected instead for the new entries to appear as subheadings of the target, something like:

* Top
** A
*** A1
**** A1x
***** A1xx
****** Test A1xx
***** Test A1x
**** A1y
*** Test A1
** B
*** B1
**** B1x

I've tried various things in the lambda() function:

1.  (org-end-of-subtree)

This just creates the entry at the end of the subtree, but as a child of the last entry.

2.  end-of-line

Fails if there is any body below the heading in question.

Is this a bug or am I doing something wrong?

Using:
  Emacs 23.4.1 on Mac
  Org-mode 7.8.03

Thanks
...cj

Reply via email to