emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] org-remember to org-capture


From: Martin Pohlack
Subject: [O] org-remember to org-capture
Date: Fri, 27 Jan 2012 15:05:50 +0100
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.24) Gecko/20111109 Thunderbird/3.1.16

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

[Prev in Thread] Current Thread [Next in Thread]