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

From: andrés ramírez <[email-masked]>
Date: Tue, 28 Apr 2020 15:48:32 +0000

Hi Eli.
>>>>> "Eli" == Eli Zaretskii <[email-masked]> writes:

[...]

    Eli> I cannot reproduce this, so I guess this is triggered by
    Eli> something specific in your environment.

My enviroment is going to be shared below.

    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---

It is needed a couple of files. file 1:
--8<---------------cut here---------------start------------->8---
;-*- mode: emacs-lisp; encoding: utf-8; -*-
(require 'erc nil 'nonil4noerror)

(when (fboundp 'erc)
  (require 'erc-fill)
  (require 'erc-join)             ; autojoin support is implemented by erc-join.el
  (require 'erc-menu)
					;(require 'erc-sasl)
  (require 'erc-sasl "~/.emacs.d/lisp/erc-sasl.el" 'nonil4noerror)

  (when (boundp 'erc-sasl-server-regexp-list)
    (add-to-list 'erc-sasl-server-regexp-list "irc\\.freenode\\.net")
    )
  (erc-fill-mode t)
 
 (erc-autojoin-enable)           ; enable channel autojoin support, by default
  (setq
   erc-autojoin-channels-alist '(("freenode.net"
                                  ))
   erc-autojoin-timing 'ident
   erc-fill-function 'erc-fill-static
   erc-lurker-hide-list '("JOIN" "PART" "QUIT")
   erc-lurker-threshold-time 43200
                                        ;erc-prompt-for-nickserv-password nil)
   erc-server-reconnect-attempts 5
   erc-server-reconnect-timeout 3
   )

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

  ;; check channels
  (erc-track-mode t)
  (setq erc-track-exclude-types '("JOIN" "NICK" "PART" "QUIT" "MODE" ))

  ;; don't show any of this
  (setq erc-hide-list '("JOIN" "PART" "QUIT" "NICK"))

  (require 'erc-services)

					; http://emacswiki.org/emacs/ErcChannelTracking
  (setq erc-format-query-as-channel-p t
        erc-track-priority-faces-only 'all
        erc-track-faces-priority-list '(erc-error-face
                                        erc-current-nick-face
                                        erc-keyword-face
                                        erc-nick-msg-face
                                        erc-direct-msg-face
                                        erc-dangerous-host-face
                                        erc-notice-face
                                        erc-prompt-face))
  (defun chacrape/erc-connect ()
    "Connect to IM networks using sasl on n800 do this from terminal."
    (interactive)
    (progn
					; could not connect to here cos of sasl
      (erc-select :server "irc.freenode.net" :port 6667 :nick "inka" :password "mypwd")
      )
    )

  ;; notify me when someone mentions me (4 now just 4 maemo n800)
  (require 'erc-match)
  (setq erc-keywords '("n800" "n900" "emacs" "h3" "mesa" "lima" "mali"))
  (setq erc-pals '("pal1" "pal1"))
	
  (erc-match-mode 1)
  (defun erc-global-notify (matched-type nick msg)
    (interactive)
    (let (
          (previous-content)
          )    

      (when (and (eq matched-type 'current-nick)
                 (not (string-match "^NickServ" nick))
                 (not (string-match "^[sS]erver" nick))
                                        ;(not (string-match "^.*has changed mode for .*" nick)) ;this line is not working
                 (not (string-match (format "^%s!" (erc-current-nick)) nick)))
                                        ;(pushover-notify (concat "ERC: " (buffer-name)) (concat "<" (car (split-string nick "!")) "> " message))
        
        (if (string-match "arm" system-configuration)
            (shell-command-to-string  "if  which espeak  > /dev/null 2>&1 ; then espeak -v es --stdout message\ message | gst-launch-1.0 -v fdsrc ! wavparse ! audioconvert ! autoaudiosink; fi")
          (noemacswiki/espeak "new message "))
        (setq previous-content (with-temp-buffer "ERC Notifications"
                                                 (buffer-string)))
        (display-message-or-buffer (concat "ERC: " (buffer-name) ": <" (car (split-string nick "!")) "> " previous-content msg) "ERC Notifications")
        )
      )
    )
  (add-hook 'erc-text-matched-hook 'erc-global-notify)

  ;;overwrite for sasl
  (defun erc-login ()
    "Perform user authentication at the IRC server."
    (erc-log (format "login: nick: %s, user: %s %s %s :%s"
		     (erc-current-nick)
		     (user-login-name)
		     (or erc-system-name (system-name))
		     erc-session-server
		     erc-session-user-full-name))
    (if erc-session-password
	(erc-server-send (format "PASS %s" erc-session-password))
      (message "Logging in without password"))
    (when (and (featurep 'erc-sasl) (erc-sasl-use-sasl-p))
      (erc-server-send "CAP REQ :sasl"))
    (erc-server-send (format "NICK %s" (erc-current-nick)))
    (erc-server-send
     (format "USER %s %s %s :%s"
	     ;; hacked - S.B.
	     (if erc-anonymous-login erc-email-userid (user-login-name))
	     "0" "*"
	     erc-session-user-full-name))
    (erc-update-mode-line))

  (provide 'my-erc-setup)
  )
--8<---------------cut here---------------end--------------->8---

file 2 comes from
{https://gitlab.com/psachin/erc-sasl/-/blob/master/erc-sasl.el}. It is
the one referenced by emacswiki.

Launch emacs with:
emacs -Q
M-x load-file erc-sasl.el
M-x find-file  file 1. 
 Change user and password on funct chacrape/erc-connect
M-x eval-buffer  from file 1. 
M-x toggle-debug-on-error
M-x chacrape/erc-connect
M-x erc-join-channel "any". type hi and press Return key; *Backtrace* should appear.

Best Regards