diff options
author | Leo Liu <sdl.web@gmail.com> | 2012-08-15 20:26:48 +0800 |
---|---|---|
committer | Leo Liu <sdl.web@gmail.com> | 2012-08-15 20:26:48 +0800 |
commit | 27d6c5a891036a40c1242f1f53cc794023f31283 (patch) | |
tree | b9e88f2846c8616d0564fba8aa7316c133dcedec /lisp | |
parent | 6f97980a9a0ca66d7b177005295cd7d6b68bf610 (diff) | |
download | emacs-27d6c5a891036a40c1242f1f53cc794023f31283.tar.gz emacs-27d6c5a891036a40c1242f1f53cc794023f31283.tar.bz2 emacs-27d6c5a891036a40c1242f1f53cc794023f31283.zip |
Fix for the buffer-local rcirc-encode-coding-system case
in rcirc-split-message.
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/ChangeLog | 5 | ||||
-rw-r--r-- | lisp/net/rcirc.el | 33 |
2 files changed, 22 insertions, 16 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 5b2c16edaf7..143c255136f 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2012-08-15 Leo Liu <sdl.web@gmail.com> + + * net/rcirc.el (rcirc-split-message): Fix for buffer-local + rcirc-encode-coding-system. + 2012-08-13 Leo Liu <sdl.web@gmail.com> * net/rcirc.el (rcirc-split-message): New function. diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el index 0eb6c7ea51b..0491e23ee24 100644 --- a/lisp/net/rcirc.el +++ b/lisp/net/rcirc.el @@ -796,22 +796,23 @@ With no argument or nil as argument, use the current buffer." (defun rcirc-split-message (message) "Split MESSAGE into chunks within `rcirc-max-message-length'." - (with-temp-buffer - (insert message) - (goto-char (point-min)) - (let (result) - (while (not (eobp)) - (goto-char (or (byte-to-position rcirc-max-message-length) - (point-max))) - ;; max message length is 512 including CRLF - (while (and (not (bobp)) - (> (length - (encode-coding-region (point-min) (point) - rcirc-encode-coding-system t)) - rcirc-max-message-length)) - (forward-char -1)) - (push (delete-and-extract-region (point-min) (point)) result)) - (nreverse result)))) + ;; `rcirc-encode-coding-system' can have buffer-local value. + (let ((encoding rcirc-encode-coding-system)) + (with-temp-buffer + (insert message) + (goto-char (point-min)) + (let (result) + (while (not (eobp)) + (goto-char (or (byte-to-position rcirc-max-message-length) + (point-max))) + ;; max message length is 512 including CRLF + (while (and (not (bobp)) + (> (length (encode-coding-region + (point-min) (point) encoding t)) + rcirc-max-message-length)) + (forward-char -1)) + (push (delete-and-extract-region (point-min) (point)) result)) + (nreverse result))))) (defun rcirc-send-message (process target message &optional noticep silent) "Send TARGET associated with PROCESS a privmsg with text MESSAGE. |