Let's discuss this on the list, before I commit a xmas bug ...

On Monday, December 18, 2006 at 21:38:18, Robert Widhopf wrote:
[...]
> Hey, I accidently committed the modifications for adding the
> lastname to the hashtable (bbdb-hash-record) and there is no
> uncommit ;-/

So there is another commit reverting that change. 

> Anyway, I also like to commit the additions from Thomas Gerds
> and another change also removing the hashkey for the lastname.
> 
> >From the location where the hashmap is used I cannot see
> anything which might be broken, except that you might get
> different candidates for completion now, but that is
> intensional. 

In fact I grepped again and now I am sure that it "breaks"
more, i.e. I missed the other places in the first run where
the hash table is not retrieved explicitly. ;-(

The "problems" summarized are:
 * The hash key might collide with another record which has
   only one name, e.g. "First Last" and "Last", but this
   does no harm if duplicates are allowed (which is the
   default). 
 * The hash must be added/deleted at several places in the
   code, i.e. also at those places where the name is edited.
 * It changes the list of completions, well that is what it
   is all about!

So I will do some more testing and listening to comments
before committing this.  Attached is my current diff for
review.

Robert

Index: bbdb-com.el
===================================================================
RCS file: /cvsroot/bbdb/bbdb/lisp/bbdb-com.el,v
retrieving revision 1.178
diff -u -r1.178 bbdb-com.el
--- bbdb-com.el 18 Dec 2006 20:09:54 -0000      1.178
+++ bbdb-com.el 18 Dec 2006 21:28:03 -0000
@@ -1039,9 +1039,12 @@
     ;;
     ;; delete the old hash entry
     (let ((name    (bbdb-record-name    bbdb-record))
+          (lastname    (bbdb-record-lastname    bbdb-record))
           (company (bbdb-record-company bbdb-record)))
       (if (> (length name) 0)
           (bbdb-remhash (downcase name) bbdb-record))
+      (if (> (length lastname) 0)
+          (bbdb-remhash (downcase lsatname) bbdb-record))
       (if (> (length company) 0)
           (bbdb-remhash (downcase company) bbdb-record)))
     (bbdb-record-set-namecache bbdb-record nil)
@@ -1066,10 +1069,7 @@
                                         ""))))))
 
     ;; delete the old hash entry
-    (let ((name    (bbdb-record-name    bbdb-record))
-          (company (bbdb-record-company bbdb-record)))
-      (if (> (length name) 0)
-          (bbdb-remhash (downcase name) bbdb-record))
+    (let ((company (bbdb-record-company bbdb-record)))
       (if (> (length company) 0)
           (bbdb-remhash (downcase company) bbdb-record)))
 
@@ -2441,6 +2441,15 @@
                                            (length pattern))))
                   (setq match-recs (cons (car recs) match-recs)
                         matched t)))
+           
+            ;; Did we match on lastname?
+            (let ((b-r-name (or (bbdb-record-lastname (car recs)) "")))
+              (if (string= pattern
+                           (substring (downcase b-r-name) 0
+                                      (min (length b-r-name)
+                                           (length pattern))))
+                  (setq match-recs (cons (car recs) match-recs)
+                        matched t)))
 
             ;; Did we match on aka?
             (when (not matched)
Index: bbdb.el
===================================================================
RCS file: /cvsroot/bbdb/bbdb/lisp/bbdb.el,v
retrieving revision 1.232
diff -u -r1.232 bbdb.el
--- bbdb.el     18 Dec 2006 21:14:31 -0000      1.232
+++ bbdb.el     18 Dec 2006 21:28:05 -0000
@@ -35,7 +35,7 @@
 ;;; |  information plus state information about how you have BBDB set up.    |
 ;;;  ------------------------------------------------------------------------
 ;;;
-;;; $Id: bbdb.el,v 1.232 2006/12/18 21:14:31 fenk Exp $
+;;; $Id: bbdb.el,v 1.231 2006/12/18 20:09:54 fenk Exp $
 
 (require 'timezone)
 (eval-when-compile (require 'cl))
@@ -65,7 +65,7 @@
  )
 
 (defconst bbdb-version "2.35")
-(defconst bbdb-version-date "$Date: 2006/12/18 21:14:31 $")
+(defconst bbdb-version-date "$Date: 2006/12/18 20:09:54 $")
 
 (defcustom bbdb-gui (if (fboundp 'display-color-p) ; Emacs 21
                         (display-color-p)
@@ -2147,11 +2147,14 @@
   "Insert the record in the appropriate hashtables.  This must be called
 while the .bbdb buffer is selected."
   (let ((name    (bbdb-record-name-1  record))  ; faster version
+        (lastname (bbdb-record-lastname record))
         (company (bbdb-record-company record))
         (aka     (bbdb-record-aka     record))
         (net     (bbdb-record-net     record)))
     (if (> (length name) 0)
         (bbdb-puthash (downcase name)    record bbdb-hashtable))
+    (if (> (length lastname) 0)
+        (bbdb-puthash (downcase lastname)    record bbdb-hashtable))
     (if (> (length company) 0)
         (bbdb-puthash (downcase company) record bbdb-hashtable))
     (while aka
@@ -2490,6 +2493,7 @@
                          (bbdb-record-marker (car (cdr tail)))
                          bbdb-end-marker))
       (let ((name    (bbdb-record-name    record))
+            (lastname (bbdb-record-lastname    record))
             (company (bbdb-record-company record))
             (aka     (bbdb-record-aka     record))
             (nets    (bbdb-record-net     record)))
@@ -2497,6 +2501,8 @@
             (bbdb-remhash (downcase name) record bbdb-hashtable))
         (if (> (length company) 0)
             (bbdb-remhash (downcase company) record bbdb-hashtable))
+        (if (> (length lastname) 0)
+            (bbdb-remhash (downcase lastname) record bbdb-hashtable))
         (while nets
           (bbdb-remhash (downcase (car nets)) record bbdb-hashtable)
           (setq nets (cdr nets)))
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
bbdb-info@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bbdb-info
BBDB Home Page: http://bbdb.sourceforge.net/

Reply via email to