Refactor Circe config

This commit is contained in:
Case Duckworth 2021-09-02 17:07:25 -05:00
parent 91be58ecb5
commit c5bba76bf8
2 changed files with 63 additions and 49 deletions

89
init.el
View File

@ -1210,51 +1210,38 @@ like a dumbass."
(require 'circe)
(require 'acdw-irc)
(setq acdw-irc/post-my-nick "-> ")
(setq circe-default-nick "acdw"
circe-default-part-message "See You, Space Cowpokes . . ."
circe-highlight-nick-type 'all
circe-network-options
`(("Libera Chat"
:channels ("#emacs" "#systemcrafters" "##webpals")
:sasl-username "acdw"
:sasl-password ,(acdw/fetch-password :host "libera.chat"))
("Tilde Chat"
:channels ("#meta" "#bread" "#dadjokes" "#team")
:host "irc.tilde.chat" :port 6697 :use-tls t
:sasl-username "acdw"
:sasl-password ,(acdw/fetch-password :host "tilde.chat"))
("Casa"
:channels ("#basement")
:host "m455.casa" :port 6697 :use-tls t
:sasl-username "acdw"
:sasl-password ,(acdw/fetch-password :host "m455.casa")))
circe-reduce-lurker-spam t
circe-server-auto-join-default-type :after-auth)
(:option acdw-irc/post-my-nick "-> "
circe-color-nicks-everywhere t
circe-default-nick "acdw"
circe-default-part-message "See You, Space Cowpokes . . ."
circe-default-user "acdw"
circe-highlight-nick-type 'sender
circe-network-options
`(("Libera Chat"
:channels ("#emacs" "#systemcrafters" "##webpals")
:sasl-username "acdw"
:sasl-password ,(acdw/fetch-password :host "libera.chat"))
("Tilde Chat"
:channels ("#meta" "#bread" "#dadjokes" "#team")
:host "irc.tilde.chat" :port 6697 :use-tls t
:sasl-username "acdw"
:sasl-password ,(acdw/fetch-password :host "tilde.chat"))
("Casa"
:channels ("#basement")
:host "m455.casa" :port 6697 :use-tls t
:sasl-username "acdw"
:sasl-password ,(acdw/fetch-password :host "m455.casa")))
circe-reduce-lurker-spam t
circe-server-auto-join-default-type :after-auth)
(defun irc ()
"Connect to IRC."
(interactive)
(dolist (network (mapcar #'car circe-network-options))
(circe-maybe-connect network)))
(custom-set-faces '(circe-nick-highlight-face
((t (:inherit (modus-themes-hl-line))))
:now))
(defun circe-network-connected-p (network)
"Return non-nil if there's any Circe server-buffer whose
`circe-server-netwok' is NETWORK."
(catch 'return
(dolist (buffer (circe-server-buffers))
(with-current-buffer buffer
(if (string= network circe-server-network)
(throw 'return t))))))
(defun circe-maybe-connect (network)
"Connect to NETWORK, but ask user for confirmation if it's
already been connected to."
(interactive "sNetwork: ")
(if (or (not (circe-network-connected-p network))
(y-or-n-p (format "Already connected to %s, reconnect?" network)))
(circe network)))
(defface highlight
'((t :inverse-video t))
"Basic face for highlighting."
:group 'basic-faces)
(add-hook 'circe-chat-mode-hook
(defun circe-chat@setup ()
@ -1270,6 +1257,9 @@ already been connected to."
(enable-circe-display-images)
(enable-circe-new-day-notifier)))
(add-hook 'circe-chat-mode-hook #'acdw/stop-paren-annoyances)
(autoload 'circe-nick-color-reset "circe-color-nicks")
(add-hook 'modus-themes-after-load-theme-hook
#'circe-nick-color-reset)
@ -1302,19 +1292,20 @@ already been connected to."
" ")
" ")))
(setq lui-time-stamp-position 'right-margin
lui-time-stamp-format "%H:%M")
(:option lui-fill-column fill-column
lui-time-stamp-position 'right-margin
lui-time-stamp-format "%H:%M"
lui-track-behavior 'before-switch-to-buffer
lui-track-indicator 'fringe)
(add-hook 'lui-mode-hook
(defun lui-mode@setup ()
(setq-local fringes-outside-margins t
lui-track-bar-behavior 'before-switch-to-buffer
right-margin-width 5
scroll-margin 0
word-wrap t
wrap-prefix (repeat-string
acdw-irc/left-margin " "))
;; (enable-lui-track-bar)
)))
acdw-irc/left-margin " ")))))
(setup (:straight crux)

View File

@ -79,6 +79,29 @@ and right on t."
(if alignment "" (repeat-string left-over " "))
after)))
(defun irc ()
"Connect to all IRC networks in `circe-network-options'."
(interactive)
(dolist (network (mapcar #'car circe-network-options))
(circe-maybe-connect network)))
(defun circe-network-connected-p (network)
"Return non-nil if there's any Circe server-buffer whose
`circe-server-netwok' is NETWORK."
(catch 'return
(dolist (buffer (circe-server-buffers))
(with-current-buffer buffer
(if (string= network circe-server-network)
(throw 'return t))))))
(defun circe-maybe-connect (network)
"Connect to NETWORK, but ask user for confirmation if it's
already been connected to."
(interactive "sNetwork: ")
(if (or (not (circe-network-connected-p network))
(y-or-n-p (format "Already connected to %s, reconnect?" network)))
(circe network)))
(provide 'acdw-irc)
;;; acdw-irc.el ends here