Update to 7.0.3.
[riece] / lisp / riece-keyword.el
index 85251b7..9cb568d 100644 (file)
@@ -44,7 +44,7 @@
 
 (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
@@ -54,7 +54,7 @@
   "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 +86,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)