* riece-irc.el (riece-irc-open-server): Init riece-coding-system-alist.
* riece-handle.el (riece-handle-privmsg-message): Retry with the
channel's coding-system if it differs from the server's
coding-system.
* riece-commands.el (riece-command-send-message): Pass prefix to
riece-send-string.
* riece-globals.el (riece-coding-system-alist): New variable.
* riece-coding.el (riece-decode-coding-string-1): Split from
riece-decode-coding-string; set riece-coding-encoded-string and
riece-coding-decoded-coding-system properties on decoded string.
(riece-retry-decode-coding-string): New function.
(riece-decoded-coding-system): Use it.
+2005-06-04 Daiki Ueno <ueno@unixuser.org>
+
+ * riece-server.el (riece-server-keyword-map): Add :coding-system-alist.
+
+ * riece-irc.el (riece-irc-open-server): Init riece-coding-system-alist.
+
+ * riece-handle.el (riece-handle-privmsg-message): Retry with the
+ channel's coding-system if it differs from the server's
+ coding-system.
+
+ * riece-commands.el (riece-command-send-message): Pass prefix to
+ riece-send-string.
+
+ * riece-globals.el (riece-coding-system-alist): New variable.
+
+ * riece-coding.el (riece-decode-coding-string-1): Split from
+ riece-decode-coding-string; set riece-coding-encoded-string and
+ riece-coding-decoded-coding-system properties on decoded string.
+ (riece-retry-decode-coding-string): New function.
+ (riece-decoded-coding-system): Use it.
+
2005-06-03 Daiki Ueno <ueno@unixuser.org>
* riece-ruby.el: New file.
(defun riece-decode-coding-string (string)
(if (and (local-variable-p 'riece-coding-system (current-buffer))
riece-coding-system) ;should be nil on non-Mule environment
- (if (consp riece-coding-system)
- (decode-coding-string string (car riece-coding-system))
- (decode-coding-string string riece-coding-system))
+ (riece-decode-coding-string-1 string
+ (if (consp riece-coding-system)
+ (car riece-coding-system)
+ riece-coding-system))
string))
+(defun riece-retry-decode-coding-string (string coding-system)
+ (if (eq (get-text-property 0 'riece-coding-decoded-coding-system string)
+ coding-system)
+ string
+ (riece-decode-coding-string-1
+ (get-text-property 0 'riece-coding-encoded-string string)
+ coding-system)))
+
+(defun riece-decoded-coding-system (string)
+ (get-text-property 0 'riece-coding-decoded-coding-system string))
+
+(defun riece-decode-coding-string-1 (string coding-system)
+ (let* ((decoded (decode-coding-string string coding-system))
+ (length (length decoded)))
+ (put-text-property 0 length 'riece-coding-encoded-string
+ string decoded)
+ (put-text-property 0 length 'riece-coding-decoded-coding-system
+ coding-system decoded)
+ decoded))
+
(provide 'riece-coding)
;;; riece-coding.el ends here
(riece-send-string
(format "NOTICE %s :%s\r\n"
(riece-identity-prefix riece-current-channel)
- message))
+ message)
+ (riece-identity-prefix riece-current-channel))
(riece-display-message
(riece-make-message (riece-current-nickname) riece-current-channel
message 'notice t)))
(riece-send-string
(format "PRIVMSG %s :%s\r\n"
(riece-identity-prefix riece-current-channel)
- message))
+ message)
+ (riece-identity-prefix riece-current-channel))
(riece-display-message
(riece-make-message (riece-current-nickname) riece-current-channel
message nil t))))
(defvar riece-coding-system nil
"Coding system for process I/O.
Local to the server buffers.")
+(defvar riece-coding-system-alist nil
+ "An alist mapping prefixes to coding-systems.
+Local to the server buffers.")
;;; Variables local to the channel buffers:
(defvar riece-freeze nil
(let* ((user (riece-prefix-nickname prefix))
(parameters (riece-split-parameters string))
(targets (split-string (car parameters) ","))
+ (coding-system (cdr (assoc (car targets) riece-coding-system-alist)))
(message (nth 1 parameters)))
- (riece-display-message
- (riece-make-message (riece-make-identity user
- riece-server-name)
- (riece-make-identity (car targets)
- riece-server-name)
- message nil
- (riece-identity-equal-no-server
- user riece-real-nickname)))))
+ (if (eq coding-system
+ (riece-decoded-coding-system string))
+ (riece-display-message
+ (riece-make-message (riece-make-identity user
+ riece-server-name)
+ (riece-make-identity (car targets)
+ riece-server-name)
+ message
+ nil
+ (riece-identity-equal-no-server
+ user riece-real-nickname)))
+ (riece-handle-privmsg-message
+ prefix
+ (riece-retry-decode-coding-string string
+ coding-system)))))
(defun riece-handle-notice-message (prefix string)
(let* ((user (if prefix
(with-current-buffer (process-buffer process)
(setq riece-last-nickname riece-real-nickname
riece-nick-accepted 'sent
- riece-coding-system coding))
+ riece-coding-system coding
+ riece-coding-system-alist coding-system-alist))
process))))
(defun riece-irc-quit-server-process (process &optional message)
(:username riece-username)
(:password)
(:function riece-default-open-connection-function)
- (:coding riece-default-coding-system))
+ (:coding riece-default-coding-system)
+ (:coding-system-alist))
"Mapping from keywords to default values.
All keywords that can be used must be listed here."))
(setq riece-send-size 0))
(while (and (not (riece-queue-empty riece-send-queue))
(<= riece-send-size riece-max-send-size))
- (setq string (riece-encode-coding-string
- (riece-queue-dequeue riece-send-queue))
+ (setq string (riece-queue-dequeue riece-send-queue)
length (length string))
(if (> length riece-max-send-size)
(message "Long message (%d > %d)" length riece-max-send-size)
(if (riece-server-opened "")
"")))))
-(defun riece-send-string (string)
+(defun riece-send-string (string &optional prefix)
(let* ((server-name (riece-current-server-name))
- (process (riece-server-process server-name)))
+ (process (riece-server-process server-name))
+ coding-system)
(unless process
(error "%s" (substitute-command-keys
"Type \\[riece-command-open-server] to open server.")))
- (riece-process-send-string process string)))
+ (riece-process-send-string
+ process
+ (if (and prefix
+ (setq coding-system
+ (cdr (assoc prefix
+ (plist-get (riece-server-properties
+ server-name)
+ :coding-system-alist)))))
+ (encode-coding-string string coding-system)
+ (riece-encode-coding-string string)))))
(defun riece-open-server (server server-name)
(let ((protocol (or (plist-get server :protocol)
(make-local-variable 'riece-channel-obarray)
(setq riece-channel-obarray (make-vector riece-channel-obarray-size 0))
(make-local-variable 'riece-coding-system)
+ (make-local-variable 'riece-coding-system-alist)
(buffer-disable-undo)
(erase-buffer)))