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

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

[elpa] externals/ebdb 16cdf2c 028/350: Provide protection for relations


From: Eric Abrahamsen
Subject: [elpa] externals/ebdb 16cdf2c 028/350: Provide protection for relations to unloaded records
Date: Mon, 14 Aug 2017 11:45:56 -0400 (EDT)

branch: externals/ebdb
commit 16cdf2cc01ea0d0677333637dc3110fd7712bcf8
Author: Eric Abrahamsen <address@hidden>
Commit: Eric Abrahamsen <address@hidden>

    Provide protection for relations to unloaded records
    
    For role and relation fields, don't blow up if the target record is
    not currently loaded.
    
    * ebdb.el (ebdb-init): Use a "record not loaded" string for role
      fields.
      (ebdb-string): And display something similar for relation fields.
---
 ebdb.el | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/ebdb.el b/ebdb.el
index eac7492..09af98f 100644
--- a/ebdb.el
+++ b/ebdb.el
@@ -924,6 +924,9 @@ process."
   (when record
     (let* ((org-uuid (slot-value role 'org-uuid))
           (org (ebdb-gethash org-uuid 'uuid))
+          (org-string (if org
+                          (ebdb-string (slot-value org 'name))
+                        "record not loaded"))
           ;; TODO: Guard against org-entry not being found.
           (org-entry (gethash org-uuid ebdb-org-hashtable))
           (record-uuid (ebdb-record-uuid record))
@@ -1000,7 +1003,10 @@ process."
   ;; This is used in person records headers, so it just shows the
   ;; organization name. Perhaps this could have a multi-line option
   ;; later.
-  (ebdb-string (ebdb-gethash (slot-value role 'org-uuid) 'uuid)))
+  (let ((org (ebdb-gethash (slot-value role 'org-uuid) 'uuid)))
+    (if org
+       (ebdb-string org)
+      "record not loaded")))
 
 ;;; Mail fields.
 
@@ -1506,7 +1512,10 @@ override parsing."
     (cl-call-next-method class slots obj)))
 
 (cl-defmethod ebdb-string ((rel ebdb-field-relation))
-  (ebdb-string (ebdb-gethash (slot-value rel 'rel-uuid) 'uuid)))
+  (let ((rec (ebdb-gethash (slot-value rel 'rel-uuid) 'uuid)))
+    (if rec
+       (ebdb-string rec)
+      "record not loaded")))
 
 ;; Image field
 



reply via email to

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