From: bg66 Date: Fri, 10 Sep 2004 11:43:36 +0000 (+0000) Subject: * riece-mini.el (riece-mini): New group. X-Git-Tag: riece-1_0_4~27 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aa597a4d8e6915f2c318f0d0b0cc61d4b4f80db9;p=elisp%2Friece.git * 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. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index e2de02f..acef142 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,14 @@ 2004-09-10 OHASHI Akira + * 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. diff --git a/lisp/riece-mini.el b/lisp/riece-mini.el index 1291e6c..c18609b 100644 --- a/lisp/riece-mini.el +++ b/lisp/riece-mini.el @@ -32,16 +32,28 @@ ;; 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) @@ -66,9 +78,13 @@ (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))