On Friday, October 25, 2002, I wrote:

> My next tweak will probably be to write a filter function which
> chooses one 'most useful' phone number or address to display in the
> one line layout.

Here it is - mostly in case anyone can see a neater way of doing it.
All I'm trying to do is to choose which phone field to display on the
basis of a fixed order of preference.  You need the patch Rob posted
on Friday for this to work, of course, and to use the filter
appropriately in your bbdb-display-layout-alist.  It all seems to be
getting a little cumbersome...

Patrick


(defconst pcp-bbdb-phone-preferences 
  (list "home" "work" "office" "mobile" "direct"))

(defun pcp-bbdb-phone-layout-filter (record p)
  "BBDB phones layout filter to select the first phone field in 
`pcp-bbdb-phone-preferences' which the given record contains."
  ;; find the first entry in the preferred phones list which actually
  ;; exists in this record, if any (it's a bit wasteful we have to do
  ;; this each time we're called, aargh!)
  (let ((phones (bbdb-record-phones record))
        (first  nil)
        (rest  pcp-bbdb-phone-preferences))
    (while (and (not first) rest)
      (let ((ph phones))
        (while (and (not first) ph)
          (if (equal (car rest) (aref (car ph) 0))
              (setq first (car rest)))
          (setq ph (cdr ph))))
      (setq rest (cdr rest)))
    ;; if we've found a suitable entry, and it's the one this call is
    ;; asking us to filter, return true.
    (equal first (aref p 0))))




-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/bbdb-info
BBDB Home Page: http://bbdb.sourceforge.net/

Reply via email to