Re: BBDBv3 will lost record when snarf an exist email to database.

2014-08-09 Thread Eric Abrahamsen
Roland Winkler wink...@gnu.org writes:

 On Sat Aug 2 2014 stardiviner wrote:
 When I use =bbdb-snarf= to add email to a new record.
 report error: 
 When I try to re-add this email, after lost the record, it report error:
 =(error BBDB: marker absent)=
 
 I think BBDB show check the database before really do write action.
 If database has exist the email, then raise exist record, or raise error.
 
 BTW, BBDB will raise error when move to next record which is already at last
 record.
 I think BBDB should not raise this error, just a message in minibuffer is
 fine.

 I am sorry, can you provide a more accurate recipe for how to
 reproduce the bug you observe?  See the emacs manual for reporting
 bugs.

This thread reminded me of the existence of bbdb-snarf (it's still
fairly useful for simple name/email combinations), and I started using
it, and I hit the same bug.

bbdb-snarf checks if the snarfed record already exists, and merges the
old and new, if so. The new record needs to be fully created (with
`bbdb-change-record', with the NEW argument true) before that happens.

Otherwise, when it's passed to `bbdb-merge-record', it eventually gets
created with a call to `bbdb-change-record' where the NEW argument is
false. That makes a sort of Frankenstein record with no cache, and that
causes problems.

Anyhow, I think the solution is as simple as the attached patch, which
always calls (bbdb-change-record record t t) whether or not the new
record is going to be merged.

E

From 610a4f8e2e8ae403aeb443a0602534d44e40dbe5 Mon Sep 17 00:00:00 2001
From: Eric Abrahamsen e...@ericabrahamsen.net
Date: Sat, 9 Aug 2014 16:40:11 +0800
Subject: [PATCH] Fully create snarfed records before merging them

* lisp/bbdb-snarf.el (bbdb-snarf): When snarfing a record that may
  already exist, `bbdb-snarf' uses `bbdb-merge-records' to merge them.
  Merging won't work unless the new record is fully created (ie cached).
---
 lisp/bbdb-snarf.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lisp/bbdb-snarf.el b/lisp/bbdb-snarf.el
index aa3f00a..9c39f6c 100644
--- a/lisp/bbdb-snarf.el
+++ b/lisp/bbdb-snarf.el
@@ -318,10 +318,10 @@ See `bbdb-snarf-rule-alist' for details.
  (bbdb-record-firstname record)
  (bbdb-record-lastname record))
 (car (bbdb-record-mail record))
+  ;; create new record
+  (bbdb-change-record record t t)
   (if old-record
   (bbdb-merge-records old-record record)
-;; create new record
-(bbdb-change-record record t t)
 (bbdb-display-records (list record))
 record
 
-- 
2.0.4

--
___
bbdb-info@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bbdb-info
BBDB Home Page: http://bbdb.sourceforge.net/

Re: BBDBv3 will lost record when snarf an exist email to database.

2014-08-09 Thread Roland Winkler
 Anyhow, I think the solution is as simple as the attached patch,
 which always calls (bbdb-change-record record t t) whether or not
 the new record is going to be merged.

Thanks, I installed a slightly different patch which also ensures
that the new record is always displayed.

On a related issue: the rules currently used by bbdb-snarf are
somewhat heuristic and not the most reliable.  If someone comes up
with new / better rules, please post them here.


2014-08-09  Roland Winkler  wink...@gnu.org
* lisp/bbdb-snarf.el (bbdb-snarf): Always install and display the
new record.


BBDB is available at
http://savannah.nongnu.org/projects/bbdb/

--
___
bbdb-info@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bbdb-info
BBDB Home Page: http://bbdb.sourceforge.net/