emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Automatic ID insertion on entry creation
@ 2011-05-19 22:28 Ivan Vilata i Balaguer
  0 siblings, 0 replies; only message in thread
From: Ivan Vilata i Balaguer @ 2011-05-19 22:28 UTC (permalink / raw)
  To: emacs-orgmode

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/emacs-orgmode@gnu.org/msg16143.html
-- 
Ivan Vilata i Balaguer -- http://ivan.lovesgazpacho.net/

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-05-19 22:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-19 22:28 Automatic ID insertion on entry creation Ivan Vilata i Balaguer

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).