From 9382b82a2ea0efbe876fcdc25e64cdc38610e373 Mon Sep 17 00:00:00 2001 From: ueno Date: Fri, 23 May 2003 05:51:36 +0000 Subject: [PATCH] Rewrite to use liece-display-message. --- contrib/plum-support.el | 64 +++++++++++++++++++++-------------------------- 1 file changed, 29 insertions(+), 35 deletions(-) diff --git a/contrib/plum-support.el b/contrib/plum-support.el index 6c16db3..2b76ac3 100644 --- a/contrib/plum-support.el +++ b/contrib/plum-support.el @@ -3,7 +3,6 @@ ;; Author: Daiki Ueno ;; Created: 1999-05-06 -;; Revised: 1999-05-06 ;; Keywords: IRC, liece, pirc ;; This file is part of Liece. @@ -23,14 +22,21 @@ ;; 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" @@ -114,40 +120,28 @@ ((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) -- 1.7.10.4