Fix error on make update-mcat.
[riece] / lisp / riece-message.el
index e32c45f..ba156a4 100644 (file)
   :type 'function
   :group 'riece-message)
 
+(defcustom riece-message-format-function-alist nil
+  "Alist mapping message types to format functions."
+  :type 'list
+  :group 'riece-message)
+
 (defun riece-message-make-open-bracket (message)
   "Make `open-bracket' string for MESSAGE."
   (if (eq (riece-message-type message) 'notice)
@@ -142,7 +147,7 @@ Normally they are *Dialogue* and/or *Others*."
        (list riece-dialogue-buffer riece-others-buffer)
       riece-dialogue-buffer)))
 
-(defun riece-format-message (message &optional global)
+(defun riece-format-message-1 (message &optional global)
   (let ((open-bracket
         (funcall riece-message-make-open-bracket-function message))
        (close-bracket
@@ -162,6 +167,12 @@ Normally they are *Dialogue* and/or *Others*."
                 " " (riece-message-text message)))
        "\n"))))
 
+(defun riece-format-message (message &optional global)
+  (funcall (or (cdr (assq (riece-message-type message)
+                         riece-message-format-function-alist))
+              #'riece-format-message-1)
+          message global))
+
 (defun riece-display-message-1 (message)
   (let ((buffer (riece-message-buffer message))
        parent-buffers)
@@ -192,7 +203,7 @@ Normally they are *Dialogue* and/or *Others*."
 Arguments are appropriate to the sender, the receiver, and text
 content, respectively.
 Optional 4th argument TYPE specifies the type of the message.
-Currently possible values are `action' and `notice'.
+Currently possible values are `nil' or `notice'.
 Optional 5th argument is the flag to indicate that this message is not
 from the network."
   (vector speaker target text type own-p))