Include the message sender in desktop notification
[riece] / lisp / riece-keyword.el
index 85251b7..f80ac3d 100644 (file)
@@ -1,4 +1,4 @@
-;;; riece-keyword.el --- detect keywords in IRC buffers
+;;; riece-keyword.el --- detect keywords in IRC buffers -*- lexical-binding: t -*-
 ;; Copyright (C) 1998-2003 Daiki Ueno
 
 ;; Author: Daiki Ueno <ueno@unixuser.org>
 
 (defcustom riece-notify-keyword-functions nil
   "Functions used to notify keyword match."
-  :type '(list function)
+  :type '(repeat function)
   :group 'riece-keyword)
 
 (make-obsolete-variable 'riece-notify-keyword-functions
-                       'riece-keyword-notify-functions)
+                       'riece-keyword-notify-functions
+                       "2003-12-22")
 
 (defcustom riece-keyword-notify-functions nil
   "Functions used to notify keyword match.
 Two arguments are passed to each function: the keyword used to match
 and the matched message object."
-  :type '(list function)
+  :type '(repeat function)
   :group 'riece-keyword)
 
 (defface riece-keyword-face
@@ -86,23 +87,26 @@ and the matched message object."
                                 (setq keywords (cons matcher keywords)))
                              matcher))
                          riece-keywords))
-              (list (cons (regexp-opt keywords) 0))))
+              (if keywords
+                  (list (cons (regexp-opt keywords) 0)))))
             index)
        (while alist
          (setq index 0)
-         (while (string-match (car (car alist))
-                              (riece-message-text message) index)
+         (while (and (< index (length (riece-message-text message)))
+                     (string-match (car (car alist))
+                                   (riece-message-text message) index))
            (put-text-property (match-beginning (cdr (car alist)))
                               (match-end (cdr (car alist)))
                               'riece-overlay-face riece-keyword-face
                               (riece-message-text message))
-           (run-hook-with-args 'riece-notify-keyword-functions
-                               (match-string (cdr (car alist))
-                                             (riece-message-text message)))
-           (run-hook-with-args 'riece-keyword-notify-functions
-                               (cdr (car alist))
-                               message)
-           (setq index (match-end (cdr (car alist)))))
+           (save-match-data
+             (run-hook-with-args 'riece-notify-keyword-functions
+                                 (match-string (cdr (car alist))
+                                               (riece-message-text message)))
+             (run-hook-with-args 'riece-keyword-notify-functions
+                                 (cdr (car alist))
+                                 message))
+           (setq index (1+ (match-end (cdr (car alist))))))
          (setq alist (cdr alist)))))
   message)
 
@@ -118,4 +122,4 @@ and the matched message object."
 
 (provide 'riece-keyword)
 
-;;; riece-keyword.el ends here
\ No newline at end of file
+;;; riece-keyword.el ends here