emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/ebdb 1b862e4 3/3: More complete version of migration fr


From: Eric Abrahamsen
Subject: [elpa] externals/ebdb 1b862e4 3/3: More complete version of migration from Org contacts, version 0.4
Date: Fri, 27 Oct 2017 19:06:55 -0400 (EDT)

branch: externals/ebdb
commit 1b862e4d7343bbfba5d52aa797f15c0c98caac04
Author: Eric Abrahamsen <address@hidden>
Commit: Eric Abrahamsen <address@hidden>

    More complete version of migration from Org contacts, version 0.4
    
    Fixes #56
    
    * ebdb-migrate.el (ebdb-migrate-from-org-contacts): Do a better job
      catching and reporting errors, mostly.
      (ebdb-migrate-from-bbdb): Make this one interactive, as well.
    * ebdb.org: Document.
    * ebdb.el: Bump version to 0.4
---
 ebdb-migrate.el |  80 ++++++++++++++++++++------------
 ebdb.el         |   2 +-
 ebdb.info       | 141 +++++++++++++++++++++++++++++++++-----------------------
 ebdb.org        |  22 +++++++--
 ebdb.texi       |  26 ++++++++++-
 5 files changed, 178 insertions(+), 93 deletions(-)

diff --git a/ebdb-migrate.el b/ebdb-migrate.el
index fa48d7a..35247c2 100644
--- a/ebdb-migrate.el
+++ b/ebdb-migrate.el
@@ -393,6 +393,7 @@ variable `bbdb-file' points to an existing file holding 
valid
 contacts in a previous BBDB format.  If that variable isn't set
 use \(locate-user-emacs-file \"bbdb\" \".bbdb\"\), which is how
 BBDB sets the default of that option."
+  (interactive)
   (require 'url-handlers)
   (require 'ebdb-org)
   (require 'ebdb-gnus)
@@ -444,7 +445,7 @@ BBDB sets the default of that option."
             (push (list r err) duds))))
        (when duds
          (pop-to-buffer
-          (get-buffer-create "*EBDB Migration*")
+          (get-buffer-create "*EBDB Migration Errors*")
           '(nil . ((window-height . 10))))
          (insert "The records below could not be migrated:\n\n")
          (insert
@@ -674,7 +675,9 @@ BBDB sets the default of that option."
   '((org-contacts-email-property . ebdb-default-mail-class)
     (org-contacts-tel-property . ebdb-default-phone-class)
     (org-contacts-note-property . ebdb-default-notes-class)
-    (org-contacts-nickname-property . ebdb-field-name-simple)
+    ;; NICKNAME is specifically meant for erc nicks, not normal
+    ;; nicknames.
+;    (org-contacts-nickname-property . ebdb-field-name-simple)
     (org-contacts-alias-property . ebdb-default-name-class))
   "The simplest property-to-field correspondences.
 This variable only holds correspondences for fields that require
@@ -687,7 +690,8 @@ no processing beyond calling `ebdb-parse' on the string 
values.")
   (require 'org-contacts)
   (unless ebdb-sources
     (error "First set `ebdb-sources' to the location of your EBDB database."))
-  (let ((db (ebdb-prompt-for-db))
+
+  (let ((db (ebdb-prompt-for-db nil t))
        ;; Postpone evaluation of the symbols until run time.
        (prop-fields
         (mapcar
@@ -696,43 +700,59 @@ no processing beyond calling `ebdb-parse' on the string 
values.")
                  (if (class-p class) class (symbol-value class))))
          ebdb-migrate-org-simple-correspondences))
        (count 0)
-       (address-buffer (get-buffer-create "*EBDB Migration Addresses*"))
-       record records f)
-    (with-current-buffer address-buffer
-      (erase-buffer))
+       (dud-fields '())
+       record records)
+
     (message "Migrating records from org-contacts... %d records" count)
+
     (pcase-dolist (`(,name ,_ ,fields) (org-contacts-db))
       (setq record (make-instance ebdb-default-record-class))
       (ebdb-record-change-name record name)
-      (dolist (field fields)
-       (setq f
-             (if (assoc-string (car field) prop-fields)
-                 (ebdb-parse (cdr (assoc-string (car field) prop-fields))
-                             (cdr field))
-               (pcase (car field)
-                 ((pred (equal org-contacts-address-property))
-                  (with-current-buffer address-buffer
-                    (insert (format "%s: %s\n" name (cdr field)))))
-                 ((pred (equal org-contacts-birthday-property))
-                  (make-instance 'ebdb-field-anniversary
-                                 :date  (calendar-gregorian-from-absolute
-                                         (org-time-string-to-absolute
-                                          (cdr field)))
-                                 :object-name "birthday")))))
-       (when f
-         (ebdb-record-insert-field record f)))
+      (pcase-dolist (`(,field-label . ,value) fields)
+       (condition-case nil
+           (let ((f (if (assoc-string field-label prop-fields)
+                        (ebdb-parse (cdr (assoc-string field-label 
prop-fields))
+                                    value)
+                      (pcase field-label
+                        ((pred (equal org-contacts-address-property))
+                         (signal 'ebdb-unparseable (list value)))
+                        ((pred (equal org-contacts-birthday-property))
+                         (make-instance 'ebdb-field-anniversary
+                                        :date  
(calendar-gregorian-from-absolute
+                                                (org-time-string-to-absolute
+                                                 value))
+                                        :object-name "birthday"))))))
+             (when f
+               (ebdb-record-insert-field record f)))
+         (ebdb-unparseable
+          (push (cons field-label value)
+                (alist-get name dud-fields '() nil #'equal)))))
       (push record records)
       (message "Migrating records from org-contacts... %d records"
               (cl-incf count)))
+
     (dolist (r records)
       (ebdb-db-add-record db r))
+
     (message "Migrating records from org-contacts... %d records"
-            (length records)))
-  (ebdb-display-records records)
-  (with-current-buffer address-buffer
-    (unless (= (point-min) (point-max))
-      (pop-to-buffer address-buffer
-                    '(display-buffer-pop-up-window . ((width . 50)))))))
+            (length records))
+
+    (ebdb-display-records records)
+
+    (when dud-fields
+      (pop-to-buffer (get-buffer-create "*EBDB Migration Errors*")
+                    '(display-buffer-pop-up-window . ((width . 50))))
+      (goto-char (point-min))
+      (pcase-dolist (`(,name . ,fields) dud-fields)
+       (insert (format "* [[ebdb:uuid/%s][%s]]\n"
+                       (ebdb-record-uuid (car (ebdb-gethash name '(fl-name))))
+                       name))
+       (pcase-dolist (`(,field-label . ,value) fields)
+         (insert (format "%s: %s\n" field-label value)))
+       (insert "\n"))
+      (goto-char (point-min))
+      (org-mode)
+      (message "Some field values could not be parsed"))))
 
 (provide 'ebdb-migrate)
 ;;; ebdb-migrate.el ends here
diff --git a/ebdb.el b/ebdb.el
index e783ec4..a74115a 100644
--- a/ebdb.el
+++ b/ebdb.el
@@ -2,7 +2,7 @@
 
 ;; Copyright (C) 2016-2017  Free Software Foundation, Inc.
 
-;; Version: 0.3.5
+;; Version: 0.4
 ;; Package-Requires: ((emacs "25.1") (cl-lib "0.5") (seq "2.15"))
 
 ;; Maintainer: Eric Abrahamsen <address@hidden>
diff --git a/ebdb.info b/ebdb.info
index dfc75a6..ecf15f8 100644
--- a/ebdb.info
+++ b/ebdb.info
@@ -1,4 +1,4 @@
-This is ebdb.info, produced by makeinfo version 6.4 from ebdb.texi.
+This is ebdb.info, produced by makeinfo version 6.5 from ebdb.texi.
 
 Copyright © 2016 Free Software Foundation, Inc.
 
@@ -47,6 +47,7 @@ EBDB Manual
 Getting Started
 
 * Migration from BBDB::
+* Migration from Org Contacts::
 
 Migration from BBDB
 
@@ -155,9 +156,10 @@ and finally open a *EBDB* buffer where you can start to 
make new records
 * Menu:
 
 * Migration from BBDB::
+* Migration from Org Contacts::
 
 
-File: ebdb.info,  Node: Migration from BBDB,  Up: Getting Started
+File: ebdb.info,  Node: Migration from BBDB,  Next: Migration from Org 
Contacts,  Up: Getting Started
 
 1.1 Migration from BBDB
 =======================
@@ -180,7 +182,9 @@ look in the default location, found using 
‘(locate-user-emacs-file
 and then run ‘ebdb-load’ (or any of the other EBDB entry commands).
 You’ll be 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* buffer.  Migration bug reports are very welcome.
+Migration Errors* buffer.  Migration bug reports are very welcome.
+
+   You can also call the command ‘ebdb-migrate-from-bbdb’ at any time.
 
 
 File: ebdb.info,  Node: Variables and Options,  Prev: Record Migration,  Up: 
Migration from BBDB
@@ -195,6 +199,23 @@ important options are detailed in this manual, you can 
also customize
 the “EBDB” group to see what’s available.
 
 
+File: ebdb.info,  Node: Migration from Org Contacts,  Prev: Migration from 
BBDB,  Up: Getting Started
+
+1.2 Migration from Org Contacts
+===============================
+
+EBDB also provides limited support for migrating from Org Contacts:
+simply call the command ‘ebdb-migrate-from-org-contacts’.  Your contacts
+database will be scanned, and all contacts will be migrated.  Any field
+values that could not be migrated will be displayed in a *EBDB Migration
+Errors* buffer.
+
+   At present, addresses cannot be migrated automatically.  Org Contacts
+stores addresses as a free-form string, which is simply too difficult to
+parse accurately.  Address values will be inserted into the migration
+errors buffer, and will have to be added to the records manually.
+
+
 File: ebdb.info,  Node: The EBDB Database,  Next: Creating Records,  Prev: 
Getting Started,  Up: Top
 
 2 The EBDB Database
@@ -2031,6 +2052,9 @@ Index
                                                               (line  54)
 * ebdb-message-clean-name-function:      Sender name display. (line  14)
 * ebdb-message-mail-as-name:             Sender name display. (line  18)
+* ebdb-migrate-from-bbdb:                Record Migration.    (line  15)
+* ebdb-migrate-from-org-contacts:        Migration from Org Contacts.
+                                                              (line   6)
 * ebdb-mua-article-body:                 Article snarfing.    (line  13)
 * ebdb-mua-article-signature:            Article snarfing.    (line  16)
 * ebdb-mua-auto-update:                  Writing Integration For New MUAs.
@@ -2144,7 +2168,9 @@ Index
 * m:                                     The Basics of ebdb-mode.
                                                               (line  56)
 * Mail aliases:                          Mail Aliases.        (line   6)
-* Migrating from BBDB:                   Migration from BBDB. (line   6)
+* Migration from BBDB:                   Migration from BBDB. (line   6)
+* Migration from Org Contacts:           Migration from Org Contacts.
+                                                              (line   6)
 * MUA Display:                           Display and Updating.
                                                               (line   6)
 * MUA Updating:                          Display and Updating.
@@ -2192,59 +2218,60 @@ Index
 
 Tag Table:
 Node: Top806
-Node: Getting Started2403
-Node: Migration from BBDB3026
-Node: Record Migration3201
-Node: Variables and Options3921
-Node: The EBDB Database4407
-Node: Creating Records8395
-Node: Record classes9476
-Node: Record names9821
-Node: Record Fields10496
-Node: Inserting New Fields10740
-Node: Editing Existing Fields11536
-Node: Deleting Records and Fields12136
-Node: Field Types12532
-Node: Role fields14723
-Node: Tag field16411
-Node: Mail folder field17055
-Node: MUA Interaction17383
-Node: Loading MUA Code17907
-Node: Display and Updating18620
-Node: Pop-up Buffers19386
-Node: Auto-Updating Records20224
-Node: Noticing and Automatic Rules22624
-Node: Interactive Commands23957
-Node: EBDB and MUA summary buffers26432
-Node: Sender name display26918
-Node: Summary buffer marks28145
-Node: EBDB Buffers29324
-Node: Searching30506
-Node: Changing Search Behavior32168
-Node: The Basics of ebdb-mode33415
-Node: Marking37016
-Node: Exporting/Formatting37440
-Node: Completion38389
-Node: Snarfing39587
-Node: Internationalization41588
-Node: Diary Integration44287
-Node: Mail Aliases45152
-Node: vCard Support45866
-Node: Org Integration46365
-Node: Citing Records48263
-Node: Hacking EBDB49021
-Node: Field Classes51340
-Node: Init and Delete Methods54324
-Node: The Labeled Field Class55831
-Node: The Singleton Field Class56685
-Node: Actions57123
-Node: Custom Field Searching57795
-Node: Fast Lookups60599
-Node: Formatting in the EBDB Buffer62409
-Node: Writing Internationalization Libraries64422
-Node: Writing Integration For New MUAs68773
-Node: Article snarfing72192
-Node: Index72910
+Node: Getting Started2435
+Node: Migration from BBDB3090
+Node: Record Migration3301
+Node: Variables and Options4104
+Node: Migration from Org Contacts4590
+Node: The EBDB Database5350
+Node: Creating Records9338
+Node: Record classes10419
+Node: Record names10764
+Node: Record Fields11439
+Node: Inserting New Fields11683
+Node: Editing Existing Fields12479
+Node: Deleting Records and Fields13079
+Node: Field Types13475
+Node: Role fields15666
+Node: Tag field17354
+Node: Mail folder field17998
+Node: MUA Interaction18326
+Node: Loading MUA Code18850
+Node: Display and Updating19563
+Node: Pop-up Buffers20329
+Node: Auto-Updating Records21167
+Node: Noticing and Automatic Rules23567
+Node: Interactive Commands24900
+Node: EBDB and MUA summary buffers27375
+Node: Sender name display27861
+Node: Summary buffer marks29088
+Node: EBDB Buffers30267
+Node: Searching31449
+Node: Changing Search Behavior33111
+Node: The Basics of ebdb-mode34358
+Node: Marking37959
+Node: Exporting/Formatting38383
+Node: Completion39332
+Node: Snarfing40530
+Node: Internationalization42531
+Node: Diary Integration45230
+Node: Mail Aliases46095
+Node: vCard Support46809
+Node: Org Integration47308
+Node: Citing Records49206
+Node: Hacking EBDB49964
+Node: Field Classes52283
+Node: Init and Delete Methods55267
+Node: The Labeled Field Class56774
+Node: The Singleton Field Class57628
+Node: Actions58066
+Node: Custom Field Searching58738
+Node: Fast Lookups61542
+Node: Formatting in the EBDB Buffer63352
+Node: Writing Internationalization Libraries65365
+Node: Writing Integration For New MUAs69716
+Node: Article snarfing73135
+Node: Index73853
 
 End Tag Table
 
diff --git a/ebdb.org b/ebdb.org
index b7d6533..67c36b3 100644
--- a/ebdb.org
+++ b/ebdb.org
@@ -40,7 +40,7 @@ string, fail to find anything (because you don't have any 
records
 yet), and finally open a {{{buf(EBDB)}}} buffer where you can start to
 make new records (see [[id:692cde31-73be-4faf-b436-7eae8a5d02d1][Creating 
Records]]).
 ** Migration from BBDB
-#+CINDEX: Migrating from BBDB
+#+CINDEX: Migration from BBDB
 *** Record Migration
 It's possible to migrate records from a BBDB database.  The
 ~bbdb-file~ variable should point to your current BBDB file;
@@ -49,15 +49,31 @@ alternately EBDB will look in the default location, found 
using
 a non-existent file name, and then run ~ebdb-load~ (or any of the
 other EBDB entry commands).  You'll be prompted to create the new
 database, and upgrade from BBDB.  If any records could not be
-upgraded, they will be displayed in an {{{buf(EBDB Migration)}}}
+upgraded, they will be displayed in an {{{buf(EBDB Migration Errors)}}}
 buffer.  Migration bug reports are very welcome.
+
+#+FINDEX: ebdb-migrate-from-bbdb
+You can also call the command ~ebdb-migrate-from-bbdb~ at any time.
 *** 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
 customizations aside, and set new EBDB options as you come across
 them.  The most important options are detailed in this manual, you can
 also customize the "EBDB" group to see what's available.
-
+** Migration from Org Contacts
+#+CINDEX: Migration from Org Contacts
+#+FINDEX: ebdb-migrate-from-org-contacts
+EBDB also provides limited support for migrating from Org Contacts:
+simply call the command ~ebdb-migrate-from-org-contacts~.  Your
+contacts database will be scanned, and all contacts will be migrated.
+Any field values that could not be migrated will be displayed in a
+{{{buf(EBDB Migration Errors)}}} buffer.
+
+At present, addresses cannot be migrated automatically.  Org Contacts
+stores addresses as a free-form string, which is simply too difficult
+to parse accurately.  Address values will be inserted into the
+migration errors buffer, and will have to be added to the records
+manually.
 * The EBDB Database
 :PROPERTIES:
 :ID:       9a02f8fb-01e2-4cd8-8166-608814a031f7
diff --git a/ebdb.texi b/ebdb.texi
index d258cac..33ffd48 100644
--- a/ebdb.texi
+++ b/ebdb.texi
@@ -70,6 +70,7 @@ modify this GNU manual.”
 Getting Started
 
 * Migration from BBDB::
+* Migration from Org Contacts::
 
 Migration from BBDB
 
@@ -176,12 +177,13 @@ make new records (see @ref{Creating Records}).
 
 @menu
 * Migration from BBDB::
+* Migration from Org Contacts::
 @end menu
 
 @node Migration from BBDB
 @section Migration from BBDB
 
address@hidden Migrating from BBDB
address@hidden Migration from BBDB
 
 @menu
 * Record Migration::
@@ -198,9 +200,12 @@ alternately EBDB will look in the default location, found 
using
 a non-existent file name, and then run @code{ebdb-load} (or any of the
 other EBDB entry commands).  You'll be 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*
+upgraded, they will be displayed in an *EBDB Migration Errors*
 buffer.  Migration bug reports are very welcome.
 
address@hidden ebdb-migrate-from-bbdb
+You can also call the command @code{ebdb-migrate-from-bbdb} at any time.
+
 @node Variables and Options
 @subsection Variables and Options
 
@@ -210,6 +215,23 @@ customizations aside, and set new EBDB options as you come 
across
 them.  The most important options are detailed in this manual, you can
 also customize the ``EBDB'' group to see what's available.
 
address@hidden Migration from Org Contacts
address@hidden Migration from Org Contacts
+
address@hidden Migration from Org Contacts
address@hidden ebdb-migrate-from-org-contacts
+EBDB also provides limited support for migrating from Org Contacts:
+simply call the command @code{ebdb-migrate-from-org-contacts}.  Your
+contacts database will be scanned, and all contacts will be migrated.
+Any field values that could not be migrated will be displayed in a
+*EBDB Migration Errors* buffer.
+
+At present, addresses cannot be migrated automatically.  Org Contacts
+stores addresses as a free-form string, which is simply too difficult
+to parse accurately.  Address values will be inserted into the
+migration errors buffer, and will have to be added to the records
+manually.
+
 @node The EBDB Database
 @chapter The EBDB Database
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]