;; Author: Daiki Ueno <ueno@unixuser.org>
;; Created: 1999-05-06
-;; Revised: 1999-05-06
;; Keywords: IRC, liece, pirc
;; This file is part of Liece.
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
-
;;; Commentary:
-;;
+
+;; To use, add the following into your ~/.liece/init.el:
+;; (eval-after-load "liece"
+;; '(progn
+;; (require 'plum-support)
+;; (add-hook 'liece-notice-hook 'plum-recent-add)
+;; (add-hook 'liece-002-hook
+;; #'(lambda (header rest)
+;; (remove-hook 'liece-notice-hook 'plum-recent-add)))))
;;; Code:
(require 'custom)
-(require 'liece-handle)
+(require 'liece-message)
(require 'liece-channel)
(defcustom plum-recent-header "plum"
((looking-at plum-recent-generic-header-regexp)
(setq time (match-string 1))
(goto-char (match-end 0))
- (list 'generic time (buffer-substring (point) (line-end-position)))))
- )))
-
-(add-hook 'liece-notice-hook 'plum-recent-add)
-(add-hook 'liece-002-hook
- (function
- (lambda (header rest)
- (remove-hook 'liece-notice-hook 'plum-recent-add))))
+ (list 'generic time (buffer-substring (point)(line-end-position))))))))
(defun plum-recent-add (header rest)
"Add recent log line into `plum-recent-log-buffer'."
- (let (from to body component type)
- (if header
- nil
- (and rest (string-match "^[^ ]* +:\\(.*\\)" rest)
- (with-temp-buffer
- (insert (match-string 1 rest) ?\n)
- (goto-char (point-min))
- (setq component (plum-parse-recent-after)
- type (pop component))
- (cond
- ((eq type 'message)
- (setq from (nth 4 component)
- to (cond
- ((eq (nth 1 component) ?=)
- (liece-current-nickname))
- ((or (eq (nth 1 component) ?<)
- (eq (nth 1 component) ?>))
- (liece-channel-real (nth 3 component))))
- body (concat "(" plum-recent-header " " (car component)
- ") " (nth 5 component)))
- (liece-handle-privmsg-message from (concat to " :" body))
- t)
- (t nil)))))))
+ (when (and (not header)
+ rest (string-match "^[^ ]* +:\\(.*\\)" rest))
+ (with-temp-buffer
+ (insert (match-string 1 rest) ?\n)
+ (goto-char (point-min))
+ (let ((component (plum-parse-recent-after)))
+ (when (eq (pop component) 'message)
+ (let ((speaker (nth 4 component))
+ (target
+ (if (eq (nth 1 component) ?=)
+ (liece-current-nickname)
+ (if (memq (nth 1 component) '(?< ?>))
+ (liece-channel-virtual (nth 3 component)))))
+ (text (concat "(" plum-recent-header " " (car component)
+ ") " (nth 5 component))))
+ (liece-display-message
+ (liece-make-message speaker target text 'notice))
+ t))))))
(provide 'plum-support)