]> crepu.dev Git - config.git/blame_incremental - djavu-asus/emacs/elpa/jabber-20230715.456/jabber-watch.el
Reorganización de directorios
[config.git] / djavu-asus / emacs / elpa / jabber-20230715.456 / jabber-watch.el
... / ...
CommitLineData
1;; jabber-watch.el - get notified when certain persons go online -*- lexical-binding: t; -*-
2
3;; Copyright (C) 2004 - Mathias Dahl
4;; Copyright (C) 2004 - Magnus Henoch - mange@freemail.hu
5
6;; This file is a part of jabber.el.
7
8;; This program is free software; you can redistribute it and/or modify
9;; it under the terms of the GNU General Public License as published by
10;; the Free Software Foundation; either version 2 of the License, or
11;; (at your option) any later version.
12
13;; This program is distributed in the hope that it will be useful,
14;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16;; GNU General Public License for more details.
17
18;; You should have received a copy of the GNU General Public License
19;; along with this program; if not, write to the Free Software
20;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
22(require 'jabber-util)
23
24(defcustom jabber-watch-alist nil
25 "Alist of buddies for which an extra notification should be sent
26when they come online, with comment strings as values."
27 ;; XXX: change symbol to jid-symbol or something, and update
28 ;; documentation
29 :type '(alist :key-type symbol :value-type string)
30 :group 'jabber-watch)
31
32(defun jabber-presence-watch (who oldstatus newstatus
33 statustext proposed-alert)
34 "Send a message if one of your extra-important buddies comes online.
35The buddies are stored in `jabber-watch-alist' and are added and removed by
36calling `jabber-watch-add' and `jabber-watch-remove'."
37 ;; check that buddy was previously offline and now online
38 (if (and (null oldstatus)
39 (not (null newstatus)))
40 (let ((entry (assq who jabber-watch-alist)))
41 (when entry
42 ;; Give an intrusive message. With a window system,
43 ;; that's easy.
44 (if window-system
45 (message-box "%s%s" proposed-alert
46 (if (cdr entry) (format ": %s" (cdr entry)) ""))
47 ;; Without a window system, yes-or-no-p should be
48 ;; sufficient.
49 (while (not
50 (yes-or-no-p (format "%s%s Got that? " proposed-alert
51 (if (cdr entry) (format ": %s" (cdr entry)) ""))))))))))
52
53(defun jabber-watch-add (buddy &optional comment)
54 (interactive (list (jabber-read-jid-completing "Add buddy to watch list: ")
55 (read-string "Comment: ")))
56 (unless (memq 'jabber-presence-watch jabber-presence-hooks)
57 (error "The jabber-presence-watch function is not in jabber-presence-hooks"))
58 (add-to-list 'jabber-watch-alist (cons
59 (jabber-jid-symbol buddy)
60 (and (not (zerop (length comment)))
61 comment))))
62
63(defun jabber-watch-remove (buddy)
64 (interactive
65 (list (jabber-read-jid-completing "Remove buddy from watch list: "
66 (or (mapcar 'car jabber-watch-alist)
67 (error "Watch list is empty"))
68 t)))
69 (setq jabber-watch-alist
70 (delq (assq (jabber-jid-symbol buddy) jabber-watch-alist)
71 jabber-watch-alist)))
72
73(provide 'jabber-watch)
74
75;; arch-tag: c27299d8-019e-44b5-9529-d67b8682be23