* riece-mini.el (riece-mini): New group.
authorbg66 <bg66>
Fri, 10 Sep 2004 11:43:36 +0000 (11:43 +0000)
committerbg66 <bg66>
Fri, 10 Sep 2004 11:43:36 +0000 (11:43 +0000)
(riece-mini-backlog-size): New user option.
(riece-mini-backlog-history): New internal variable.
(riece-mini-backlog-shown): Ditto.
(riece-mini-show-backlog): New function.
(riece-mini-pre-command): Ditto.
(riece-mini-display-message-function): Use them.
(riece-mini-insinuate): Ditto.

lisp/ChangeLog
lisp/riece-mini.el

index e2de02f..acef142 100644 (file)
@@ -1,5 +1,14 @@
 2004-09-10  OHASHI Akira  <bg66@koka-in.org>
 
+       * riece-mini.el (riece-mini): New group.
+       (riece-mini-backlog-size): New user option.
+       (riece-mini-backlog-history): New internal variable.
+       (riece-mini-backlog-shown): Ditto.
+       (riece-mini-show-backlog): New function.
+       (riece-mini-pre-command): Ditto.
+       (riece-mini-display-message-function): Use them.
+       (riece-mini-insinuate): Ditto.
+
        * riece-biff.el (toplevel): Remove eval-when-compile.
        * riece-log.el (toplevel): Ditto.
        * riece-mini.el (toplevel): Ditto.
index 1291e6c..c18609b 100644 (file)
 ;; To use, add the following line to your ~/.riece/init.el:
 ;; (add-to-list 'riece-addons 'riece-mini)
 ;;
-;; And for using conveniently, bind any global key to
-;; `riece-mini-send-message'.
+;; For using conveniently, bind any global key to
+;; `riece-mini-send-message' and `riece-mini-show-backlog'.
 ;; For example:
 ;; (global-set-key "\C-cm" 'riece-mini-send-message)
+;; (global-set-key "\C-cb" 'riece-mini-show-backlog)
 
 ;;; Code:
 
 (require 'riece-message)
 
+(defgroup riece-mini nil
+  "riece on minibuffer"
+  :group 'riece)
+
+(defcustom riece-mini-backlog-size 10
+  "*Line numbers for logging back log."
+  :type 'integer
+  :group 'riece-mini)
+
 (defvar riece-mini-last-channel nil)
+(defvar riece-mini-backlog-history nil)
+(defvar riece-mini-backlog-shown nil)
 
 (defvar riece-mini-enabled nil)
 
                      (active-minibuffer-window))))
     (unless (riece-message-type message)
       (setq riece-mini-last-channel (riece-message-target message)))
-    (riece-mini-message-no-log
-     "%s" (concat (format-time-string "%H:%M") " "
-                 (riece-format-message message t)))))
+    (let ((string (concat (format-time-string "%H:%M") " "
+                         (riece-format-message message t))))
+      (riece-mini-message-no-log "%s" string)
+      (when (>= (length riece-mini-backlog-history)
+               riece-mini-backlog-size)
+       (pop riece-mini-backlog-history))
+      (push string riece-mini-backlog-history))))
 
 (defun riece-mini-send-message (arg)
   "Send message using minibuffer.
@@ -94,9 +110,26 @@ If twice (C-u C-u), then ask the channel."
        (riece-make-message (riece-current-nickname) target
                           message nil t)))))
 
+(defun riece-mini-show-backlog ()
+  "Send back logs to minibuffer."
+  (interactive)
+  (let ((max-mini-window-height riece-mini-backlog-size)
+       (resize-mini-windows t))
+    (when riece-mini-backlog-history
+      (setq riece-mini-backlog-shown t)
+      (riece-mini-message-no-log
+       (mapconcat 'identity (reverse riece-mini-backlog-history) "")))))
+
+(defun riece-mini-pre-command ()
+  (when riece-mini-backlog-shown
+    (let ((resize-mini-windows t))
+      (setq riece-mini-backlog-shown nil)
+      (riece-mini-message-no-log ""))))
+
 (defun riece-mini-insinuate ()
   (add-hook 'riece-after-display-message-functions
-           'riece-mini-display-message-function))
+           'riece-mini-display-message-function)
+  (add-hook 'pre-command-hook 'riece-mini-pre-command))
 
 (defun riece-mini-enable ()
   (setq riece-mini-enabled t))