[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ebdb 49a2e8d 03/12: Make "record" argument to field ini
From: |
Eric Abrahamsen |
Subject: |
[elpa] externals/ebdb 49a2e8d 03/12: Make "record" argument to field init and delete non-optional |
Date: |
Tue, 12 Jun 2018 22:06:10 -0400 (EDT) |
branch: externals/ebdb
commit 49a2e8d4823f46ad76f09d58efc1a758da2f8601
Author: Eric Abrahamsen <address@hidden>
Commit: Eric Abrahamsen <address@hidden>
Make "record" argument to field init and delete non-optional
* ebdb.el (ebdb-init-field, ebdb-delete-field): There is no location
where we're not passing in the record, and we want to be able to
specialize on it. Change for all definitions.
* ebdb-mua.el (ebdb-init-field, ebdb-delete-field): And here.
* ebdb-i18n.el (ebdb-init-field, ebdb-delete-field): Same for the
extra methods here.
---
ebdb-i18n.el | 4 +-
ebdb-mua.el | 7 +--
ebdb.el | 177 +++++++++++++++++++++++++++++------------------------------
ebdb.org | 2 +-
4 files changed, 92 insertions(+), 98 deletions(-)
diff --git a/ebdb-i18n.el b/ebdb-i18n.el
index a311b19..99a5a95 100644
--- a/ebdb-i18n.el
+++ b/ebdb-i18n.el
@@ -823,7 +823,7 @@ for their symbol representations."
(cl-no-method nil)))
str))
-(cl-defmethod ebdb-init-field :extra "i18n" ((name ebdb-field-name) &optional
record)
+(cl-defmethod ebdb-init-field :extra "i18n" ((name ebdb-field-name) record)
"Do additional initialization work for international names."
(let* ((res (cl-call-next-method name record))
(str (ebdb-string name))
@@ -834,7 +834,7 @@ for their symbol representations."
(cl-no-method nil)))
res))
-(cl-defmethod ebdb-delete-field :extra "i18n" ((name ebdb-field-name)
&optional record unload)
+(cl-defmethod ebdb-delete-field :extra "i18n" ((name ebdb-field-name) record
&optional unload)
"Do additional deletion work for international names."
(let* ((str (ebdb-string name))
(script (aref char-script-table (aref str 0))))
diff --git a/ebdb-mua.el b/ebdb-mua.el
index 515907b..f82d49e 100644
--- a/ebdb-mua.el
+++ b/ebdb-mua.el
@@ -536,8 +536,7 @@ variable should be set before EBDB is loaded.")
(setq slots (plist-put slots :folder str)))
(cl-call-next-method c str slots))
-(cl-defmethod ebdb-init-field ((f ebdb-field-mail-folder)
- &optional record)
+(cl-defmethod ebdb-init-field ((f ebdb-field-mail-folder) record)
(when record
(let* ((folder (slot-value f 'folder))
(mails (mapcar #'regexp-quote (ebdb-record-mail-canon record)))
@@ -551,8 +550,8 @@ variable should be set before EBDB is loaded.")
ebdb-mail-folder-list)))))
(cl-call-next-method))
-(cl-defmethod ebdb-delete-field ((f ebdb-field-mail-folder)
- &optional record _unload)
+(cl-defmethod ebdb-delete-field ((f ebdb-field-mail-folder) record
+ &optional _unload)
(when record
(let* ((folder (slot-value f 'folder))
(mails (mapcar #'regexp-quote (ebdb-record-mail-canon record)))
diff --git a/ebdb.el b/ebdb.el
index 885f073..0ef1816 100644
--- a/ebdb.el
+++ b/ebdb.el
@@ -1037,7 +1037,7 @@ process."
(setf (slot-value field 'object-name) label))
field))
-(cl-defmethod ebdb-init-field ((field ebdb-field-labeled) &optional _record)
+(cl-defmethod ebdb-init-field ((field ebdb-field-labeled) _record)
"Add FIELD's label to its class label list."
(let ((label-var (slot-value field 'label-list)))
(ebdb-add-to-list label-var (slot-value field 'object-name))
@@ -1254,30 +1254,30 @@ first one."
;; value also gets stored in the cache.
(ebdb-name-fl name t))
-(cl-defmethod ebdb-init-field ((name ebdb-field-name-complex) &optional record)
- (when record
- (let ((lf-full (ebdb-name-lf name t))
- (fl-full (ebdb-name-fl name t))
- (fl (ebdb-name-fl name)))
- (ebdb-puthash lf-full record)
- (ebdb-puthash fl-full record)
- ;; Also hash against "first last", as an alternate search
- ;; strategy.
- (ebdb-puthash fl record)
- (object-add-to-list (ebdb-record-cache record) 'alt-names lf-full)
- (object-add-to-list (ebdb-record-cache record) 'alt-names fl-full)))
+(cl-defmethod ebdb-init-field ((name ebdb-field-name-complex) record)
+ (let ((lf-full (ebdb-name-lf name t))
+ (fl-full (ebdb-name-fl name t))
+ (fl (ebdb-name-fl name)))
+ (ebdb-puthash lf-full record)
+ (ebdb-puthash fl-full record)
+ ;; Also hash against "first last", as an alternate search
+ ;; strategy.
+ (ebdb-puthash fl record)
+ (object-add-to-list (ebdb-record-cache record) 'alt-names lf-full)
+ (object-add-to-list (ebdb-record-cache record) 'alt-names fl-full)
+ (object-add-to-list (ebdb-record-cache record 'alt-names fl)))
(cl-call-next-method))
-(cl-defmethod ebdb-delete-field ((name ebdb-field-name-complex) &optional
record _unload)
- (when record
- (let ((lf-full (ebdb-name-lf name t))
- (fl-full (ebdb-name-fl name t))
- (fl (ebdb-name-fl name)))
- (ebdb-remhash lf-full record)
- (ebdb-remhash fl-full record)
- (ebdb-remhash fl record)
- (object-remove-from-list (ebdb-record-cache record) 'alt-names lf-full)
- (object-remove-from-list (ebdb-record-cache record) 'alt-names fl-full)))
+(cl-defmethod ebdb-delete-field ((name ebdb-field-name-complex) record
&optional _unload)
+ (let ((lf-full (ebdb-name-lf name t))
+ (fl-full (ebdb-name-fl name t))
+ (fl (ebdb-name-fl name)))
+ (ebdb-remhash lf-full record)
+ (ebdb-remhash fl-full record)
+ (ebdb-remhash fl record)
+ (object-remove-from-list (ebdb-record-cache record) 'alt-names lf-full)
+ (object-remove-from-list (ebdb-record-cache record) 'alt-names fl-full)
+ (object-remove-from-list (ebdb-record-cache record) 'atl-names fl))
(cl-call-next-method))
(cl-defmethod ebdb-read ((class (subclass ebdb-field-name-complex)) &optional
slots obj)
@@ -1344,61 +1344,59 @@ first one."
might be relevant to the role."
:human-readable "role")
-(cl-defmethod ebdb-init-field ((role ebdb-field-role) &optional record)
- (when record
- (with-slots (org-uuid mail (role-record-uuid record-uuid)) role
- (let* (;; TODO: Guard against org-entry not being found.
- (org-entry (gethash org-uuid ebdb-org-hashtable))
- (record-uuid (ebdb-record-uuid record))
- (org-string
- (condition-case nil
- (ebdb-record-name
- (ebdb-record-related record role))
- (ebdb-related-unfound
- "record not loaded"))))
-
- ;; Setting the 'record-uuid slot value when it wasn't set before
- ;; technically means that the record is now "dirty". That's
- ;; okay in our current database implementation, because
- ;; `ebdb-record-insert-field' first calls
- ;; `ebdb-db-add-record-field', which sets the record "dirty",
- ;; and then calls this `ebdb-init' method -- ie, record is
- ;; "dirty" when we get here. Theoretically, however, nothing in
- ;; `ebdb-init-field' should change a record's slots.
- (unless role-record-uuid
- (setf role-record-uuid record-uuid))
- (object-add-to-list (ebdb-record-cache record) 'organizations
org-string)
- ;; Init the role mail against the record.
- (when (and mail (slot-value mail 'mail))
- (ebdb-init-field mail record))
- ;; Make sure this role is in the `ebdb-org-hashtable'.
- (unless (member role org-entry)
- (push role org-entry))
- (puthash org-uuid org-entry ebdb-org-hashtable))))
- (cl-call-next-method))
-
-(cl-defmethod ebdb-delete-field ((role ebdb-field-role) &optional record
unload)
- (when record
- (let* ((org-uuid (slot-value role 'org-uuid))
+(cl-defmethod ebdb-init-field ((role ebdb-field-role) record)
+ (with-slots (org-uuid mail (role-record-uuid record-uuid)) role
+ (let* (;; TODO: Guard against org-entry not being found.
+ (org-entry (gethash org-uuid ebdb-org-hashtable))
+ (record-uuid (ebdb-record-uuid record))
(org-string
(condition-case nil
(ebdb-record-name
(ebdb-record-related record role))
(ebdb-related-unfound
- nil)))
- (org-entry (gethash org-uuid ebdb-org-hashtable))
- (record-uuid (ebdb-record-uuid record)))
- (setq org-entry (delete role org-entry))
- (if org-entry
- (puthash org-uuid org-entry ebdb-org-hashtable)
- (remhash org-uuid ebdb-org-hashtable))
- (when (and org-string
- (null (assoc-string
- record-uuid
- (object-assoc-list 'record-uuid org-entry))))
- ;; RECORD no long has any roles at ORG.
- (object-remove-from-list (ebdb-record-cache record)
- 'organizations org-string))))
+ "record not loaded"))))
+
+ ;; Setting the 'record-uuid slot value when it wasn't set before
+ ;; technically means that the record is now "dirty". That's
+ ;; okay in our current database implementation, because
+ ;; `ebdb-record-insert-field' first calls
+ ;; `ebdb-db-add-record-field', which sets the record "dirty",
+ ;; and then calls this `ebdb-init' method -- ie, record is
+ ;; "dirty" when we get here. Theoretically, however, nothing in
+ ;; `ebdb-init-field' should change a record's slots.
+ (unless role-record-uuid
+ (setf role-record-uuid record-uuid))
+ (object-add-to-list (ebdb-record-cache record) 'organizations org-string)
+ ;; Init the role mail against the record.
+ (when (and mail (slot-value mail 'mail))
+ (ebdb-init-field mail record))
+ ;; Make sure this role is in the `ebdb-org-hashtable'.
+ (unless (member role org-entry)
+ (push role org-entry))
+ (puthash org-uuid org-entry ebdb-org-hashtable)))
+ (cl-call-next-method))
+
+(cl-defmethod ebdb-delete-field ((role ebdb-field-role) record &optional
unload)
+ (let* ((org-uuid (slot-value role 'org-uuid))
+ (org-string
+ (condition-case nil
+ (ebdb-record-name
+ (ebdb-record-related record role))
+ (ebdb-related-unfound
+ nil)))
+ (org-entry (gethash org-uuid ebdb-org-hashtable))
+ (record-uuid (ebdb-record-uuid record)))
+ (setq org-entry (delete role org-entry))
+ (if org-entry
+ (puthash org-uuid org-entry ebdb-org-hashtable)
+ (remhash org-uuid ebdb-org-hashtable))
+ (when (and org-string
+ (null (assoc-string
+ record-uuid
+ (object-assoc-list 'record-uuid org-entry))))
+ ;; RECORD no long has any roles at ORG.
+ (object-remove-from-list (ebdb-record-cache record)
+ 'organizations org-string)))
(when (slot-value role 'mail)
(ebdb-delete-field (slot-value role 'mail) record unload))
(cl-call-next-method))
@@ -1466,7 +1464,7 @@ first one."
The optional \"object-name\" slot can serve as a mail aka."
:human-readable "mail")
-(cl-defmethod ebdb-init-field ((field ebdb-field-mail) &optional record)
+(cl-defmethod ebdb-init-field ((field ebdb-field-mail) record)
(with-slots (aka mail) field
(ebdb-puthash mail record)
(object-add-to-list (ebdb-record-cache record) 'mail-canon mail)
@@ -1474,14 +1472,13 @@ first one."
(ebdb-puthash aka record)
(object-add-to-list (ebdb-record-cache record) 'mail-aka aka))))
-(cl-defmethod ebdb-delete-field ((field ebdb-field-mail) &optional record
_unload)
+(cl-defmethod ebdb-delete-field ((field ebdb-field-mail) record &optional
_unload)
(with-slots (aka mail) field
- (when record
- (when aka
- (ebdb-remhash aka record)
- (object-remove-from-list (ebdb-record-cache record) 'mail-aka aka))
- (ebdb-remhash mail record)
- (object-remove-from-list (ebdb-record-cache record) 'mail-canon mail)))
+ (when aka
+ (ebdb-remhash aka record)
+ (object-remove-from-list (ebdb-record-cache record) 'mail-aka aka))
+ (ebdb-remhash mail record)
+ (object-remove-from-list (ebdb-record-cache record) 'mail-canon mail))
(cl-call-next-method))
(cl-defmethod ebdb-string ((mail ebdb-field-mail))
@@ -1580,7 +1577,7 @@ Primary sorts before normal sorts before defunct."
:documentation "A field representing an address."
:human-readable "address")
-(cl-defmethod ebdb-init-field ((address ebdb-field-address) &optional _record)
+(cl-defmethod ebdb-init-field ((address ebdb-field-address) _record)
(with-slots (object-name streets locality region postcode country) address
(dolist (s streets)
(ebdb-add-to-list 'ebdb-street-list s))
@@ -1940,17 +1937,15 @@ Eventually this method will go away."
str))
;; `ebdb-field-anniv-diary-entry' is defined below.
-(cl-defmethod ebdb-init-field ((anniv ebdb-field-anniversary) &optional record)
- (when (and ebdb-use-diary
- record)
+(cl-defmethod ebdb-init-field ((anniv ebdb-field-anniversary) record)
+ (when ebdb-use-diary
(add-to-list
'ebdb-diary-entries
(ebdb-field-anniv-diary-entry anniv record))))
(cl-defmethod ebdb-delete-field ((anniv ebdb-field-anniversary)
- &optional record _unload)
- (when (and ebdb-use-diary
- record)
+ record &optional _unload)
+ (when ebdb-use-diary
(setq
ebdb-diary-entries
(delete (ebdb-field-anniv-diary-entry anniv record)
@@ -2317,7 +2312,7 @@ See `ebdb-url-valid-schemes' for a list of acceptable
schemes."
(add-to-list 'ebdb-tags tag)
(ebdb-puthash tag record))))
-(cl-defmethod ebdb-delete-field ((field ebdb-field-tags) &optional record
_unload)
+(cl-defmethod ebdb-delete-field ((field ebdb-field-tags) record &optional
_unload)
(dolist (tag (slot-value field 'tags))
(ebdb-remhash tag record)))
@@ -2364,7 +2359,7 @@ record uuids.")
"%s")
alias (ebdb-string address))))
-(cl-defmethod ebdb-init-field ((field ebdb-field-mail-alias) &optional record)
+(cl-defmethod ebdb-init-field ((field ebdb-field-mail-alias) record)
(with-slots (alias address) field
(let ((existing (assoc alias ebdb-mail-alias-alist)))
(if existing
@@ -2372,7 +2367,7 @@ record uuids.")
(push (list alias (list record address)) ebdb-mail-alias-alist)))))
(cl-defmethod ebdb-delete-field ((field ebdb-field-mail-alias)
- &optional record _unload)
+ record &optional _unload)
(with-slots (alias address) field
(let* ((existing (assoc alias ebdb-mail-alias-alist))
(entry (assq record (cdr-safe existing))))
diff --git a/ebdb.org b/ebdb.org
index 6e17556..afaa69e 100644
--- a/ebdb.org
+++ b/ebdb.org
@@ -1405,7 +1405,7 @@ their fields.
Initialize @@texinfo:@var{field}@@ against @@texinfo:@var{record}@@.
#+END_deffn
-#+attr_texinfo: :options Method ebdb-delete-field field &optional record unload
+#+attr_texinfo: :options Method ebdb-delete-field field record &optional unload
#+BEGIN_deffn
Delete @@texinfo:@var{field}@@ of record @@texinfo:@var{record}@@. If
the optional argument @@texinfo:@var{unload}@@ is non-nil, it means
- [elpa] externals/ebdb updated (cadffb1 -> 60f8828), Eric Abrahamsen, 2018/06/12
- [elpa] externals/ebdb da1c6f6 01/12: Improve name parsing, Eric Abrahamsen, 2018/06/12
- [elpa] externals/ebdb 365fa1c 04/12: Add nicknames to person record cache 'alt-names, Eric Abrahamsen, 2018/06/12
- [elpa] externals/ebdb 9febf18 02/12: New command ebdb-save-ebdb, Eric Abrahamsen, 2018/06/12
- [elpa] externals/ebdb 91f0953 05/12: Let the typos begin!, Eric Abrahamsen, 2018/06/12
- [elpa] externals/ebdb b2b56f8 07/12: Fix to "add nicknames to person record cache", Eric Abrahamsen, 2018/06/12
- [elpa] externals/ebdb 60f8828 12/12: Bump and flush: 0.5.3, Eric Abrahamsen, 2018/06/12
- [elpa] externals/ebdb 140381f 09/12: Update README.org (#70), Eric Abrahamsen, 2018/06/12
- [elpa] externals/ebdb 49a2e8d 03/12: Make "record" argument to field init and delete non-optional,
Eric Abrahamsen <=
- [elpa] externals/ebdb 5f00a46 10/12: Tweak default formatter settings, Eric Abrahamsen, 2018/06/12
- [elpa] externals/ebdb 7d20db4 06/12: Further improvements to snarfing, Eric Abrahamsen, 2018/06/12
- [elpa] externals/ebdb b89a009 08/12: Move defmethods beneath all classes used as specializers, Eric Abrahamsen, 2018/06/12
- [elpa] externals/ebdb 8ef0b9c 11/12: Document customization options for *EBDB* buffer display, Eric Abrahamsen, 2018/06/12