logo       

Sponsor
FREE Network Mapping Tool for Microsoft® Office Visio® Professional 2007
Don't map your network by hand - let LANsurveyor Exx press for Microsoft Visio Professional 2007 automatically create network diagrams for you!

BBDB tags =): msg#00000

emacs.bbdb.user

Subject: BBDB tags =)

Hiya, everyone!

I was thinking about contact management with BBDB
(http://sacha.free.net.ph/notebook/wiki/2005.05.06.php#1). Tags seemed
like a neat way to organize my contacts, and I thought I'd share the
results of an hour's fun hacking with you. If you add a tags: field to
your BBDB records and set this to a space-delimited list of tags
(case-sensitive for now), then you can use sacha/bbdb-search-tags to
display all records matching a set of tags.

You can also use sacha/planner-bbdb-insert-tags-alist to insert an
index of entries into a PlannerMode page. (Planner is this ultracool
personal information manager for Emacs that I'm so totally in love
with. http://www.emacswiki.org/cgi-bin/wiki/PlannerMode)

----------------------------------------------------------------
(defun sacha/bbdb-get-tags (record)
"Return the tags for RECORD as a list."
(let ((tags (bbdb-record-getprop record 'tags)))
(when tags (split-string tags))))

(defun sacha/bbdb-test-tags (query tags)
"Return non-nil if QUERY is a subset of TAGS."
(let ((result t))
(while (and result query)
(unless (member (car query) tags)
(setq result nil))
(setq query (cdr query)))
result))

(defun sacha/bbdb-search-tags-internal (records tags)
"Return a list of RECORDS matching TAGS."
(when (stringp tags) (setq tags (split-string tags)))
(let (result)
(while records
(when (sacha/bbdb-test-tags tags
(sacha/bbdb-get-tags (car records)))
(setq result (cons (car records) result)))
(setq records (cdr records)))
result))

(defun sacha/bbdb-search-tags (tags)
"Display all the records that match TAGS."
(interactive "MTags: ")
(bbdb-display-records (sacha/bbdb-search-tags-internal (bbdb-records) tags)))

(defun sacha/planner-bbdb-link (record)
"Return a link to RECORD."
(or (bbdb-record-getprop record 'plan)
;; From a BBDB entry with a plan page; use that. Yay!
(concat "[[bbdb://"
(emacs-wiki-replace-regexp-in-string
" " "."
(bbdb-record-name record))
"][" (or (bbdb-record-getprop record 'nick) (bbdb-record-name
record))
"]]")))

(defun sacha/bbdb-get-tags-index ()
"Return a list of tags and records."
(let ((tags-alist '())
(records (bbdb-records))
tags
entry
list
link)
(while records
(setq tags (sacha/bbdb-get-tags (car records)))
(while tags
(setq entry (assoc (car tags) tags-alist))
(setq list (cdr entry))
(add-to-list 'list (car records))
(if entry
(setcdr entry list)
(add-to-list 'tags-alist (cons (car tags) list)))
(setq tags (cdr tags)))
(setq records (cdr records)))
tags-alist))

(defun sacha/planner-bbdb-insert-tags-alist (&optional tag-alist)
"Insert TAG-ALIST into the current buffer."
(interactive)
(unless tag-alist (setq tag-alist (sacha/bbdb-get-tags-index)))
(insert (mapconcat
(lambda (item)
(concat (car item) " | "
(mapconcat
'sacha/planner-bbdb-link
(cdr item)
",")))
tag-alist
"\n")))
----------------------------------------------------------------

I'm going to refine this by making it easier to insert lists for a
single tag. I'm also going to tweak the linking function because I'm
starting to have problems disambiguating BBDB records. I'm thinking of
using a numeric ID field and then letting hippie-expansion and
functions convert familiar names into links containing the IDs.
Then I'm going to improve the cross-referencing with my wiki pages... =)

I might also just move all of this information into a set of wiki
pages (one page per person) but BBDB lets me prototype quickly. It's
so cool!

--
Sacha Chua <sacha@xxxxxxxxxxx> - open source geekette
http://sacha.free.net.ph/ - PGP Key ID: 0xE7FDF77C
interests: emacs, gnu/linux, personal information management, CS ed
sachac on irc.freenode.net#emacs . YM: sachachua83


-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games.
Get your fingers limbered up and give it your best shot. 4 great events, 4
opportunities to win big! Highest score wins.NEC IT Guy Games. Play to
win an NEC 61 plasma display. Visit http://www.necitguy.com/?r=20
_______________________________________________
bbdb-info@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/bbdb-info
BBDB Home Page: http://bbdb.sourceforge.net/



<Prev in Thread] Current Thread [Next in Thread>
Sponsor
FREE Network Mapping Tool for Microsoft® OfficeVisio Professional 2007
Don't map your network by hand - let LANsurveyor Express for Microsoft Visio Professional 2007
automatically create network diagrams for you!
Google Custom Search

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe

Navigation

Home | sitemap | advertise | OSDir is an inevitable website. super tiny logo