* riece-xemacs.el (riece-make-overlay): New alias.
authorDaiki Ueno <ueno@unixuser.org>
Mon, 13 Oct 2003 21:48:44 +0000 (21:48 +0000)
committerDaiki Ueno <ueno@unixuser.org>
Mon, 13 Oct 2003 21:48:44 +0000 (21:48 +0000)
(riece-overlay-put): New alias.
(riece-overlay-start): New alias.
(riece-overlay-buffer): New alias.

* riece-emacs.el (riece-make-overlay): New alias.
(riece-overlay-put): New alias.
(riece-overlay-start): New alias.
(riece-overlay-buffer): New alias.

* riece-keyword.el: New add-on.
* COMPILE (riece-modules): Add riece-keyword.
* Makefile.am (EXTRA_DIST): Add riece-keyword.el

* riece-message.el (riece-message-filter-functions): New user option.
(riece-display-message-1): New function.
(riece-display-message): Use it.

lisp/COMPILE
lisp/ChangeLog
lisp/riece-button.el
lisp/riece-emacs.el
lisp/riece-keyword.el [new file with mode: 0644]
lisp/riece-message.el
lisp/riece-xemacs.el

index 2cbc846..5e7f64e 100644 (file)
@@ -53,7 +53,8 @@
                riece-skk-kakutei
                riece-guess
                riece-history
                riece-skk-kakutei
                riece-guess
                riece-history
-               riece-button))))
+               riece-button
+               riece-keyword))))
 
 (defun riece-compile-modules (modules)
   (let ((load-path (cons nil load-path)))
 
 (defun riece-compile-modules (modules)
   (let ((load-path (cons nil load-path)))
index 643f623..5868949 100644 (file)
@@ -1,3 +1,23 @@
+2003-10-13  Daiki Ueno  <ueno@unixuser.org>
+
+       * riece-xemacs.el (riece-make-overlay): New alias.
+       (riece-overlay-put): New alias.
+       (riece-overlay-start): New alias.
+       (riece-overlay-buffer): New alias.
+
+       * riece-emacs.el (riece-make-overlay): New alias.
+       (riece-overlay-put): New alias.
+       (riece-overlay-start): New alias.
+       (riece-overlay-buffer): New alias.
+
+       * riece-keyword.el: New add-on.
+       * COMPILE (riece-modules): Add riece-keyword.
+       * Makefile.am (EXTRA_DIST): Add riece-keyword.el
+
+       * riece-message.el (riece-message-filter-functions): New user option.
+       (riece-display-message-1): New function.
+       (riece-display-message): Use it.
+
 2003-10-13  Daiki Ueno  <ueno@unixuser.org>
 
        * riece.el (riece-channel-list-mode): Initialize
 2003-10-13  Daiki Ueno  <ueno@unixuser.org>
 
        * riece.el (riece-channel-list-mode): Initialize
index 21b7039..cba6fd3 100644 (file)
@@ -65,8 +65,8 @@
            ;; window, overlay, position.
            (riece-format-identity
             (if overlay
            ;; window, overlay, position.
            (riece-format-identity
             (if overlay
-                (with-current-buffer (overlay-buffer overlay)
-                  (widget-value (widget-at (overlay-start overlay))))
+                (with-current-buffer (riece-overlay-buffer overlay)
+                  (widget-value (widget-at (riece-overlay-start overlay))))
               (widget-value widget/window))))))
 
 (defun riece-button-switch-to-identity (widget &optional event)
               (widget-value widget/window))))))
 
 (defun riece-button-switch-to-identity (widget &optional event)
index 8d0de2e..6f5eca6 100644 (file)
        (boundp 'mark-active)
        mark-active))
 
        (boundp 'mark-active)
        mark-active))
 
