;;; erc.el --- erc config -*- lexical-binding: t -*-
;;; Commentary:

(defun pt/erc-connect-network (network)
  "Connect to Libera IRC network."
  (erc-tls :server "paraboletancza.org"
           :port 6697
           :user (fmt "whiteman808/#{network}")
           :password (pt/lookup-password :host "znc.paraboletancza.org" :user "whiteman808")
           :full-name "whiteman808"))

(use-package erc
  :custom
  ;; user data
  (erc-nick "whiteman808")
  (erc-user-full-name "whiteman808")
  ;; protect me from accidentally sending excess lines
  (erc-inhibit-multiline-input t)
  (erc-send-whitespace-lines t)
  (erc-ask-about-multiline-input t)
  ;; scroll all windows to prompt when submitting input
  (erc-scrolltobottom-all t)
  ;; reconnect automatically using a fancy strategy
  (erc-server-reconnect-function #'erc-server-delayed-check-reconnect)
  (erc-server-reconnect-timeout 30)
  ;; show new buffers in the current window instead of a split
  (erc-interactive-display 'buffer)
  ;; highlight references to me
  (erc-keywords '("whiteman808" "whiteman809"))
  :hook
  ;; automatically connect to irc
  ;; (after-init . (lambda nil
  ;;                 (pt/erc-connect-network "Libera")
  ;;                 (pt/erc-connect-network "PIRC")))
  ;; enable matching keywords
  (erc-mode . erc-match-mode)
  ;; insert a newline when I hit <RET> at the prompt, and prefer
  ;; something more deliberate for actually sending messages
  ;; :bind (:map erc-mode-map
  ;;             ("RET" . nil)
  ;;             ("C-c C-c" . #'erc-send-current-line))
  ;; emphasize buttonized text in notices
  :custom-face (erc-notice-face ((t (:slant italic :weight unspecified)))))

(provide 'erc)
;;; erc.el ends here
