summaryrefslogtreecommitdiff
path: root/elisp/erbot/erball.el
blob: e5e48ae95ebf3803074b41494a63bf9e86282d00 (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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
;;; erball.el --- Functions on all files. 
;; Time-stamp: <2006-04-24 13:43:38 deego>
;; Copyright (C) 2002 D. Goel
;; Emacs Lisp Archive entry
;; Filename: erbc.el
;; Package: erbc
;; Author: D. Goel <deego@gnufans.org>
;; Version: 



;; Usually maintenance
;; not all of these may be required depending on how you use erbot..
(require 'cl)

;; Compilation

(defvar erball-compilation-paths-rel-to
  (let (args ret)
    (while command-line-args-left
      (if (string= "--paths-rel-to" (car command-line-args-left))
          (progn
            (setq ret (cadr command-line-args-left))
            (setq command-line-args-left (cddr command-line-args-left)))
        (add-to-list 'args (car command-line-args-left) t)
        (setq command-line-args-left (cdr command-line-args-left))))
    (setq command-line-args-left args)
    ret)
  "Text to be prepended to each element in `erball-compilation-paths'.
Can be specified by passing \"--paths-rel-to ARG\" on the emacs
command line.
This value is also added to the load-path.
A trailing backslash is required.")

(defun erball-assoc-string (key list)
  "Like `assoc' but specifically for strings."
  (if (fboundp 'assoc-string)
      (assoc-string key list)
    (catch 'found
      (dolist (el list)
        (when (string= key el)
          (throw 'found el))))))

(defvar erball-compiling-p
  (if (erball-assoc-string "--compile-erbot" command-line-args-left)
      (progn
        (message "%s" (concat "\nCompiling source in "
			      (file-name-nondirectory (expand-file-name "."))
			      " ...\n"))
        (setq command-line-args-left
              (delete "--compile-erbot" command-line-args-left))
        t)
    nil)
  "Determine whether erbot is currently being compiled.")

(defcustom erball-compilation-paths
  '("contrib"
    ".."
    "../erc"
    "../bbdb/lisp")
  "Elements to add to the load path during compilation.
If `erball-compilation-paths-rel-to' is specified, it is
prepended to each element and also added verbatim to the path.
The current directory is automatically added to the path."
  :group 'erball
  )

(when erball-compiling-p
  (add-to-list 'load-path ".")
  (when erball-compilation-paths-rel-to
    (add-to-list 'load-path erball-compilation-paths-rel-to))
  (dolist (dir erball-compilation-paths)
    (add-to-list 'load-path
                 (concat erball-compilation-paths-rel-to dir))))

;; Load all erbot files

(defmacro erball-ignore-errors-loudly (&rest body)
  "Like ignore-errors, but tells the error..

Copied from deego's `ignore-errors-my', which owes some of its work
to: Kalle on 7/3/01:
 * used backquote: something i was too lazy to convert my macro to..
 * removed the progn: condition-case automatically has one..
 * made sure that the return is nil.. just as it is in ignore-errors. "
  (let ((err (gensym)))
    `(condition-case ,err (progn ,@body)
       (error
	(ding t)
	(ding t)
	(ding t)
	(message "IGNORED ERROR: %s" (error-message-string ,err))
	(sit-for 1)
	nil))))



(erball-ignore-errors-loudly (require 'bbdb))
(erball-ignore-errors-loudly (require 'doctor))
(erball-ignore-errors-loudly (require 'erc))
(erball-ignore-errors-loudly (require 'erc-stamp))



(unless noninteractive (erball-ignore-errors-loudly (require 'dunnet)))
(erball-ignore-errors-loudly (require 'erbot))
(erball-ignore-errors-loudly (require 'erbcountry))
(erball-ignore-errors-loudly (require 'erbutils))
(erball-ignore-errors-loudly (require 'erblog))
(erball-ignore-errors-loudly (require 'erbeng))
(erball-ignore-errors-loudly (require 'erbdata))
(erball-ignore-errors-loudly (require 'erbkarma))
(erball-ignore-errors-loudly (require 'erblisp))
(erball-ignore-errors-loudly (require 'erbc))
(erball-ignore-errors-loudly (require 'erbc2))
(erball-ignore-errors-loudly (require 'erbc3))
(erball-ignore-errors-loudly (require 'erbc4))
(erball-ignore-errors-loudly (require 'erbc5))
(erball-ignore-errors-loudly (require 'erbc6))
(erball-ignore-errors-loudly (require 'erbcspecial))
(erball-ignore-errors-loudly (require 'erbbdb))
(erball-ignore-errors-loudly (require 'erbforget))
(erball-ignore-errors-loudly (require 'erbedit))
(erball-ignore-errors-loudly (require 'erbtrain))
(erball-ignore-errors-loudly (require 'erbwiki))
(erball-ignore-errors-loudly (require 'erbunlisp))
(erball-ignore-errors-loudly (require 'erbcompat))

(erball-ignore-errors-loudly (require 'erbmsg))
(erball-ignore-errors-loudly (require 'erbtranslate))
(erball-ignore-errors-loudly (require 'erbim))

(erball-ignore-errors-loudly (require 'flame))

(erball-ignore-errors-loudly (require 'mkback))
(erball-ignore-errors-loudly (require 'lines))
(erball-ignore-errors-loudly (require 'google))
(erball-ignore-errors-loudly (require 'oct))

;; the rest of the commands here are useful to the author when editing erbot. 

(defcustom erball-files
  (if erball-compiling-p
      (directory-files "." nil "\.el$")
    '("erbot.el"
      "erbutils.el"
      "erblog.el"
      "erbeng.el"
      "erbcountry.el"
      "erbdata.el"
      "erbedit.el"
      "erbforget.el"
      "erbkarma.el"
      "erblisp.el"
      "erbunlisp.el"
      "erbtrain.el"
      "erbwiki.el"
      "erbc.el"
      "erbc2.el"
      "erbc3.el"
      "erbc4.el"
      "erbc5.el"
      "erbc6.el"
      ))

    ""
    :group 'erball
    )

(defun erball-reload ()
  (interactive)
  (mapcar
   'load
   erball-files))

(defun erball-visit ()
  (interactive)
  (mapcar
   (lambda (a)
     (find-file (locate-library a))
     (auto-revert-mode 1))
   erball-files))

;;;###autoload
(defun erball-compile ()
  (interactive)
  (if erball-compiling-p
      (progn
        (ignore-errors (erball-reload))
        (mapcar
         (lambda (arg)
           (erball-ignore-errors-loudly
            (byte-compile-file arg)))
         erball-files)
        (message "\nCompilation complete!\n"))
    (ignore-errors (kill-buffer "*Compile-Log*"))
    (erball-visit)
    (erball-reload)
    (mapcar
     (lambda (arg)
       (erball-ignore-errors-loudly
        (byte-compile-file (locate-library arg))))
     erball-files)
    (switch-to-buffer "*Compile-Log*")
    (delete-other-windows)
    (goto-char (point-min))))


(provide 'erball)