From mboxrd@z Thu Jan 1 00:00:00 1970 From: Martin Pohlack Subject: Re: org-remember to org-capture Date: Sat, 28 Jan 2012 22:34:08 +0100 Message-ID: <4F2469D0.7090309@os.inf.tu-dresden.de> References: <4F22AF3E.70109@os.inf.tu-dresden.de> <87ty3fyfzy.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([140.186.70.92]:34916) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RrFud-0008N1-NJ for emacs-orgmode@gnu.org; Sat, 28 Jan 2012 16:34:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RrFub-0004cr-6A for emacs-orgmode@gnu.org; Sat, 28 Jan 2012 16:34:19 -0500 Received: from os.inf.tu-dresden.de ([141.76.48.99]:35949) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RrFua-0004cj-Ug for emacs-orgmode@gnu.org; Sat, 28 Jan 2012 16:34:17 -0500 In-Reply-To: <87ty3fyfzy.fsf@gnu.org> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Bastien Cc: org-mode Hi Bastien, thanks for your reply. On 28.01.2012 17:00, Bastien wrote: > Hi Martin, > > Martin Pohlack writes: > >> I am in the process of switching from org-remember to org-capture. > > Possibly useless hint: M-x org-capture-import-remember-templates RET Yes thanks. Unfortunately, this does not convert my custom function :-). In fact, it does not convert anything (with org-mode 7.6). > Can you restate the problem more directly? What are your capture > template, what is it supposed to achieve, how does it fail to do > what you want -- we'll work out something from there. All right, here is my (stripped down) setup: '(org-remember-templates (quote ( ("Inbox-Arbeit" 97 "* INBOX %^{Title} %U%? %i" "~/Daten/plan_arbeit.org" my-org-remember-headline nil) ("Inbox-Privat" 112 "* INBOX %^{Title} %U%? %i" "~/Daten/plan_privat.org" my-org-remember-headline nil) ("Journal" 106 "* %^{Eintrag}%?%i%&" "~/Daten/Journal.org" return_formated_date nil)))) Let' focus on the first entry (Inbox-Arbeit): the only non-standard thing here is the function my-org-remember-headline. ---->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---------------------------------------------------------------- Run on “host1” it will return “Inbox:host1”, etc. My “plan_arbeit.org” file contains this structure: ---->8---------------------------------------------------------------- * Inbox *** Inbox:host1 *** Inbox:host2 ---->8---------------------------------------------------------------- So that each machine has a separate inbox under a global container. This reduces git merge conflicts when I merge my plan files from different machines (but this is a side discussion). What changed from org-remember to org-capture is that custom functions used to return a string with a target parent headline. Now they are expected to modify “point” as a side effect before the actual capturing happens (and not return anything). Here is my new capture template: '(org-capture-templates (quote ( ("a" "Inbox-Arbeit" entry (file+function "~/Daten/plan_arbeit.org" my-org-capture-function) "* INBOX %^{Title} %U%? %i")))) I drafted this new function for org-capture: ---->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---------------------------------------------------------------- This shall capture again under “Inbox/Inbox:$hostname”. The function feels clumsy because this functionality should already be in org-mode (e.g., the refiling stuff). Also, it files new items as first child under the target and not as last child. The question is simply: Is there a more elegant approach, maybe using the refiling mechanism? Have I overlooked something obvious? Thanks, Martin