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

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

[elpa] externals/ebdb 4e035f9: Add missing pieces to reverse relations,


From: Eric Abrahamsen
Subject: [elpa] externals/ebdb 4e035f9: Add missing pieces to reverse relations, bump to 0.6.16
Date: Fri, 17 Apr 2020 14:49:43 -0400 (EDT)

branch: externals/ebdb
commit 4e035f971f63713b71f0c0d92c2ebc89dbdafc75
Author: Eric Abrahamsen <address@hidden>
Commit: Eric Abrahamsen <address@hidden>

    Add missing pieces to reverse relations, bump to 0.6.16
    
    * ebdb-com.el (ebdb-com-delete-field, ebdb-com-edit-field): Forgot we
    need to rewire the edit and delete methods, now that relation fields
    can appear on the "wrong" record.
    * ebdb.el (ebdb-read): Prompt for values based on existing object. We
    seriously need to do something about the field prompts, they are
    deeply confusing.
---
 ebdb-com.el | 19 +++++++++++++++++++
 ebdb.el     | 11 ++++++++---
 2 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/ebdb-com.el b/ebdb-com.el
index b61521b..7b74efa 100644
--- a/ebdb-com.el
+++ b/ebdb-com.el
@@ -1900,6 +1900,15 @@ commands, called from an *EBDB* buffer, and the 
lower-level
                 'uuid)))
     (ebdb-record-change-field person field)))
 
+(cl-defmethod ebdb-com-edit-field ((record ebdb-record-person)
+                                  (field ebdb-field-relation))
+  (if (equal (slot-value field 'rel-uuid)
+            (ebdb-record-uuid record))
+      (ebdb-record-change-field
+       (ebdb-record-related record field)
+       field)
+    (cl-call-next-method)))
+
 ;;;###autoload
 (defun ebdb-edit-field-customize (record field)
   "Use the customize interface to edit FIELD of RECORD."
@@ -2058,6 +2067,16 @@ confirm before deleting the field."
   (let ((person (ebdb-gethash (slot-value field 'record-uuid) 'uuid)))
     (ebdb-com-delete-field person field noprompt)))
 
+(cl-defmethod ebdb-com-delete-field ((record ebdb-record-person)
+                                    (field ebdb-field-relation)
+                                    noprompt)
+  (if (equal (slot-value field 'rel-uuid)
+            (ebdb-record-uuid record))
+      (ebdb-com-delete-field
+       (ebdb-record-related record field)
+       field noprompt)
+    (cl-call-next-method)))
+
 (cl-defmethod ebdb-com-delete-field :after ((record ebdb-record-entity)
                                            (mail ebdb-field-mail)
                                            _noprompt)
diff --git a/ebdb.el b/ebdb.el
index c3cc195..a1c7a95 100644
--- a/ebdb.el
+++ b/ebdb.el
@@ -2,7 +2,7 @@
 
 ;; Copyright (C) 2016-2020  Free Software Foundation, Inc.
 
-;; Version: 0.6.15
+;; Version: 0.6.16
 ;; Package-Requires: ((emacs "25.1") (cl-lib "0.5") (seq "2.15"))
 
 ;; Maintainer: Eric Abrahamsen <address@hidden>
@@ -2082,9 +2082,14 @@ Eventually this method will go away."
   :human-readable "relationship")
 
 (cl-defmethod ebdb-read ((class (subclass ebdb-field-relation)) &optional 
slots obj)
-  (let* ((rec (ebdb-record-uuid (ebdb-prompt-for-record nil 
ebdb-default-record-class)))
+  (let* ((rec (if obj
+                 (slot-value obj 'rel-uuid)
+               (ebdb-record-uuid (ebdb-prompt-for-record
+                                  nil ebdb-default-record-class))))
         (rel-label (ebdb-read-string "Reverse label (for the other record): "
-                                     nil ebdb-relation-label-list)))
+                                     (when obj
+                                       (slot-value obj 'rel-label))
+                                     ebdb-relation-label-list)))
     (setq slots (plist-put slots :rel-uuid rec))
     (setq slots (plist-put slots :rel-label rel-label))
     (cl-call-next-method class slots obj)))



reply via email to

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