diff options
| author | Leo Liu | 2012-08-14 01:22:42 +0800 |
|---|---|---|
| committer | Leo Liu | 2012-08-14 01:22:42 +0800 |
| commit | 4432d2e25bc56cd06c9ed0c987d6570b2d57f230 (patch) | |
| tree | b4e8307ebc973f70d7392cf84d6fdbc62197862b | |
| parent | 170aedb97ebee3edb81d2c447e6baa465978b03f (diff) | |
| download | emacs-4432d2e25bc56cd06c9ed0c987d6570b2d57f230.tar.gz emacs-4432d2e25bc56cd06c9ed0c987d6570b2d57f230.zip | |
* lisp/net/rcirc.el (rcirc-split-message): New function.
(rcirc-send-message): Use it.
Fixes: debbugs:12051
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/net/rcirc.el | 39 |
2 files changed, 29 insertions, 15 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 65017383de8..4e03a56111c 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2012-08-13 Leo Liu <sdl.web@gmail.com> | ||
| 2 | |||
| 3 | * net/rcirc.el (rcirc-split-message): New function. | ||
| 4 | (rcirc-send-message): Use it. (Bug#12051) | ||
| 5 | |||
| 1 | 2012-08-10 Glenn Morris <rgm@gnu.org> | 6 | 2012-08-10 Glenn Morris <rgm@gnu.org> |
| 2 | 7 | ||
| 3 | * emacs-lisp/copyright.el (copyright-update-directory): Logic fix. | 8 | * emacs-lisp/copyright.el (copyright-update-directory): Logic fix. |
diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el index e34b7c79b3b..0eb6c7ea51b 100644 --- a/lisp/net/rcirc.el +++ b/lisp/net/rcirc.el | |||
| @@ -794,26 +794,35 @@ With no argument or nil as argument, use the current buffer." | |||
| 794 | (defvar rcirc-max-message-length 420 | 794 | (defvar rcirc-max-message-length 420 |
| 795 | "Messages longer than this value will be split.") | 795 | "Messages longer than this value will be split.") |
| 796 | 796 | ||
| 797 | (defun rcirc-split-message (message) | ||
| 798 | "Split MESSAGE into chunks within `rcirc-max-message-length'." | ||
| 799 | (with-temp-buffer | ||
| 800 | (insert message) | ||
| 801 | (goto-char (point-min)) | ||
| 802 | (let (result) | ||
| 803 | (while (not (eobp)) | ||
| 804 | (goto-char (or (byte-to-position rcirc-max-message-length) | ||
| 805 | (point-max))) | ||
| 806 | ;; max message length is 512 including CRLF | ||
| 807 | (while (and (not (bobp)) | ||
| 808 | (> (length | ||
| 809 | (encode-coding-region (point-min) (point) | ||
| 810 | rcirc-encode-coding-system t)) | ||
| 811 | rcirc-max-message-length)) | ||
| 812 | (forward-char -1)) | ||
| 813 | (push (delete-and-extract-region (point-min) (point)) result)) | ||
| 814 | (nreverse result)))) | ||
| 815 | |||
| 797 | (defun rcirc-send-message (process target message &optional noticep silent) | 816 | (defun rcirc-send-message (process target message &optional noticep silent) |
| 798 | "Send TARGET associated with PROCESS a privmsg with text MESSAGE. | 817 | "Send TARGET associated with PROCESS a privmsg with text MESSAGE. |
| 799 | If NOTICEP is non-nil, send a notice instead of privmsg. | 818 | If NOTICEP is non-nil, send a notice instead of privmsg. |
| 800 | If SILENT is non-nil, do not print the message in any irc buffer." | 819 | If SILENT is non-nil, do not print the message in any irc buffer." |
| 801 | ;; max message length is 512 including CRLF | 820 | (let ((response (if noticep "NOTICE" "PRIVMSG"))) |
| 802 | (let* ((response (if noticep "NOTICE" "PRIVMSG")) | ||
| 803 | (oversize (> (length message) rcirc-max-message-length)) | ||
| 804 | (text (if oversize | ||
| 805 | (substring message 0 rcirc-max-message-length) | ||
| 806 | message)) | ||
| 807 | (text (if (string= text "") | ||
| 808 | " " | ||
| 809 | text)) | ||
| 810 | (more (if oversize | ||
| 811 | (substring message rcirc-max-message-length)))) | ||
| 812 | (rcirc-get-buffer-create process target) | 821 | (rcirc-get-buffer-create process target) |
| 813 | (rcirc-send-string process (concat response " " target " :" text)) | 822 | (dolist (msg (rcirc-split-message message)) |
| 814 | (unless silent | 823 | (rcirc-send-string process (concat response " " target " :" msg)) |
| 815 | (rcirc-print process (rcirc-nick process) response target text)) | 824 | (unless silent |
| 816 | (when more (rcirc-send-message process target more noticep)))) | 825 | (rcirc-print process (rcirc-nick process) response target msg))))) |
| 817 | 826 | ||
| 818 | (defvar rcirc-input-ring nil) | 827 | (defvar rcirc-input-ring nil) |
| 819 | (defvar rcirc-input-ring-index 0) | 828 | (defvar rcirc-input-ring-index 0) |