aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Ingebrigtsen2018-04-13 20:24:04 +0200
committerLars Ingebrigtsen2018-04-13 20:24:04 +0200
commitcad2b8d109d4fd2b78d4e064af729336f348a2bb (patch)
treea0098b37143c658356f859a2e5eac95680fee3e7
parentb7ac2761fc5e58dd48b8b11642d16ba2b4f04c74 (diff)
downloademacs-cad2b8d109d4fd2b78d4e064af729336f348a2bb.tar.gz
emacs-cad2b8d109d4fd2b78d4e064af729336f348a2bb.zip
Compute erc line lengths correctly for utf-8 (etc.)
* lisp/erc/erc-backend.el (erc-split-line): Fold the lines according to octet length, not the number of characters (bug#23047).
-rw-r--r--lisp/erc/erc-backend.el10
1 files changed, 7 insertions, 3 deletions
diff --git a/lisp/erc/erc-backend.el b/lisp/erc/erc-backend.el
index 7eec56e363b..814ecfae85a 100644
--- a/lisp/erc/erc-backend.el
+++ b/lisp/erc/erc-backend.el
@@ -466,14 +466,18 @@ If this is set to nil, never try to reconnect."
466The length is specified in `erc-split-line-length'. 466The length is specified in `erc-split-line-length'.
467 467
468Currently this is called by `erc-send-input'." 468Currently this is called by `erc-send-input'."
469 (if (< (length longline) 469 (let ((charset (car (erc-coding-system-for-target nil))))
470 erc-split-line-length)
471 (list longline)
472 (with-temp-buffer 470 (with-temp-buffer
473 (insert longline) 471 (insert longline)
472 ;; The line lengths are in octets, not characters (because these
473 ;; are server protocol limits), so we have to first make the
474 ;; text into bytes, then fold the bytes on "word" boundaries,
475 ;; and then make the bytes into text again.
476 (encode-coding-region (point-min) (point-max) charset)
474 (let ((fill-column erc-split-line-length)) 477 (let ((fill-column erc-split-line-length))
475 (fill-region (point-min) (point-max) 478 (fill-region (point-min) (point-max)
476 nil t)) 479 nil t))
480 (decode-coding-region (point-min) (point-max) charset)
477 (split-string (buffer-string) "\n")))) 481 (split-string (buffer-string) "\n"))))
478 482
479(defun erc-forward-word () 483(defun erc-forward-word ()