[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ebdb 7a5ce18 13/15: Handle mail priority after customiz
From: |
Eric Abrahamsen |
Subject: |
[elpa] externals/ebdb 7a5ce18 13/15: Handle mail priority after customization edits |
Date: |
Sun, 1 Apr 2018 06:02:49 -0400 (EDT) |
branch: externals/ebdb
commit 7a5ce181ccc3329a515875cabea5a2a0e7e39916
Author: Eric Abrahamsen <address@hidden>
Commit: Eric Abrahamsen <address@hidden>
Handle mail priority after customization edits
* ebdb-com.el (eieio-done-customizing): New :after method to set
record's mail priorities based on edits to this mail address. Split
redisplay out into its own :after method, so it runs after this, as well.
---
ebdb-com.el | 25 +++++++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)
diff --git a/ebdb-com.el b/ebdb-com.el
index ff6d447..ac96ad2 100644
--- a/ebdb-com.el
+++ b/ebdb-com.el
@@ -1733,8 +1733,29 @@ commands, called from an *EBDB* buffer, and the
lower-level
(cl-defmethod eieio-done-customizing ((f ebdb-field))
(let ((rec ebdb-custom-field-record))
(when rec
- (ebdb-record-insert-field rec f)
- (ebdb-redisplay-records rec 'reformat t))))
+ (ebdb-record-insert-field rec f))))
+
+(cl-defmethod eieio-done-customizing :after ((f ebdb-field))
+ (ebdb-redisplay-records rec 'reformat t))
+
+(cl-defmethod eieio-done-customizing :after ((mail ebdb-field-mail))
+ "Handle mail priority after customizing.
+Check that some mail is marked as primary after MAIL is edited."
+ (let* ((rec ebdb-custom-field-record)
+ (all-mails (remove mail (ebdb-record-mail rec)))
+ (primaries (when rec (seq-filter
+ (lambda (m)
+ (eq (slot-value m 'priority) 'primary))
+ all-mails)))
+ (prim (eq (slot-value mail 'priority) 'primary)))
+ (cond ((and prim primaries)
+ (dolist (p primaries)
+ (ebdb-record-change-field rec p (clone p :priority 'normal))))
+ ((and (null (or prim primaries))
+ (car-safe all-mails))
+ (ebdb-record-change-field
+ rec (car all-mails)
+ (clone (car all-mails) :priority 'primary))))))
;;;###autoload
(defun ebdb-edit-foo (record field)
- [elpa] externals/ebdb bbfdc70 04/15: Set mail priority on record creation, (continued)
- [elpa] externals/ebdb bbfdc70 04/15: Set mail priority on record creation, Eric Abrahamsen, 2018/04/01
- [elpa] externals/ebdb 5b4d834 01/15: Organization/role delete method needs to be an :around, Eric Abrahamsen, 2018/04/01
- [elpa] externals/ebdb 9ab7b56 07/15: Improvements to ebdb-edit-foo, Eric Abrahamsen, 2018/04/01
- [elpa] externals/ebdb a25e1eb 06/15: Use values from "slots" in role field ebdb-read, Eric Abrahamsen, 2018/04/01
- [elpa] externals/ebdb 9bd965b 02/15: Simplify ebdb-with-record-edits, Eric Abrahamsen, 2018/04/01
- [elpa] externals/ebdb 4bb77e3 11/15: Add mail deletion behavior, Eric Abrahamsen, 2018/04/01
- [elpa] externals/ebdb 27a1fa5 05/15: Move field manipulation "convenience logic" into ebdb-com, Eric Abrahamsen, 2018/04/01
- [elpa] externals/ebdb 70754b8 08/15: Fix unnecessary code in ebdb-follow-related, Eric Abrahamsen, 2018/04/01
- [elpa] externals/ebdb c3e06ee 12/15: Use quoted field class, Eric Abrahamsen, 2018/04/01
- [elpa] externals/ebdb a7e88d4 14/15: Update copyright dates, Eric Abrahamsen, 2018/04/01
- [elpa] externals/ebdb 7a5ce18 13/15: Handle mail priority after customization edits,
Eric Abrahamsen <=
- [elpa] externals/ebdb d60338c 15/15: Bump version to 0.5, Eric Abrahamsen, 2018/04/01
- [elpa] externals/ebdb b323307 09/15: Add a "follow related" action to role fields, Eric Abrahamsen, 2018/04/01
- [elpa] externals/ebdb dd2f73c 10/15: Change behavior of mail insertion, Eric Abrahamsen, 2018/04/01