[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ebdb ee1b81f 3/5: New customization option ebdb-default
From: |
Eric Abrahamsen |
Subject: |
[elpa] externals/ebdb ee1b81f 3/5: New customization option ebdb-default-phone-country |
Date: |
Fri, 3 Sep 2021 18:09:21 -0400 (EDT) |
branch: externals/ebdb
commit ee1b81f363ced98b10c9000f2d6da66d8972b710
Author: Eric Abrahamsen <eric@ericabrahamsen.net>
Commit: Eric Abrahamsen <eric@ericabrahamsen.net>
New customization option ebdb-default-phone-country
* ebdb.el (ebdb-default-phone-country): Phone country-code to use if
none is specified/parsed out.
(ebdb-string): Don't display the country code if it matches the
default.
(ebdb-parse): If no cc can be parsed, and there's a default, use that
default.
* ebdb-migrate.el (ebdb-migrate-vector-to-class): Use default phone
country when migrating BBDB phone fields with no country.
* ebdb.org: Document.
---
ebdb-i18n-basic.el | 10 +++--
ebdb-migrate.el | 33 +++++++-------
ebdb.el | 30 ++++++++++---
ebdb.info | 126 +++++++++++++++++++++++++++++------------------------
ebdb.org | 10 +++++
ebdb.texi | 10 +++++
6 files changed, 137 insertions(+), 82 deletions(-)
diff --git a/ebdb-i18n-basic.el b/ebdb-i18n-basic.el
index d2bf7f4..2da5b26 100644
--- a/ebdb-i18n-basic.el
+++ b/ebdb-i18n-basic.el
@@ -121,7 +121,9 @@ number, and any remaining as an extension."
(cl-defmethod ebdb-string-i18n ((phone ebdb-field-phone)
(_cc (eql 1)))
(with-slots (area-code number extension) phone
- (format "+1 (%d) %s-%s%s"
+ (format "%s(%d) %s-%s%s"
+ (if (eql ebdb-default-phone-country 1)
+ "" "+1 ")
area-code
(substring number 0 3)
(substring number 3)
@@ -171,7 +173,8 @@ number, and any remaining as an extension."
(_cc (eql 33)))
(with-slots (area-code number extension) phone
(concat
- "+33 "
+ (unless (eql ebdb-default-phone-country 33)
+ "+33 ")
(when area-code
(format "%02d" area-code))
(apply #'format "%s%s %s%s %s%s %s%s"
@@ -242,7 +245,8 @@ number, and any remaining as an extension."
(_cc (eql 8)))
(with-slots (area-code number extension) phone
(concat
- "+8 "
+ (unless (eql ebdb-default-phone-country 8)
+ "+8 ")
(when area-code (format "%d " area-code))
(apply #'format
(cl-case (length number)
diff --git a/ebdb-migrate.el b/ebdb-migrate.el
index bdb5116..f2bbbf7 100644
--- a/ebdb-migrate.el
+++ b/ebdb-migrate.el
@@ -491,21 +491,24 @@ BBDB sets the default of that option."
(when phone
(dolist (p phone)
(let ((label (aref p 0))
- area extension number)
- (if (= 2 (length p))
- (setq number (aref p 1))
- (setq area (ebdb-vphone-area p)
- number (format "%d%d"
- (ebdb-vphone-exchange p)
- (ebdb-vphone-suffix p))
- extension (ebdb-vphone-extension p)))
- (push (make-instance ebdb-default-phone-class
- :label label
- :area-code area
- :number (replace-regexp-in-string "[- ]+"
- "" number)
- :extension extension)
- phones))))
+ instance)
+ (setq instance
+ (if (= 2 (length p))
+ (ebdb-parse ebdb-default-phone-class (aref p 1))
+ (make-instance ebdb-default-phone-class
+ :area-code (ebdb-vphone-area p)
+ :number (replace-regexp-in-string
+ "[- ]+"
+ "" (format "%d%d"
+ (ebdb-vphone-exchange p)
+ (ebdb-vphone-suffix p)))
+ :extension (ebdb-vphone-extension p))))
+ (setf (slot-value instance 'label) label)
+ (when (and (null (slot-value instance 'country-code))
+ ebdb-default-phone-country)
+ (setf (slot-value instance 'country-code)
+ ebdb-default-phone-country))
+ (push instance phones))))
(when address
(dolist (a address)
(let ((label (aref a 0))
diff --git a/ebdb.el b/ebdb.el
index 47c7f72..1dcca8c 100644
--- a/ebdb.el
+++ b/ebdb.el
@@ -691,11 +691,24 @@ In rare cases, this may lead to confusion with EBDB's MUA
interface."
:type '(repeat string))
(defcustom ebdb-default-country "Emacs";; what do you mean, it's not a country?
- "Default country to use if none is specified."
+ "Default country to use for addresses."
:group 'ebdb-record-edit
:type '(choice (const :tag "None" nil)
(string :tag "Default Country")))
+(defcustom ebdb-default-phone-country nil
+ "Default country to use for phone numbers.
+Should be an integer representing the country code for phone
+numbers.
+
+If EBDB can't determine the country when parsing a phone number,
+it will assume this default, if set. When displaying phone
+numbers, the country code will be omitted if it matches this
+option."
+ :group 'ebdb-record-edit
+ :type '(choice (const :tag "None" nil)
+ (integer :tag "Default Country")))
+
(defcustom ebdb-default-user-field 'ebdb-field-notes
"Default field when editing EBDB records."
:group 'ebdb-record-edit
@@ -1973,7 +1986,9 @@ internationalization."
(push number outstring))
(when area-code
(push (format "(%d) " area-code) outstring))
- (when country-code
+ (when (and country-code
+ (null (eql country-code
+ ebdb-default-phone-country)))
(push (format "+%d " country-code) outstring))
(when outstring
(apply #'concat outstring)))))
@@ -2013,10 +2028,13 @@ internationalization."
(insert (ebdb-string-trim string))
(goto-char (point-min))
(unless (plist-member slots :country-code)
- (when (looking-at country-regexp)
- (setq slots
- (plist-put slots :country-code (string-to-number (match-string
1))))
- (goto-char (match-end 0))))
+ (if (looking-at country-regexp)
+ (progn
+ (setq slots
+ (plist-put slots :country-code (string-to-number
(match-string 1))))
+ (goto-char (match-end 0)))
+ (when ebdb-default-phone-country
+ (plist-put slots :country-code ebdb-default-phone-country))))
(unless (plist-member slots :area-code)
(when (looking-at area-regexp)
;; Bit of a hack. If we seem to have an area code, but there
diff --git a/ebdb.info b/ebdb.info
index d54213d..a903682 100644
--- a/ebdb.info
+++ b/ebdb.info
@@ -239,6 +239,14 @@ prompted to create the new database, and upgrade from
BBDB. If any
records could not be upgraded, they will be displayed in an *EBDB
Migration Errors* buffer. Migration bug reports are very welcome.
+ BBDB does not provide a country code field for phone numbers. If
+you’ve stored your BBDB phone numbers as plain strings, and those
+strings contain country codes (formatted as “+44”, etc), then migration
+will parse them correctly. Otherwise, if most of the records you’re
+migrating have phones in the same country, you can set
+‘ebdb-default-phone-country’ to the (integer) value of that country’s
+code.
+
File: ebdb.info, Node: Variables and Options, Prev: Record Migration, Up:
Migration from BBDB
@@ -2397,6 +2405,7 @@ File: ebdb.info, Node: Index, Prev: Hacking EBDB, Up:
Top
* C-k <1>: The Basics of ebdb-mode.
(line 45)
* Command: Snarfing. (line 40)
+* Country codes for BBDB phone numbers: Record Migration. (line 14)
* Creating a database: The EBDB Database. (line 11)
* Creating records: Creating Records. (line 6)
* Customizing search: Changing Search Behavior.
@@ -2482,6 +2491,7 @@ File: ebdb.info, Node: Index, Prev: Hacking EBDB, Up:
Top
* ebdb-default-oneline-include: Customizing Record Display.
(line 73)
* ebdb-default-phone-class: Hacking EBDB. (line 40)
+* ebdb-default-phone-country: Record Migration. (line 14)
* ebdb-default-record-class: Creating Records. (line 10)
* ebdb-default-record-class <1>: Hacking EBDB. (line 24)
* ebdb-default-window-size: Pop-up Buffers. (line 33)
@@ -2758,64 +2768,64 @@ Node: Getting Started2680
Node: Starting a New Database4630
Node: Migration from BBDB5454
Node: Record Migration5697
-Node: Variables and Options6337
-Node: Migration from Org Contacts6824
-Node: The EBDB Database7584
-Node: Creating Records11745
-Node: Record classes12826
-Node: Record names13171
-Node: Record Fields13846
-Node: Inserting New Fields14090
-Node: Editing Existing Fields14886
-Node: Deleting Records and Fields15486
-Node: Field Types15882
-Node: Role fields18168
-Node: Tag field20534
-Node: Mail folder field21103
-Node: MUA Interaction21431
-Node: Loading MUA Code21984
-Node: Display and Updating22697
-Node: Pop-up Buffers23463
-Node: Auto-Updating Records26313
-Node: Noticing and Automatic Rules31107
-Node: Interactive Commands32929
-Node: EBDB and MUA summary buffers35403
-Node: Sender name display35921
-Node: Summary buffer marks37148
-Node: Mail Address Completion38327
-Node: A Note on Completion40836
-Node: Specific MUAs41459
-Node: Gnus41607
-Node: Posting Styles41829
-Node: EBDB Buffers43385
-Node: Searching44596
-Node: Changing Search Behavior46310
-Node: The Basics of ebdb-mode47557
-Node: Customizing Record Display51905
-Node: Marking56225
-Node: Exporting/Formatting56652
-Node: Completion57587
-Node: Snarfing58383
-Node: Internationalization60400
-Node: Diary Integration63101
-Node: Mail Aliases63794
-Node: vCard Support64508
-Node: Org Integration65007
-Node: Citing Records67041
-Node: Hacking EBDB67799
-Node: Field Classes70392
-Node: Init and Delete Methods73573
-Node: Manipulating Field Data Programmatically75097
-Node: The Labeled Field Class76809
-Node: The Singleton Field Class77680
-Node: Actions78118
-Node: Custom Field Searching78790
-Node: Fast Lookups81657
-Node: Formatting in the EBDB Buffer83467
-Node: Writing Internationalization Libraries85543
-Node: Writing Integration For New MUAs89959
-Node: Article snarfing93407
-Node: Index94125
+Node: Variables and Options6759
+Node: Migration from Org Contacts7246
+Node: The EBDB Database8006
+Node: Creating Records12167
+Node: Record classes13248
+Node: Record names13593
+Node: Record Fields14268
+Node: Inserting New Fields14512
+Node: Editing Existing Fields15308
+Node: Deleting Records and Fields15908
+Node: Field Types16304
+Node: Role fields18590
+Node: Tag field20956
+Node: Mail folder field21525
+Node: MUA Interaction21853
+Node: Loading MUA Code22406
+Node: Display and Updating23119
+Node: Pop-up Buffers23885
+Node: Auto-Updating Records26735
+Node: Noticing and Automatic Rules31529
+Node: Interactive Commands33351
+Node: EBDB and MUA summary buffers35825
+Node: Sender name display36343
+Node: Summary buffer marks37570
+Node: Mail Address Completion38749
+Node: A Note on Completion41258
+Node: Specific MUAs41881
+Node: Gnus42029
+Node: Posting Styles42251
+Node: EBDB Buffers43807
+Node: Searching45018
+Node: Changing Search Behavior46732
+Node: The Basics of ebdb-mode47979
+Node: Customizing Record Display52327
+Node: Marking56647
+Node: Exporting/Formatting57074
+Node: Completion58009
+Node: Snarfing58805
+Node: Internationalization60822
+Node: Diary Integration63523
+Node: Mail Aliases64216
+Node: vCard Support64930
+Node: Org Integration65429
+Node: Citing Records67463
+Node: Hacking EBDB68221
+Node: Field Classes70814
+Node: Init and Delete Methods73995
+Node: Manipulating Field Data Programmatically75519
+Node: The Labeled Field Class77231
+Node: The Singleton Field Class78102
+Node: Actions78540
+Node: Custom Field Searching79212
+Node: Fast Lookups82079
+Node: Formatting in the EBDB Buffer83889
+Node: Writing Internationalization Libraries85965
+Node: Writing Integration For New MUAs90381
+Node: Article snarfing93829
+Node: Index94547
End Tag Table
diff --git a/ebdb.org b/ebdb.org
index cc03e03..d794338 100644
--- a/ebdb.org
+++ b/ebdb.org
@@ -94,6 +94,16 @@ alternately EBDB will look in the default location, found
using
database, and upgrade from BBDB. If any records could not be
upgraded, they will be displayed in an {{{buf(EBDB Migration
Errors)}}} buffer. Migration bug reports are very welcome.
+
+#+CINDEX: Country codes for BBDB phone numbers
+#+VINDEX: ebdb-default-phone-country
+BBDB does not provide a country code field for phone numbers. If
+you've stored your BBDB phone numbers as plain strings, and those
+strings contain country codes (formatted as "+44", etc), then
+migration will parse them correctly. Otherwise, if most of the
+records you're migrating have phones in the same country, you can set
+~ebdb-default-phone-country~ to the (integer) value of that country's
+code.
*** Variables and Options
Many of the old BBDB customization options have been changed or
removed entirely in EBDB. It's probably best to put your BBDB
diff --git a/ebdb.texi b/ebdb.texi
index 158c7a6..3283a71 100644
--- a/ebdb.texi
+++ b/ebdb.texi
@@ -261,6 +261,16 @@ alternately EBDB will look in the default location, found
using
database, and upgrade from BBDB@. If any records could not be
upgraded, they will be displayed in an *EBDB Migration Errors* buffer.
Migration bug reports are very welcome.
+@cindex Country codes for BBDB phone numbers
+@vindex ebdb-default-phone-country
+BBDB does not provide a country code field for phone numbers. If
+you've stored your BBDB phone numbers as plain strings, and those
+strings contain country codes (formatted as ``+44'', etc), then
+migration will parse them correctly. Otherwise, if most of the
+records you're migrating have phones in the same country, you can set
+@code{ebdb-default-phone-country} to the (integer) value of that country's
+code.
+
@node Variables and Options
@subsection Variables and Options
- [elpa] externals/ebdb updated (365cf0c -> fb13955), Eric Abrahamsen, 2021/09/03
- [elpa] externals/ebdb e6717b8 1/5: Small updates to phone number parsing, Eric Abrahamsen, 2021/09/03
- [elpa] externals/ebdb ee1b81f 3/5: New customization option ebdb-default-phone-country,
Eric Abrahamsen <=
- [elpa] externals/ebdb 3f5dda3 4/5: Add Germany-specific phone and address display methods, Eric Abrahamsen, 2021/09/03
- [elpa] externals/ebdb 6377fb5 2/5: Add a "neighborhood" slot for addresses, Eric Abrahamsen, 2021/09/03
- [elpa] externals/ebdb fb13955 5/5: Add menu item for `ebdb-edit-field-customize', do minor point release, Eric Abrahamsen, 2021/09/03