Subject: Re: bug#40914: 27.0.91; erc send is failing on pretest

From: Eli Zaretskii <[email-masked]>
Date: Tue, 28 Apr 2020 19:10:48 +0300

> From: andrés ramírez <[email-masked]>
> Cc: [email-masked]
> Date: Tue, 28 Apr 2020 15:48:32 +0000
> 
>     Eli> What does the following yield in a session that fails like
>     Eli> this?
> 
>     Eli>   M-: (erc-coding-system-for-target nil) RET
> 
> --8<---------------cut here---------------start------------->8---
> utf-8
> --8<---------------cut here---------------end--------------->8---

That's the problem.  The question is: how did that happen?

And here's the answer:

>   (setq
>    erc-nick-uniquifier "_"
>    erc-kill-queries-on-quit t
>    erc-server-coding-system (quote utf-8)
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

So does the patch below fix the problem?

diff --git a/lisp/erc/erc-backend.el b/lisp/erc/erc-backend.el
index 0e3495e..526e854 100644
--- a/lisp/erc/erc-backend.el
+++ b/lisp/erc/erc-backend.el
@@ -466,7 +466,8 @@ erc-split-line
 The length is specified in `erc-split-line-length'.
 
 Currently this is called by `erc-send-input'."
-  (let ((charset (car (erc-coding-system-for-target nil))))
+  (let* ((coding (erc-coding-system-for-target nil))
+         (charset (if (consp coding) (car coding) coding)))
     (with-temp-buffer
       (insert longline)
       ;; The line lengths are in octets, not characters (because these