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

View File

@ -79,6 +79,29 @@ and right on t."
(if alignment "" (repeat-string left-over " ")) (if alignment "" (repeat-string left-over " "))
after))) 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) (provide 'acdw-irc)
;;; acdw-irc.el ends here ;;; acdw-irc.el ends here