Simplify.
[riece] / doc / HACKING
1 -*- mode: text -*-
2
3 This document is for Riece developers or those who are interested in
4 becoming a developer.  The main topic explained here is about
5 development process and the internals.
6
7 * Development process
8
9 ** Bug report
10
11 You can create a template of a bug report by clicking the "bug" button
12 in a toolbar, or M-x riece-submit-bug-report.  You need to set
13 riece-debug to t when preparing a bug report.
14
15 ** Debug output
16
17 If riece-debug is t, "*Debug*" buffer will have debugging information.
18 Also, interactions with IRC servers will be written to "
19 *IRC*<IRC-server-name>" buffers.  Note that these buffers have a name
20 starting with a whitespace character (" ").
21
22 ** Joining the development
23
24 To join the development, send us a patch or an add-on.
25
26 ** CVS
27
28 The development of Riece uses CVS.  The latest development version is
29 available from cvs.m17n.org.  The instructions to obtain and build the
30 source from the CVS are below.
31
32 (1) checkout modules
33
34     cvs -d :pserver:anonymous@cvs.m17n.org:/cvs/root checkout riece
35
36 You can specify a tag in front of the module name.
37
38 (2) generate configure script
39
40     autoreconf -f -i -v
41
42 Note that "autoreconf" is not "autoconf".
43
44 * Internals
45
46 ** Modules
47
48 Riece consists of many elisp modules listed below, ordered by the
49 number of dependencies they have.
50
51 - riece-globals
52   This module defines global variables.
53
54 - riece-options
55   This module defines user options.
56
57 - riece-version
58   This module defines the version of Riece.
59
60 - riece-coding
61   This module provides functions which support character code conversions.
62
63 - riece-complete
64   This module provides functions which support tab completion feature
65   in a mini buffer.
66
67 - riece-addon
68   This module manages add-ons.
69
70 - riece-mode
71   This module manages modes of riece-channel/riece-user objects.
72
73 - riece-identity
74   This module defines the riece-identity object type which represents
75   global names of riece-channel/riece-user objects.
76
77 - riece-channel
78   This module defines the riece-channel object type.
79
80 - riece-user
81   This module defines the riece-user object type.
82
83 - riece-misc
84   This module provides miscellaneous functions.
85
86 - riece-signal
87   This module defines the riece-signal object type used to manage
88   display events.
89
90 - riece-layout
91   This module manages window layouts.
92
93 - riece-display
94   This module manages display events.
95
96 - riece-server
97   This module manages connections to IRC servers.
98
99 - riece-naming
100   This module is a so called the Mediator design pattern.  It knows
101   relationships of riece-channel/riece-user objects.
102
103 - riece-message
104   This module defines the riece-message object type.
105
106 - riece-filter
107   This module only provides the process filter function.
108
109 - riece-handle
110   This module provides handler functions for IRC messages.  These
111   functions are called from riece-filter.
112
113 - riece-000
114   This module provides handler functions for numeric replies whose
115   response codes are in 000 to 100 range.  These handlers are called
116   from riece-filter.
117
118 - riece-200
119   This module provides handler functions for numeric replies whose
120   response codes are in 200 to 300 range.  These handlers are called
121   from riece-filter.
122
123 - riece-300
124   This module provides handler functions for numeric replies whose
125   response codes are in 300 to 400 range.  These handlers are called
126   from riece-filter.
127
128 - riece-400
129   This module provides handler functions for numeric replies whose
130   response codes are in 400 to 500 range.  These handlers are called
131   from riece-filter.
132
133 - riece-500
134   This module provides handler functions for numeric replies whose
135   response codes are in 500 to 600 range.  These handlers are called
136   from riece-filter.
137
138 - riece-commands
139   This module provides user commands.
140
141 - riece-irc
142   This module provides the binding for the IRC protocol.
143
144 - riece
145   This module is the entry point of M-x riece.
146
147 ** Namespace management
148
149 Riece is capable to connect to several IRC servers.
150
151 Riece has separate namespace (obarray) for each connection.  These
152 namespaces can be accessed as buffer local variables of process
153 buffer.
154
155 *** Obtaining server buffer
156
157 To access to the buffer local variables of process buffer, it is
158 needed to distinguish process object of each connection by its name.
159
160 It can be known by:
161
162 (1) checking the value of riece-overriding-server-name,
163
164 (2) checking the value of riece-server-name,
165     (If the variable riece-server-name is local to the current buffer,
166     you are already in the process buffer.)
167
168 (3) or parsing riece-identity objects
169
170 Once you get the name of the IRC server, you can get the process
171 object by passing the name to the function riece-server-process.
172
173 *** riece-identity objects
174
175 A riece-identity object represents a name of a channel/user.  It is
176 used to distinguish a channel/user among several servers.
177
178 A riece-identity object is actually a vector, which consists of two
179 elements listed below.
180
181 - prefix
182   A channel/user name local to an IRC server.
183
184 - server
185   The name of the IRC server.
186
187 Methods to manipulate riece-identity object are listed below.
188
189 - riece-make-identity prefix &optional server
190   Create a new riece-identity object.  If the server argument is
191   omitted, it sets the server part to the value returned by the
192   riece-find-server-name function.
193
194 - riece-identity-prefix identity
195   Return the prefix element from the given riece-identity object.
196
197 - riece-identity-server identity
198   Return the server element from the given riece-identity object.
199
200 - riece-identity-equal ident1 ident2
201   Return t, if two riece-identity objects are equal.
202
203 - riece-identity-equal-no-server ident1 ident2
204   Return t, if two riece-identity objects are equal.  This function
205   only consider a prefix part of a riece-identity object.
206
207 - riece-identity-member elt list
208   Return non-nil if a riece-identity object is an element of a list.
209
210 *** Channels and users
211
212 A riece-channel object provides an abstraction of a channel.
213 Likewise, a riece-user object provides an abstraction of a user.
214
215 **** riece-channel objects
216
217 A riece-channel object has many information about a channel.  A
218 riece-channel object is actually a vector whose seven elements are listed
219 below.
220
221 - users
222   A list of nicknames which are of users in this channel.
223
224 - operators
225   A list of nicknames which are of channel operators in this channel.
226
227 - speakers
228   A list of nicknames which are of users who have the right to speak
229   in this channel.
230
231 - modes
232   An alist which represents modes of this channel.
233
234 - banned
235   A list of patterns set by MODE +b.
236
237 - invited
238   A list of patterns set by MODE +I.
239
240 - uninvited
241   A list of patterns set by MODE +e.
242
243 **** riece-user objects
244
245 A riece-user object has many information about a user.  A riece-user
246 object is actually a vector whose four elements are listed below.
247
248 - channels
249   A list of channel names this user is participating.
250
251 - user-at-host
252   Connection information of this user, set in "<user>@<host>" format.
253
254 - modes
255   An alist which represents modes of this user.
256
257 - away
258   A flag represent whether this user is AWAY.
259
260 **** The Mediator pattern
261
262 The riece-naming module is used to manage relationships between
263 channels and users.  It utilizes the Mediator design pattern.
264
265 Using the riece-naming module allows to safely access to the namespace
266 rather than directly connects riece-channel/riece-user objects.
267
268 The riece-naming module provides the following functions.
269
270 - riece-naming-assert-join user-name channel-name
271   Assert that a user is a member of a channel.
272
273 - riece-naming-assert-part user-name channel-name
274   Assert that a user is no longer a member of a channel.
275
276 - riece-naming-assert-rename old-name new-name
277   Assert that a user changed his nickname.
278
279 ** Signals
280
281 There is a mechanism to connect events and display objects (windows,
282 buffers, and modeline indicators).  This is done by signals.
283
284 When it is needed to redraw, a signal is emitted.  The concept of
285 signals is corresponding to signals in generic window system toolkit
286 such as Qt or GTK+.
287
288 To emit a signal, use riece-emit-signal.
289
290 - riece-emit-signal signal-name &rest args
291   Emit a signal named signal-name with args.
292
293 To define a function called when a signal is emitted, use
294 riece-connect-signal.
295
296 - riece-connect-signal signal-name slot-function &optional
297                        filter-function handback
298
299   Give a signal a slot-function.  The slot-function gets two
300   arguments: the signal object itself and a handback object given as
301   the fourth argument of riece-connect-signal.
302
303   If the third argument filter-function is specified, the
304   slot-function is called conditionally.  The filter-function gets the
305   signal object and returns nil or t.  If the return value is nil, the
306   slot-function is not called.
307
308 To access to a signal object, use the following functions.
309
310 - riece-signal-name signal
311   Return the name of a signal.
312
313 - riece-signal-args
314   Return the data of a signal.
315
316 Below is a list of signal names reserved.
317
318 - channel-list-changed
319   Need update the channel list.
320
321 - user-list-changed
322   Need update the user list.
323   (This signal gets a riece-identity object as an argument which
324   represents the channel.)
325
326 - channel-switched
327   A user selected another channel.
328
329 - user-joined-channel
330   A user joined a channel.
331   (This signal gets two riece-identity objects as arguments
332   corresponding to the user and the channel respectively.)
333
334 - user-left-channel
335   A user left a channel.
336   (This signal gets two riece-identity objects as arguments
337   corresponding to the user and the channel respectively.)
338
339 - user-renamed
340   A user changed his nickname.
341   (This signal gets two riece-identity objects as arguments
342   corresponding to the old and the new nickname respectively.)
343
344 - user-away-changed
345   A user changed his AWAY status.
346   (This signal gets a riece-identity object as an argument which
347   represents the user.)
348
349 - user-operator-changed
350   A user changed his IRC operator status. 
351   (This signal gets a riece-identity object as an argument which
352   represents the user.)
353
354 - channel-topic-changed
355   A topic of a channel changed.
356   (This signal gets a riece-identity object as an argument which
357   represents the channel.)
358
359 - channel-modes-changed
360   Modes of a channel changed.
361   (This signal gets a riece-identity object as an argument which
362   represents the channel.)
363
364 - channel-operators-changed
365   A list of operators in a channel changed.
366   (This signal gets a riece-identity object as an argument which
367   represents the channel.)
368
369 - channel-speakers-changed
370   A list of users who have the right to speak in a channel changed.
371   (This signal gets a riece-identity object as an argument which
372   represents the channel.)
373
374 - buffer-freeze-changed
375   A buffer is frozen or unfrozen.
376   (This signal gets a buffer as an argument.)
377
378 ** Writing add-ons
379
380 Elisp modules that satisfy add-on spec should provide the following
381 functions.
382
383 - <module-name>-requires (optional)
384   Return a list of names of other add-ons this add-on depends.
385
386 - <module-name>-insinuate
387   Called on initialization of this module.
388
389 - <module-name>-uninstall (optional)
390   Called on uninstallation of this module.
391
392 - <module-name>-enable (optional)
393   Called when this add-on is enabled.
394
395 - <module-name>-disable (optional)
396   Called when this add-on is disabled.
397
398 It is recommended to set short explanation of the add-on to
399 <module-name>-description variable which is displayed on add-on
400 listing shown up by C-c ^ (M-x riece-command-list-addons).
401
402 To see the add-on's enabled/disabled status, check riece-addon-enabled
403 property set on <module-name> symbol.
404
405 Riece does the following procedure on add-ons when startup.
406
407 (1) Load add-ons listed in the riece-addons variable.
408
409 (2) Call <module-name>-requires on each add-on (if exists) and build a
410     dependency graph.
411
412 (3) Sort the dependency graph.
413
414 (4) Call <module-name>-insinuate on each add-on in order of the
415     dependencies.
416
417 (5) Call <module-name>-enable on each add-on, iff it supports
418     enabling/disabling and is not disabled explicitly.
419
420 Add-ons are loaded from directories listed in load-path, or from
421 ~/.riece/addons/.
422
423 ** Handler hooks
424
425 There are hooks called "handler hooks " which have special meaning in
426 Riece.  Handler hooks are called before/after processing IRC messages.
427
428 - riece-<message>-hook
429   Called before processing an IRC message.
430
431 - riece-after-<message>-hook
432   Called after processing an IRC message.
433
434 Where <message> is a type of IRC message and consists only lowercase
435 characters.
436
437 If riece-<message>-hook returns non-nil, <message> is not processed.
438 In this case riece-after-<message>-hook is not called.
439
440 Handler hooks gets two arguments corresponding to prefix and
441 parameters in RFC2812.