;; 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.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
;;; Code:
(require 'riece-misc)
(defgroup riece-message nil
- "Messages"
+ "Display messages."
:tag "Message"
:prefix "riece-"
:group 'riece)
(defun riece-message-make-open-bracket (message)
"Make `open-bracket' string for MESSAGE."
- (if (riece-message-own-p message)
- ">"
- (if (eq (riece-message-type message) 'notice)
- "{"
+ (if (eq (riece-message-type message) 'notice)
+ "{"
+ (if (riece-message-own-p message)
+ ">"
(if (riece-message-private-p message)
"="
(if (riece-message-external-p message)
(defun riece-message-make-close-bracket (message)
"Make `close-bracket' string for MESSAGE."
- (if (riece-message-own-p message)
- "<"
- (if (eq (riece-message-type message) 'notice)
- "}"
+ (if (eq (riece-message-type message) 'notice)
+ "}"
+ (if (riece-message-own-p message)
+ "<"
(if (riece-message-private-p message)
"="
(if (riece-message-external-p message)
(riece-message-target message))))
(unless (riece-identity-member target riece-current-channels)
(riece-join-channel target)
- ;; If you are not joined any channel,
+ ;; If you are not joined to any channel,
;; switch to the target immediately.
(unless riece-current-channel
(riece-switch-to-channel target)))
(funcall riece-message-make-global-name-function message)
(funcall riece-message-make-name-function message)))
(server-name (riece-identity-server (riece-message-speaker message))))
- (riece-with-server-buffer (riece-current-server-name)
+ (riece-with-server-buffer server-name
(concat
(if global
(riece-concat-server-name
(setq parent-buffers (riece-message-parent-buffers message buffer))
(riece-insert buffer (riece-format-message message))
(riece-insert parent-buffers (riece-format-message message t))
- (run-hook-with-args 'riece-after-display-message-functions message)))
+ (with-current-buffer buffer
+ (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
+ (while (and functions message)
(setq message (funcall (car functions) message)
functions (cdr functions)))
(if message
"Return t if MESSAGE is not from the network."
(aref message 4))
+(defun riece-message-set-speaker (message speaker)
+ "Set the sender of MESSAGE."
+ (aset message 0 speaker))
+
+(defun riece-message-set-target (message target)
+ "Set the receiver of MESSAGE."
+ (aset message 1 target))
+
+(defun riece-message-set-text (message text)
+ "Set the text part of MESSAGE."
+ (aset message 2 text))
+
+(defun riece-message-set-type (message type)
+ "Set the type of MESSAGE.
+Currently possible values are `action' and `notice'."
+ (aset message 3 type))
+
+(defun riece-message-set-own-p (message own-p)
+ "Set t if MESSAGE is not from the network."
+ (aset message 4 own-p))
+
(defun riece-message-private-p (message)
"Return t if MESSAGE is a private message."
(not (or (riece-channel-p (riece-identity-prefix