emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/org-contacts 25211e8066 068/154: org-contacts: Ensure c


From: ELPA Syncer
Subject: [elpa] externals/org-contacts 25211e8066 068/154: org-contacts: Ensure contacts cache is updated if it contains markers with no buffer
Date: Fri, 9 Sep 2022 15:58:27 -0400 (EDT)

branch: externals/org-contacts
commit 25211e8066e544a50226e746b62dd37b2ff1f478
Author: Øyvind Stegard <oyvind.stegard@ifi.uio.no>
Commit: Grégoire Jadi <gregoire.jadi@gmail.com>

    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.
---
 org-contacts.el | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/org-contacts.el b/org-contacts.el
index 71f7bf4016..a220993685 100644
--- a/org-contacts.el
+++ b/org-contacts.el
@@ -224,7 +224,20 @@ A regexp matching strings of whitespace, `,' and `;'.")
       (org-find-if (lambda (file)
                     (or (time-less-p org-contacts-last-update
                                      (elt (file-attributes file) 5))))
-                  (org-contacts-files))))
+                  (org-contacts-files))
+      (org-contacts-db-has-dead-markers-p org-contacts-db)))
+
+(defun org-contacts-db-has-dead-markers-p (org-contacts-db)
+  "Returns t if at least one dead marker is found in
+ORG-CONTACTS-DB. A dead marker in this case is a marker pointing
+to dead or no buffer."
+    ;; Scan contacts list looking for dead markers, and return t at first 
found.
+    (catch 'dead-marker-found
+      (while org-contacts-db
+        (unless (marker-buffer (nth 1 (car org-contacts-db)))
+          (throw 'dead-marker-found t))
+        (setq org-contacts-db (cdr org-contacts-db)))
+      nil))
 
 (defun org-contacts-db ()
   "Return the latest Org Contacts Database."



reply via email to

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