org-contacts: Ensure contacts cache is updated if it contains markers with no buffer
commitcc74ae8b7a9284efd7f2d5fb56e53cd97af40400
authorØyvind Stegard <oyvind.stegard@ifi.uio.no>
Fri, 12 Jul 2013 10:17:12 +0000 (12 12:17 +0200)
committerGrégoire Jadi <gregoire.jadi@gmail.com>
Sat, 20 Jul 2013 15:21:37 +0000 (20 17:21 +0200)
treed9f135a382662a258999b809fc3810432124fdeb
parent17b584df89bac8f16ffd0e11f5d6b889439820c9
org-contacts: Ensure contacts cache is updated if it contains markers with no buffer

* contrib/lisp/org-contacts.el (org-contacts-db-need-update-p):
Check if org-contacts-db cache contains markers with no buffer as well, when
determining if cache should be updated from files.

The function `org-contacts-db-need-update-p' does two checks to determine if the
contacts cache should be updated:
1. If the variable `org-contacts-last-update' is nil.
2. If modification time of any file containing contacts is more recent than
   timestamp recorded in `org-contacts-last-update'.

There is another case where an update is required: when marker objects contained
in the contact cache `org-contacts-db' suddenly point to no buffer. If a buffer
containing contacts is killed, but underlying file is not modified, org-contacts
will not detect this, and cached markers that pointed to the now killed buffer
will become "dead" (e.g. have no buffer associated with them). This seems to cause
problems for instance in `org-contacts-anniversaries', which if used as diary
sexp in agenda file, will cause "Bad sexp" errors.
contrib/lisp/org-contacts.el