[Top][All Lists]

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

[elpa] externals/ebdb 4bb77e3 11/15: Add mail deletion behavior

From: Eric Abrahamsen
Subject: [elpa] externals/ebdb 4bb77e3 11/15: Add mail deletion behavior
Date: Sun, 1 Apr 2018 06:02:49 -0400 (EDT)

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

    Add mail deletion behavior
    * ebdb.el (ebdb-record-delete-field): If deleting a record mail leaves
      no primary mail address, set the first of the remaining mails as
 ebdb.el | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/ebdb.el b/ebdb.el
index 613660b..e23e294 100644
--- a/ebdb.el
+++ b/ebdb.el
@@ -3025,9 +3025,21 @@ If FIELD doesn't specify a year, use the current year."
   "Possibly set the priority of a newly-added mail address.
 If RECORD has no other primary mail, set MAIL's priority to
-  (when (null (object-assoc 'primary 'priority (ebdb-record-mail record)))
+  (when (null (object-assoc 'primary 'priority (ebdb-record-mail record t)))
     (setf (slot-value mail 'priority) 'primary)))
+(cl-defmethod ebdb-record-delete-field :after ((record ebdb-record-entity)
+                                              (mail ebdb-field-mail)
+                                              &optional _slot)
+  "Possibly alter the priority of RECORD's remaining mails.
+If there aren't any other primary mails, make the first of the
+remaining mails primary."
+  (let* ((mails (remove mail (ebdb-record-mail record)))
+        (clone (unless (object-assoc 'primary 'priority mails)
+                 (clone (car mails)))))
+    (when clone
+     (ebdb-record-change-field record (car mails) clone))))
 (defun ebdb-compose-mail (&rest args)
   "Start composing a mail message to send.
 ARGS is passed to `compose-mail'."

reply via email to

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