(defvar rcirc-pounces nil
"Alist with a message queue per nick.")
(when (boundp 'session-globals-include)
(add-to-list 'session-globals-include 'rcirc-pounces))
(when (boundp 'desktop-globals-to-save)
(add-to-list 'desktop-globals-to-save 'rcirc-pounces))
(defun rcirc-add-pounce (nick message)
"Add MESSAGE for NICK to `rcirc-pounces'."
(let ((cell (assoc nick rcirc-pounces)))
(setcdr cell (cons message (cdr cell)))
(setq rcirc-pounces (cons (list nick message) rcirc-pounces)))))
(defun rcirc-pounce-queue (nick)
"Show queue for NICK."
(dolist (msg (or (cdr (assoc nick rcirc-pounces)) '("No messages")))
(rcirc-print process nick "NOTICE" target msg)))
(defun rcirc-pounce-queue-overview ()
"Show nicks in queue."
(rcirc-print process (rcirc-nick process) "NOTICE" target
(or (mapconcat 'identity (mapcar 'car rcirc-pounces) " ")
(defun-rcirc-command pounce (message)
"Add private MESSAGE for TARGET to its queue.
Without any argument, show the list of targets.
Without a message, show the list of messages for a target."
(if (not (string-match "\\([^ ]+\\)\\( \\(.+\\)\\)?" message))
(let ((nick (match-string 1 message))
(text (match-string 3 message)))
(rcirc-add-pounce nick text)
(defun-rcirc-command unpounce (nick)
"Clear queue for NICK."
(setq rcirc-pounces (delete (assoc nick rcirc-pounces) rcirc-pounces)))
(defun rcirc-pounce-process (sender)
"Send all messages for SENDER."
(let ((nick (rcirc-user-nick sender)))
(dolist (msg (cdr (assoc nick rcirc-pounces)))
(rcirc-send-message process nick msg))
(defadvice rcirc-handler-JOIN (after rcirc-handler-JOIN-pounce activate)
"Process pounces in `rcirc-pounces'."
(defadvice rcirc-handler-MODE (after rcirc-handler-MODE-pounce activate)
"Process pounces in `rcirc-pounces' on mode change."