* riece-options.el (riece-data-directory): Avoid compile time
[elisp/riece.git] / lisp / riece-options.el
1 ;;; riece-options.el --- customization
2 ;; Copyright (C) 1998-2003 Daiki Ueno
3
4 ;; Author: Daiki Ueno <ueno@unixuser.org>
5 ;; Created: 1998-09-28
6 ;; Keywords: IRC, riece
7
8 ;; This file is part of Riece.
9
10 ;; This program is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
13 ;; any later version.
14
15 ;; This program is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 ;; GNU General Public License for more details.
19
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
24
25 ;;; Code:
26
27 (require 'riece-version)
28 (require 'riece-globals)
29
30 ;; User modifiable variables.
31 (defgroup riece nil
32   "Riece specific customize group")
33
34 (defgroup riece-options nil
35   "Riece user customizable variables"
36   :prefix "riece-"
37   :group 'riece)
38
39 (defcustom riece-saved-forms
40   '(riece-server-alist
41     riece-channel-buffer-mode
42     riece-others-buffer-mode
43     riece-user-list-buffer-mode
44     riece-channel-list-buffer-mode
45     riece-layout)
46   "Variables saved after each session is completed."
47   :type 'string
48   :group 'riece-options)
49
50 (defcustom riece-debug nil
51   "If non-nil, random debug spews."
52   :type 'boolean
53   :group 'riece-options)
54
55 (defcustom riece-command-prefix "\C-c"
56   "Key sequence to be used as prefix for command mode key bindings."
57   :type 'string
58   :group 'riece-options)
59
60 (defgroup riece-looks nil
61   "Related to look and feel"
62   :prefix "riece-"
63   :group 'riece)
64
65 (defcustom riece-use-full-window t
66   "If non-nil, whole Emacs window is used to display dialogue."
67   :type 'boolean
68   :group 'riece-looks)
69
70 (defcustom riece-window-center-line -2
71   "Line number of center point in window when scrolling.
72 If nil, erases the entire frame and then redraws with point in the
73 center of the window.  Negative means relative to bottom of window.
74 See the document of the function `recenter'."
75   :type 'integer
76   :group 'riece-looks)
77
78 (defcustom riece-directory (expand-file-name "~/.riece")
79   "Where to look for startup files."
80   :type 'directory
81   :group 'riece-options)
82
83 (defcustom riece-addon-directory
84   (expand-file-name "addons" riece-directory)
85   "Where to look for add-on files."
86   :type 'directory
87   :group 'riece-options)
88
89 (defcustom riece-data-directory
90   (cond ((fboundp 'locate-data-directory)
91          (locate-data-directory "riece"))
92         ((symbol-file 'riece-data-directory)
93          (file-name-directory
94           (locate-library (symbol-file 'riece-data-directory))))
95         (t
96          (expand-file-name "riece" data-directory)))
97   "Where to look for data files."
98   :type 'directory
99   :group 'riece-options)
100
101 (defcustom riece-variables-file
102   (expand-file-name "init" riece-directory)
103   "Where to look for variables."
104   :type 'file
105   :group 'riece-options)
106
107 (defcustom riece-saved-variables-file
108   (expand-file-name "save" riece-directory)
109   "Where to look for variables.
110 This file was saved the last session."
111   :type 'file
112   :group 'riece-options)
113
114 (defcustom riece-variables-files
115   (list riece-saved-variables-file riece-variables-file)
116   "Where to look for variables.  Helps to remove clutter from your .emacs.
117 This feature is most likely to dissappear in near future.  The preferred
118 way is to put Riece variables on .emacs or file loaded from there."
119   :type '(repeat (file :tag "Initialization File"))
120   :group 'riece-options)
121
122 (defcustom riece-addons '(riece-highlight
123                           riece-ctcp
124                           riece-guess
125                           riece-unread
126                           riece-history
127                           riece-url
128                           riece-button
129                           riece-menu
130                           riece-icon
131                           riece-ignore
132                           riece-log
133                           riece-toolbar
134                           riece-alias
135                           riece-ctlseq
136                           riece-keyword)
137   "Add-ons insinuated into Riece."
138   :type '(repeat symbol)
139   :group 'riece-options)
140
141 (defgroup riece-server nil
142   "Server settings"
143   :prefix "riece-"
144   :group 'riece)
145
146 (defgroup riece-channel nil
147   "Channel settings"
148   :prefix "riece-"
149   :group 'riece)
150
151 (define-widget 'riece-service-spec 'radio
152   "Edit service spec entries"
153   :convert-widget 'riece-service-spec-convert)
154
155 (defun riece-service-spec-convert (widget)
156   (widget-put widget :args '((integer :tag "Port Number")
157                              (string :tag "Name")))
158   widget)
159
160 (define-widget 'riece-server-spec 'repeat
161   "Edit server spec entries"
162   :match (lambda (widget value)
163            (eval `(and ,@(mapcar
164                           (lambda (entry)
165                             (or (stringp (cdr entry))
166                                 (listp (cdr entry))))
167                           value))))
168   :convert-widget 'riece-server-spec-convert)
169
170 (defun riece-server-spec-convert (widget)
171   (let* ((host '(const :format "" :value :host))
172          (service '(const :format "" :value :service))
173          (host
174           `(group :inline t ,host (string :tag "Host")))
175          (service
176           `(group :inline t ,service riece-service-spec))
177          (spec
178           `(cons (string :tag "Name")
179                  (radio (string :tag "Host")
180                         (list ,host ,service))))
181          (args (list spec)))
182     (widget-put widget :args args)
183     widget))
184
185 (defcustom riece-server-alist nil
186   "An alist mapping server names to plist."
187   :type 'riece-server-spec
188   :group 'riece-server)
189
190 (defcustom riece-server (getenv "IRCSERVER")
191   "IRC server host we are connecting to."
192   :type 'string
193   :group 'riece-server)
194
195 (defcustom riece-protocol 'irc
196   "Protocol support."
197   :type 'symbol
198   :group 'riece-server)
199
200 (defcustom riece-max-send-size 512
201   "Maximum size of messages to be sent at a time."
202   :type 'integer
203   :group 'riece-server)
204
205 (defcustom riece-send-delay 2
206   "Duration of multiple send."
207   :type 'integer
208   :group 'riece-server)
209   
210 (defcustom riece-default-password (getenv "IRCPASSWORD")
211   "Your password."
212   :type '(radio (string :tag "Password")
213                 (const :tag "No" nil))
214   :group 'riece-server)
215
216 (defcustom riece-username nil
217   "Your user name."
218   :type 'string
219   :group 'riece-server)
220
221 (defcustom riece-nickname (or (getenv "IRCNICK")
222                               (user-real-login-name))
223   "Your nickname."
224   :type 'string
225   :group 'riece-server)
226
227 (defcustom riece-startup-channel-list nil
228   "A list of channels to join automatically at startup."
229   :type '(repeat (choice (string :tag "Channel")
230                          (list (string :tag "Channel") (string :tag "Key"))))
231   :group 'riece-channel)
232
233 (defcustom riece-startup-server-list nil
234   "A list of servers to connect automatically at startup."
235   :type '(repeat (string :tag "Server"))
236   :group 'riece-server)
237
238 (defcustom riece-retry-with-new-nickname nil
239   "When nickname has already been in use, grow-tail automatically."
240   :type 'boolean
241   :group 'riece-server)
242
243 (defcustom riece-quit-timeout 1
244   "Quit timeout when there is no response from server."
245   :type '(radio (integer :tag "Seconds")
246                 (const nil))
247   :group 'riece-server)
248
249 (defcustom riece-default-open-connection-function #'open-network-stream
250   "Default function used for connecting to an IRC server."
251   :type 'function
252   :group 'riece-server)
253
254 (defcustom riece-channel-buffer-mode t
255   "When non-nil, Riece will display a channel buffer."
256   :type 'boolean
257   :group 'riece-looks)
258
259 (defcustom riece-others-buffer-mode t
260   "When non-nil, Riece will display an \"*Others*\" buffer."
261   :type 'boolean
262   :group 'riece-looks)
263
264 (defcustom riece-user-list-buffer-mode t
265   "When non-nil, Riece will display a nick list buffer."
266   :type 'boolean
267   :group 'riece-looks)
268
269 (defcustom riece-channel-list-buffer-mode t
270   "When non-nil, Riece will display a channel list buffer."
271   :type 'boolean
272   :group 'riece-looks)
273
274 (defcustom riece-default-freeze nil
275   "Channel buffer local freeze flag is on at starting."
276   :type 'boolean
277   :group 'riece-looks)
278
279 (defcustom riece-default-channel-binding nil
280   "The channel list to bind the channel number when joining."
281   :type '(repeat (radio (string :tag "Bound Channel")
282                         (const nil)))
283   :group 'riece-channel)
284
285 (defcustom riece-blink-parens nil
286   "Should we blink matching parenthesis in the command buffer?"
287   :type 'boolean
288   :group 'riece-options)
289
290 (defcustom riece-quit-message (riece-extended-version)
291   "Default quit message."
292   :type '(string :tag "Quit message")
293   :group 'riece-options)
294
295 (defcustom riece-part-message nil
296   "Default part message."
297   :type '(choice (const :tag "No message" nil)
298                  (string :tag "Part message"))
299   :group 'riece-options)
300
301 (defcustom riece-away-message "Gone"
302   "Default away message."
303   :type '(string :tag "Away message")
304   :group 'riece-options)
305
306 (defcustom riece-gather-channel-modes nil
307   "If non-nil, gather channel modes when we join a channel."
308   :type 'boolean
309   :group 'riece-options)
310
311 (defcustom riece-buffer-dispose-function #'kill-buffer
312   "Function called after the buffer was disposed."
313   :type 'function
314   :group 'riece-options)
315
316 (defcustom riece-shrink-buffer-idle-time-delay 5
317   "Number of idle seconds to wait before shrinking channel buffers."
318   :type 'integer
319   :group 'riece-options)
320
321 (defcustom riece-max-buffer-size nil
322   "Maximum size of channel buffers."
323   :type '(radio (integer :tag "Number of characters")
324                 (const nil))
325   :group 'riece-options)
326
327 (defcustom riece-shrink-buffer-remove-chars (/ riece-max-send-size 2)
328   "Number of chars removed when shrinking channel buffers."
329   :type 'integer
330   :group 'riece-options)
331
332 (defcustom riece-format-time-function #'current-time-string
333   "Function to convert the specified time to the human readable form."
334   :type 'function
335   :group 'riece-options)
336
337 (provide 'riece-options)
338
339 ;;; riece-options.el ends here