Tidy-up irc.el

Move the variable definitions to the top of the module.
This commit is contained in:
William Carroll 2021-10-07 19:05:55 -07:00
parent a8a8cb9a25
commit 657ff5f262

View file

@ -30,22 +30,34 @@
;; Configuration ;; Configuration
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defcustom irc-install-kbds? t
"When t, install the keybindings defined herein.")
(setq erc-rename-buffers t) (setq erc-rename-buffers t)
;; Setting `erc-join-buffer' to 'bury prevents erc from stealing focus of the
;; current buffer when it connects to IRC servers.
(setq erc-join-buffer 'bury)
;; TODO: Find a way to avoid putting "freenode" and "#freenode" as channels ;; TODO: Find a way to avoid putting "freenode" and "#freenode" as channels
;; here. I'm doing it because when erc first connects, it's `(buffer-name)' is ;; here. I'm doing it because when erc first connects, it's `(buffer-name)' is
;; "freenode", so when `irc-next-channel' is called, it 404s on the ;; "freenode", so when `irc-next-channel' is called, it 404s on the
;; `cycle-contains?' call in `irc-channel->cycle" unless "freenode" is there. To ;; `cycle-contains?' call in `irc-channel->cycle" unless "freenode" is there. To
;; make matters even uglier, when `erc-join-channel' is called with "freenode" ;; make matters even uglier, when `erc-join-channel' is called with "freenode"
;; as the value, it connects to the "#freenode" channel, so unless "#freenode" ;; as the value, it connects to the "#freenode" channel, so unless "#freenode"
;; exists in this cycle also, `irc-next-channel' breaks again. This doesn't ;; exists in this cycle also, `irc-next-channel' breaks again.
;; pass my smell test.
(defconst irc-server->channels (defconst irc-server->channels
`(("irc.freenode.net" . ,(cycle-new "freenode" "#freenode" "#nixos" "#emacs" "#pass")) `(("irc.freenode.net" . ,(cycle-new "freenode" "#freenode" "#nixos" "#emacs" "#pass"))
("irc.corp.google.com" . ,(cycle-new "#omg" "#london" "#panic" "#prod-team"))) ("irc.corp.google.com" . ,(cycle-new "#drive-prod")))
"Mapping of IRC servers to a cycle of my preferred channels.") "Mapping of IRC servers to a cycle of my preferred channels.")
;; TODO: Here is another horrible hack that should be revisted.
(setq erc-autojoin-channels-alist
(->> irc-server->channels
(al-map-values #'cycle-to-list)
(al-map-keys (>-> (s-chop-prefix "irc.")
(s-chop-suffix ".net")))))
;; TODO: Assert that no two servers have a channel with the same name. We need ;; TODO: Assert that no two servers have a channel with the same name. We need
;; this because that's the assumption that underpins the `irc-channel->server' ;; this because that's the assumption that underpins the `irc-channel->server'
;; function. This will probably be an O(n^2) operation. ;; function. This will probably be an O(n^2) operation.
@ -71,20 +83,6 @@
(al-get (irc-channel->server server->channels channel) (al-get (irc-channel->server server->channels channel)
server->channels)) server->channels))
;; Setting `erc-join-buffer' to 'bury prevents erc from stealing focus of the
;; current buffer when it connects to IRC servers.
(setq erc-join-buffer 'bury)
;; TODO: Here is another horrible hack that should be revisted.
(setq erc-autojoin-channels-alist
(->> irc-server->channels
(al-map-values #'cycle-to-list)
(al-map-keys (>-> (s-chop-prefix "irc.")
(s-chop-suffix ".net")))))
(defcustom irc-install-kbds? t
"When t, install the keybindings defined herein.")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Library ;; Library
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;