chiark / gitweb /
el/dot-emacs.el: Fix bungled face-spec.
[profile] / dot / ercrc.el
CommitLineData
54896c4f
MW
1;;; -*-emacs-lisp-*-
2;;;
3;;; ERC configuration
4
54896c4f
MW
5(setq erc-nick "mdw"
6 erc-user-full-name "Mark Wooding")
7
96f2d8b3
MW
8(if (not (memq 'truncate erc-modules))
9 (setq erc-modules (cons 'truncate erc-modules)))
10
db8b2f3c
MW
11(setq erc-fill-column 76
12 erc-timestamp-right-column 68
96f2d8b3
MW
13 erc-fill-prefix " "
14 erc-max-buffer-size (* 60 3000))
54896c4f
MW
15
16(load "~/.erc-local.el")
17
18(setq erc-track-exclude-types '("NICK" "JOIN" "PART"))
19
20(setq erc-auto-query 'buffer)
21
c655b794
MW
22(defun mdw-erc-turn-off-truncate-lines ()
23 (setq truncate-lines nil
24 truncate-partial-with-windows nil
25 word-wrap t
d9be013a 26 wrap-prefix (concat (propertize " " 'face 'erc-prompt-face)
c655b794
MW
27 " ")))
28(add-hook 'erc-mode-hook 'mdw-erc-turn-off-truncate-lines)
29
54896c4f
MW
30(setq erc-autojoin t
31 erc-autojoin-domain-only nil
32 erc-autojoin-channels-alist
33 '(("irc.ssdis.loc" "#devel" "#jukebox" "#nextgen")
34 ("cam.irc.devel.ncipher.com"
35 "#devel" "#jukebox" "#nextgen" "#sec-team")
9781db34 36 ("chiark.greenend.org.uk" "#chiark")
75ea07de
MW
37 ("irc.distorted.org.uk" "#distorted" "#jukebox")
38 ("irc.hstg.corp.good.com" "#hstg")))
54896c4f 39
10c4d64f 40(defvar mdw-erc-auto-greet-bots-alist nil
54896c4f
MW
41 "*Alist of (SERVER-REGEXP BOT-NICK MESSAGE-FORM).
42Evaluate MESSAGE-FORM and sent to BOT-NICK when connected to a server which
43matches SERVER-REGEXP.")
44
61181450
MW
45(defvar mdw-erc-ircop-alist nil
46 "*Alist of (SERVER-REGEXP ACCT PASSWD).
47Login details for claiming server admin rights.")
48
f67381a0
MW
49(defun mdw-remprop-nondestructive (indic plist)
50 "Return a plist like PLIST, only without the first entry for INDIC.
51The PLIST is not itself modified."
52 (if (getf plist indic)
53 (let* ((head (cons nil nil))
54 (tail head))
55 (while (and plist (not (eq (car plist) indic)))
56 (let* ((i (pop plist)) (v (pop plist))
57 (vv (cons v nil)) (ii (cons i vv)))
58 (rplacd tail ii)
59 (setq tail vv)))
60 (rplacd tail (cddr plist))
61 (cdr head))
62 plist))
63
64(defmacro* mdw-pushnew-replace
65 (item place &rest keys &key (key '#'identity) &allow-other-keys)
66 "Add ITEM to the list PLACE, replacing any existing matching item.
67Specifically, any item in the list satisfying the test are removed
68\(nondestructively), and then the new ITEM is added to the front.
69
70Evaluation order for the keywords is a bit screwy: don't rely on it."
71 ;; `cl-setf-do-modify' returns a list (LETS STORE FETCH).
72 (let ((setf-things (cl-setf-do-modify place (cons 'list keys)))
73 (keyfn (gensym "key"))
74 (itemvar (gensym "item")))
75 `(let ((,keyfn ,key)
76 (,itemvar ,item)
77 ,@(car setf-things))
78 ,(cl-setf-do-store (cadr setf-things)
79 `(cons ,itemvar
80 (remove* (funcall ,keyfn ,itemvar)
81 ,(caddr setf-things)
82 :key ,keyfn
83 ,@(mdw-remprop-nondestructive
84 :key keys)))))))
85
10c4d64f
MW
86(defun mdw-define-bot-greeting (server bot greeting)
87 "Define a new bot greeting."
f67381a0
MW
88 (mdw-pushnew-replace (list server bot greeting)
89 mdw-erc-auto-greet-bots-alist
90 :test #'string= :key #'car))
61181450
MW
91(defun mdw-add-ircop-credentials (server acct passwd)
92 "Define a new set of `ircop' credentials."
f67381a0
MW
93 (mdw-pushnew-replace (list server acct passwd)
94 mdw-erc-ircop-alist
95 :test #'string= :key #'car))
10c4d64f
MW
96(load "~/.erc-auth.el")
97
1cf7ff22
MW
98(defun mdw-assoc-regexp (regexp alist)
99 "Return the association in ALIST whose car matches REGEXP."
100 (let ((answer nil))
101 (dolist (l alist)
102 (when (string-match (car l) regexp)
103 (setq answer l)))
104 answer))
105
54896c4f
MW
106(defun mdw-erc-auto-greet-bots (server nick)
107 "Send greeting message to bots."
1cf7ff22
MW
108 (let ((a (mdw-assoc-regexp server mdw-erc-auto-greet-bots-alist)))
109 (when a
110 (let ((bot (cadr a))
111 (message (caddr a)))
54896c4f
MW
112 (erc-server-send (concat "PRIVMSG " bot " :" message))))))
113(add-hook 'erc-after-connect 'mdw-erc-auto-greet-bots)
6a08737d
MW
114
115(defun erc-cmd-GREET ()
116 "Send greeting messages, according to `mdw-erc-auto-greet-bots-alist'."
117 (mdw-erc-auto-greet-bots erc-session-server (erc-current-nick)))
61181450
MW
118
119(defun erc-cmd-IRCOP ()
120 "Claim `ircop' privileges."
121 (let ((a (mdw-assoc-regexp erc-session-server mdw-erc-ircop-alist)))
122 (when a
123 (let ((acct (cadr a))
124 (passwd (caddr a)))
125 (erc-server-send (concat "OPER " acct " " passwd))))))