From 959345b6506b2fac51663b7a2f07d79e08227fa9 Mon Sep 17 00:00:00 2001 From: Magnus Henoch Date: Fri, 5 Nov 2004 23:22:07 +0000 Subject: [PATCH] Revision: mange@freemail.hu--2004/emacs-jabber--cvs-head--0--patch-93 Creator: Magnus Henoch Add watch capability New file jabber-watch.el. jabber-presence-watch added to default value of jabber-alert-presence-hooks. --- jabber-alert.el | 8 +++++-- jabber-watch.el | 62 +++++++++++++++++++++++++++++++++++++++++++++++++ jabber.el | 1 + jabber.texi | 22 ++++++++++++++++-- 4 files changed, 89 insertions(+), 4 deletions(-) create mode 100644 jabber-watch.el diff --git a/jabber-alert.el b/jabber-alert.el index 55094eb..27beaf8 100644 --- a/jabber-alert.el +++ b/jabber-alert.el @@ -51,7 +51,10 @@ every time." :group 'jabber-alerts) (defcustom jabber-alert-presence-hooks - '(jabber-presence-beep jabber-presence-update-roster jabber-presence-echo) + '(jabber-presence-beep + jabber-presence-update-roster + jabber-presence-echo + jabber-presence-watch) "Hooks run when a user's presence changes. Arguments are WHO, OLDSTATUS, NEWSTATUS, STATUSTEXT and @@ -69,7 +72,8 @@ one of \"subscribe\", \"unsubscribe\", \"subscribed\" and jabber-presence-display jabber-presence-ratpoison jabber-presence-screen - jabber-presence-echo) + jabber-presence-echo + jabber-presence-watch) :group 'jabber-alerts) (defcustom jabber-alert-presence-message-function diff --git a/jabber-watch.el b/jabber-watch.el new file mode 100644 index 0000000..e5dbf57 --- /dev/null +++ b/jabber-watch.el @@ -0,0 +1,62 @@ +;; jabber-watch.el - get notified when certain persons go online + +;; Copyright (C) 2004 - Mathias Dahl +;; Copyright (C) 2004 - Magnus Henoch - mange@freemail.hu + +;; This file is a part of jabber.el. + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 2 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program; if not, write to the Free Software +;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +(require 'jabber-util) + +(defvar jabber-watch-list nil + "List of buddies for which an extra notification should be sent +when they come online") + +(defun jabber-presence-watch (who oldstatus newstatus + statustext proposed-alert) + "Checks if one of your extra-important buddies comes online and +sends a message if that happens. The buddies are stored in +`jabber-watch-list' and are added and removed by calling +`jabber-watch-add' and `jabber-watch-remove.'" + ;; check that buddy was previously offline and now online + (if (and (null oldstatus) + (not (null newstatus))) + (when (memq who jabber-watch-list) + ;; Give an intrusive message. With a window system, + ;; that's easy. + (if window-system + (message-box "%s" proposed-alert) + ;; Without a window system, yes-or-no-p should be + ;; sufficient. + (while (not + (yes-or-no-p (format "%s Got that? " proposed-alert)))))))) + +(defun jabber-watch-add (buddy) + (interactive (list (jabber-read-jid-completing "Add buddy to watch list: "))) + (add-to-list 'jabber-watch-list (jabber-jid-symbol buddy))) + +(defun jabber-watch-remove (buddy) + (interactive + (list (jabber-read-jid-completing "Remove buddy from watch list: " + (or jabber-watch-list + (error "Watch list is empty")) + t))) + (setq jabber-watch-list + (delq (jabber-jid-symbol buddy) jabber-watch-list))) + +(provide 'jabber-watch) + +;; arch-tag: c27299d8-019e-44b5-9529-d67b8682be23 diff --git a/jabber.el b/jabber.el index 345633d..ccf16a6 100644 --- a/jabber.el +++ b/jabber.el @@ -44,6 +44,7 @@ (require 'jabber-ahc-presence) (require 'jabber-modeline) (require 'jabber-keepalive) +(require 'jabber-watch) (defvar *jabber-current-status* "" "the users current presence staus") diff --git a/jabber.texi b/jabber.texi index 5e36e6a..6c2aae1 100644 --- a/jabber.texi +++ b/jabber.texi @@ -48,6 +48,7 @@ this permission notice are preserved on all copies. * Services:: * Modeline status:: * Keepalive:: +* Watch buddies:: * Customization:: * Hacking and extending:: * Concept index:: @@ -456,7 +457,7 @@ status in mode lines. The information is your own presence status, and six numbers indicating the number of chatty, online, away, extended away, dnd, and offline contacts, respectively. -@node Keepalive, Customization, Modeline status, Top +@node Keepalive, Watch buddies, Modeline status, Top @chapter Keepalive @cindex keepalive @@ -483,7 +484,24 @@ You can customize the interval and the timeout with the variables @code{jabber-keepalive-interval} and @code{jabber-keepalive-timeout}, respectively. -@node Customization, Hacking and extending, Keepalive, Top +@node Watch buddies, Customization, Keepalive, Top +@chapter Watch buddies + +@cindex watch +@findex jabber-watch-add +@findex jabber-watch-remove + +Sometimes you might be waiting for a certain person to come online, +and you don't want that occasion to get lost in the noise. To get an +obtrusive message when that happens, type @kbd{M-x jabber-watch-add} +and select the person in question. + +You will get a message whenever that person goes from offline to +online. jabber.el will remember this for the rest of your Emacs +session (it's not saved to disk, though), but if you want to get rid +of it, type @kbd{M-x jabber-watch-remove}. + +@node Customization, Hacking and extending, Watch buddies, Top @chapter Customization @findex jabber-customize