emacs-orgmode
[Top][All Lists]
Advanced

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

[O] Automatic ID insertion on entry creation


From: Ivan Vilata i Balaguer
Subject: [O] Automatic ID insertion on entry creation
Date: Fri, 20 May 2011 00:28:15 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux)

Hi all, I'm toying with MobileOrg and I see it prefers agenda entries
having an ID property.  That's ok with me, but since I'm keeping my
agenda files under version control, I don't like that they are modified
a long time after they are created, when pushing entries to MobileOrg.

So I've tried that entries in agenda files be created right away with an
ID property.  Since I didn't find an option for that, I tried to use
=%(org-id-get)= in my task template, which didn't work either.  Then I
came across this thread[1] and wrote the following function:

#+BEGIN_SRC emacs-lisp
(defun ivb/org-id-insert-maybe ()
  "Insert an ID property into the current entry and return it.
This is only done if the file has the local variable `auto-insert-id'
set to `t'.  This function is intended for `org-insert-heading-hook'
and `org-capture-after-finalize-hook'."
  (if (member (cons 'auto-insert-id t) file-local-variables-alist)
      (org-id-get-create)))
#+END_SRC

It works right for inserted headings, but it's quite unreliable when
capturing: when capturing to a file with =auto-insert-id= set to =t=,
=file-local-variables-alist= is sometimes nil (esp. when capturing from
outside the file) and sometimes it has the right variables (when
capturing from the same file, but not always).  I got the values by
debugging the function.

Any suggestions to fix the function (or getting the same result by other
means)?  I'm using Emacs 23.3 and Org 7.5, both from Debian unstable.

Thanks a lot,

[1] http://www.mail-archive.com/address@hidden/msg16143.html
-- 
Ivan Vilata i Balaguer -- http://ivan.lovesgazpacho.net/




reply via email to

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