+(defalias 'riece-make-overlay 'make-overlay)
+(defalias 'riece-overlay-put 'overlay-put)
+(defalias 'riece-overlay-start 'overlay-start)
+(defalias 'riece-overlay-buffer 'overlay-buffer)
+
 (provide 'riece-emacs)
 
 ;;; riece-emacs.el ends here
 (provide 'riece-emacs)
 
 ;;; riece-emacs.el ends here
diff --git a/lisp/riece-keyword.el b/lisp/riece-keyword.el
new file mode 100644 (file)
index 0000000..37ae4af
--- /dev/null
@@ -0,0 +1,106 @@
+;;; riece-keyword.el --- highlight keywords in channel buffers
+;; Copyright (C) 1998-2003 Daiki Ueno
+
+;; Author: Daiki Ueno <ueno@unixuser.org>
+;; Created: 1998-09-28
+;; Keywords: IRC, riece
+
+;; This file is part of Riece.
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.         See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING.  If not, write to the
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+;;; Commentary:
+
+;; To use, add the following line to your ~/.riece/init.el:
+;; (add-to-list 'riece-addons 'riece-keyword)
+
+;;; Code:
+
+(defgroup riece-keyword nil
+  "Highlight keyword in IRC buffer."
+  :group 'riece-vars)
+
+(defcustom riece-keywords nil
+  "Keywords to be highlightened."
+  :type '(repeat string)
+  :group 'riece-keyword)
+
+(defcustom riece-notify-keyword-functions nil
+  "Functions used to notify keyword match."
+  :type '(list function)
+  :group 'riece-keyword)
+
+(defface riece-keyword-face
+  '((((class color))
+     (:foreground "red" :underline t))
+    (t
+     ()))
+  "Face used for highlightening matching keyword."
+  :group 'riece-highlight-faces)
+(defvar riece-keyword-face 'riece-keyword-face)
+
+;;; The old XEmacs package doesn't have autoload setting for regexp-opt.
+(autoload 'regexp-opt "regexp-opt")
+(defun riece-keyword-message-filter (message)
+  (if riece-keywords
+      (let ((regexp (regexp-opt riece-keywords))
+           (index 0))
+       (while (string-match regexp (riece-message-text message) index)
+         (if (memq 'riece-highlight riece-addons)
+             (put-text-property (match-beginning 0) (match-end 0)
+                                'riece-keyword t
+                                (riece-message-text message)))
+         (save-match-data
+           (run-hook-with-args 'riece-notify-keyword-functions
+                               (match-string 0 (riece-message-text message))))
+         (setq index (match-end 0)))))
+  message)
+
+(defun riece-keyword-map-region (start end function)
+  (catch 'done
+    (while t
+      ;; Search for the beginning of the button region.
+      (unless (get-text-property start 'riece-keyword)
+       (setq start (next-single-property-change start 'riece-keyword
+                                                nil end)))
+      (if (= start end)
+         (throw 'done nil))
+      ;; Search for the end of the button region.
+      (let ((button-end (next-single-property-change start 'riece-keyword
+                                                    nil end)))
+       (if (= button-end end)
+           (throw 'done nil))
+       (funcall function start button-end)
+       (setq start button-end)))))
+
+(defun riece-keyword-scan-region (start end)
+  (riece-keyword-map-region
+   start end
+   (lambda (start end)
+     (riece-overlay-put (riece-make-overlay start end)
+                       'face riece-keyword-face))))
+
+(defun riece-keyword-requires ()
+  (if (memq 'riece-highlight riece-addons)
+      '(riece-highlight)))
+
+(defun riece-keyword-insinuate ()
+  (add-hook 'riece-message-filter-functions 'riece-keyword-message-filter)
+  (add-hook 'riece-after-insert-functions 'riece-keyword-scan-region))
+
+(provide 'riece-keyword)
+
+;;; riece-keyword.el ends here
\ No newline at end of file
index 8a20efb..bac5784 100644 (file)
   :prefix "riece-"
   :group 'riece)
 
   :prefix "riece-"
   :group 'riece)
 
+(defcustom riece-message-filter-functions nil
+  "Functions to filter incoming messages."
+  :type 'function
+  :group 'riece-message)
+
 (defcustom riece-message-make-open-bracket-function
   #'riece-message-make-open-bracket
   "Function which makes `open-bracket' string for each message."
 (defcustom riece-message-make-open-bracket-function
   #'riece-message-make-open-bracket
   "Function which makes `open-bracket' string for each message."
@@ -138,8 +143,7 @@ Normally they are *Dialogue* and/or *Others*."
        (list riece-dialogue-buffer riece-others-buffer)
       riece-dialogue-buffer)))
 
        (list riece-dialogue-buffer riece-others-buffer)
       riece-dialogue-buffer)))
 
-(defun riece-display-message (message)
-  "Display MESSAGE object."
+(defun riece-display-message-1 (message)
   (let ((open-bracket
         (funcall riece-message-make-open-bracket-function message))
        (close-bracket
   (let ((open-bracket
         (funcall riece-message-make-open-bracket-function message))
        (close-bracket
@@ -170,6 +174,16 @@ Normally they are *Dialogue* and/or *Others*."
                             " (from " server-name ")\n")))
     (run-hook-with-args 'riece-after-display-message-functions message)))
 
                             " (from " server-name ")\n")))
     (run-hook-with-args 'riece-after-display-message-functions message)))
 
+(defun riece-display-message (message)
+  "Display MESSAGE object."
+  (let ((functions riece-message-filter-functions))
+    (setq message (copy-sequence message))
+    (while functions
+      (setq message (funcall (car functions) message)
+           functions (cdr functions)))
+    (if message
+       (riece-display-message-1 message))))
+
 (defun riece-make-message (speaker target text &optional type own-p)
   "Make an instance of message object.
 Arguments are appropriate to the sender, the receiver, and text
 (defun riece-make-message (speaker target text &optional type own-p)
   "Make an instance of message object.
 Arguments are appropriate to the sender, the receiver, and text
index f884117..72efb4c 100644 (file)
@@ -91,6 +91,11 @@ Modify whole identification by side effect."
 ;;; stolen (and renamed) from gnus-xmas.el.
 (defalias 'riece-region-active-p 'region-active-p)
 
 ;;; stolen (and renamed) from gnus-xmas.el.
 (defalias 'riece-region-active-p 'region-active-p)
 
+(defalias 'riece-make-overlay 'make-extent)
+(defalias 'riece-overlay-put 'set-extent-property)
+(defalias 'riece-overlay-start 'extent-start-position)
+(defalias 'riece-overlay-buffer 'extent-buffer)
+
 (provide 'riece-xemacs)
 
 ;;; riece-xemacs.el ends here
 (provide 'riece-xemacs)
 
 ;;; riece-xemacs.el ends here