To get a sensible sort order (when printing, etc.) for entries that
represent companies (rather than individuals), I use only a company
name and leave the (person) name empty.  For the first time in a lot
of years this had caused me grief!  Now, if the short answer is "don't
do that", I'd be happy to "fix" my BBDB and forget about it.  However,
I'd be surprised if that's the most sensible answer...  so here's an
example...

I have an entry where the company is "Sample Company" (and the name is
nil) and I have a bunch of addresses in the record, but I do not have
"[EMAIL PROTECTED]".  I then receive a message from:

  Sample Company <[EMAIL PROTECTED]>

and I get an error.

I've found a similar report in the archives:

  From: Alastair Burt 
  Subject: Bug report - bbdb 2.32 - bbdb-simple-query 
  Date: Sun, 24 Jun 2001 23:01:23 -0700

but my case is a little bit different and I think I see a more general
problem than Alastair did.  I think his patch avoids the problem
rather than fixing it.  If BBDB allows company to be set but name to
be nil, then in many cases it will need to fall back to the company
when there is no name.

Details...

bbdb-vm.el drills down through:

  (bbdb/vm-update-records ...)
  (bbdb-annotate-message-sender ...)
  (bbdb-search-simple "Sample Company" "[EMAIL PROTECTED]")

That looks cool!

In bbdb-search-simple, bbdb-gethash appears to do the right thing when
given a company name.  However, bbdb-simple-search assumes that it can
unconditionally use the result of bbdb-record-name when doing a
comparison against records returned by bbdb-gethash.

The following is a simple work-around for this problem, since it avoids
the error that stops me reading the message and gets me part of the
way towards a solution.

--------8<---------8<-------- CUT HERE --------8<---------8<--------
*** bbdb.el     2001/05/22 09:44:39     1.1
--- bbdb.el     2001/09/19 23:58:56
***************
*** 1636,1642 ****
                           (while recs
                             (let ((n-rec (car recs)))
                               (if (string= (downcase name)
!                                           (downcase (bbdb-record-name n-rec)))
                                   (setq answer (append recs n-rec)))
                               (setq recs (cdr recs))))
                           answer)))
--- 1636,1642 ----
                           (while recs
                             (let ((n-rec (car recs)))
                               (if (string= (downcase name)
!                                           (downcase (or (bbdb-record-name n-rec) 
(bbdb-record-company n-rec))))
                                   (setq answer (append recs n-rec)))
                               (setq recs (cdr recs))))
                           answer)))
--------8<---------8<-------- CUT HERE --------8<---------8<--------

I can't see any other way of returning a relevant record out of the
bottom of the function.  However, this is a very incomplete fix, since
code down in bbdb-annotate-message-sender assume that it can use
bbdb-record-name to get something useful, and the BBDB prompts become
weird (something like "Do you want to add a new record for nil?" :-).
It looks like some hacking is required on
bbdb-annotate-message-sender.

I guess the question is, should records where company is set, but the
name isn't, be treated as 1st class citizens?  :-)

I'm more than happy to "fix" bbdb-annotate-message-sender, if people
think it is the right way to go...

peace & happiness,
martin

_______________________________________________
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/bbdb-info
BBDB Home Page: http://bbdb.sourceforge.net/

Reply via email to