aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/net
diff options
context:
space:
mode:
authorGlenn Morris2012-08-28 09:01:59 -0700
committerGlenn Morris2012-08-28 09:01:59 -0700
commiteada086196ccb005ded188ac2e58d41f3682a125 (patch)
treef195bbf91841ea4e85d465307d62c709924892c2 /lisp/net
parent37b9743e79bac608a45fade0744248446aaa0a33 (diff)
parent806f0cc7302bd1dacfad8366f67a97e9bfbc8fc9 (diff)
downloademacs-eada086196ccb005ded188ac2e58d41f3682a125.tar.gz
emacs-eada086196ccb005ded188ac2e58d41f3682a125.zip
Merge from emacs-24; up to 2012-05-04T19:17:01Z!monnier@iro.umontreal.ca
Diffstat (limited to 'lisp/net')
-rw-r--r--lisp/net/rcirc.el40
1 files changed, 25 insertions, 15 deletions
diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el
index 27cf50f06ca..dd345630b9b 100644
--- a/lisp/net/rcirc.el
+++ b/lisp/net/rcirc.el
@@ -802,26 +802,36 @@ With no argument or nil as argument, use the current buffer."
802(defvar rcirc-max-message-length 420 802(defvar rcirc-max-message-length 420
803 "Messages longer than this value will be split.") 803 "Messages longer than this value will be split.")
804 804
805(defun rcirc-split-message (message)
806 "Split MESSAGE into chunks within `rcirc-max-message-length'."
807 ;; `rcirc-encode-coding-system' can have buffer-local value.
808 (let ((encoding rcirc-encode-coding-system))
809 (with-temp-buffer
810 (insert message)
811 (goto-char (point-min))
812 (let (result)
813 (while (not (eobp))
814 (goto-char (or (byte-to-position rcirc-max-message-length)
815 (point-max)))
816 ;; max message length is 512 including CRLF
817 (while (and (not (bobp))
818 (> (length (encode-coding-region
819 (point-min) (point) encoding t))
820 rcirc-max-message-length))
821 (forward-char -1))
822 (push (delete-and-extract-region (point-min) (point)) result))
823 (nreverse result)))))
824
805(defun rcirc-send-message (process target message &optional noticep silent) 825(defun rcirc-send-message (process target message &optional noticep silent)
806 "Send TARGET associated with PROCESS a privmsg with text MESSAGE. 826 "Send TARGET associated with PROCESS a privmsg with text MESSAGE.
807If NOTICEP is non-nil, send a notice instead of privmsg. 827If NOTICEP is non-nil, send a notice instead of privmsg.
808If SILENT is non-nil, do not print the message in any irc buffer." 828If SILENT is non-nil, do not print the message in any irc buffer."
809 ;; max message length is 512 including CRLF 829 (let ((response (if noticep "NOTICE" "PRIVMSG")))
810 (let* ((response (if noticep "NOTICE" "PRIVMSG"))
811 (oversize (> (length message) rcirc-max-message-length))
812 (text (if oversize
813 (substring message 0 rcirc-max-message-length)
814 message))
815 (text (if (string= text "")
816 " "
817 text))
818 (more (if oversize
819 (substring message rcirc-max-message-length))))
820 (rcirc-get-buffer-create process target) 830 (rcirc-get-buffer-create process target)
821 (rcirc-send-string process (concat response " " target " :" text)) 831 (dolist (msg (rcirc-split-message message))
822 (unless silent 832 (rcirc-send-string process (concat response " " target " :" msg))
823 (rcirc-print process (rcirc-nick process) response target text)) 833 (unless silent
824 (when more (rcirc-send-message process target more noticep)))) 834 (rcirc-print process (rcirc-nick process) response target msg)))))
825 835
826(defvar rcirc-input-ring nil) 836(defvar rcirc-input-ring nil)
827(defvar rcirc-input-ring-index 0) 837(defvar rcirc-input-ring-index 0)