Revision: mange@freemail.hu--2004/emacs-jabber--cvs-head--0--patch-93

Creator:  Magnus Henoch <mange@freemail.hu>

Add watch capability

New file jabber-watch.el.  jabber-presence-watch added to
default value of jabber-alert-presence-hooks.
This commit is contained in:
Magnus Henoch 2004-11-05 23:22:07 +00:00 committed by Kirill A. Korinskiy
parent d292bbae3c
commit 959345b650
4 changed files with 89 additions and 4 deletions

View File

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

62
jabber-watch.el Normal file
View File

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

View File

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

View File

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