[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ebdb 0539addcbd 1/3: Look for comments in BBDB phone nu
From: |
Eric Abrahamsen |
Subject: |
[elpa] externals/ebdb 0539addcbd 1/3: Look for comments in BBDB phone numbers during migration |
Date: |
Sun, 20 Mar 2022 20:08:08 -0400 (EDT) |
branch: externals/ebdb
commit 0539addcbd0decb528370b75ab753e7ffc010d29
Author: Eric Abrahamsen <eric@ericabrahamsen.net>
Commit: Eric Abrahamsen <eric@ericabrahamsen.net>
Look for comments in BBDB phone numbers during migration
* ebdb-migrate.el (ebdb-migrate-vector-to-class): The plain-string
form of BBDB phone numbers allowed random text after the number; draw
that out and put it in the 'comment slot.
---
ebdb-migrate.el | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/ebdb-migrate.el b/ebdb-migrate.el
index dea2e521e7..6e96b48c45 100644
--- a/ebdb-migrate.el
+++ b/ebdb-migrate.el
@@ -493,10 +493,19 @@ BBDB sets the default of that option."
(when phone
(dolist (p phone)
(let ((label (aref p 0))
- instance)
+ instance comment)
(setq instance
(if (= 2 (length p))
- (ebdb-parse ebdb-default-phone-class (aref p 1))
+ ;; BBDB let users put arbitrary strings in after
+ ;; the phone number, when the number itself was a
+ ;; plain string. Pull that out and put it in the
+ ;; `comment' slot.
+ (let ((p-string (aref p 1)))
+ (if (null (string-match "\\([^[:digit:]]+\\)\\'"
p-string))
+ (ebdb-parse ebdb-default-phone-class p-string)
+ (setq comment (string-trim (match-string 1 p-string)))
+ (ebdb-parse ebdb-default-phone-class
+ (substring p-string 0 (match-beginning
1)))))
(make-instance ebdb-default-phone-class
:area-code (ebdb-vphone-area p)
:number (replace-regexp-in-string
@@ -505,6 +514,8 @@ BBDB sets the default of that option."
(ebdb-vphone-exchange p)
(ebdb-vphone-suffix p)))
:extension (ebdb-vphone-extension p))))
+ (when comment
+ (setf (slot-value instance 'comment) comment))
(setf (slot-value instance 'label) label)
(when (and (null (slot-value instance 'country-code))
ebdb-default-phone-country)