branch: externals/ebdb
commit c4ea244879931717dcb24d75521ff9c29e6f9f07
Author: Eric Abrahamsen <[email protected]>
Commit: Eric Abrahamsen <[email protected]>
Add new ebdb-field-id field
* ebdb.el (ebdb-field-id): Inherits ebdb-field-obfuscated, so won't
display in the *EBDB* buffer. Inherits ebdb-field-labeled.
(ebdb-id-label-list): Label list for field instances.
---
ebdb.el | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/ebdb.el b/ebdb.el
index b8c1d60..cf68f60 100644
--- a/ebdb.el
+++ b/ebdb.el
@@ -1451,6 +1451,32 @@ override parsing."
(calendar-gregorian-from-absolute (slot-value ann 'date))
nil t))
+;;; Id field
+
+;; Used for recording an ID or tax id number. Ie, national
+;; identification numbers, SSNs, TINs, UTRs, and so on.
+
+(defvar ebdb-id-label-list '("SSN" "TIN" "ID" "UTR")
+ "List of known ID labels.")
+
+(defclass ebdb-field-id (ebdb-field-labeled ebdb-field-obfuscated
ebdb-field-user)
+ ((label-list :initform ebdb-id-label-list)
+ (id-number
+ :type string
+ :custom string
+ :initarg :id-number
+ :initform ""
+ :documentation "The ID number itself."))
+ :human-readable "id number")
+
+(cl-defmethod ebdb-read ((class (subclass ebdb-field-id)) &optional slots obj)
+ (let ((id-number (ebdb-read-string "ID number: "
+ (when obj (slot-value obj 'id-number)))))
+ (cl-call-next-method class (plist-put slots :id-number id-number) obj)))
+
+(cl-defmethod ebdb-string ((field ebdb-field-id))
+ (slot-value field 'id-number))
+
;;; Relationship field
;; This is a bit different from the organization role field, mostly