emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Andrew Hyatt <ahyatt@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Coloring jabber contacts in org-mode tags according to availability
Date: Sat, 2 May 2009 19:08:42 -0400	[thread overview]
Message-ID: <c8389b600905021608p414f2c6cs162e58332c9c1c32@mail.gmail.com> (raw)

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)))))

                 reply	other threads:[~2009-05-02 23:08 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c8389b600905021608p414f2c6cs162e58332c9c1c32@mail.gmail.com \
    --to=ahyatt@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).