1 ;;; riece-mini.el --- "riece on minibuffer" add-on
2 ;; Copyright (C) 2003 OHASHI Akira
4 ;; Author: OHASHI Akira <bg66@koka-in.org>
5 ;; Keywords: IRC, riece
7 ;; This file is part of Riece.
9 ;; This program is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; This program is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 ;; Boston, MA 02111-1307, USA.
26 ;; This add-on shows arrival messages to minibuffer. And you can send
27 ;; message using minibuffer.
29 ;; By using this add-on, you can use always "mini riece", even if you
30 ;; are visiting other buffers.
32 ;; To use, add the following line to your ~/.riece/init.el:
33 ;; (add-to-list 'riece-addons 'riece-mini)
35 ;; And for using conveniently, bind any global key to
36 ;; `riece-mini-send-message'.
38 ;; (global-set-key "\C-cm" 'riece-mini-send-message)
42 (eval-when-compile (require 'riece-message))
44 (defvar riece-mini-last-channel nil)
46 (defvar riece-mini-enabled nil)
48 (defconst riece-mini-description
49 "Send arrival messages to minibuffer")
51 (defmacro riece-mini-message-no-log (string &rest args)
52 "Like `message', except that message logging is disabled."
53 (if (featurep 'xemacs)
55 `(display-message 'no-log (format ,string ,@args))
56 `(display-message 'no-log ,string))
57 `(let (message-log-max)
58 (message ,string ,@args))))
60 (defun riece-mini-display-message-function (message)
61 "Show arrival messages to minibuffer."
62 (when (and riece-mini-enabled
63 (not (or (eq (window-buffer (selected-window))
64 (get-buffer riece-command-buffer))
65 (riece-message-own-p message)
66 (active-minibuffer-window))))
67 (unless (riece-message-type message)
68 (setq riece-mini-last-channel (riece-message-target message)))
69 (riece-mini-message-no-log
70 "%s" (concat (format-time-string "%H:%M") " "
71 (riece-format-message message t)))))
73 (defun riece-mini-send-message (arg)
74 "Send message using minibuffer.
75 Prefix argument onece (C-u), send message to last received channel.
76 If twice (C-u C-u), then ask the channel."
78 (let* ((completion-ignore-case t)
82 (riece-completing-read-identity
83 "Channel/User: " riece-current-channels nil t))
84 (arg (or riece-mini-last-channel riece-current-channel))
85 (t riece-current-channel)))
86 (message (read-string (format "Message to %s: " target))))
87 (unless (equal message "")
88 (riece-switch-to-channel target)
90 (format "PRIVMSG %s :%s\r\n"
91 (riece-identity-prefix target)
93 (riece-display-message
94 (riece-make-message (riece-current-nickname) target
97 (defun riece-mini-insinuate ()
98 (add-hook 'riece-after-display-message-functions
99 'riece-mini-display-message-function))
101 (defun riece-mini-enable ()
102 (setq riece-mini-enabled t))
104 (defun riece-mini-disable ()
105 (setq riece-mini-enabled nil))
107 (provide 'riece-mini)
109 ;;; riece-mini.el ends here