* riece-keyword.el (riece-keywords): Change custom spec.
authorueno <ueno>
Mon, 27 Oct 2003 13:18:00 +0000 (13:18 +0000)
committerueno <ueno>
Mon, 27 Oct 2003 13:18:00 +0000 (13:18 +0000)
(riece-keyword-message-filter): Normalize riece-keywords.

lisp/ChangeLog
lisp/riece-keyword.el

index 911d649..ecf1f19 100644 (file)
@@ -1,5 +1,8 @@
 2003-10-27  Daiki Ueno  <ueno@unixuser.org>
 
+       * riece-keyword.el (riece-keywords): Change custom spec.
+       (riece-keyword-message-filter): Normalize riece-keywords.
+
        * riece-identity.el (riece-identity-prefix-case-table): Use
        riece-copy-case-table to define.
 
index 1e1e3b8..b0b0952 100644 (file)
@@ -37,7 +37,9 @@
 
 (defcustom riece-keywords nil
   "Keywords to be highlightened."
-  :type '(repeat string)
+  :type '(repeat (choice (string :tag "Keyword")
+                        (cons (string :tag "Regexp")
+                              (integer :tag "Match"))))
   :group 'riece-keyword)
 
 (defcustom riece-notify-keyword-functions nil
   (if (and riece-keywords
           ;; Ignore messages which belongs to myself.
           (not (riece-message-own-p message)))
-      (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)))))
+      (let* (keywords
+            (alist
+             (nconc
+              (delq nil (mapcar
+                         (lambda (matcher)
+                           (if (stringp matcher)
+                               (ignore
+                                (setq keywords (cons matcher keywords)))
+                             matcher))
+                         riece-keywords))
+              (list (cons (regexp-opt keywords) 0))))
+            index)
+       (while alist
+         (setq index 0)
+         (while (string-match (car (car alist))
+                              (riece-message-text message) index)
+           (if (memq 'riece-highlight riece-addons)
+               (put-text-property (match-beginning (cdr (car alist)))
+                                  (match-end (cdr (car alist)))
+                                  'riece-keyword t
+                                  (riece-message-text message)))
+           (save-match-data
+             (run-hook-with-args 'riece-notify-keyword-functions
+                                 (match-string (cdr (car alist))
+                                               (riece-message-text message))))
+           (setq index (match-end (cdr (car alist)))))
+         (setq alist (cdr alist)))))
   message)
 
 (defun riece-keyword-scan-region (start end)