Hi,

I am in the process of switching from org-remember to org-capture.

I used a custom function with org-remember to capture into a
host-specific sub-tree under "* Inbox" in order to minimize git merge
conflicts between my machines.

My tree typically looks like this:

* Inbox
*** Inbox:host1
***** INBOX idea 1
***** INBOX idea 2
*** Inbox:host2
***** INBOX idea 3

The custom function with org-remember only needed to create the target
headline's name.  Org-remember would find it or create it (IIRC):

---->8----------------------------------------------------------------
(defun my-host-name ()
  "Returns the name of the current host minus the domain."
  (let ((hostname (downcase (system-name))))
    (save-match-data
      (substring hostname (string-match "^[^.]+" hostname) (match-end 0)))))

(defun my-org-remember-headline ()
  (concatenate 'string "Inbox:" (my-host-name)))
---->8----------------------------------------------------------------

The problem is now that org-capture expects a function that creates
the target node and positions point at a child of the target, is this
correct?

My hacky solution is to use the file+function template and looks like
this:

---->8----------------------------------------------------------------
(defun my-org-capture-function ()
  (goto-char
   (org-find-exact-headline-in-buffer
    (concatenate 'string "Inbox:" (my-host-name)) nil t))
  (org-end-of-line)
  (org-insert-subheading ""))
---->8----------------------------------------------------------------

But it looks clumsy and always inserts as first child.  Is there a
more elegant approach, maybe using the refiling mechanism?

Thanks,
Martin

Reply via email to