[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ebdb 8546047 2/3: Rename ebdb-record-name to ebdb-recor
From: |
Eric Abrahamsen |
Subject: |
[elpa] externals/ebdb 8546047 2/3: Rename ebdb-record-name to ebdb-record-name-string |
Date: |
Sun, 19 Apr 2020 17:46:24 -0400 (EDT) |
branch: externals/ebdb
commit 854604719c8dada0f44015c96663f23f891f4daa
Author: Eric Abrahamsen <address@hidden>
Commit: Eric Abrahamsen <address@hidden>
Rename ebdb-record-name to ebdb-record-name-string
To make it clearer that it returns a string, not a name class
instance, and that it's a record-cache accessor.
* ebdb.el (ebdb-record-name): Delete this method.
(ebdb-record-name-string): Define with `define-inline', access cache
slot.
* ebdb-com.el:
* ebdb-format.el:
* ebdb-html.el:
* ebdb-ispell.el:
* ebdb-mua.el:
* ebdb-org.el:
* ebdb-vcard.el:
* ebdb-vm.el: Change all callers.
---
ebdb-com.el | 37 +++++++++++++++++---------------
ebdb-format.el | 2 +-
ebdb-html.el | 2 +-
ebdb-ispell.el | 2 +-
ebdb-migrate.el | 2 +-
ebdb-mua.el | 8 +++----
ebdb-org.el | 2 +-
ebdb-vcard.el | 12 ++++++-----
ebdb-vm.el | 2 +-
ebdb.el | 65 +++++++++++++++++++++++++++++++--------------------------
10 files changed, 72 insertions(+), 62 deletions(-)
diff --git a/ebdb-com.el b/ebdb-com.el
index 7b74efa..8fee692 100644
--- a/ebdb-com.el
+++ b/ebdb-com.el
@@ -664,7 +664,7 @@ record that actually owns the field."
(with-slots (mail defunct) field
(let* ((rec-string
(condition-case nil
- (ebdb-record-name
+ (ebdb-record-name-string
(ebdb-record-related record field))
(ebdb-related-unfound "record not loaded")))
(value (if mail
@@ -706,7 +706,7 @@ record that actually owns the field."
(concat
(ebdb-record-db-char-string record)
" "
- (propertize (ebdb-record-name record)
+ (propertize (ebdb-record-name-string record)
'face (cdr (assoc record-class
ebdb-name-face-alist))))
;; We don't actually ask the name field to format itself, just use
@@ -1354,7 +1354,8 @@ database."
(popup-menu
(append
(list
- (format "Commands for record \"%s\":" (ebdb-record-name record))
+ (format "Commands for record \"%s\":"
+ (ebdb-record-name-string record))
["Delete Record" ebdb-delete-records t]
["Toggle Record Display Layout" ebdb-toggle-records-format t]
["Fully Display Record" ebdb-display-records-completely t]
@@ -2399,13 +2400,13 @@ The search results are displayed in the EBDB buffer
using formatter FMT."
(dolist (record (ebdb-records))
(when (and (memq 'name fields)
- (ebdb-record-name record)
- (setq hash (ebdb-gethash (ebdb-record-name record)
+ (ebdb-record-name-string record)
+ (setq hash (ebdb-gethash (ebdb-record-name-string record)
'(fl-name lf-name aka)))
(> (length hash) 1))
(setq ret (append hash ret))
(message "EBDB record `%s' has duplicate name."
- (ebdb-record-name record))
+ (ebdb-record-name-string record))
(sit-for 0))
(if (memq 'mail fields)
@@ -2414,7 +2415,7 @@ The search results are displayed in the EBDB buffer using
formatter FMT."
(when (> (length hash) 1)
(setq ret (append hash ret))
(message "EBDB record `%s' has duplicate mail `%s'."
- (ebdb-record-name record) mail)
+ (ebdb-record-name-string record) mail)
(sit-for 0))))
(if (and (memq 'aka fields)
@@ -2425,7 +2426,7 @@ The search results are displayed in the EBDB buffer using
formatter FMT."
(when (> (length hash) 1)
(setq ret (append hash ret))
(message "EBDB record `%s' has duplicate aka `%s'"
- (ebdb-record-name record) aka)
+ (ebdb-record-name-string record) aka)
(sit-for 0)))))
(ebdb-display-records (sort (delete-dups ret)
@@ -2768,14 +2769,15 @@ as part of the MUA insinuation."
;; Do we have a preferential order for the following tests?
;; (1) If ORIG matches name, AKA, or organization of ONE-RECORD,
;; then ADDRESS will be the first mail address of ONE-RECORD.
- (if (try-completion orig
- (append
- (if (memq 'name completion-list)
- (list (or (ebdb-record-name one-record)
"")))
- (if (memq 'alt-names completion-list)
- (or (ebdb-record-alt-names one-record)
(list "")))
- (if (memq 'organization completion-list)
- (ebdb-record-organizations one-record))))
+ (if (try-completion
+ orig
+ (append
+ (if (memq 'name completion-list)
+ (list (or (ebdb-record-name-string one-record) "")))
+ (if (memq 'alt-names completion-list)
+ (or (ebdb-record-alt-names one-record) (list "")))
+ (if (memq 'organization completion-list)
+ (ebdb-record-organizations one-record))))
(setq mail (car mails)))
;; (2) If ORIG matches one or multiple mail addresses of
ONE-RECORD,
;; then we take the first one matching ORIG.
@@ -2823,7 +2825,8 @@ as part of the MUA insinuation."
(when mails
(dolist (field completion-list)
(cond ((eq field 'name)
- (if (ebdb-string= key (ebdb-record-name record))
+ (if (ebdb-string= key
+ (ebdb-record-name-string record))
(push (car mails) accept)))
((eq field 'alt-names)
(if (member-ignore-case
diff --git a/ebdb-format.el b/ebdb-format.el
index ac6954d..4156a36 100644
--- a/ebdb-format.el
+++ b/ebdb-format.el
@@ -473,7 +473,7 @@ multiple instances in a single alist."
(with-slots (field-separator) fmt
(concat
- (ebdb-record-name rec)
+ (ebdb-record-name-string rec)
field-separator
(mapconcat
(lambda (f)
diff --git a/ebdb-html.el b/ebdb-html.el
index dc3ef27..3185c89 100644
--- a/ebdb-html.el
+++ b/ebdb-html.el
@@ -56,7 +56,7 @@
header-fields)
(concat
"<header>\n"
- (format "<h1>%s</h1>\n" (ebdb-record-name rec))
+ (format "<h1>%s</h1>\n" (ebdb-record-name-string rec))
(mapconcat
(pcase-lambda ((map style inst _class))
(format "<p>%s</p>" (mapconcat (lambda (f) (ebdb-fmt-field fmt f style
rec)) inst ", ")))
diff --git a/ebdb-ispell.el b/ebdb-ispell.el
index a8768ea..3a044bb 100644
--- a/ebdb-ispell.el
+++ b/ebdb-ispell.el
@@ -46,7 +46,7 @@
(seq-mapcat
(lambda (r)
(ebdb-ispell-collect-words
- (cons (ebdb-record-name r)
+ (cons (ebdb-record-name-string r)
(ebdb-record-alt-names r))))
(ebdb-records)))
(count 0))
diff --git a/ebdb-migrate.el b/ebdb-migrate.el
index 0e4c544..f8ee5da 100644
--- a/ebdb-migrate.el
+++ b/ebdb-migrate.el
@@ -410,7 +410,7 @@ BBDB sets the default of that option."
(setq org (or (seq-find
(lambda (r)
(and (ebdb-record-organization-p r)
- (string= o (ebdb-record-name r))))
+ (string= o (ebdb-record-name-string
r))))
c-records)
(let ((time (current-time)))
(ebdb-db-add-record
diff --git a/ebdb-mua.el b/ebdb-mua.el
index e3e9c88..c3f8bb8 100644
--- a/ebdb-mua.el
+++ b/ebdb-mua.el
@@ -974,7 +974,7 @@ Return the records matching ADDRESS or nil."
(ebdb-db-add-record (ebdb-prompt-for-db nil t) (car records))))
(dolist (record records)
- (let* ((old-name (ebdb-record-name record))
+ (let* ((old-name (ebdb-record-name-string record))
(mail mail) ;; possibly changed below
(created-p created-p)
(update-p update-p)
@@ -1095,7 +1095,7 @@ Return the records matching ADDRESS or nil."
(let ((form (format "redundant mail%s %s"
(if (< 1 (length redundant)) "s"
"")
(ebdb-concat 'mail (nreverse
redundant))))
- (name (ebdb-record-name record)))
+ (name (ebdb-record-name-string record)))
(if redundant
(cond ((numberp ignore-redundant)
(unless ebdb-silent
@@ -1116,7 +1116,7 @@ Return the records matching ADDRESS or nil."
(cond (created-p
(unless ebdb-silent
- (if (ebdb-record-name record)
+ (if (ebdb-record-name-string record)
(message "created %s's record with address \"%s\""
(ebdb-string record)
(ebdb-string mail))
@@ -1129,7 +1129,7 @@ Return the records matching ADDRESS or nil."
(unless ebdb-silent
(cond ((eq change-p 'name)
(message "noticed \"%s\"" (ebdb-string record)))
- ((ebdb-record-name record)
+ ((ebdb-record-name-string record)
(message "noticed %s's address \"%s\""
(ebdb-string record)
(ebdb-string mail)))
diff --git a/ebdb-org.el b/ebdb-org.el
index 8f49dc8..0743bd7 100644
--- a/ebdb-org.el
+++ b/ebdb-org.el
@@ -83,7 +83,7 @@
(when (eq major-mode 'ebdb-mode)
(let* ((rec (ebdb-current-record))
(uuid (ebdb-record-uuid rec))
- (name (ebdb-record-name rec))
+ (name (ebdb-record-name-string rec))
(link (format "ebdb:uuid/%s" uuid)))
(with-no-warnings
(funcall (if (fboundp 'org-link-store-props)
diff --git a/ebdb-vcard.el b/ebdb-vcard.el
index 7ba0217..5ffc0e7 100644
--- a/ebdb-vcard.el
+++ b/ebdb-vcard.el
@@ -201,17 +201,19 @@ All this does is split role instances into multiple
fields."
;; stick a UUID somewhere, but haven't immediately
;; figured out how that would be done.
(push (cons "ORG"
- (ebdb-record-name org))
+ (ebdb-record-name-string org))
out-list)
- (push (cons (format "TITLE;TYPE=\"%s\"" (ebdb-record-name org))
+ (push (cons (format "TITLE;TYPE=\"%s\""
+ (ebdb-record-name-string org))
(slot-value f 'label))
out-list)
(when (or mail fields)
(dolist (elt (cons mail fields))
(push (cons
- (format "%s;%s"
- (ebdb-fmt-field-label fmt elt 'normal record)
- (format "TYPE=\"%s\"" (ebdb-record-name org)))
+ (format
+ "%s;%s"
+ (ebdb-fmt-field-label fmt elt 'normal record)
+ (format "TYPE=\"%s\"" (ebdb-record-name-string org)))
(ebdb-fmt-field fmt elt 'normal record))
out-list)))))
(push f out-list)))
diff --git a/ebdb-vm.el b/ebdb-vm.el
index 09552b1..a0692bf 100644
--- a/ebdb-vm.el
+++ b/ebdb-vm.el
@@ -108,7 +108,7 @@ Respect `vm-summary-uninteresting-senders'."
(record (car (ebdb-message-search (car data) (cadr data)))))
(if record
(or (ebdb-record-xfield record 'mail-name)
- (ebdb-record-name record))))))
+ (ebdb-record-name-string record))))))
diff --git a/ebdb.el b/ebdb.el
index e12b7e5..a8e1e0d 100644
--- a/ebdb.el
+++ b/ebdb.el
@@ -850,6 +850,10 @@ The test for presence of ELEMENT is done with `equal'."
:abstract t :documentation "Abstract class for EBDB fields.
Subclass this to produce real field types.")
+(define-inline ebdb-record-name-string (record)
+ "Record cache function: return RECORD's name as a string."
+ (slot-value (ebdb-record-cache record) 'name-string))
+
(cl-defgeneric ebdb-init-field (field record)
"Initialize FIELD.
What this means is entirely dependent upon the field class in
@@ -1422,7 +1426,7 @@ first one."
(record-uuid (ebdb-record-uuid record))
(org-string
(condition-case nil
- (ebdb-record-name
+ (ebdb-record-name-string
(ebdb-record-related record role))
(ebdb-related-unfound
"record not loaded"))))
@@ -1451,7 +1455,7 @@ first one."
(let* ((org-uuid (slot-value role 'org-uuid))
(org-string
(condition-case nil
- (ebdb-record-name
+ (ebdb-record-name-string
(ebdb-record-related record role))
(ebdb-related-unfound
nil)))
@@ -1493,7 +1497,7 @@ first one."
;; later.
(let ((rec (ebdb-gethash (slot-value role 'record-uuid) 'uuid)))
(condition-case nil
- (ebdb-record-name
+ (ebdb-record-name-string
(ebdb-record-related rec role))
(ebdb-related-unfound
"record not loaded"))))
@@ -2963,22 +2967,13 @@ only return fields that are suitable for user editing.")
(push (cons 'notes notes) f-list)))
f-list)
-;; TODO: rename this to `ebdb-record-name-string', it's confusing.
-(cl-defmethod ebdb-record-name ((record ebdb-record))
- "Get or set-and-get the cached name string of RECORD."
- (let ((cached (slot-value (ebdb-record-cache record) 'name-string)))
- (or cached
- (and (slot-value record 'name)
- (setf (slot-value (ebdb-record-cache record) 'name-string)
- (ebdb-string (slot-value record 'name)))))))
-
(cl-defmethod ebdb-record-alt-names ((record ebdb-record))
(slot-value (ebdb-record-cache record) 'alt-names))
(cl-defmethod cl-print-object ((record ebdb-record) stream)
(princ (format "#<%S %s>"
(eieio-object-class-name record)
- (ebdb-record-name record))
+ (ebdb-record-name-string record))
stream))
(cl-defgeneric ebdb-record-related (record field)
@@ -3217,7 +3212,7 @@ If FIELD doesn't specify a year, use the current year."
(name ebdb-field-name))
(when (slot-value record 'name)
(ebdb-record-delete-field record (slot-value record 'name) 'name))
- (setf (slot-value (ebdb-record-cache record) 'name-string)
+ (setf (ebdb-record-name-string record)
(ebdb-string name))
(ebdb-record-insert-field record name 'name))
@@ -3283,7 +3278,7 @@ ARGS are passed to `ebdb-compose-mail', and then to
(cl-defmethod ebdb-string ((record ebdb-record-person))
"Return a readable string label for RECORD."
- (ebdb-record-name record))
+ (ebdb-record-name-string record))
(cl-defmethod ebdb-read ((class (subclass ebdb-record-person)) &optional slots)
"Read the name slot for a \"person\" record."
@@ -3294,7 +3289,9 @@ ARGS are passed to `ebdb-compose-mail', and then to
(cl-defmethod ebdb-init-record ((record ebdb-record-person))
(with-slots (name aka relations organizations) record
(when name
- (ebdb-init-field name record))
+ (ebdb-init-field name record)
+ (setf (ebdb-record-name-string record)
+ (ebdb-string name)))
(dolist (f (append aka relations organizations))
(ebdb-init-field f record)))
(cl-call-next-method))
@@ -3327,15 +3324,20 @@ ARGS are passed to `ebdb-compose-mail', and then to
(unless (equal rname lname)
(let ((prefix (format "Merging %s with %s:"
- (ebdb-record-name right)
- (ebdb-record-name left))))
- (if (yes-or-no-p (format "%s Use %s as primary name? " prefix
(ebdb-record-name right)))
- (progn
- (ebdb-record-change-name left rname)
- (when (yes-or-no-p (format "%s Keep %s as an aka? " prefix
(ebdb-record-name left)))
- (object-add-to-list left 'aka lname)))
- (when (yes-or-no-p (format "%s Keep %s as an aka? " prefix
(ebdb-record-name right)))
- (object-add-to-list left 'aka rname))))))
+ (ebdb-record-name-string right)
+ (ebdb-record-name-string left))))
+ (if (yes-or-no-p (format "%s Use %s as primary name? "
+ prefix (ebdb-record-name-string right)))
+ (progn
+ (ebdb-record-change-name left rname)
+ (when (yes-or-no-p
+ (format "%s Keep %s as an aka? "
+ prefix (ebdb-record-name-string left)))
+ (object-add-to-list left 'aka lname)))
+ (when (yes-or-no-p
+ (format "%s Keep %s as an aka? "
+ prefix (ebdb-record-name-string right)))
+ (object-add-to-list left 'aka rname))))))
(setf (slot-value left 'relations)
(delete-dups (append rrelations lrelations)))
@@ -3475,6 +3477,8 @@ FIELD."
(cl-defmethod ebdb-init-record ((record ebdb-record-organization))
(let ((name (slot-value record 'name)))
(ebdb-init-field name record)
+ (setf (ebdb-record-name-string record)
+ (ebdb-string name)))
(cl-call-next-method)))
(cl-defmethod ebdb-delete-record ((org ebdb-record-organization) &optional _db
unload)
@@ -3493,7 +3497,7 @@ FIELD."
(cl-defmethod ebdb-string ((record ebdb-record-organization))
"Return a string representation of RECORD."
- (ebdb-record-name record))
+ (ebdb-record-name-string record))
(cl-defmethod ebdb-read ((class (subclass ebdb-record-organization)) &optional
slots)
(let ((name (ebdb-read 'ebdb-field-name-simple slots
@@ -3551,7 +3555,7 @@ FIELD."
(cl-defmethod ebdb-record-search ((record ebdb-record-organization)
(_type (eql organization))
(regex string))
- (or (string-match-p regex (ebdb-record-name record))
+ (or (string-match-p regex (ebdb-record-name-string record))
(and (slot-value record 'domain)
(string-match-p regex (ebdb-string (slot-value record 'domain))))))
@@ -4492,7 +4496,8 @@ to use."
(unless (ebdb-field-mail-p mail)
(setq mail (ebdb-record-one-mail record (eq mail 'prompt) t)))
(unless mail (error "Record has no mail addresses"))
- (let* ((name-base (or (slot-value mail 'aka) (ebdb-record-name record)))
+ (let* ((name-base (or (slot-value mail 'aka)
+ (ebdb-record-name-string record)))
(mail (slot-value mail 'mail))
(name
(cond
@@ -4957,7 +4962,7 @@ single record, otherwise returns a list."
"Throw `ebdb-hash-ok' non-nil if KEY matches RECORD acording to PREDICATE.
PREDICATE may take the same values as the elements of `ebdb-completion-list'."
(if (and (seq-intersection '(name ebdb-field-name) predicate)
- (ebdb-string= key (or (ebdb-record-name record) "")))
+ (ebdb-string= key (or (ebdb-record-name-string record) "")))
(throw 'ebdb-hash-ok 'name))
(if (seq-intersection '(organization ebdb-field-role) predicate)
(mapc (lambda (organization) (if (ebdb-string= key organization)
@@ -5602,7 +5607,7 @@ values, by default the search is not handed to the name
field itself."
(cl-defmethod ebdb-record-search ((record ebdb-record)
(_type (subclass ebdb-field-name))
(regexp string))
- (or (string-match-p regexp (or (ebdb-record-name record) ""))
+ (or (string-match-p regexp (or (ebdb-record-name-string record) ""))
(seq-find
(lambda (n)
(string-match-p regexp n))