Idiomdrottning’s homepage

Using rcirc with soju.im

Here is the general config for rcirc as per the soju contrib/clients.md:

(setq rcirc-server-alist
      '(("<server>"
         :port 6697
         :encryption tls
         :nick "<nick>"
         :user-name "<username>/irc.libera.chat" ;; Example with Libera.Chat
         :password "<password>")))

My notes:

Here, "<server>" means the server that is running soju. You can have multiple entries for different networks, just set the user-name correspondingly (and the "<nick>" if that’s different). Even though the var is called rcirc-server-alist, it’s not really an alist, it’s just a list, and it’s OK that multiple entries have the same "<server>".

Detaching channels

Here’s how to detach an rcirc channel when using soju:

(defun-rcirc-command detach (channel)
   "Detach channel to soju."
  (interactive "sPart channel: ")
  (let ((channel (if (> (length channel) 0) channel target)))
    (rcirc-send-privmsg
     process "BouncerServ"
     (format
      "channel update %s -detached true -reattach-on highlight" channel))))

Soju/rcirc already lets you reattached detached channels with /join, and this lets you type /detach in a channel to detach it. This makes it easy to attach and detach channels.

Also, rcirc parts the channel when you kill the buffer or change the major mode. To instead detach the channel when you do that, change rcirc-clean-up-buffer to this (after definining detach above):

(defun rcirc-clean-up-buffer (reason)
  (let ((buffer (current-buffer)))
    (rcirc-clear-activity buffer)
    (when (and (rcirc-buffer-process)
	       (rcirc--connection-open-p (rcirc-buffer-process)))
      (with-rcirc-server-buffer
	(setq rcirc-buffer-alist
	      (rassq-delete-all buffer rcirc-buffer-alist)))
      (rcirc-update-short-buffer-names)
      (when (rcirc-channel-p rcirc-target)
	(rcirc-cmd-detach rcirc-target)))
    (setq rcirc-target nil)))

This means that whenever you kill a channel buffer, you’ll just detach it and still be idling in it; when you actually do want to leave a channel, /part it before you kill it.