about summary refs log tree commit diff
path: root/configs/shared/.emacs.d/wpc/irc.el
blob: 3dfaabdb397bd8d081c092f3220caf5eef757cfc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
;;; irc.el --- Configuration for IRC chat -*- lexical-binding: t -*-
;; Author: William Carroll <wpcarro@gmail.com>

;;; Commentary:
;; Need to decide which client I will use for IRC.

;;; Code:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Dependencies
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(require 'erc)
(require 'cycle)
(require 'string)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Configuration
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(setq erc-rename-buffers t)

(defvar irc/channels-cycle
  (cycle/from-list
   '("#omg" "#london" "#panic" "#prod-team"))
  "List of channels through which I can cycle.")

;; 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)

(setq erc-autojoin-channels-alist
      `(("corp.google.com" . ,(cycle/to-list irc/channels-cycle))))

(defcustom irc/install-kbds? t
  "When t, install the keybindings defined herein.")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Library
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defun irc/message (x)
  "Print message X in a structured way."
  (message (string/format "[irc.el] %s" x)))

(defun irc/connect-to-google ()
  "Connect to Google's Corp IRC using ERC."
  (interactive)
  (erc-ssl :server "irc.corp.google.com"
           :port 6697
           :nick "wpcarro"
           :full-name "William Carroll"))

(defun irc/next-channel ()
  "Join the next channel in `irc/channels-cycle'."
  (interactive)
  (erc-join-channel
   (cycle/next irc/channels-cycle))
  (irc/message
   (string/format "Current IRC channel: %s"
                  (cycle/current irc/channels-cycle))))

(defun irc/prev-channel ()
  "Join the previous channel in `irc/channels-cycle'."
  (interactive)
  (erc-join-channel
   (cycle/prev irc/channels-cycle))
  (irc/message
   (string/format "Current IRC channel: %s"
                  (cycle/current irc/channels-cycle))))

(when irc/install-kbds?
  (general-define-key
   :keymaps 'erc-mode-map
   "<C-tab>" #'irc/next-channel
   "<C-S-iso-lefttab>" #'irc/prev-channel))

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