emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Martin Pohlack <mp26@os.inf.tu-dresden.de>
To: Bastien <bzg@altern.org>
Cc: org-mode <emacs-orgmode@gnu.org>
Subject: Re: org-remember to org-capture
Date: Sat, 28 Jan 2012 22:34:08 +0100	[thread overview]
Message-ID: <4F2469D0.7090309@os.inf.tu-dresden.de> (raw)
In-Reply-To: <87ty3fyfzy.fsf@gnu.org>

Hi Bastien,

thanks for your reply.

On 28.01.2012 17:00, Bastien wrote:
> Hi Martin,
> 
> Martin Pohlack <mp26@os.inf.tu-dresden.de> 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

      reply	other threads:[~2012-01-28 21:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-27 14:05 org-remember to org-capture Martin Pohlack
2012-01-28 16:00 ` Bastien
2012-01-28 21:34   ` Martin Pohlack [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4F2469D0.7090309@os.inf.tu-dresden.de \
    --to=mp26@os.inf.tu-dresden.de \
    --cc=bzg@altern.org \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).