summaryrefslogtreecommitdiff
path: root/dotfiles/.emacs.d/erc.el
blob: 3f26d1600b7fba70b9aa274bc0ee3681db133596 (plain)
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
80
81
82
(require 'erc)
(require 'erc-log)
(require 'erc-notify)
;;(require 'erc-spelling)
(require 'erc-autoaway)
(require 'erc-services)
(require 'notifications)
(require 'tls)

;; Notify the user of private messages
(defun erc-private-message-notify (proc parsed)
  (let ((nick (car (erc-parse-user (erc-response.sender parsed))))
        (target (car (erc-response.command-args parsed)))
        (msg (erc-response.contents parsed)))
    (notifications-notify :title nick :body msg)))

;; (add-hook 'erc-server-PRIVMSG-functions 'erc-private-message-notify)

;; Interpret mIRC-style color commands in IRC chats
(setq erc-interpret-mirc-color t)

;; The following are commented out by default, but users of other
;; non-Emacs IRC clients might find them useful.
;; Kill buffers for channels after /part
(setq erc-kill-buffer-on-part t)
;; Kill buffers for private queries after quitting the server
(setq erc-kill-queries-on-quit t)
;; Kill buffers for server messages after quitting the server
(setq erc-kill-server-buffer-on-quit t)

;; exclude boring stuff from tracking
(erc-track-mode t)
(setq erc-track-exclude-types '("JOIN" "NICK" "PART" "QUIT" "MODE"
                                "324" "329" "332" "333" "353" "477"))

;; logging
(setq erc-log-channels-directory "~/.erc/logs/")

(if (not (file-exists-p erc-log-channels-directory))
    (mkdir erc-log-channels-directory t))

(setq erc-save-buffer-on-part t)

;; utf-8 always and forever
(setq erc-server-coding-system '(utf-8 . utf-8))

;; Auto-join channels
(erc-autojoin-mode t)
(setq erc-autojoin-channels-alist
      '(("freenode.net" "#guile" "#guix" "#lispgames" "#librelounge")))

;; Don't open channel buffers in place of the current buffer because
;; that drives me fucking crazy.
(setq erc-join-buffer 'bury)

;; Secret password file
(defvar freenode-password nil)
(let ((password-file "~/.emacs.d/.ercpasswords"))
  (when (file-exists-p password-file)
    (load password-file)))

;; Start and stop erc
(defun start-irc ()
  "Connect to IRC."
  (interactive)
  (erc-tls :server "irc.freenode.net"
           :port 6697
           :nick "davexunit"))

(defun filter-erc-server-buffers ()
  (delq nil
        (mapcar
         (lambda (x) (and (erc-server-buffer-p x) x))
         (buffer-list))))

(defun stop-irc ()
  "Disconnects from all irc servers"
  (interactive)
  (dolist (buffer (filter-erc-server-buffers))
    (message "Server buffer: %s" (buffer-name buffer))
    (with-current-buffer buffer
      (erc-quit-server "Later"))))