BBDB tags
| emacs, organizer, productivityRight, that tags thing looks like a good idea. It should be easy to
hack into BBDB. I’ll need to actually tag people, and then write an
Emacs Lisp script that scans through all of the records, gathers them
into categories, and then creates the list.
HEY. This might actually work. Here’s a quick test of tags:
Use C-o to add a “tags” field to your BBDB records. This should be a space-delimited list of tags (case-sensitive for now).
Call M-x sacha/planner-bbdb-insert-tags-alist to produce a list like the one above.
(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)) "][" (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")))
To think that only took me an hour of leisurely coding (including tagging my contact information)…
You can comment with Disqus or you can e-mail me at sacha@sachachua.com.