[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ebdb ed6e228 136/350: Make ebdb-annotate-message more c
From: |
Eric Abrahamsen |
Subject: |
[elpa] externals/ebdb ed6e228 136/350: Make ebdb-annotate-message more class agnostic |
Date: |
Mon, 14 Aug 2017 11:46:22 -0400 (EDT) |
branch: externals/ebdb
commit ed6e2285a61f8ec3a75ba29ad97f1638df7aaf40
Author: Eric Abrahamsen <address@hidden>
Commit: Eric Abrahamsen <address@hidden>
Make ebdb-annotate-message more class agnostic
* ebdb-mua.el (ebdb-annotate-message): This function was previously
assuming person records, and complex names. Change so that it
doesn't need to know what kind of record it's annotating.
---
ebdb-mua.el | 59 +++++++++++++++++++++--------------------------------------
1 file changed, 21 insertions(+), 38 deletions(-)
diff --git a/ebdb-mua.el b/ebdb-mua.el
index 4c1dd68..e075800 100644
--- a/ebdb-mua.el
+++ b/ebdb-mua.el
@@ -865,6 +865,7 @@ Type q to quit updating records. No more search or
annotation is done.")
+;; I wonder if this could be somehow folded into snarfing.
(defun ebdb-annotate-message (address &optional update-p)
"Fill the records for message ADDRESS with as much info as possible.
If a record for ADDRESS does not yet exist, UPDATE-P controls whether
@@ -878,7 +879,7 @@ Return the records matching ADDRESS or nil."
(let* ((mail (nth 1 address)) ; possibly nil
(name (unless (or (equal mail (car address))
(null (car address)))
- (ebdb-string (ebdb-parse ebdb-default-name-class (car
address)))))
+ (car address)))
(records (ebdb-message-search name mail))
created-p new-records)
(if (and (not records) (functionp update-p))
@@ -909,28 +910,27 @@ Return the records matching ADDRESS or nil."
(dolist (record records)
(let* ((old-name (ebdb-record-name record))
- (fullname (ebdb-divide-name (or name "")))
- (fname (car fullname))
- (lname (cdr fullname))
(mail mail) ;; possibly changed below
(created-p created-p)
(update-p update-p)
+ (name-slot (ignore-errors
+ (car
+ (ebdb-record-field-slot-query
+ record
+ `(nil . ,(eieio-object-class
+ (ebdb-parse 'ebdb-field-name name)))))))
change-p add-mails add-name ignore-redundant)
;; Analyze the name part of the record.
(cond ((or (not name)
;; The following tests can differ for more complicated names
(ebdb-string= name old-name)
- (and (equal fname (ebdb-record-firstname record)) ; possibly
- (equal lname (ebdb-record-lastname record))) ; nil
- (member-ignore-case name (ebdb-record-aka record)))) ; do
nothing
+ (ebdb-record-search record 'ebdb-field-name name)) ; do
nothing
(created-p ; new record
(ebdb-record-change-name
record
- (make-instance ebdb-default-name-class
- :surname lname
- :given-names (when fname (list fname)))))
+ (ebdb-parse 'ebdb-field-name name)))
((not (setq add-name (ebdb-add-job ebdb-add-name record name))))
; do nothing
@@ -948,24 +948,25 @@ Return the records matching ADDRESS or nil."
name (car (ebdb-record-mail
record)))))
;; Keep old-name as AKA?
(when (and old-name
- (not (member-ignore-case old-name (ebdb-record-aka
record))))
+ name-slot
+ (not (member-ignore-case old-name
(ebdb-record-alt-names record))))
(if (ebdb-eval-spec (ebdb-add-job ebdb-add-aka record
old-name)
(format "Keep name \"%s\" as an AKA? "
old-name))
- (ebdb-record-set-field
- record 'aka (cons old-name (ebdb-record-aka record)))
- (ebdb-remhash old-name record)))
- (ebdb-record-set-field record 'name (cons fname lname))
+ (ebdb-record-insert-field
+ record name-slot (slot-value record 'name))))
+ (ebdb-record-change-name record (ebdb-parse 'ebdb-field-name
name))
(setq change-p 'name))
;; make new name an AKA?
((and old-name
- (not (member-ignore-case name (ebdb-record-aka record)))
+ name-slot
+ (not (member-ignore-case name (ebdb-record-alt-names
record)))
(ebdb-eval-spec (ebdb-add-job ebdb-add-aka record name)
(format "Make \"%s\" an alternate for
\"%s\"? "
name old-name)))
- (ebdb-record-set-field
- record 'aka (cons name (ebdb-record-aka record)))
- (setq change-p 'name)))
+ (ebdb-record-insert-field
+ record name-slot (ebdb-parse 'ebdb-field-name name))
+ (setq change-p 'name))))
;; Is MAIL redundant compared with the mail addresses
;; that are already known for RECORD?
@@ -1020,9 +1021,7 @@ Return the records matching ADDRESS or nil."
(ebdb-db-add-record (car ebdb-db-list) record)
(ebdb-record-change-name
record
- (make-instance ebdb-default-name-class
- :given-names (list fname)
- :surname lname))
+ (ebdb-parse 'ebdb-field-name name))
(setq created-p t))))
(let ((mails (ebdb-record-mail record)))
@@ -1208,22 +1207,6 @@ If ANNOTATION is an empty string and REPLACE is non-nil,
delete FIELD."
((not field) (setq field ebdb-annotate-field)))
(ebdb-record-change-field record field annotation))
-;; FIXME: For interactive calls of the following commands, the arg UPDATE-P
-;; should have the same meaning as for `ebdb-mua-display-records',
-;; that is, it should use `ebdb-mua-update-interactive-p'.
-;; But here the prefix arg is already used in a different way.
-;; We could possibly solve this problem if all `ebdb-mua-*' commands
-;; used another prefix arg that is consistently used only for
-;; `ebdb-mua-update-interactive-p'.
-;; Yet this prefix arg must be defined within the key space of the MUA(s).
-;; This results in lots of conflicts...
-;;
-;; Current workaround:
-;; These commands use merely the car of `ebdb-mua-update-interactive-p'.
-;; If one day someone proposes a smart solution to this problem (suggestions
-;; welcome!), this solution will hopefully include the current workaround
-;; as a subset of all its features.
-
(defun ebdb-mua-annotate-field-interactive ()
"Interactive specification for `ebdb-mua-annotate-sender' and friends."
(let ((field (if (eq 'all-fields ebdb-annotate-field)
- [elpa] externals/ebdb 05f67d6 081/350: Fix merging procedure, (continued)
- [elpa] externals/ebdb 05f67d6 081/350: Fix merging procedure, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 1ded570 086/350: Note new database-related commands in manual, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb ef673e2 094/350: Improve organization searching, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb bc71bda 099/350: Many fixes to migration routine, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 548e05d 106/350: Tweaks to MUA interactive commands, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb dd83c7e 115/350: Short-circuit ebdb-info, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb a0eada8 128/350: Change some of the EBDB buffer formatting defaults, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 20906ae 131/350: ebdb-prompt-for-record should load if necessary, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 1bc78ab 133/350: Add helm-ebdb file, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb ed3e270 119/350: Reverse order of args in return value of ebdb-popup-window, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb ed6e228 136/350: Make ebdb-annotate-message more class agnostic,
Eric Abrahamsen <=
- [elpa] externals/ebdb aa2d973 147/350: Allow optional records argument to ebdb-initialize, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 42f6dce 130/350: Add "Hacking EBDB" section to manual, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 5dda311 118/350: Force mode line update after renaming EBDB buffers, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb a94483d 122/350: Refinements to snarfing, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb d9b4865 146/350: More tweaks to snarfing process, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb b635b4e 155/350: First stab at article snarfing, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 6c267e9 159/350: Fix pop-up mouse menus in EBDB buffers, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 55b3f82 160/350: Fixup with fix popup menus, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb abdb8cd 158/350: Update copyright years to 2017, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 5fdf286 166/350: Feeding incorrect args to ebdb-snarf, Eric Abrahamsen, 2017/08/14