emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ivan Vilata i Balaguer <ivan@selidor.net>
To: emacs-orgmode@gnu.org
Subject: Automatic ID insertion on entry creation
Date: Fri, 20 May 2011 00:28:15 +0200	[thread overview]
Message-ID: <877h9ml400.fsf@rampella.terramar.selidor.net> (raw)

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/

                 reply	other threads:[~2011-05-19 22:28 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=877h9ml400.fsf@rampella.terramar.selidor.net \
    --to=ivan@selidor.net \
    --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).