From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Hyatt Subject: Coloring jabber contacts in org-mode tags according to availability Date: Sat, 2 May 2009 19:08:42 -0400 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M0OKA-0000Ba-HL for emacs-orgmode@gnu.org; Sat, 02 May 2009 19:08:50 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M0OK6-00007H-My for emacs-orgmode@gnu.org; Sat, 02 May 2009 19:08:50 -0400 Received: from [199.232.76.173] (port=59784 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M0OK6-00007E-Jb for emacs-orgmode@gnu.org; Sat, 02 May 2009 19:08:46 -0400 Received: from rv-out-0708.google.com ([209.85.198.246]:57704) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1M0OK6-0006co-6B for emacs-orgmode@gnu.org; Sat, 02 May 2009 19:08:46 -0400 Received: by rv-out-0708.google.com with SMTP id f25so675896rvb.2 for ; Sat, 02 May 2009 16:08:44 -0700 (PDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org I like to put coworker's usernames as tags to my tasks, if I need to interact with them to get the task done. Looking over the agenda for the day while i decide on my next task, I decided I wanted to see if my coworkers were available so that I don't have to check around when deciding on my next task. So, I wrote the following function to color my tags based on the jabber availability of the person in question (green / yellow / red). It's not super-efficient, but it should work quickly for most people. If there is widespread interest in this, I can develop it into a contrib package. (defun ash-jabber-colorize-tags () (let ((contact-hash (make-hash-table :test 'equal))) (dolist (jc jabber-connections) (dolist (contact (plist-get (fsm-get-state-data jc) :roster)) (puthash (car (split-string (symbol-name contact) "@")) contact contact-hash))) (save-excursion (goto-char (point-min)) (while (re-search-forward ":\\(\\w+\\):" nil t) (let ((tag (match-string-no-properties 1))) (when (and tag (gethash tag contact-hash)) (let* ((js (jabber-jid-symbol (gethash tag contact-hash))) (connected (get js 'connected)) (show (get js 'show))) (if connected (let ((o (make-overlay (match-beginning 1) (- (point) 1)))) (overlay-put o 'face (cons 'foreground-color (cond ((equal "away" show) "yellow") ((equal "dnd" show) "red") (t "green"))))))))) (backward-char)))))