-
Notifications
You must be signed in to change notification settings - Fork 1
/
erc-extra-commands-mode.el
98 lines (93 loc) · 3.17 KB
/
erc-extra-commands-mode.el
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
;;; erc-extra-commands-mode.el ---
;;
;; Filename: erc-extra-commands-mode.el
;; Description:
;; Author: James
;; Maintainer:
;; Created: Sat Jun 26 19:55:37 2010 (+0000)
;; Version:
;; Last-Updated:
;; By:
;; Update #: 4
;; URL:
;; Keywords:
;; Compatibility:
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Commentary:
;;
;;
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Change log:
;;
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
;; published by the Free Software Foundation; either version 3, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
;; Floor, Boston, MA 02110-1301, USA.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Code:
(require 'erc)
(defgroup erc-extra-commands-mode nil
"Extra commands for erc."
:group 'erc)
(define-erc-module extra-commands nil
"Allows enabling extra erc-mode commands.
See the group `erc-extra-commands-mode' for more."
()
())
(defcustom erc-extra-commands nil
"Extra commands that can be enabled."
:group 'erc-extra-commands-mode
:get (lambda (sym)
(symbol-value sym))
:set (lambda (sym val)
;; disable modules which have just been removed
(when (and (boundp 'erc-extra-commands))
(dolist (command erc-extra-commands)
(unless (member command val)
(let ((f (intern-soft (format "erc-extra-command-%s" command))))
(when (and (fboundp f))
;; original had (and .... (boundp f) (symbol-value f))
(message "Disabling `erc-extra-command-%s'" command)
(funcall f 0))))))
(set sym val)
;; this test is for the case where erc hasn't been loaded yet
(when (fboundp 'erc-update-extra-commands)
(erc-update-extra-commands)))
:type
'(set :greedy t
(const :tag "elisp: Evaluate emacs lisp" elisp)
(const :tag "cl: Evaluate common lisp" cl)))
(defun erc-update-extra-commands ()
"run this to enable commands for `erc-extra-commands'."
(if (listp erc-extra-commands)
(dolist (command erc-extra-commands)
(let ((.require (concat "erc-extra-command-" (symbol-name command))))
(condition-case nil
(require (intern .require))
(error nil))
(let ((sym (intern-soft (concat "erc-extra-command-" (symbol-name command)))))
(if (fboundp sym)
(funcall sym 1)
(error "`%s' is not a known erc command" command)))))))
(provide 'erc-extra-commands-mode)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; erc-extra-commands-mode.el ends here