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