From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ivan Vilata i Balaguer Subject: Automatic ID insertion on entry creation Date: Fri, 20 May 2011 00:28:15 +0200 Message-ID: <877h9ml400.fsf@rampella.terramar.selidor.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from eggs.gnu.org ([140.186.70.92]:57939) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QNBi3-0006tn-CX for emacs-orgmode@gnu.org; Thu, 19 May 2011 18:28:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QNBi2-0004hK-3M for emacs-orgmode@gnu.org; Thu, 19 May 2011 18:28:47 -0400 Received: from lo.gmane.org ([80.91.229.12]:55104) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QNBi1-0004hG-Su for emacs-orgmode@gnu.org; Thu, 19 May 2011 18:28:46 -0400 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1QNBi0-0002q3-Qm for emacs-orgmode@gnu.org; Fri, 20 May 2011 00:28:44 +0200 Received: from 217.213.76.188.dynamic.jazztel.es ([188.76.213.217]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 20 May 2011 00:28:44 +0200 Received: from ivan by 217.213.76.188.dynamic.jazztel.es with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 20 May 2011 00:28:44 +0200 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: emacs-orgmode@gnu.org 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/