6 erc-user-full-name "Mark Wooding")
8 (if (not (memq 'truncate erc-modules))
9 (setq erc-modules (cons 'truncate erc-modules)))
11 (setq erc-fill-column 76
12 erc-timestamp-right-column 68
14 erc-max-buffer-size (* 60 3000))
16 (load "~/.erc-local.el")
18 (setq erc-track-exclude-types '("NICK" "JOIN" "PART"))
20 (setq erc-auto-query 'buffer)
22 (defun mdw-erc-turn-off-truncate-lines ()
23 (setq truncate-lines nil
24 truncate-partial-with-windows nil
26 wrap-prefix (concat (propertize " " 'face 'erc-prompt-face)
28 (add-hook 'erc-mode-hook 'mdw-erc-turn-off-truncate-lines)
31 erc-autojoin-domain-only nil
32 erc-autojoin-channels-alist
33 '(("chiark.greenend.org.uk" "#chiark")
34 ("irc.distorted.org.uk" "#distorted" "#jukebox")
35 ("irc.hstg.corp.good.com" "#hstg")))
37 (defvar mdw-erc-auto-greet-bots-alist nil
38 "*Alist of (SERVER-REGEXP BOT-NICK MESSAGE-FORM).
39 Evaluate MESSAGE-FORM and sent to BOT-NICK when connected to a server which
40 matches SERVER-REGEXP.")
42 (defvar mdw-erc-ircop-alist nil
43 "*Alist of (SERVER-REGEXP ACCT PASSWD).
44 Login details for claiming server admin rights.")
46 (defun mdw-remprop-nondestructive (indic plist)
47 "Return a plist like PLIST, only without the first entry for INDIC.
48 The PLIST is not itself modified."
49 (if (getf plist indic)
50 (let* ((head (cons nil nil))
52 (while (and plist (not (eq (car plist) indic)))
53 (let* ((i (pop plist)) (v (pop plist))
54 (vv (cons v nil)) (ii (cons i vv)))
57 (rplacd tail (cddr plist))
61 (defun* mdw-cons-replace
62 (item list &rest keys &key (key '#'identity) &allow-other-keys)
63 "Return LIST, with ITEM at the start, replacing any existing matching item.
64 Specifically, any item in the list satisfying the test are removed
65 \(nondestructively), and then the new ITEM is added to the front."
66 (cons item (apply #'remove* (funcall key item) list :key key
67 (mdw-remprop-nondestructive :key keys))))
69 (defmacro* mdw-pushnew-replace (item place &rest keys)
70 "Add ITEM to the list PLACE, replacing any existing matching item.
71 Specifically, any item in the list satisfying the test are removed
72 \(nondestructively), and then the new ITEM is added to the front.
74 Evaluation order for the keywords is a bit screwy: don't rely on it."
75 (cond ((fboundp 'cl-callf2)
76 `(cl-callf2 mdw-cons-replace ,item ,place ,@keys))
77 ((fboundp 'cl-setf-do-modify)
78 ;; `cl-setf-do-modify' returns a list (LETS STORE FETCH).
79 (let ((setf-things (cl-setf-do-modify place (cons 'list keys))))
80 `(let (,@(car setf-things))
81 ,(cl-setf-do-store (cadr setf-things)
82 `(mdw-cons-replace ,item ,place
84 (t (error "Don't know how to hack places on this Emacs."))))
86 (defun mdw-define-bot-greeting (server bot greeting)
87 "Define a new bot greeting."
88 (mdw-pushnew-replace (list server bot greeting)
89 mdw-erc-auto-greet-bots-alist
90 :test #'string= :key #'car))
91 (defun mdw-add-ircop-credentials (server acct passwd)
92 "Define a new set of `ircop' credentials."
93 (mdw-pushnew-replace (list server acct passwd)
95 :test #'string= :key #'car))
96 (load "~/.erc-auth.el")
98 (defun mdw-assoc-regexp (regexp alist)
99 "Return the association in ALIST whose car matches REGEXP."
102 (when (string-match (car l) regexp)
106 (defun mdw-erc-auto-greet-bots (server nick)
107 "Send greeting message to bots."
108 (let ((a (mdw-assoc-regexp server mdw-erc-auto-greet-bots-alist)))
112 (erc-server-send (concat "PRIVMSG " bot " :" message))))))
113 (add-hook 'erc-after-connect 'mdw-erc-auto-greet-bots)
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)))
119 (defun erc-cmd-IRCOP ()
120 "Claim `ircop' privileges."
121 (let ((a (mdw-assoc-regexp erc-session-server mdw-erc-ircop-alist)))
123 (let ((acct (cadr a))
125 (erc-server-send (concat "OPER " acct " " passwd))))))