summaryrefslogtreecommitdiff
path: root/modules/erc-config.el
blob: ddc8f7372dc6ba43657ae044f1152a1d2d5331da (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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
;;; erc-config --- Preferences for Emacs Relay Chat (IRC Client) -*- lexical-binding: t; -*-
;; author Craig Jennings <c@cjennings.net>

;;; Commentary:

;; The main entry point into ERC is the C-c C-c keybinding.
;; Channels in erc-autojoin-channels-alist will open in background.
;; After connecting, switch to any ERC buffer with C-c C-c.
;; Quit current channel with C-c C-p; Quit ERC altogether with C-c C-q

;;; Code:

;; ------------------------------------ ERC ------------------------------------
;; Emacs Relay Chat - an IRC client

(use-package erc
  :defer 1
  :ensure nil ;; built-in
  :commands (erc erc-tls)
  :bind
  ;; the global keybinding
  ("C-c I" . 'cj/erc-start-or-switch)
  (:map erc-mode-map
		;; overrides erc-toggle-interpret-controls
		("C-c I" . 'cj/erc-start-or-switch))
  :hook
  (erc-mode . emojify-mode)
  :custom
  (erc-modules
   '(autojoin
	 button
	 completion
	 fill
	 irccontrols
	 list
	 log
	 match
	 move-to-prompt
	 noncommands
	 notifications
	 readonly
	 services
	 stamp))

  (erc-autojoin-channels-alist
   '(("libera"
      "#erc"
	  "#ledger"
	  "#emacs"
	  "#emacs-social"
	  "#zfsonlinux"
	  "#systemcrafters"
	  "#org-mode")))

  (erc-nick "craigjennings")
  (erc-user-full-name user-whole-name)
  (erc-use-auth-source-for-nickserv-password t)
  (erc-kill-buffer-on-part t)
  (erc-kill-queries-on-quit t)
  (erc-kill-server-buffer-on-quit t)
  (erc-fill-column 120)
  (erc-fill-function 'erc-fill-static)
  (erc-fill-static-center 20)

  :config
  ;; use all text mode abbrevs in ercmode
  (abbrev-table-put erc-mode-abbrev-table :parents (list text-mode-abbrev-table))

  ;; create log directory if it doesn't exist
  (setq erc-log-channels-directory (concat user-emacs-directory "erc/logs/"))
  (if (not (file-exists-p erc-log-channels-directory))
	  (mkdir erc-log-channels-directory t)))

;; --------------------------------- ERC Image ---------------------------------
;; show inlined images (png/jpg/gif/svg) in erc buffers.

(use-package erc-image
  :defer 1
  :after erc
  :config
  (setq erc-image-inline-rescale 300)
  (add-to-list 'erc-modules 'image)
  (erc-update-modules))

;; -------------------------------- ERC Hl Nicks -------------------------------
;; uniquely identify names in ERC

(use-package erc-hl-nicks
  :defer 1
  :after erc
  :config
  (add-to-list 'erc-modules 'hl-nicks))

;; -------------------------------- Connect IRC --------------------------------
;; convenience function to auto-connect to irc.libera.chat

(defun cj/erc-start-or-switch ()
  "Start ERC or switch to ERC buffer if it has started already."
  (interactive)
  (if (get-buffer "Libera.Chat")
	  (erc-switch-to-buffer)
	(erc-tls
	 :server "irc.libera.chat"
	 :port 6697
	 :nick "craigjennings"
	 :full-name user-whole-name)))

(provide 'erc-config)
;;; erc-config.el ends here