0
|
1 \input texinfo @c -*-texinfo-*-
|
|
2 @c %**start of header
|
|
3 @setfilename ../../info/internals.info
|
|
4 @settitle XEmacs Internals Manual
|
|
5 @c %**end of header
|
|
6
|
|
7 @ifinfo
|
|
8
|
|
9 Copyright @copyright{} 1992 - 1996 Ben Wing.
|
44
|
10 Copyright @copyright{} 1996, 1997 Sun Microsystems.
|
0
|
11 Copyright @copyright{} 1994, 1995 Free Software Foundation.
|
|
12 Copyright @copyright{} 1994, 1995 Board of Trustees, University of Illinois.
|
|
13
|
|
14
|
|
15 Permission is granted to make and distribute verbatim copies of this
|
|
16 manual provided the copyright notice and this permission notice are
|
|
17 preserved on all copies.
|
|
18
|
|
19 @ignore
|
|
20 Permission is granted to process this file through TeX and print the
|
|
21 results, provided the printed document carries copying permission notice
|
|
22 identical to this one except for the removal of this paragraph (this
|
|
23 paragraph not being relevant to the printed manual).
|
|
24
|
|
25 @end ignore
|
|
26 Permission is granted to copy and distribute modified versions of this
|
|
27 manual under the conditions for verbatim copying, provided that the
|
|
28 entire resulting derived work is distributed under the terms of a
|
|
29 permission notice identical to this one.
|
|
30
|
|
31 Permission is granted to copy and distribute translations of this manual
|
|
32 into another language, under the above conditions for modified versions,
|
|
33 except that this permission notice may be stated in a translation
|
|
34 approved by the Foundation.
|
|
35
|
|
36 Permission is granted to copy and distribute modified versions of this
|
|
37 manual under the conditions for verbatim copying, provided also that the
|
|
38 section entitled ``GNU General Public License'' is included exactly as
|
|
39 in the original, and provided that the entire resulting derived work is
|
|
40 distributed under the terms of a permission notice identical to this
|
|
41 one.
|
|
42
|
|
43 Permission is granted to copy and distribute translations of this manual
|
|
44 into another language, under the above conditions for modified versions,
|
|
45 except that the section entitled ``GNU General Public License'' may be
|
|
46 included in a translation approved by the Free Software Foundation
|
|
47 instead of in the original English.
|
|
48 @end ifinfo
|
|
49
|
|
50 @c Combine indices.
|
|
51 @synindex cp fn
|
|
52 @syncodeindex vr fn
|
|
53 @syncodeindex ky fn
|
|
54 @syncodeindex pg fn
|
|
55 @syncodeindex tp fn
|
|
56
|
|
57 @setchapternewpage odd
|
|
58 @finalout
|
|
59
|
|
60 @titlepage
|
|
61 @title XEmacs Internals Manual
|
44
|
62 @subtitle Version 1.1, March 1997
|
0
|
63
|
|
64 @author Ben Wing
|
44
|
65 @author Martin Buchholz
|
0
|
66 @page
|
|
67 @vskip 0pt plus 1fill
|
|
68
|
|
69 @noindent
|
|
70 Copyright @copyright{} 1992 - 1996 Ben Wing. @*
|
|
71 Copyright @copyright{} 1996 Sun Microsystems, Inc. @*
|
|
72 Copyright @copyright{} 1994 Free Software Foundation. @*
|
|
73 Copyright @copyright{} 1994, 1995 Board of Trustees, University of Illinois.
|
|
74
|
|
75 @sp 2
|
44
|
76 Version 1.1 @*
|
|
77 March, 1997.@*
|
0
|
78
|
|
79 Permission is granted to make and distribute verbatim copies of this
|
|
80 manual provided the copyright notice and this permission notice are
|
|
81 preserved on all copies.
|
|
82
|
|
83 Permission is granted to copy and distribute modified versions of this
|
|
84 manual under the conditions for verbatim copying, provided also that the
|
|
85 section entitled ``GNU General Public License'' is included
|
|
86 exactly as in the original, and provided that the entire resulting
|
|
87 derived work is distributed under the terms of a permission notice
|
|
88 identical to this one.
|
|
89
|
|
90 Permission is granted to copy and distribute translations of this manual
|
|
91 into another language, under the above conditions for modified versions,
|
|
92 except that the section entitled ``GNU General Public License'' may be
|
|
93 included in a translation approved by the Free Software Foundation
|
|
94 instead of in the original English.
|
|
95 @end titlepage
|
|
96 @page
|
|
97
|
|
98 @node Top, A History of Emacs, (dir), (dir)
|
|
99
|
|
100 @ifinfo
|
|
101 This Info file contains v1.0 of the XEmacs Internals Manual.
|
|
102 @end ifinfo
|
|
103
|
|
104 @menu
|
|
105 * A History of Emacs:: Times, dates, important events.
|
|
106 * XEmacs From the Outside:: A broad conceptual overview.
|
|
107 * The Lisp Language:: An overview.
|
|
108 * XEmacs From the Perspective of Building::
|
|
109 * XEmacs From the Inside::
|
|
110 * The XEmacs Object System (Abstractly Speaking)::
|
|
111 * How Lisp Objects Are Represented in C::
|
|
112 * Rules When Writing New C Code::
|
|
113 * A Summary of the Various XEmacs Modules::
|
|
114 * Allocation of Objects in XEmacs Lisp::
|
|
115 * Events and the Event Loop::
|
|
116 * Evaluation; Stack Frames; Bindings::
|
|
117 * Symbols and Variables::
|
|
118 * Buffers and Textual Representation::
|
|
119 * MULE Character Sets and Encodings::
|
|
120 * The Lisp Reader and Compiler::
|
|
121 * Lstreams::
|
|
122 * Consoles; Devices; Frames; Windows::
|
|
123 * The Redisplay Mechanism::
|
|
124 * Extents::
|
|
125 * Faces and Glyphs::
|
|
126 * Specifiers::
|
|
127 * Menus::
|
|
128 * Subprocesses::
|
|
129 * Interface to X Windows::
|
|
130 * Index:: Index including concepts, functions, variables,
|
|
131 and other terms.
|
|
132
|
|
133 --- The Detailed Node Listing ---
|
|
134
|
|
135 Here are other nodes that are inferiors of those already listed,
|
|
136 mentioned here so you can get to them in one step:
|
|
137
|
|
138 A History of Emacs
|
|
139
|
|
140 * Through Version 18:: Unification prevails.
|
|
141 * Lucid Emacs:: One version 19 Emacs.
|
|
142 * GNU Emacs 19:: The other version 19 Emacs.
|
|
143 * XEmacs:: The continuation of Lucid Emacs.
|
|
144
|
|
145 Rules When Writing New C Code
|
|
146
|
|
147 * General Coding Rules::
|
|
148 * Writing Lisp Primitives::
|
|
149 * Adding Global Lisp Variables::
|
2
|
150 * Techniques for XEmacs Developers::
|
0
|
151
|
|
152 A Summary of the Various XEmacs Modules
|
|
153
|
|
154 * Low-Level Modules::
|
|
155 * Basic Lisp Modules::
|
|
156 * Modules for Standard Editing Operations::
|
|
157 * Editor-Level Control Flow Modules::
|
|
158 * Modules for the Basic Displayable Lisp Objects::
|
|
159 * Modules for other Display-Related Lisp Objects::
|
|
160 * Modules for the Redisplay Mechanism::
|
|
161 * Modules for Interfacing with the File System::
|
|
162 * Modules for Other Aspects of the Lisp Interpreter and Object System::
|
|
163 * Modules for Interfacing with the Operating System::
|
|
164 * Modules for Interfacing with X Windows::
|
|
165 * Modules for Internationalization::
|
|
166
|
|
167 Allocation of Objects in XEmacs Lisp
|
|
168
|
|
169 * Introduction to Allocation::
|
|
170 * Garbage Collection::
|
|
171 * GCPROing::
|
|
172 * Integers and Characters::
|
|
173 * Allocation from Frob Blocks::
|
|
174 * lrecords::
|
|
175 * Low-level allocation::
|
|
176 * Pure Space::
|
|
177 * Cons::
|
|
178 * Vector::
|
|
179 * Bit Vector::
|
|
180 * Symbol::
|
|
181 * Marker::
|
|
182 * String::
|
|
183 * Bytecode::
|
|
184
|
|
185 Events and the Event Loop
|
|
186
|
|
187 * Introduction to Events::
|
|
188 * Main Loop::
|
|
189 * Specifics of the Event Gathering Mechanism::
|
|
190 * Specifics About the Emacs Event::
|
|
191 * The Event Stream Callback Routines::
|
|
192 * Other Event Loop Functions::
|
|
193 * Converting Events::
|
|
194 * Dispatching Events; The Command Builder::
|
|
195
|
|
196 Evaluation; Stack Frames; Bindings
|
|
197
|
|
198 * Evaluation::
|
|
199 * Dynamic Binding; The specbinding Stack; Unwind-Protects::
|
|
200 * Simple Special Forms::
|
|
201 * Catch and Throw::
|
|
202
|
|
203 Symbols and Variables
|
|
204
|
|
205 * Introduction to Symbols::
|
|
206 * Obarrays::
|
|
207 * Symbol Values::
|
|
208
|
|
209 Buffers and Textual Representation
|
|
210
|
|
211 * Introduction to Buffers:: A buffer holds a block of text such as a file.
|
58
|
212 * The Text in a Buffer:: Representation of the text in a buffer.
|
0
|
213 * Buffer Lists:: Keeping track of all buffers.
|
|
214 * Markers and Extents:: Tagging locations within a buffer.
|
|
215 * Bufbytes and Emchars:: Representation of individual characters.
|
|
216 * The Buffer Object:: The Lisp object corresponding to a buffer.
|
|
217
|
|
218 MULE Character Sets and Encodings
|
|
219
|
|
220 * Character Sets::
|
|
221 * Encodings::
|
|
222 * Internal Mule Encodings::
|
|
223
|
|
224 Encodings
|
|
225
|
|
226 * Japanese EUC (Extended Unix Code)::
|
|
227 * JIS7::
|
|
228
|
|
229 Internal Mule Encodings
|
|
230
|
|
231 * Internal String Encoding::
|
|
232 * Internal Character Encoding::
|
|
233
|
|
234 The Lisp Reader and Compiler
|
|
235
|
|
236 Lstreams
|
|
237
|
|
238 Consoles; Devices; Frames; Windows
|
|
239
|
|
240 * Introduction to Consoles; Devices; Frames; Windows::
|
|
241 * Point::
|
|
242 * Window Hierarchy::
|
|
243
|
|
244 The Redisplay Mechanism
|
|
245
|
|
246 * Critical Redisplay Sections::
|
|
247 * Line Start Cache::
|
|
248
|
|
249 Extents
|
|
250
|
|
251 * Introduction to Extents:: Extents are ranges over text, with properties.
|
|
252 * Extent Ordering:: How extents are ordered internally.
|
|
253 * Format of the Extent Info:: The extent information in a buffer or string.
|
|
254 * Zero-Length Extents:: A weird special case.
|
|
255 * Mathematics of Extent Ordering:: A rigorous foundation.
|
|
256 * Extent Fragments:: Cached information useful for redisplay.
|
|
257
|
|
258 Faces and Glyphs
|
|
259
|
|
260 Specifiers
|
|
261
|
|
262 Menus
|
|
263
|
|
264 Subprocesses
|
|
265
|
|
266 Interface to X Windows
|
|
267
|
|
268 @end menu
|
|
269
|
|
270 @node A History of Emacs, XEmacs From the Outside, Top, Top
|
|
271 @chapter A History of Emacs
|
|
272 @cindex history of Emacs
|
|
273 @cindex Hackers (Steven Levy)
|
|
274 @cindex Levy, Steven
|
|
275 @cindex ITS (Incompatible Timesharing System)
|
|
276 @cindex Stallman, Richard
|
|
277 @cindex RMS
|
|
278 @cindex MIT
|
|
279 @cindex TECO
|
|
280 @cindex FSF
|
|
281 @cindex Free Software Foundation
|
|
282
|
|
283 XEmacs is a powerful, customizable text editor and development
|
|
284 environment. It began as Lucid Emacs, which was in turn derived from
|
|
285 GNU Emacs, a program written by Richard Stallman of the Free Software
|
|
286 Foundation. GNU Emacs dates back to the 1970's, and was modelled
|
|
287 after a package called ``Emacs'', written in 1976, that was a set of
|
|
288 macros on top of TECO, an old, old text editor written at MIT on the
|
|
289 DEC PDP 10 under one of the earliest time-sharing operating systems,
|
|
290 ITS (Incompatible Timesharing System). (ITS dates back well before
|
|
291 Unix.) ITS, TECO, and Emacs were products of a group of people at MIT
|
|
292 who called themselves ``hackers'', who shared an idealistic belief
|
|
293 system about the free exchange of information and were fanatical in
|
|
294 their devotion to and time spent with computers. (The hacker
|
|
295 subculture dates back to the late 1950's at MIT and is described in
|
|
296 detail in Steven Levy's book @cite{Hackers}. This book also includes
|
|
297 a lot of information about Stallman himself and the development of
|
|
298 Lisp, a programming language developed at MIT that underlies Emacs.)
|
|
299
|
|
300 @menu
|
|
301 * Through Version 18:: Unification prevails.
|
|
302 * Lucid Emacs:: One version 19 Emacs.
|
|
303 * GNU Emacs 19:: The other version 19 Emacs.
|
58
|
304 * GNU Emacs 20:: The other version 20 Emacs.
|
0
|
305 * XEmacs:: The continuation of Lucid Emacs.
|
|
306 @end menu
|
|
307
|
|
308 @node Through Version 18
|
|
309 @section Through Version 18
|
|
310 @cindex Gosling, James
|
|
311 @cindex Great Usenet Renaming
|
|
312
|
|
313 Although the history of the early versions of GNU Emacs is unclear,
|
|
314 the history is well-known from the middle of 1985. A time line is:
|
|
315
|
|
316 @itemize @bullet
|
|
317 @item
|
|
318 GNU Emacs version 15 (15.34) was released sometime in 1984 or 1985 and
|
|
319 shared some code with a version of Emacs written by James Gosling (the
|
|
320 same James Gosling who later created the Java language).
|
|
321 @item
|
|
322 GNU Emacs version 16 (first released version was 16.56) was released on
|
|
323 July 15, 1985. All Gosling code was removed due to potential copyright
|
|
324 problems with the code.
|
|
325 @item
|
|
326 version 16.57: released on September 16, 1985.
|
|
327 @item
|
|
328 versions 16.58, 16.59: released on September 17, 1985.
|
|
329 @item
|
|
330 version 16.60: released on September 19, 1985. These later version 16's
|
|
331 incorporated patches from the net, esp. for getting Emacs to work under
|
|
332 System V.
|
|
333 @item
|
|
334 version 17.36 (first official v17 release) released on December 20,
|
|
335 1985. Included a TeX-able user manual. First official unpatched
|
|
336 version that worked on vanilla System V machines.
|
|
337 @item
|
|
338 version 17.43 (second official v17 release) released on January 25,
|
|
339 1986.
|
|
340 @item
|
|
341 version 17.45 released on January 30, 1986.
|
|
342 @item
|
|
343 version 17.46 released on February 4, 1986.
|
|
344 @item
|
|
345 version 17.48 released on February 10, 1986.
|
|
346 @item
|
|
347 version 17.49 released on February 12, 1986.
|
|
348 @item
|
|
349 version 17.55 released on March 18, 1986.
|
|
350 @item
|
|
351 version 17.57 released on March 27, 1986.
|
|
352 @item
|
|
353 version 17.58 released on April 4, 1986.
|
|
354 @item
|
|
355 version 17.61 released on April 12, 1986.
|
|
356 @item
|
|
357 version 17.63 released on May 7, 1986.
|
|
358 @item
|
|
359 version 17.64 released on May 12, 1986.
|
|
360 @item
|
|
361 version 18.24 (a beta version) released on October 2, 1986.
|
|
362 @item
|
|
363 version 18.30 (a beta version) released on November 15, 1986.
|
|
364 @item
|
|
365 version 18.31 (a beta version) released on November 23, 1986.
|
|
366 @item
|
|
367 version 18.32 (a beta version) released on December 7, 1986.
|
|
368 @item
|
|
369 version 18.33 (a beta version) released on December 12, 1986.
|
|
370 @item
|
|
371 version 18.35 (a beta version) released on January 5, 1987.
|
|
372 @item
|
|
373 version 18.36 (a beta version) released on January 21, 1987.
|
|
374 @item
|
2
|
375 January 27, 1987: The Great Usenet Renaming. net.emacs is now
|
|
376 comp.emacs.
|
|
377 @item
|
0
|
378 version 18.37 (a beta version) released on February 12, 1987.
|
|
379 @item
|
|
380 version 18.38 (a beta version) released on March 3, 1987.
|
|
381 @item
|
|
382 version 18.39 (a beta version) released on March 14, 1987.
|
|
383 @item
|
|
384 version 18.40 (a beta version) released on March 18, 1987.
|
|
385 @item
|
|
386 version 18.41 (the first ``official'' release) released on March 22,
|
|
387 1987.
|
|
388 @item
|
|
389 version 18.45 released on June 2, 1987.
|
|
390 @item
|
|
391 version 18.46 released on June 9, 1987.
|
|
392 @item
|
|
393 version 18.47 released on June 18, 1987.
|
|
394 @item
|
|
395 version 18.48 released on September 3, 1987.
|
|
396 @item
|
|
397 version 18.49 released on September 18, 1987.
|
|
398 @item
|
|
399 version 18.50 released on February 13, 1988.
|
|
400 @item
|
|
401 version 18.51 released on May 7, 1988.
|
|
402 @item
|
|
403 version 18.52 released on September 1, 1988.
|
|
404 @item
|
|
405 version 18.53 released on February 24, 1989.
|
|
406 @item
|
|
407 version 18.54 released on April 26, 1989.
|
|
408 @item
|
|
409 version 18.55 released on August 23, 1989. This is the earliest version
|
|
410 that is still available by FTP.
|
|
411 @item
|
|
412 version 18.56 released on January 17, 1991.
|
|
413 @item
|
|
414 version 18.57 released late January, 1991.
|
|
415 @item
|
|
416 version 18.58 released ?????.
|
|
417 @item
|
|
418 version 18.59 released October 31, 1992.
|
|
419 @end itemize
|
|
420
|
|
421 @node Lucid Emacs
|
|
422 @section Lucid Emacs
|
|
423 @cindex Lucid Emacs
|
|
424 @cindex Lucid Inc.
|
|
425 @cindex Energize
|
|
426 @cindex Epoch
|
|
427
|
|
428 Lucid Emacs was developed by the (now-defunct) Lucid Inc., a maker of
|
|
429 C++ and Lisp development environments. It began when Lucid decided they
|
|
430 wanted to use Emacs as the editor and cornerstone of their C++
|
|
431 development environment (called ``Energize''). They needed many features
|
|
432 that were not available in the existing version of GNU Emacs (version
|
|
433 18.5something), in particular good and integrated support for GUI
|
|
434 elements such as mouse support, multiple fonts, multiple window-system
|
|
435 windows, etc. A branch of GNU Emacs called Epoch, written at the
|
|
436 University of Illinois, existed that supplied many of these features;
|
|
437 however, Lucid needed more than what existed in Epoch. At the time, the
|
|
438 Free Software Foundation was working on version 19 of Emacs (this was
|
|
439 sometime around 1991), which was planned to have similar features, and
|
|
440 so Lucid decided to work with the Free Software Foundation. Their plan
|
|
441 was to add features that they needed, and coordinate with the FSF so
|
|
442 that the features would get included back into Emacs version 19.
|
|
443
|
|
444 Delays in the release of version 19 occurred, however (resulting in it
|
|
445 finally being released more than a year after what was initially
|
|
446 planned), and Lucid encountered unexpected technical resistance in
|
|
447 getting their changes merged back into version 19, so they decided to
|
|
448 release their own version of Emacs, which became Lucid Emacs 19.0.
|
|
449
|
|
450 @cindex Zawinski, Jamie
|
|
451 @cindex Sexton, Harlan
|
|
452 @cindex Benson, Eric
|
|
453 @cindex Devin, Matthieu
|
|
454 The initial authors of Lucid Emacs were Matthieu Devin, Harlan Sexton,
|
|
455 and Eric Benson, and the work was later taken over by Jamie Zawinski,
|
|
456 who became ``Mr. Lucid Emacs'' for many releases.
|
|
457
|
|
458 A time line for Lucid Emacs/XEmacs is
|
|
459
|
|
460 @itemize @bullet
|
|
461 @item
|
|
462 version 19.0 shipped with Energize 1.0, April 1992.
|
|
463 @item
|
|
464 version 19.1 released June 4, 1992.
|
|
465 @item
|
|
466 version 19.2 released June 19, 1992.
|
|
467 @item
|
|
468 version 19.3 released September 9, 1992.
|
|
469 @item
|
|
470 version 19.4 released January 21, 1993.
|
|
471 @item
|
|
472 version 19.5 was a repackaging of 19.4 with a few bug fixes and
|
|
473 shipped with Energize 2.0. Never released to the net.
|
|
474 @item
|
|
475 version 19.6 released April 9, 1993.
|
|
476 @item
|
|
477 version 19.7 was a repackaging of 19.6 with a few bug fixes and
|
|
478 shipped with Energize 2.1. Never released to the net.
|
|
479 @item
|
|
480 version 19.8 released September 6, 1993.
|
|
481 @item
|
|
482 version 19.9 released January 12, 1994.
|
|
483 @item
|
|
484 version 19.10 released May 27, 1994.
|
|
485 @item
|
|
486 version 19.11 (first XEmacs) released September 13, 1994.
|
|
487 @item
|
|
488 version 19.12 released June 23, 1995.
|
|
489 @item
|
|
490 version 19.13 released September 1, 1995.
|
34
|
491 @item
|
|
492 version 19.14 released June 23, 1996.
|
|
493 @item
|
|
494 version 20.0 released February 9, 1997.
|
54
|
495 @item
|
|
496 version 19.15 released March 28, 1997.
|
|
497 @item
|
|
498 version 20.1 (not released to the net) April 15, 1997.
|
|
499 @item
|
|
500 version 20.2 released May 16, 1997.
|
0
|
501 @end itemize
|
|
502
|
|
503 @node GNU Emacs 19
|
|
504 @section GNU Emacs 19
|
|
505 @cindex GNU Emacs 19
|
|
506 @cindex FSF Emacs
|
|
507
|
|
508 About a year after the initial release of Lucid Emacs, the FSF
|
|
509 released a beta of their version of Emacs 19 (referred to here as ``GNU
|
|
510 Emacs''). By this time, the current version of Lucid Emacs was
|
|
511 19.6. (Strangely, the first released beta from the FSF was GNU Emacs
|
|
512 19.7.) A time line for GNU Emacs version 19 is
|
|
513
|
|
514 @itemize @bullet
|
|
515 @item
|
|
516 version 19.8 (beta) released May 27, 1993.
|
|
517 @item
|
|
518 version 19.9 (beta) released May 27, 1993.
|
|
519 @item
|
|
520 version 19.10 (beta) released May 30, 1993.
|
|
521 @item
|
|
522 version 19.11 (beta) released June 1, 1993.
|
|
523 @item
|
|
524 version 19.12 (beta) released June 2, 1993.
|
|
525 @item
|
|
526 version 19.13 (beta) released June 8, 1993.
|
|
527 @item
|
|
528 version 19.14 (beta) released June 17, 1993.
|
|
529 @item
|
|
530 version 19.15 (beta) released June 19, 1993.
|
|
531 @item
|
|
532 version 19.16 (beta) released July 6, 1993.
|
|
533 @item
|
|
534 version 19.17 (beta) released late July, 1993.
|
|
535 @item
|
|
536 version 19.18 (beta) released August 9, 1993.
|
|
537 @item
|
|
538 version 19.19 (beta) released August 15, 1993.
|
|
539 @item
|
|
540 version 19.20 (beta) released November 17, 1993.
|
|
541 @item
|
|
542 version 19.21 (beta) released November 17, 1993.
|
|
543 @item
|
|
544 version 19.22 (beta) released November 28, 1993.
|
|
545 @item
|
|
546 version 19.23 (beta) released May 17, 1994.
|
|
547 @item
|
|
548 version 19.24 (beta) released May 16, 1994.
|
|
549 @item
|
|
550 version 19.25 (beta) released June 3, 1994.
|
|
551 @item
|
|
552 version 19.26 (beta) released September 11, 1994.
|
|
553 @item
|
|
554 version 19.27 (beta) released September 14, 1994.
|
|
555 @item
|
|
556 version 19.28 (first ``official'' release) released November 1, 1994.
|
|
557 @item
|
|
558 version 19.29 released June 21, 1995.
|
34
|
559 @item
|
|
560 version 19.30 released November 24, 1995.
|
|
561 @item
|
|
562 version 19.31 released May 25, 1996.
|
|
563 @item
|
|
564 version 19.32 released July 31, 1996.
|
|
565 @item
|
|
566 version 19.33 released August 11, 1996.
|
|
567 @item
|
|
568 version 19.34 released August 21, 1996.
|
|
569 @item
|
|
570 version 19.34b released September 6, 1996.
|
0
|
571 @end itemize
|
|
572
|
|
573 @cindex Mlynarik, Richard
|
|
574 In some ways, GNU Emacs 19 was better than Lucid Emacs; in some ways,
|
|
575 worse. Lucid soon began incorporating features from GNU Emacs 19 into
|
|
576 Lucid Emacs; the work was mostly done by Richard Mlynarik, who had been
|
|
577 working on and using GNU Emacs for a long time (back as far as version
|
|
578 16 or 17).
|
|
579
|
58
|
580 @node GNU Emacs 20
|
|
581 @section GNU Emacs 20
|
|
582 @cindex GNU Emacs 20
|
|
583 @cindex FSF Emacs
|
|
584
|
|
585 On February 2, 1997 work began on GNU Emacs to integrate Mule. The first
|
|
586 release was made in September of that year.
|
|
587
|
|
588 A timeline for Emacs 20 is
|
|
589
|
|
590 @itemize @bullet
|
|
591 @item
|
|
592 version 20.1 released September 17, 1997.
|
60
|
593 @item
|
|
594 version 20.2 released September 20, 1997.
|
58
|
595 @end itemize
|
|
596
|
0
|
597 @node XEmacs
|
|
598 @section XEmacs
|
|
599 @cindex XEmacs
|
|
600
|
|
601 @cindex Sun Microsystems
|
|
602 @cindex University of Illinois
|
|
603 @cindex Illinois, University of
|
|
604 @cindex SPARCWorks
|
|
605 @cindex Andreessen, Marc
|
54
|
606 @cindex Baur, Steve
|
|
607 @cindex Buchholz, Martin
|
0
|
608 @cindex Kaplan, Simon
|
|
609 @cindex Wing, Ben
|
|
610 @cindex Thompson, Chuck
|
|
611 @cindex Win-Emacs
|
|
612 @cindex Epoch
|
|
613 @cindex Amdahl Corporation
|
|
614 Around the time that Lucid was developing Energize, Sun Microsystems
|
|
615 was developing their own development environment (called ``SPARCWorks'')
|
|
616 and also decided to use Emacs. They joined forces with the Epoch team
|
|
617 at the University of Illinois and later with Lucid. The maintainer of
|
|
618 the last-released version of Epoch was Marc Andreessen, but he dropped
|
|
619 out and the Epoch project, headed by Simon Kaplan, lured Chuck Thompson
|
|
620 away from a system administration job to become the primary Lucid Emacs
|
|
621 author for Epoch and Sun. Chuck's area of specialty became the
|
|
622 redisplay engine (he replaced the old Lucid Emacs redisplay engine with
|
|
623 a ported version from Epoch and then later rewrote it from scratch).
|
|
624 Sun also hired Ben Wing (the author of Win-Emacs, a port of Lucid Emacs
|
|
625 to Microsoft Windows 3.1) in 1993, for what was initially a one-month
|
|
626 contract to fix some event problems but later became a many-year
|
|
627 involvement, punctuated by a six-month contract with Amdahl Corporation.
|
|
628
|
|
629 @cindex rename to XEmacs
|
|
630 In 1994, Sun and Lucid agreed to rename Lucid Emacs to XEmacs (a name
|
|
631 not favorable to either company); the first release called XEmacs was
|
|
632 version 19.11. In June 1994, Lucid folded and Jamie quit to work for
|
|
633 the newly formed Mosaic Communications Corp., later Netscape
|
|
634 Communications Corp. (co-founded by the same Marc Andreessen, who had
|
|
635 quit his Epoch job to work on a graphical browser for the World Wide
|
|
636 Web). Chuck then become the primary maintainer of XEmacs, and put out
|
54
|
637 versions 19.11 through 19.14 in conjunction with Ben. For 19.12 and
|
0
|
638 19.13, Chuck added the new redisplay and many other display improvements
|
|
639 and Ben added MULE support (support for Asian and other languages) and
|
|
640 redesigned most of the internal Lisp subsystems to better support the
|
54
|
641 MULE work and the various other features being added to XEmacs. After
|
|
642 19.14 Chuck retired as primary maintainer and Steve Baur stepped in.
|
|
643
|
|
644 @cindex MULE merged XEmacs appears
|
|
645 Soon after 19.13 was released, work began in earnest on the MULE
|
|
646 internationalization code and the source tree was divided into two
|
|
647 development paths. The MULE version was initially called 19.20, but was
|
|
648 soon renamed to 20.0. In 1996 Martin Buchholz of Sun Microsystems took
|
|
649 over the care and feeding of it and worked on it in parallel with the
|
|
650 19.14 development that was occurring at the same time. After much work
|
|
651 by Martin, it was decided to release 20.0 ahead of 19.15 in February
|
|
652 1997. The source tree remained divided until 20.1 when the version 19
|
|
653 source was finally retired.
|
0
|
654
|
|
655 @cindex merging attempts
|
|
656 Many attempts have been made to merge XEmacs and GNU Emacs, but they
|
|
657 have consistently run into the same technical disagreements and other
|
|
658 problems that Lucid ran into when originally attempting to merge Lucid
|
|
659 Emacs into GNU Emacs.
|
|
660
|
|
661 A more detailed history is contained in the XEmacs About page.
|
|
662
|
|
663 @node XEmacs From the Outside, The Lisp Language, A History of Emacs, Top
|
|
664 @chapter XEmacs From the Outside
|
|
665 @cindex read-eval-print
|
|
666
|
|
667 XEmacs appears to the outside world as an editor, but it is really a
|
|
668 Lisp environment. At its heart is a Lisp interpreter; it also
|
|
669 ``happens'' to contain many specialized object types (e.g. buffers,
|
|
670 windows, frames, events) that are useful for implementing an editor.
|
|
671 Some of these objects (in particular windows and frames) have
|
|
672 displayable representations, and XEmacs provides a function
|
|
673 @code{redisplay()} that ensures that the display of all such objects
|
|
674 matches their internal state. Most of the time, a standard Lisp
|
|
675 environment is in a @dfn{read-eval-print} loop -- i.e. ``read some Lisp
|
|
676 code, execute it, and print the results''. XEmacs has a similar loop:
|
|
677
|
|
678 @itemize @bullet
|
|
679 @item
|
|
680 read an event
|
|
681 @item
|
|
682 dispatch the event (i.e. ``do it'')
|
|
683 @item
|
|
684 redisplay
|
|
685 @end itemize
|
|
686
|
|
687 Reading an event is done using the Lisp function @code{next-event},
|
|
688 which waits for something to happen (typically, the user presses a key
|
|
689 or moves the mouse) and returns an event object describing this.
|
|
690 Dispatching an event is done using the Lisp function
|
|
691 @code{dispatch-event}, which looks up the event in a keymap object (a
|
|
692 particular kind of object that associates an event with a Lisp function)
|
|
693 and calls that function. The function ``does'' what the user has
|
|
694 requested by changing the state of particular frame objects, buffer
|
|
695 objects, etc. Finally, @code{redisplay()} is called, which updates the
|
|
696 display to reflect those changes just made. Thus is an ``editor'' born.
|
|
697
|
|
698 @cindex bridge, playing
|
|
699 @cindex taxes, doing
|
|
700 @cindex pi, calculating
|
|
701 Note that you do not have to use XEmacs as an editor; you could just
|
|
702 as well make it do your taxes, compute pi, play bridge, etc. You'd just
|
|
703 have to write functions to do those operations in Lisp.
|
|
704
|
|
705 @node The Lisp Language, XEmacs From the Perspective of Building, XEmacs From the Outside, Top
|
|
706 @chapter The Lisp Language
|
|
707 @cindex Lisp vs. C
|
|
708 @cindex C vs. Lisp
|
|
709 @cindex Lisp vs. Java
|
|
710 @cindex Java vs. Lisp
|
|
711 @cindex dynamic scoping
|
|
712 @cindex scoping, dynamic
|
|
713 @cindex dynamic types
|
|
714 @cindex types, dynamic
|
|
715 @cindex Java
|
|
716 @cindex Common Lisp
|
|
717 @cindex Gosling, James
|
|
718
|
|
719 Lisp is a general-purpose language that is higher-level than C and in
|
|
720 many ways more powerful than C. Powerful dialects of Lisp such as
|
|
721 Common Lisp are probably much better languages for writing very large
|
|
722 applications than is C. (Unfortunately, for many non-technical
|
|
723 reasons C and its successor C++ have become the dominant languages for
|
|
724 application development. These languages are both inadequate for
|
|
725 extremely large applications, which is evidenced by the fact that newer,
|
|
726 larger programs are becoming ever harder to write and are requiring ever
|
|
727 more programmers despite great increases in C development environments;
|
|
728 and by the fact that, although hardware speeds and reliability have been
|
|
729 growing at an exponential rate, most software is still generally
|
|
730 considered to be slow and buggy.)
|
|
731
|
|
732 The new Java language holds promise as a better general-purpose
|
|
733 development language than C. Java has many features in common with
|
|
734 Lisp that are not shared by C (this is not a coincidence, since
|
|
735 Java was designed by James Gosling, a former Lisp hacker). This
|
|
736 will be discussed more later.
|
|
737
|
|
738 For those used to C, here is a summary of the basic differences between
|
|
739 C and Lisp:
|
|
740
|
|
741 @enumerate
|
|
742 @item
|
|
743 Lisp has an extremely regular syntax. Every function, expression,
|
|
744 and control statement is written in the form
|
|
745
|
|
746 @example
|
|
747 (@var{func} @var{arg1} @var{arg2} ...)
|
|
748 @end example
|
|
749
|
|
750 This is as opposed to C, which writes functions as
|
|
751
|
|
752 @example
|
|
753 func(@var{arg1}, @var{arg2}, ...)
|
|
754 @end example
|
|
755
|
|
756 but writes expressions involving operators as (e.g.)
|
|
757
|
|
758 @example
|
|
759 @var{arg1} + @var{arg2}
|
|
760 @end example
|
|
761
|
|
762 and writes control statements as (e.g.)
|
|
763
|
|
764 @example
|
|
765 while (@var{expr}) @{ @var{statement1}; @var{statement2}; ... @}
|
|
766 @end example
|
|
767
|
|
768 Lisp equivalents of the latter two would be
|
|
769
|
|
770 @example
|
|
771 (+ @var{arg1} @var{arg2} ...)
|
|
772 @end example
|
|
773
|
|
774 and
|
|
775
|
|
776 @example
|
|
777 (while @var{expr} @var{statement1} @var{statement2} ...)
|
|
778 @end example
|
|
779
|
|
780 @item
|
|
781 Lisp is a safe language. Assuming there are no bugs in the Lisp
|
|
782 interpreter/compiler, it is impossible to write a program that ``core
|
|
783 dumps'' or otherwise causes the machine to execute an illegal
|
|
784 instruction. This is very different from C, where perhaps the most
|
|
785 common outcome of a bug is exactly such a crash. A corollary of this is that
|
|
786 the C operation of casting a pointer is impossible (and unnecessary) in
|
|
787 Lisp, and that it is impossible to access memory outside the bounds of
|
|
788 an array.
|
|
789
|
|
790 @item
|
|
791 Programs and data are written in the same form. The
|
|
792 parenthesis-enclosing form described above for statements is the same
|
|
793 form used for the most common data type in Lisp, the list. Thus, it is
|
|
794 possible to represent any Lisp program using Lisp data types, and for
|
|
795 one program to construct Lisp statements and then dynamically
|
|
796 @dfn{evaluate} them, or cause them to execute.
|
|
797
|
|
798 @item
|
|
799 All objects are @dfn{dynamically typed}. This means that part of every
|
|
800 object is an indication of what type it is. A Lisp program can
|
|
801 manipulate an object without knowing what type it is, and can query an
|
|
802 object to determine its type. This means that, correspondingly,
|
|
803 variables and function parameters can hold objects of any type and are
|
|
804 not normally declared as being of any particular type. This is opposed
|
|
805 to the @dfn{static typing} of C, where variables can hold exactly one
|
|
806 type of object and must be declared as such, and objects do not contain
|
|
807 an indication of their type because it's implicit in the variables they
|
|
808 are stored in. It is possible in C to have a variable hold different
|
|
809 types of objects (e.g. through the use of @code{void *} pointers or
|
|
810 variable-argument functions), but the type information must then be
|
|
811 passed explicitly in some other fashion, leading to additional program
|
|
812 complexity.
|
|
813
|
|
814 @item
|
|
815 Allocated memory is automatically reclaimed when it is no longer in use.
|
|
816 This operation is called @dfn{garbage collection} and involves looking
|
|
817 through all variables to see what memory is being pointed to, and
|
|
818 reclaiming any memory that is not pointed to and is thus
|
|
819 ``inaccessible'' and out of use. This is as opposed to C, in which
|
|
820 allocated memory must be explicitly reclaimed using @code{free()}. If
|
|
821 you simply drop all pointers to memory without freeing it, it becomes
|
|
822 ``leaked'' memory that still takes up space. Over a long period of
|
|
823 time, this can cause your program to grow and grow until it runs out of
|
|
824 memory.
|
|
825
|
|
826 @item
|
|
827 Lisp has built-in facilities for handling errors and exceptions. In C,
|
|
828 when an error occurs, usually either the program exits entirely or the
|
|
829 routine in which the error occurs returns a value indicating this. If
|
|
830 an error occurs in a deeply-nested routine, then every routine currently
|
|
831 called must unwind itself normally and return an error value back up to
|
|
832 the next routine. This means that every routine must explicitly check
|
|
833 for an error in all the routines it calls; if it does not do so,
|
|
834 unexpected and often random behavior results. This is an extremely
|
|
835 common source of bugs in C programs. An alternative would be to do a
|
|
836 non-local exit using @code{longjmp()}, but that is often very dangerous
|
|
837 because the routines that were exited past had no opportunity to clean
|
|
838 up after themselves and may leave things in an inconsistent state,
|
|
839 causing a crash shortly afterwards.
|
|
840
|
|
841 Lisp provides mechanisms to make such non-local exits safe. When an
|
|
842 error occurs, a routine simply signals that an error of a particular
|
|
843 class has occurred, and a non-local exit takes place. Any routine can
|
|
844 trap errors occurring in routines it calls by registering an error
|
|
845 handler for some or all classes of errors. (If no handler is registered,
|
|
846 a default handler, generally installed by the top-level event loop, is
|
|
847 executed; this prints out the error and continues.) Routines can also
|
|
848 specify cleanup code (called an @dfn{unwind-protect}) that will be
|
|
849 called when control exits from a block of code, no matter how that exit
|
|
850 occurs -- i.e. even if a function deeply nested below it causes a
|
|
851 non-local exit back to the top level.
|
|
852
|
|
853 Note that this facility has appeared in some recent vintages of C, in
|
|
854 particular Visual C++ and other PC compilers written for the Microsoft
|
|
855 Win32 API.
|
|
856
|
|
857 @item
|
|
858 In Emacs Lisp, local variables are @dfn{dynamically scoped}. This means
|
|
859 that if you declare a local variable in a particular function, and then
|
|
860 call another function, that subfunction can ``see'' the local variable
|
|
861 you declared. This is actually considered a bug in Emacs Lisp and in
|
|
862 all other early dialects of Lisp, and was corrected in Common Lisp. (In
|
|
863 Common Lisp, you can still declare dynamically scoped variables if you
|
|
864 want to -- they are sometimes useful -- but variables by default are
|
|
865 @dfn{lexically scoped} as in C.)
|
|
866 @end enumerate
|
|
867
|
|
868 For those familiar with Lisp, Emacs Lisp is modelled after MacLisp, an
|
|
869 early dialect of Lisp developed at MIT (no relation to the Macintosh
|
|
870 computer). There is a Common Lisp compatibility package available for
|
|
871 Emacs that provides many of the features of Common Lisp.
|
|
872
|
|
873 The Java language is derived in many ways from C, and shares a similar
|
|
874 syntax, but has the following features in common with Lisp (and different
|
|
875 from C):
|
|
876
|
|
877 @enumerate
|
|
878 @item
|
|
879 Java is a safe language, like Lisp.
|
|
880 @item
|
|
881 Java provides garbage collection, like Lisp.
|
|
882 @item
|
|
883 Java has built-in facilities for handling errors and exceptions, like
|
|
884 Lisp.
|
|
885 @item
|
|
886 Java has a type system that combines the best advantages of both static
|
|
887 and dynamic typing. Objects (except very simple types) are explicitly
|
|
888 marked with their type, as in dynamic typing; but there is a hierarchy
|
|
889 of types and functions are declared to accept only certain types, thus
|
|
890 providing the increased compile-time error-checking of static typing.
|
|
891 @end enumerate
|
|
892
|
|
893 @node XEmacs From the Perspective of Building, XEmacs From the Inside, The Lisp Language, Top
|
|
894 @chapter XEmacs From the Perspective of Building
|
|
895
|
|
896 The heart of XEmacs is the Lisp environment, which is written in C.
|
|
897 This is contained in the @file{src/} subdirectory. Underneath
|
|
898 @file{src/} are two subdirectories of header files: @file{s/} (header
|
|
899 files for particular operating systems) and @file{m/} (header files for
|
|
900 particular machine types). In practice the distinction between the two
|
|
901 types of header files is blurred. These header files define or undefine
|
|
902 certain preprocessor constants and macros to indicate particular
|
|
903 characteristics of the associated machine or operating system. As part
|
|
904 of the configure process, one @file{s/} file and one @file{m/} file is
|
|
905 identified for the particular environment in which XEmacs is being
|
|
906 built.
|
|
907
|
|
908 XEmacs also contains a great deal of Lisp code. This implements the
|
|
909 operations that make XEmacs useful as an editor as well as just a
|
|
910 Lisp environment, and also contains many add-on packages that allow
|
|
911 XEmacs to browse directories, act as a mail and Usenet news reader,
|
44
|
912 compile Lisp code, etc. There is actually more Lisp code than
|
0
|
913 C code associated with XEmacs, but much of the Lisp code is
|
|
914 peripheral to the actual operation of the editor. The Lisp code
|
|
915 all lies in subdirectories underneath the @file{lisp/} directory.
|
|
916
|
|
917 The @file{lwlib/} directory contains C code that implements a
|
|
918 generalized interface onto different X widget toolkits and also
|
|
919 implements some widgets of its own that behave like Motif widgets but
|
|
920 are faster, free, and in some cases more powerful. The code in this
|
|
921 directory compiles into a library and is mostly independent from XEmacs.
|
|
922
|
|
923 The @file{etc/} directory contains various data files associated with
|
|
924 XEmacs. Some of them are actually read by XEmacs at startup; others
|
|
925 merely contain useful information of various sorts.
|
|
926
|
|
927 The @file{lib-src/} directory contains C code for various auxiliary
|
|
928 programs that are used in connection with XEmacs. Some of them are used
|
|
929 during the build process; others are used to perform certain functions
|
|
930 that cannot conveniently be placed in the XEmacs executable (e.g. the
|
44
|
931 @file{movemail} program for fetching mail out of @file{/var/spool/mail},
|
|
932 which must be setgid to @file{mail} on many systems; and the
|
|
933 @file{gnuclient} program, which allows an external script to communicate
|
|
934 with a running XEmacs process).
|
0
|
935
|
|
936 The @file{man/} directory contains the sources for the XEmacs
|
|
937 documentation. It is mostly in a form called Texinfo, which can be
|
44
|
938 converted into either a printed document (by passing it through @TeX{})
|
|
939 or into on-line documentation called @dfn{info files}.
|
0
|
940
|
|
941 The @file{info/} directory contains the results of formatting the
|
|
942 XEmacs documentation as @dfn{info files}, for on-line use. These files
|
|
943 are used when you enter the Info system using @kbd{C-h i} or through the
|
|
944 Help menu.
|
|
945
|
|
946 The @file{dynodump/} directory contains auxiliary code used to build
|
|
947 XEmacs on Solaris platforms.
|
|
948
|
|
949 The other directories contain various miscellaneous code and
|
|
950 information that is not normally used or needed.
|
|
951
|
|
952 The first step of building involves running the @file{configure}
|
|
953 program and passing it various parameters to specify any optional
|
|
954 features you want and compiler arguments and such, as described in the
|
|
955 @file{INSTALL} file. This determines what the build environment is,
|
|
956 chooses the appropriate @file{s/} and @file{m/} file, and runs a series
|
|
957 of tests to determine many details about your environment, such as which
|
|
958 library functions are available and exactly how they work. (The
|
|
959 @file{s/} and @file{m/} files only contain information that cannot be
|
|
960 conveniently detected in this fashion.) The reason for running these
|
|
961 tests is that it allows XEmacs to be compiled on a much wider variety of
|
|
962 platforms than those that the XEmacs developers happen to be familiar
|
|
963 with, including various sorts of hybrid platforms. This is especially
|
|
964 important now that many operating systems give you a great deal of
|
|
965 control over exactly what features you want installed, and allow for
|
|
966 easy upgrading of parts of a system without upgrading the rest. It
|
|
967 would be impossible to pre-determine and pre-specify the information for
|
|
968 all possible configurations.
|
|
969
|
|
970 When configure is done running, it generates @file{Makefile}s and the
|
|
971 file @file{config.h} (which describes the features of your system) from
|
|
972 template files. You then run @file{make}, which compiles the auxiliary
|
|
973 code and programs in @file{lib-src/} and @file{lwlib/} and the main
|
|
974 XEmacs executable in @file{src/}. The result of this is an executable
|
|
975 called @file{temacs}, which is @emph{not} the XEmacs executable.
|
|
976 @file{temacs} by itself cannot function as an editor or even display any
|
|
977 windows on the screen, and if you simply run it, it will exit
|
|
978 immediately. The Makefile runs @file{temacs} with certain options that
|
|
979 cause it to initialize itself, read in a number of basic Lisp files, and
|
|
980 then dump itself out into a new executable called @file{xemacs}. This
|
|
981 new executable has been pre-initialized and contains pre-digested Lisp
|
44
|
982 code that is necessary for the editor to function (this includes most
|
|
983 basic Lisp functions, e.g. @code{not}, that can be defined in terms of
|
|
984 other Lisp primitives; some initialization code that is called when
|
|
985 certain objects, such as frames, are created; and all of the standard
|
|
986 keybindings and code for the actions they result in). This executable,
|
|
987 @file{xemacs}, is the executable that you run to use the XEmacs editor.
|
0
|
988
|
|
989 @node XEmacs From the Inside, The XEmacs Object System (Abstractly Speaking), XEmacs From the Perspective of Building, Top
|
|
990 @chapter XEmacs From the Inside
|
|
991
|
|
992 Internally, XEmacs is quite complex, and can be very confusing. To
|
|
993 simplify things, it can be useful to think of XEmacs as containing an
|
|
994 event loop that ``drives'' everything, and a number of other subsystems,
|
44
|
995 such as a Lisp engine and a redisplay mechanism. Each of these other
|
0
|
996 subsystems exists simultaneously in XEmacs, and each has a certain
|
|
997 state. The flow of control continually passes in and out of these
|
|
998 different subsystems in the course of normal operation of the editor.
|
|
999
|
|
1000 It is important to keep in mind that, most of the time, the editor is
|
|
1001 ``driven'' by the event loop. Except during initialization and batch
|
|
1002 mode, all subsystems are entered directly or indirectly through the
|
|
1003 event loop, and ultimately, control exits out of all subsystems back up
|
|
1004 to the event loop. This cycle of entering a subsystem, exiting back out
|
|
1005 to the event loop, and starting another iteration of the event loop
|
|
1006 occurs once each keystroke, mouse motion, etc.
|
|
1007
|
|
1008 If you're trying to understand a particular subsystem (other than the
|
|
1009 event loop), think of it as a ``daemon'' process or ``servant'' that is
|
|
1010 responsible for one particular aspect of a larger system, and
|
|
1011 periodically receives commands or environment changes that cause it to
|
|
1012 do something. Ultimately, these commands and environment changes are
|
|
1013 always triggered by the event loop. For example:
|
|
1014
|
|
1015 @itemize @bullet
|
|
1016 @item
|
|
1017 The window and frame mechanism is responsible for keeping track of what
|
|
1018 windows and frames exist, what buffers are in them, etc. It is
|
|
1019 periodically given commands (usually from the user) to make a change to
|
|
1020 the current window/frame state: i.e. create a new frame, delete a
|
|
1021 window, etc.
|
|
1022
|
|
1023 @item
|
|
1024 The buffer mechanism is responsible for keeping track of what buffers
|
|
1025 exist and what text is in them. It is periodically given commands
|
|
1026 (usually from the user) to insert or delete text, create a buffer, etc.
|
44
|
1027 When it receives a text-change command, it notifies the redisplay
|
|
1028 mechanism.
|
0
|
1029
|
|
1030 @item
|
|
1031 The redisplay mechanism is responsible for making sure that windows and
|
|
1032 frames are displayed correctly. It is periodically told (by the event
|
|
1033 loop) to actually ``do its job'', i.e. snoop around and see what the
|
|
1034 current state of the environment (mostly of the currently-existing
|
|
1035 windows, frames, and buffers) is, and make sure that that state matches
|
|
1036 what's actually displayed. It keeps lots and lots of information around
|
|
1037 (such as what is actually being displayed currently, and what the
|
|
1038 environment was last time it checked) so that it can minimize the work
|
|
1039 it has to do. It is also helped along in that whenever a relevant
|
|
1040 change to the environment occurs, the redisplay mechanism is told about
|
|
1041 this, so it has a pretty good idea of where it has to look to find
|
|
1042 possible changes and doesn't have to look everywhere.
|
|
1043
|
|
1044 @item
|
|
1045 The Lisp engine is responsible for executing the Lisp code in which most
|
|
1046 user commands are written. It is entered through a call to @code{eval}
|
|
1047 or @code{funcall}, which occurs as a result of dispatching an event from
|
|
1048 the event loop. The functions it calls issue commands to the buffer
|
|
1049 mechanism, the window/frame subsystem, etc.
|
|
1050
|
|
1051 @item
|
|
1052 The Lisp allocation subsystem is responsible for keeping track of Lisp
|
|
1053 objects. It is given commands from the Lisp engine to allocate objects,
|
|
1054 garbage collect, etc.
|
|
1055 @end itemize
|
|
1056
|
|
1057 etc.
|
|
1058
|
|
1059 The important idea here is that there are a number of independent
|
2
|
1060 subsystems each with its own responsibility and persistent state, just
|
0
|
1061 like different employees in a company, and each subsystem is
|
|
1062 periodically given commands from other subsystems. Commands can flow
|
|
1063 from any one subsystem to any other, but there is usually some sort of
|
|
1064 hierarchy, with all commands originating from the event subsystem.
|
|
1065
|
|
1066 XEmacs is entered in @code{main()}, which is in @file{emacs.c}. When
|
|
1067 this is called the first time (in a properly-invoked @file{temacs}), it
|
|
1068 does the following:
|
|
1069
|
|
1070 @enumerate
|
|
1071 @item
|
|
1072 It does some very basic environment initializations, such as determining
|
|
1073 where it and its directories (e.g. @file{lisp/} and @file{etc/}) reside
|
|
1074 and setting up signal handlers.
|
|
1075 @item
|
|
1076 It initializes the entire Lisp interpreter.
|
|
1077 @item
|
|
1078 It sets the initial values of many built-in variables (including many
|
|
1079 variables that are visible to Lisp programs), such as the global keymap
|
|
1080 object and the built-in faces (a face is an object that describes the
|
|
1081 display characteristics of text). This involves creating Lisp objects
|
|
1082 and thus is dependent on step (2).
|
|
1083 @item
|
|
1084 It performs various other initializations that are relevant to the
|
|
1085 particular environment it is running in, such as retrieving environment
|
|
1086 variables, determining the current date and the user who is running the
|
|
1087 program, examining its standard input, creating any necessary file
|
|
1088 descriptors, etc.
|
|
1089 @item
|
|
1090 At this point, the C initialization is complete. A Lisp program that
|
|
1091 was specified on the command line (usually @file{loadup.el}) is called
|
|
1092 (temacs is normally invoked as @code{temacs -batch -l loadup.el dump}).
|
|
1093 @file{loadup.el} loads all of the other Lisp files that are needed for
|
|
1094 the operation of the editor, calls the @code{dump-emacs} function to
|
|
1095 write out @file{xemacs}, and then kills the temacs process.
|
|
1096 @end enumerate
|
|
1097
|
|
1098 When @file{xemacs} is then run, it only redoes steps (1) and (4)
|
|
1099 above; all variables already contain the values they were set to when
|
|
1100 the executable was dumped, and all memory that was allocated with
|
|
1101 @code{malloc()} is still around. (XEmacs knows whether it is being run
|
|
1102 as @file{xemacs} or @file{temacs} because it sets the global variable
|
|
1103 @code{initialized} to 1 after step (4) above.) At this point,
|
|
1104 @file{xemacs} calls a Lisp function to do any further initialization,
|
|
1105 which includes parsing the command-line (the C code can only do limited
|
|
1106 command-line parsing, which includes looking for the @samp{-batch} and
|
|
1107 @samp{-l} flags and a few other flags that it needs to know about before
|
|
1108 initialization is complete), creating the first frame (or @dfn{window}
|
|
1109 in standard window-system parlance), running the user's init file
|
|
1110 (usually the file @file{.emacs} in the user's home directory), etc. The
|
|
1111 function to do this is usually called @code{normal-top-level};
|
|
1112 @file{loadup.el} tells the C code about this function by setting its
|
|
1113 name as the value of the Lisp variable @code{top-level}.
|
|
1114
|
|
1115 When the Lisp initialization code is done, the C code enters the event
|
|
1116 loop, and stays there for the duration of the XEmacs process. The code
|
|
1117 for the event loop is contained in @file{keyboard.c}, and is called
|
|
1118 @code{Fcommand_loop_1()}. Note that this event loop could very well be
|
|
1119 written in Lisp, and in fact a Lisp version exists; but apparently,
|
|
1120 doing this makes XEmacs run noticeably slower.
|
|
1121
|
|
1122 Notice how much of the initialization is done in Lisp, not in C.
|
|
1123 In general, XEmacs tries to move as much code as is possible
|
|
1124 into Lisp. Code that remains in C is code that implements the
|
|
1125 Lisp interpreter itself, or code that needs to be very fast, or
|
|
1126 code that needs to do system calls or other such stuff that
|
|
1127 needs to be done in C, or code that needs to have access to
|
|
1128 ``forbidden'' structures. (One conscious aspect of the design of
|
|
1129 Lisp under XEmacs is a clean separation between the external
|
|
1130 interface to a Lisp object's functionality and its internal
|
|
1131 implementation. Part of this design is that Lisp programs
|
|
1132 are forbidden from accessing the contents of the object other
|
|
1133 than through using a standard API. In this respect, XEmacs Lisp
|
|
1134 is similar to modern Lisp dialects but differs from GNU Emacs,
|
|
1135 which tends to expose the implementation and allow Lisp
|
|
1136 programs to look at it directly. The major advantage of
|
|
1137 hiding the implementation is that it allows the implementation
|
|
1138 to be redesigned without affecting any Lisp programs, including
|
|
1139 those that might want to be ``clever'' by looking directly at
|
|
1140 the object's contents and possibly manipulating them.)
|
|
1141
|
|
1142 Moving code into Lisp makes the code easier to debug and maintain and
|
|
1143 makes it much easier for people who are not XEmacs developers to
|
|
1144 customize XEmacs, because they can make a change with much less chance
|
|
1145 of obscure and unwanted interactions occurring than if they were to
|
|
1146 change the C code.
|
|
1147
|
|
1148 @node The XEmacs Object System (Abstractly Speaking), How Lisp Objects Are Represented in C, XEmacs From the Inside, Top
|
|
1149 @chapter The XEmacs Object System (Abstractly Speaking)
|
|
1150
|
|
1151 At the heart of the Lisp interpreter is its management of objects.
|
|
1152 XEmacs Lisp contains many built-in objects, some of which are
|
|
1153 simple and others of which can be very complex; and some of which
|
|
1154 are very common, and others of which are rarely used or are only
|
|
1155 used internally. (Since the Lisp allocation system, with its
|
|
1156 automatic reclamation of unused storage, is so much more convenient
|
|
1157 than @code{malloc()} and @code{free()}, the C code makes extensive use of it
|
|
1158 in its internal operations.)
|
|
1159
|
|
1160 The basic Lisp objects are
|
|
1161
|
|
1162 @table @code
|
|
1163 @item integer
|
|
1164 28 bits of precision, or 60 bits on 64-bit machines; the reason for this
|
|
1165 is described below when the internal Lisp object representation is
|
|
1166 described.
|
|
1167 @item float
|
|
1168 Same precision as a double in C.
|
|
1169 @item cons
|
|
1170 A simple container for two Lisp objects, used to implement lists and
|
|
1171 most other data structures in Lisp.
|
|
1172 @item char
|
|
1173 An object representing a single character of text; chars behave like
|
|
1174 integers in many ways but are logically considered text rather than
|
|
1175 numbers and have a different read syntax. (the read syntax for a char
|
|
1176 contains the char itself or some textual encoding of it -- for example,
|
|
1177 a Japanese Kanji character might be encoded as @samp{^[$(B#&^[(B} using the
|
|
1178 ISO-2022 encoding standard -- rather than the numerical representation
|
|
1179 of the char; this way, if the mapping between chars and integers
|
|
1180 changes, which is quite possible for Kanji characters and other extended
|
|
1181 characters, the same character will still be created. Note that some
|
|
1182 primitives confuse chars and integers. The worst culprit is @code{eq},
|
|
1183 which makes a special exception and considers a char to be @code{eq} to
|
|
1184 its integer equivalent, even though in no other case are objects of two
|
|
1185 different types @code{eq}. The reason for this monstrosity is
|
|
1186 compatibility with existing code; the separation of char from integer
|
|
1187 came fairly recently.)
|
|
1188 @item symbol
|
|
1189 An object that contains Lisp objects and is referred to by name;
|
|
1190 symbols are used to implement variables and named functions
|
|
1191 and to provide the equivalent of preprocessor constants in C.
|
|
1192 @item vector
|
|
1193 A one-dimensional array of Lisp objects providing constant-time access
|
|
1194 to any of the objects; access to an arbitrary object in a vector is
|
|
1195 faster than for lists, but the operations that can be done on a vector
|
|
1196 are more limited.
|
|
1197 @item string
|
|
1198 Self-explanatory; behaves much like a vector of chars
|
|
1199 but has a different read syntax and is stored and manipulated
|
|
1200 more compactly and efficiently.
|
|
1201 @item bit-vector
|
|
1202 A vector of bits; similar to a string in spirit.
|
|
1203 @item compiled-function
|
|
1204 An object describing compiled Lisp code, known as @dfn{byte code}.
|
|
1205 @item subr
|
|
1206 An object describing a Lisp primitive.
|
|
1207 @end table
|
|
1208
|
|
1209 @cindex closure
|
|
1210 Note that there is no basic ``function'' type, as in more powerful
|
|
1211 versions of Lisp (where it's called a @dfn{closure}). XEmacs Lisp does
|
|
1212 not provide the closure semantics implemented by Common Lisp and Scheme.
|
|
1213 The guts of a function in XEmacs Lisp are represented in one of four
|
|
1214 ways: a symbol specifying another function (when one function is an
|
|
1215 alias for another), a list containing the function's source code, a
|
|
1216 bytecode object, or a subr object. (In other words, given a symbol
|
|
1217 specifying the name of a function, calling @code{symbol-function} to
|
|
1218 retrieve the contents of the symbol's function cell will return one of
|
|
1219 these types of objects.)
|
|
1220
|
|
1221 XEmacs Lisp also contains numerous specialized objects used to
|
|
1222 implement the editor:
|
|
1223
|
44
|
1224 @table @code
|
0
|
1225 @item buffer
|
|
1226 Stores text like a string, but is optimized for insertion and deletion
|
|
1227 and has certain other properties that can be set.
|
|
1228 @item frame
|
|
1229 An object with various properties whose displayable representation is a
|
|
1230 @dfn{window} in window-system parlance.
|
|
1231 @item window
|
|
1232 A section of a frame that displays the contents of a buffer;
|
|
1233 often called a @dfn{pane} in window-system parlance.
|
|
1234 @item window-configuration
|
|
1235 An object that represents a saved configuration of windows in a frame.
|
|
1236 @item device
|
|
1237 An object representing a screen on which frames can be displayed;
|
|
1238 equivalent to a @dfn{display} in the X Window System and a @dfn{TTY} in
|
|
1239 character mode.
|
|
1240 @item face
|
|
1241 An object specifying the appearance of text or graphics; it contains
|
|
1242 characteristics such as font, foreground color, and background color.
|
|
1243 @item marker
|
|
1244 An object that refers to a particular position in a buffer and moves
|
|
1245 around as text is inserted and deleted to stay in the same relative
|
|
1246 position to the text around it.
|
|
1247 @item extent
|
|
1248 Similar to a marker but covers a range of text in a buffer; can also
|
|
1249 specify properties of the text, such as a face in which the text is to
|
|
1250 be displayed, whether the text is invisible or unmodifiable, etc.
|
|
1251 @item event
|
|
1252 Generated by calling @code{next-event} and contains information
|
|
1253 describing a particular event happening in the system, such as the user
|
|
1254 pressing a key or a process terminating.
|
|
1255 @item keymap
|
|
1256 An object that maps from events (described using lists, vectors, and
|
|
1257 symbols rather than with an event object because the mapping is for
|
|
1258 classes of events, rather than individual events) to functions to
|
|
1259 execute or other events to recursively look up; the functions are
|
|
1260 described by name, using a symbol, or using lists to specify the
|
|
1261 function's code.
|
|
1262 @item glyph
|
|
1263 An object that describes the appearance of an image (e.g. pixmap) on
|
|
1264 the screen; glyphs can be attached to the beginning or end of extents
|
|
1265 and in some future version of XEmacs will be able to be inserted
|
|
1266 directly into a buffer.
|
|
1267 @item process
|
|
1268 An object that describes a connection to an externally-running process.
|
|
1269 @end table
|
|
1270
|
|
1271 There are some other, less-commonly-encountered general objects:
|
|
1272
|
44
|
1273 @table @code
|
0
|
1274 @item hashtable
|
|
1275 An object that maps from an arbitrary Lisp object to another arbitrary
|
|
1276 Lisp object, using hashing for fast lookup.
|
|
1277 @item obarray
|
|
1278 A limited form of hashtable that maps from strings to symbols; obarrays
|
|
1279 are used to look up a symbol given its name and are not actually their
|
|
1280 own object type but are kludgily represented using vectors with hidden
|
|
1281 fields (this representation derives from GNU Emacs).
|
|
1282 @item specifier
|
|
1283 A complex object used to specify the value of a display property; a
|
|
1284 default value is given and different values can be specified for
|
|
1285 particular frames, buffers, windows, devices, or classes of device.
|
|
1286 @item char-table
|
|
1287 An object that maps from chars or classes of chars to arbitrary Lisp
|
|
1288 objects; internally char tables use a complex nested-vector
|
|
1289 representation that is optimized to the way characters are represented
|
|
1290 as integers.
|
|
1291 @item range-table
|
|
1292 An object that maps from ranges of integers to arbitrary Lisp objects.
|
|
1293 @end table
|
|
1294
|
|
1295 And some strange special-purpose objects:
|
|
1296
|
44
|
1297 @table @code
|
0
|
1298 @item charset
|
|
1299 @itemx coding-system
|
|
1300 Objects used when MULE, or multi-lingual/Asian-language, support is
|
|
1301 enabled.
|
|
1302 @item color-instance
|
|
1303 @itemx font-instance
|
|
1304 @itemx image-instance
|
|
1305 An object that encapsulates a window-system resource; instances are
|
|
1306 mostly used internally but are exposed on the Lisp level for cleanness
|
|
1307 of the specifier model and because it's occasionally useful for Lisp
|
|
1308 program to create or query the properties of instances.
|
|
1309 @item subwindow
|
|
1310 An object that encapsulate a @dfn{subwindow} resource, i.e. a
|
|
1311 window-system child window that is drawn into by an external process;
|
|
1312 this object should be integrated into the glyph system but isn't yet,
|
|
1313 and may change form when this is done.
|
|
1314 @item tooltalk-message
|
|
1315 @itemx tooltalk-pattern
|
|
1316 Objects that represent resources used in the ToolTalk interprocess
|
|
1317 communication protocol.
|
|
1318 @item toolbar-button
|
|
1319 An object used in conjunction with the toolbar.
|
|
1320 @item x-resource
|
|
1321 An object that encapsulates certain miscellaneous resources in the X
|
|
1322 window system, used only when Epoch support is enabled.
|
|
1323 @end table
|
|
1324
|
|
1325 And objects that are only used internally:
|
|
1326
|
|
1327 @table @asis
|
|
1328 @item opaque
|
|
1329 A generic object for encapsulating arbitrary memory; this allows you the
|
|
1330 generality of @code{malloc()} and the convenience of the Lisp object
|
|
1331 system.
|
|
1332 @item lstream
|
|
1333 A buffering I/O stream, used to provide a unified interface to anything
|
|
1334 that can accept output or provide input, such as a file descriptor, a
|
|
1335 stdio stream, a chunk of memory, a Lisp buffer, a Lisp string, etc.;
|
|
1336 it's a Lisp object to make its memory management more convenient.
|
|
1337 @item char-table-entry
|
|
1338 Subsidiary objects in the internal char-table representation.
|
|
1339 @item extent-auxiliary
|
|
1340 @itemx menubar-data
|
|
1341 @itemx toolbar-data
|
|
1342 Various special-purpose objects that are basically just used to
|
|
1343 encapsulate memory for particular subsystems, similar to the more
|
|
1344 general ``opaque'' object.
|
|
1345 @item symbol-value-forward
|
|
1346 @itemx symbol-value-buffer-local
|
|
1347 @itemx symbol-value-varalias
|
|
1348 @itemx symbol-value-lisp-magic
|
|
1349 Special internal-only objects that are placed in the value cell of a
|
|
1350 symbol to indicate that there is something special with this variable --
|
|
1351 e.g. it has no value, it mirrors another variable, or it mirrors some C
|
|
1352 variable; there is really only one kind of object, called a
|
|
1353 @dfn{symbol-value-magic}, but it is sort-of halfway kludged into
|
|
1354 semi-different object types.
|
|
1355 @end table
|
|
1356
|
|
1357 @cindex permanent objects
|
|
1358 @cindex temporary objects
|
|
1359 Some types of objects are @dfn{permanent}, meaning that once created,
|
|
1360 they do not disappear until explicitly destroyed, using a function such
|
|
1361 as @code{delete-buffer}, @code{delete-window}, @code{delete-frame}, etc.
|
|
1362 Others will disappear once they are not longer used, through the garbage
|
|
1363 collection mechanism. Buffers, frames, windows, devices, and processes
|
|
1364 are among the objects that are permanent. Note that some objects can go
|
|
1365 both ways: Faces can be created either way; extents are normally
|
|
1366 permanent, but detached extents (extents not referring to any text, as
|
|
1367 happens to some extents when the text they are referring to is deleted)
|
|
1368 are temporary. Note that some permanent objects, such as faces and
|
|
1369 coding systems, cannot be deleted. Note also that windows are unique in
|
|
1370 that they can be @emph{undeleted} after having previously been
|
|
1371 deleted. (This happens as a result of restoring a window configuration.)
|
|
1372
|
|
1373 @cindex read syntax
|
|
1374 Note that many types of objects have a @dfn{read syntax}, i.e. a way of
|
|
1375 specifying an object of that type in Lisp code. When you load a Lisp
|
|
1376 file, or type in code to be evaluated, what really happens is that the
|
|
1377 function @code{read} is called, which reads some text and creates an object
|
|
1378 based on the syntax of that text; then @code{eval} is called, which
|
|
1379 possibly does something special; then this loop repeats until there's
|
|
1380 no more text to read. (@code{eval} only actually does something special
|
|
1381 with symbols, which causes the symbol's value to be returned,
|
|
1382 similar to referencing a variable; and with conses [i.e. lists],
|
|
1383 which cause a function invocation. All other values are returned
|
|
1384 unchanged.)
|
|
1385
|
|
1386 The read syntax
|
|
1387
|
|
1388 @example
|
|
1389 17297
|
|
1390 @end example
|
|
1391
|
|
1392 converts to an integer whose value is 17297.
|
|
1393
|
|
1394 @example
|
|
1395 1.983e-4
|
|
1396 @end example
|
|
1397
|
|
1398 converts to a float whose value is 1983.23e-4, or .0001983.
|
|
1399
|
|
1400 @example
|
|
1401 ?b
|
|
1402 @end example
|
|
1403
|
|
1404 converts to a char that represents the lowercase letter b.
|
|
1405
|
|
1406 @example
|
|
1407 ?^[$(B#&^[(B
|
|
1408 @end example
|
|
1409
|
|
1410 (where @samp{^[} actually is an @samp{ESC} character) converts to a
|
44
|
1411 particular Kanji character when using an ISO2022-based coding system for
|
|
1412 input. (To decode this gook: @samp{ESC} begins an escape sequence;
|
|
1413 @samp{ESC $ (} is a class of escape sequences meaning ``switch to a
|
|
1414 94x94 character set''; @samp{ESC $ ( B} means ``switch to Japanese
|
|
1415 Kanji''; @samp{#} and @samp{&} collectively index into a 94-by-94 array
|
|
1416 of characters [subtract 33 from the ASCII value of each character to get
|
|
1417 the corresponding index]; @samp{ESC (} is a class of escape sequences
|
|
1418 meaning ``switch to a 94 character set''; @samp{ESC (B} means ``switch
|
|
1419 to US ASCII''. It is a coincidence that the letter @samp{B} is used to
|
|
1420 denote both Japanese Kanji and US ASCII. If the first @samp{B} were
|
|
1421 replaced with an @samp{A}, you'd be requesting a Chinese Hanzi character
|
|
1422 from the GB2312 character set.)
|
0
|
1423
|
|
1424 @example
|
|
1425 "foobar"
|
|
1426 @end example
|
|
1427
|
|
1428 converts to a string.
|
|
1429
|
|
1430 @example
|
|
1431 foobar
|
|
1432 @end example
|
|
1433
|
|
1434 converts to a symbol whose name is @code{"foobar"}. This is done by
|
|
1435 looking up the string equivalent in the global variable
|
|
1436 @code{obarray}, whose contents should be an obarray. If no symbol
|
|
1437 is found, a new symbol with the name @code{"foobar"} is automatically
|
|
1438 created and adding it to @code{obarray}; this process is called
|
|
1439 @dfn{interning} the symbol.
|
|
1440 @cindex interning
|
|
1441
|
|
1442 @example
|
|
1443 (foo . bar)
|
|
1444 @end example
|
|
1445
|
|
1446 converts to a cons cell containing the symbols @code{foo} and @code{bar}.
|
|
1447
|
|
1448 @example
|
|
1449 (1 a 2.5)
|
|
1450 @end example
|
|
1451
|
|
1452 converts to a three-element list containing the specified objects
|
|
1453 (note that a list is actually a set of nested conses; see the
|
|
1454 XEmacs Lisp Reference).
|
|
1455
|
|
1456 @example
|
|
1457 [1 a 2.5]
|
|
1458 @end example
|
|
1459
|
|
1460 converts to a three-element vector containing the specified objects.
|
|
1461
|
|
1462 @example
|
|
1463 #[... ... ... ...]
|
|
1464 @end example
|
|
1465
|
|
1466 converts to a compiled-function object (the actual contents are not
|
|
1467 shown since they are not relevant here; look at a file that ends with
|
|
1468 @file{.elc} for examples).
|
|
1469
|
|
1470 @example
|
|
1471 #*01110110
|
|
1472 @end example
|
|
1473
|
|
1474 converts to a bit-vector.
|
|
1475
|
|
1476 @example
|
|
1477 #s(range-table ... ...)
|
|
1478 @end example
|
|
1479
|
|
1480 converts to a range table (the actual contents are not shown).
|
|
1481
|
|
1482 @example
|
|
1483 #s(char-table ... ...)
|
|
1484 @end example
|
|
1485
|
|
1486 converts to a char table (the actual contents are not shown).
|
|
1487 (Note that the #s syntax is the general syntax for structures,
|
|
1488 which are not really implemented in XEmacs Lisp but should be.)
|
|
1489
|
|
1490 When an object is printed out (using @code{print} or a related
|
|
1491 function), the read syntax is used, so that the same object can be read
|
|
1492 in again.
|
|
1493
|
|
1494 The other objects do not have read syntaxes, usually because it does
|
|
1495 not really make sense to create them in this fashion (i.e. processes,
|
|
1496 where it doesn't make sense to have a subprocess created as a side
|
|
1497 effect of reading some Lisp code), or because they can't be created at
|
|
1498 all (e.g. subrs). Permanent objects, as a rule, do not have a read
|
|
1499 syntax; nor do most complex objects, which contain too much state to be
|
|
1500 easily initialized through a read syntax.
|
|
1501
|
|
1502 @node How Lisp Objects Are Represented in C, Rules When Writing New C Code, The XEmacs Object System (Abstractly Speaking), Top
|
|
1503 @chapter How Lisp Objects Are Represented in C
|
|
1504
|
|
1505 Lisp objects are represented in C using a 32- or 64-bit machine word
|
|
1506 (depending on the processor; i.e. DEC Alphas use 64-bit Lisp objects and
|
|
1507 most other processors use 32-bit Lisp objects). The representation
|
|
1508 stuffs a pointer together with a tag, as follows:
|
|
1509
|
|
1510 @example
|
|
1511 [ 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 ]
|
|
1512 [ 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 ]
|
|
1513
|
|
1514 ^ <---> <------------------------------------------------------>
|
|
1515 | tag a pointer to a structure, or an integer
|
|
1516 |
|
|
1517 `---> mark bit
|
|
1518 @end example
|
|
1519
|
|
1520 The tag describes the type of the Lisp object. For integers and
|
|
1521 chars, the lower 28 bits contain the value of the integer or char; for
|
|
1522 all others, the lower 28 bits contain a pointer. The mark bit is used
|
|
1523 during garbage-collection, and is always 0 when garbage collection is
|
|
1524 not happening. Many macros that extract out parts of a Lisp object
|
|
1525 expect that the mark bit is 0, and will produce incorrect results if
|
|
1526 it's not. (The way that garbage collection works, basically, is that it
|
|
1527 loops over all places where Lisp objects could exist -- this includes
|
|
1528 all global variables in C that contain Lisp objects [including
|
|
1529 @code{Vobarray}, the C equivalent of @code{obarray}; through this, all
|
|
1530 Lisp variables will get marked], plus various other places -- and
|
|
1531 recursively scans through the Lisp objects, marking each object it finds
|
|
1532 by setting the mark bit. Then it goes through the lists of all objects
|
|
1533 allocated, freeing the ones that are not marked and turning off the
|
|
1534 mark bit of the ones that are marked.)
|
|
1535
|
|
1536 Lisp objects use the typedef @code{Lisp_Object}, but the actual C type
|
|
1537 used for the Lisp object can vary. It can be either a simple type
|
|
1538 (@code{long} on the DEC Alpha, @code{int} on other machines) or a
|
|
1539 structure whose fields are bit fields that line up properly (actually,
|
|
1540 it's a union of structures that's used). Generally the simple integral
|
|
1541 type is preferable because it ensures that the compiler will actually
|
|
1542 use a machine word to represent the object (some compilers will use more
|
|
1543 general and less efficient code for unions and structs even if they can
|
|
1544 fit in a machine word). The union type, however, has the advantage of
|
|
1545 stricter type checking (if you accidentally pass an integer where a Lisp
|
|
1546 object is desired, you get a compile error), and it makes it easier to
|
|
1547 decode Lisp objects when debugging. The choice of which type to use is
|
|
1548 determined by the presence or absence of the preprocessor constant
|
|
1549 @code{NO_UNION_TYPE}. (Shouldn't it be @code{USE_UNION_TYPE}, with
|
|
1550 opposite semantics? ``Hysterical reasons'', of course.)
|
|
1551
|
|
1552 @cindex record type
|
|
1553 Note that there are only eight types that the tag can represent,
|
|
1554 but many more actual types than this. This is handled by having
|
44
|
1555 one of the tag types specify a meta-type called a @dfn{record};
|
0
|
1556 for all such objects, the first four bytes of the pointed-to
|
|
1557 structure indicate what the actual type is.
|
|
1558
|
|
1559 Note also that having 28 bits for pointers and integers restricts a
|
|
1560 lot of things to 256 megabytes of memory. (Basically, enough pointers
|
|
1561 and indices and whatnot get stuffed into Lisp objects that the total
|
|
1562 amount of memory used by XEmacs can't grow above 256 megabytes. In
|
|
1563 older versions of XEmacs and GNU Emacs, the tag was 5 bits wide,
|
|
1564 allowing for 32 types, which was more than the actual number of types
|
|
1565 that existed at the time, and no ``record'' type was necessary.
|
|
1566 However, this limited the editor to 64 megabytes total, which some users
|
|
1567 who edited large files might conceivably exceed.)
|
|
1568
|
|
1569 Also, note that there is an implicit assumption here that all pointers
|
|
1570 are low enough that the top bits are all zero and can just be chopped
|
|
1571 off. On standard machines that allocate memory from the bottom up (and
|
|
1572 give each process its own address space), this works fine. Some
|
|
1573 machines, however, put the data space somewhere else in memory
|
|
1574 (e.g. beginning at 0x80000000). Those machines cope by defining
|
|
1575 @code{DATA_SEG_BITS} in the corresponding @file{m/} or @file{s/} file to
|
|
1576 the proper mask. Then, pointers retrieved from Lisp objects are
|
|
1577 automatically OR'ed with this value prior to being used.
|
|
1578
|
44
|
1579 A corollary of the previous paragraph is that @strong{(pointers to)
|
|
1580 stack-allocated structures cannot be put into Lisp objects}. The stack
|
|
1581 is generally located near the top of memory; if you put such a pointer
|
|
1582 into a Lisp object, it will get its top bits chopped off, and you will
|
|
1583 lose.
|
0
|
1584
|
|
1585 Various macros are used to construct Lisp objects and extract the
|
|
1586 components. Macros of the form @code{XINT()}, @code{XCHAR()},
|
|
1587 @code{XSTRING()}, @code{XSYMBOL()}, etc. mask out the pointer/integer
|
|
1588 field and cast it to the appropriate type. All of the macros that
|
|
1589 construct pointers will @code{OR} with @code{DATA_SEG_BITS} if
|
|
1590 necessary. @code{XINT()} needs to be a bit tricky so that negative
|
|
1591 numbers are properly sign-extended: Usually it does this by shifting the
|
|
1592 number four bits to the left and then four bits to the right. This
|
|
1593 assumes that the right-shift operator does an arithmetic shift (i.e. it
|
|
1594 leaves the most-significant bit as-is rather than shifting in a zero, so
|
|
1595 that it mimics a divide-by-two even for negative numbers). Not all
|
|
1596 machines/compilers do this, and on the ones that don't, a more
|
|
1597 complicated definition is selected by defining
|
|
1598 @code{EXPLICIT_SIGN_EXTEND}.
|
|
1599
|
|
1600 Note that when @code{ERROR_CHECK_TYPECHECK} is defined, the extractor
|
|
1601 macros become more complicated -- they check the tag bits and/or the
|
|
1602 type field in the first four bytes of a record type to ensure that the
|
|
1603 object is really of the correct type. This is great for catching places
|
|
1604 where an incorrect type is being dereferenced -- this typically results
|
|
1605 in a pointer being dereferenced as the wrong type of structure, with
|
|
1606 unpredictable (and sometimes not easily traceable) results.
|
|
1607
|
44
|
1608 There are similar @code{XSET@var{TYPE}()} macros that construct a Lisp object.
|
|
1609 These macros are of the form @code{XSET@var{TYPE} (@var{lvalue}, @var{result})},
|
0
|
1610 i.e. they have to be a statement rather than just used in an expression.
|
|
1611 The reason for this is that standard C doesn't let you ``construct'' a
|
|
1612 structure (but GCC does). Granted, this sometimes isn't too convenient;
|
|
1613 for the case of integers, at least, you can use the function
|
|
1614 @code{make_number()}, which constructs and @emph{returns} an integer
|
44
|
1615 Lisp object. Note that the @code{XSET@var{TYPE}()} macros are also
|
|
1616 affected by @code{ERROR_CHECK_TYPECHECK} and make sure that the
|
|
1617 structure is of the right type in the case of record types, where the
|
|
1618 type is contained in the structure.
|
0
|
1619
|
|
1620 @node Rules When Writing New C Code, A Summary of the Various XEmacs Modules, How Lisp Objects Are Represented in C, Top
|
|
1621 @chapter Rules When Writing New C Code
|
|
1622
|
|
1623 The XEmacs C Code is extremely complex and intricate, and there are
|
|
1624 many rules that are more or less consistently followed throughout the code.
|
|
1625 Many of these rules are not obvious, so they are explained here. It is
|
|
1626 of the utmost importance that you follow them. If you don't, you may get
|
|
1627 something that appears to work, but which will crash in odd situations,
|
|
1628 often in code far away from where the actual breakage is.
|
|
1629
|
|
1630 @menu
|
|
1631 * General Coding Rules::
|
|
1632 * Writing Lisp Primitives::
|
|
1633 * Adding Global Lisp Variables::
|
2
|
1634 * Techniques for XEmacs Developers::
|
0
|
1635 @end menu
|
|
1636
|
|
1637 @node General Coding Rules
|
|
1638 @section General Coding Rules
|
|
1639
|
|
1640 Almost every module contains a @code{syms_of_*()} function and a
|
|
1641 @code{vars_of_*()} function. The former declares any Lisp primitives
|
|
1642 you have defined and defines any symbols you will be using. The latter
|
|
1643 declares any global Lisp variables you have added and initializes global
|
|
1644 C variables in the module. For each such function, declare it in
|
|
1645 @file{symsinit.h} and make sure it's called in the appropriate place in
|
44
|
1646 @file{emacs.c}. @strong{Important}: There are stringent requirements on
|
0
|
1647 exactly what can go into these functions. See the comment in
|
44
|
1648 @file{emacs.c}. The reason for this is to avoid obscure unwanted
|
0
|
1649 interactions during initialization. If you don't follow these rules,
|
|
1650 you'll be sorry! If you want to do anything that isn't allowed, create
|
|
1651 a @code{complex_vars_of_*()} function for it. Doing this is tricky,
|
|
1652 though: You have to make sure your function is called at the right time
|
|
1653 so that all the initialization dependencies work out.
|
|
1654
|
|
1655 Every module includes @file{<config.h>} (angle brackets so that
|
44
|
1656 @samp{--srcdir} works correctly; @file{config.h} may or may not be in
|
|
1657 the same directory as the C sources) and @file{lisp.h}. @file{config.h}
|
0
|
1658 should always be included before any other header files (including
|
|
1659 system header files) to ensure that certain tricks played by various
|
|
1660 @file{s/} and @file{m/} files work out correctly.
|
|
1661
|
|
1662 @strong{All global and static variables that are to be modifiable must
|
|
1663 be declared uninitialized.} This means that you may not use the ``declare
|
|
1664 with initializer'' form for these variables, such as @code{int
|
|
1665 some_variable = 0;}. The reason for this has to do with some kludges
|
|
1666 done during the dumping process: If possible, the initialized data
|
|
1667 segment is re-mapped so that it becomes part of the (unmodifiable) code
|
|
1668 segment in the dumped executable. This allows this memory to be shared
|
|
1669 among multiple running XEmacs processes. XEmacs is careful to place as
|
|
1670 much constant data as possible into initialized variables (in
|
|
1671 particular, into what's called the @dfn{pure space} -- see below) during
|
|
1672 the @file{temacs} phase.
|
|
1673
|
|
1674 @cindex copy-on-write
|
|
1675 @strong{Note:} This kludge only works on a few systems nowadays, and is
|
|
1676 rapidly becoming irrelevant because most modern operating systems provide
|
|
1677 @dfn{copy-on-write} semantics. All data is initially shared between
|
|
1678 processes, and a private copy is automatically made (on a page-by-page
|
|
1679 basis) when a process first attempts to write to a page of memory.
|
|
1680
|
|
1681 Formerly, there was a requirement that static variables not be
|
|
1682 declared inside of functions. This had to do with another hack along
|
|
1683 the same vein as what was just described: old USG systems put
|
|
1684 statically-declared variables in the initialized data space, so those
|
|
1685 header files had a @code{#define static} declaration. (That way, the
|
|
1686 data-segment remapping described above could still work.) This fails
|
|
1687 badly on static variables inside of functions, which suddenly become
|
|
1688 automatic variables; therefore, you weren't supposed to have any of
|
|
1689 them. This awful kludge has been removed in XEmacs because
|
|
1690
|
|
1691 @enumerate
|
|
1692 @item
|
|
1693 almost all of the systems that used this kludge ended up having
|
|
1694 to disable the data-segment remapping anyway;
|
|
1695 @item
|
|
1696 the only systems that didn't were extremely outdated ones;
|
|
1697 @item
|
|
1698 this hack completely messed up inline functions.
|
|
1699 @end enumerate
|
|
1700
|
|
1701 @node Writing Lisp Primitives
|
|
1702 @section Writing Lisp Primitives
|
|
1703
|
|
1704 Lisp primitives are Lisp functions implemented in C. The details of
|
|
1705 interfacing the C function so that Lisp can call it are handled by a few
|
|
1706 C macros. The only way to really understand how to write new C code is
|
|
1707 to read the source, but we can explain some things here.
|
|
1708
|
|
1709 An example of a special form is the definition of @code{or}, from
|
|
1710 @file{eval.c}. (An ordinary function would have the same general
|
|
1711 appearance.)
|
|
1712
|
|
1713 @cindex garbage collection protection
|
|
1714 @smallexample
|
|
1715 @group
|
44
|
1716 DEFUN ("or", For, 0, UNEVALLED, 0, /*
|
0
|
1717 Eval args until one of them yields non-nil, then return that value.
|
|
1718 The remaining args are not evalled at all.
|
|
1719 If all args return nil, return nil.
|
44
|
1720 */
|
|
1721 (args))
|
0
|
1722 @{
|
|
1723 /* This function can GC */
|
|
1724 REGISTER Lisp_Object val;
|
|
1725 Lisp_Object args_left;
|
|
1726 struct gcpro gcpro1;
|
44
|
1727
|
0
|
1728 if (NILP (args))
|
|
1729 return Qnil;
|
|
1730
|
|
1731 args_left = args;
|
|
1732 GCPRO1 (args_left);
|
44
|
1733
|
0
|
1734 do
|
|
1735 @{
|
|
1736 val = Feval (Fcar (args_left));
|
|
1737 if (!NILP (val))
|
44
|
1738 break;
|
0
|
1739 args_left = Fcdr (args_left);
|
|
1740 @}
|
|
1741 while (!NILP (args_left));
|
44
|
1742
|
0
|
1743 UNGCPRO;
|
|
1744 return val;
|
|
1745 @}
|
|
1746 @end group
|
|
1747 @end smallexample
|
|
1748
|
|
1749 Let's start with a precise explanation of the arguments to the
|
|
1750 @code{DEFUN} macro. Here is a template for them:
|
|
1751
|
|
1752 @example
|
44
|
1753 DEFUN (@var{lname}, @var{fname}, @var{min}, @var{max}, @var{interactive}, /*
|
|
1754 @var{docstring}
|
|
1755 */
|
|
1756 (@var{arglist}) )
|
0
|
1757 @end example
|
|
1758
|
|
1759 @table @var
|
|
1760 @item lname
|
44
|
1761 This string is the name of the Lisp symbol to define as the function
|
|
1762 name; in the example above, it is @code{"or"}.
|
0
|
1763
|
|
1764 @item fname
|
44
|
1765 This is the C function name for this function. This is the name that is
|
|
1766 used in C code for calling the function. The name is, by convention,
|
|
1767 @samp{F} prepended to the Lisp name, with all dashes (@samp{-}) in the
|
|
1768 Lisp name changed to underscores. Thus, to call this function from C
|
|
1769 code, call @code{For}. Remember that the arguments are of type
|
|
1770 @code{Lisp_Object}; various macros and functions for creating values of
|
|
1771 type @code{Lisp_Object} are declared in the file @file{lisp.h}.
|
0
|
1772
|
|
1773 Primitives whose names are special characters (e.g. @code{+} or
|
|
1774 @code{<}) are named by spelling out, in some fashion, the special
|
|
1775 character: e.g. @code{Fplus()} or @code{Flss()}. Primitives whose names
|
|
1776 begin with normal alphanumeric characters but also contain special
|
|
1777 characters are spelled out in some creative way, e.g. @code{let*}
|
|
1778 becomes @code{FletX()}.
|
|
1779
|
44
|
1780 Each function also has an associated structure that holds the data for
|
0
|
1781 the subr object that represents the function in Lisp. This structure
|
|
1782 conveys the Lisp symbol name to the initialization routine that will
|
44
|
1783 create the symbol and store the subr object as its definition. The C
|
|
1784 variable name of this structure is always @samp{S} prepended to the
|
|
1785 @var{fname}. You hardly ever need to be aware of the existence of this
|
|
1786 structure.
|
0
|
1787
|
|
1788 @item min
|
|
1789 This is the minimum number of arguments that the function requires. The
|
|
1790 function @code{or} allows a minimum of zero arguments.
|
|
1791
|
|
1792 @item max
|
|
1793 This is the maximum number of arguments that the function accepts, if
|
|
1794 there is a fixed maximum. Alternatively, it can be @code{UNEVALLED},
|
|
1795 indicating a special form that receives unevaluated arguments, or
|
|
1796 @code{MANY}, indicating an unlimited number of evaluated arguments (the
|
|
1797 equivalent of @code{&rest}). Both @code{UNEVALLED} and @code{MANY} are
|
|
1798 macros. If @var{max} is a number, it may not be less than @var{min} and
|
44
|
1799 it may not be greater than 8. (If you need to add a function with
|
|
1800 more than 8 arguments, either use the @code{MANY} form or edit the
|
0
|
1801 definition of @code{DEFUN} in @file{lisp.h}. If you do the latter,
|
|
1802 make sure to also add another clause to the switch statement in
|
|
1803 @code{primitive_funcall().})
|
|
1804
|
|
1805 @item interactive
|
|
1806 This is an interactive specification, a string such as might be used as
|
|
1807 the argument of @code{interactive} in a Lisp function. In the case of
|
|
1808 @code{or}, it is 0 (a null pointer), indicating that @code{or} cannot be
|
|
1809 called interactively. A value of @code{""} indicates a function that
|
|
1810 should receive no arguments when called interactively.
|
|
1811
|
44
|
1812 @item docstring
|
0
|
1813 This is the documentation string. It is written just like a
|
44
|
1814 documentation string for a function defined in Lisp; in particular, the
|
|
1815 first line should be a single sentence. Note how the documentation
|
|
1816 string is enclosed in a comment, none of the documentation is placed on
|
|
1817 the same lines as the comment-start and comment-end characters, and the
|
|
1818 comment-start characters are on the same line as the interactive
|
0
|
1819 specification. @file{make-docfile}, which scans the C files for
|
44
|
1820 documentation strings, is very particular about what it looks for, and
|
|
1821 will not properly extract the doc string if it's not in this exact format.
|
|
1822
|
|
1823 You are free to put the various arguments to @code{DEFUN} on separate
|
0
|
1824 lines to avoid overly long lines. However, make sure to put the
|
|
1825 comment-start characters for the doc string on the same line as the
|
44
|
1826 interactive specification, and put a newline directly after them (and
|
|
1827 before the comment-end characters).
|
|
1828
|
|
1829 @item arglist
|
|
1830 This is the comma-separated list of arguments to the C function. For a
|
|
1831 function with a fixed maximum number of arguments, provide a C argument
|
|
1832 for each Lisp argument. In this case, unlike regular C functions, the
|
|
1833 types of the arguments are not declared; they are simply always of type
|
|
1834 @code{Lisp_Object}.
|
|
1835
|
|
1836 The names of the C arguments will be used as the names of the arguments
|
|
1837 to the Lisp primitive as displayed in its documentation, modulo the same
|
|
1838 concerns described above for @code{F...} names (in particular,
|
0
|
1839 underscores in the C arguments become dashes in the Lisp arguments).
|
54
|
1840
|
|
1841 There is one additional kludge: A trailing `_' on the C argument is
|
|
1842 discarded when forming the Lisp argument. This allows C language
|
|
1843 reserved words (like @code{default}) or global symbols (like
|
|
1844 @code{dirname}) to be used as argument names without compiler warnings
|
|
1845 or errors.
|
0
|
1846
|
44
|
1847 A Lisp function with @w{@var{max} = @code{UNEVALLED}} is a
|
|
1848 @w{@dfn{special form}}; its arguments are not evaluated. Instead it
|
|
1849 receives one argument of type @code{Lisp_Object}, a (Lisp) list of the
|
|
1850 unevaluated arguments, conventionally named @code{(args)}.
|
|
1851
|
|
1852 When a Lisp function has no upper limit on the number of arguments,
|
|
1853 specify @w{@var{max} = @code{MANY}}. In this case its implementation in
|
|
1854 C actually receives exactly two arguments: the number of Lisp arguments
|
|
1855 (an @code{int}) and the address of a block containing their values (a
|
|
1856 @w{@code{Lisp_Object *}}). In this case only are the C types specified
|
|
1857 in the @var{arglist}: @w{@code{(int nargs, Lisp_Object *args)}}.
|
|
1858
|
|
1859 @end table
|
0
|
1860
|
|
1861 Within the function @code{For} itself, note the use of the macros
|
|
1862 @code{GCPRO1} and @code{UNGCPRO}. @code{GCPRO1} is used to ``protect''
|
|
1863 a variable from garbage collection---to inform the garbage collector
|
|
1864 that it must look in that variable and regard its contents as an
|
|
1865 accessible object. This is necessary whenever you call @code{Feval} or
|
|
1866 anything that can directly or indirectly call @code{Feval} (this
|
|
1867 includes the @code{QUIT} macro!). At such a time, any Lisp object that
|
|
1868 you intend to refer to again must be protected somehow. @code{UNGCPRO}
|
|
1869 cancels the protection of the variables that are protected in the
|
|
1870 current function. It is necessary to do this explicitly.
|
|
1871
|
|
1872 The macro @code{GCPRO1} protects just one local variable. If you want
|
|
1873 to protect two, use @code{GCPRO2} instead; repeating @code{GCPRO1} will
|
|
1874 not work. Macros @code{GCPRO3} and @code{GCPRO4} also exist.
|
|
1875
|
|
1876 These macros implicitly use local variables such as @code{gcpro1}; you
|
|
1877 must declare these explicitly, with type @code{struct gcpro}. Thus, if
|
|
1878 you use @code{GCPRO2}, you must declare @code{gcpro1} and @code{gcpro2}.
|
|
1879
|
|
1880 @cindex caller-protects (@code{GCPRO} rule)
|
|
1881 Note also that the general rule is @dfn{caller-protects}; i.e. you
|
|
1882 are only responsible for protecting those Lisp objects that you create.
|
|
1883 Any objects passed to you as parameters should have been protected
|
|
1884 by whoever created them, so you don't in general have to protect them.
|
|
1885 @code{For} is an exception; it protects its parameters to provide
|
|
1886 extra assurance against Lisp primitives elsewhere that are incorrectly
|
|
1887 written, and against malicious self-modifying code. There are a few
|
|
1888 other standard functions that also do this.
|
|
1889
|
|
1890 @code{GCPRO}ing is perhaps the trickiest and most error-prone part
|
|
1891 of XEmacs coding. It is @strong{extremely} important that you get this
|
|
1892 right and use a great deal of discipline when writing this code.
|
|
1893 @xref{GCPROing, ,@code{GCPRO}ing}, for full details on how to do this.
|
|
1894
|
|
1895 What @code{DEFUN} actually does is declare a global structure of
|
44
|
1896 type @code{Lisp_Subr} whose name begins with capital @samp{SF} and
|
0
|
1897 which contains information about the primitive (e.g. a pointer to the
|
|
1898 function, its minimum and maximum allowed arguments, a string describing
|
|
1899 its Lisp name); @code{DEFUN} then begins a normal C function
|
|
1900 declaration using the @code{F...} name. The Lisp subr object that is
|
|
1901 the function definition of a primitive (i.e. the object in the function
|
|
1902 slot of the symbol that names the primitive) actually points to this
|
44
|
1903 @samp{SF} structure; when @code{Feval} encounters a subr, it looks in the
|
0
|
1904 structure to find out how to call the C function.
|
|
1905
|
|
1906 Defining the C function is not enough to make a Lisp primitive
|
|
1907 available; you must also create the Lisp symbol for the primitive (the
|
|
1908 symbol is @dfn{interned}; @pxref{Obarrays}) and store a suitable subr
|
|
1909 object in its function cell. (If you don't do this, the primitive won't
|
|
1910 be seen by Lisp code.) The code looks like this:
|
|
1911
|
|
1912 @example
|
44
|
1913 DEFSUBR (@var{fname});
|
0
|
1914 @end example
|
|
1915
|
44
|
1916 @noindent
|
|
1917 Here @var{fname} is the name you used as the second argument to
|
|
1918 @code{DEFUN}.
|
|
1919
|
|
1920 This call to @code{DEFSUBR} should go in the @code{syms_of_*()}
|
0
|
1921 function at the end of the module. If no such function exists, create
|
|
1922 it and make sure to also declare it in @file{symsinit.h} and call it
|
|
1923 from the appropriate spot in @code{main()}. @xref{General Coding
|
|
1924 Rules}.
|
|
1925
|
|
1926 Note that C code cannot call functions by name unless they are defined
|
44
|
1927 in C. The way to call a function written in Lisp from C is to use
|
0
|
1928 @code{Ffuncall}, which embodies the Lisp function @code{funcall}. Since
|
|
1929 the Lisp function @code{funcall} accepts an unlimited number of
|
|
1930 arguments, in C it takes two: the number of Lisp-level arguments, and a
|
|
1931 one-dimensional array containing their values. The first Lisp-level
|
|
1932 argument is the Lisp function to call, and the rest are the arguments to
|
|
1933 pass to it. Since @code{Ffuncall} can call the evaluator, you must
|
|
1934 protect pointers from garbage collection around the call to
|
|
1935 @code{Ffuncall}. (However, @code{Ffuncall} explicitly protects all of
|
|
1936 its parameters, so you don't have to protect any pointers passed
|
|
1937 as parameters to it.)
|
|
1938
|
|
1939 The C functions @code{call0}, @code{call1}, @code{call2}, and so on,
|
|
1940 provide handy ways to call a Lisp function conveniently with a fixed
|
|
1941 number of arguments. They work by calling @code{Ffuncall}.
|
|
1942
|
|
1943 @file{eval.c} is a very good file to look through for examples;
|
|
1944 @file{lisp.h} contains the definitions for some important macros and
|
|
1945 functions.
|
|
1946
|
|
1947 @node Adding Global Lisp Variables
|
|
1948 @section Adding Global Lisp Variables
|
|
1949
|
|
1950 Global variables whose names begin with @samp{Q} are constants whose
|
|
1951 value is a symbol of a particular name. The name of the variable should
|
|
1952 be derived from the name of the symbol using the same rules as for Lisp
|
|
1953 primitives. These variables are initialized using a call to
|
|
1954 @code{defsymbol()} in the @code{syms_of_*()} function. (This call
|
|
1955 interns a symbol, sets the C variable to the resulting Lisp object, and
|
|
1956 calls @code{staticpro()} on the C variable to tell the
|
|
1957 garbage-collection mechanism about this variable. What
|
|
1958 @code{staticpro()} does is add a pointer to the variable to a large
|
|
1959 global array; when garbage-collection happens, all pointers listed in
|
|
1960 the array are used as starting points for marking Lisp objects. This is
|
|
1961 important because it's quite possible that the only current reference to
|
|
1962 the object is the C variable. In the case of symbols, the
|
|
1963 @code{staticpro()} doesn't matter all that much because the symbol is
|
|
1964 contained in @code{obarray}, which is itself @code{staticpro()}ed.
|
|
1965 However, it's possible that a naughty user could do something like
|
|
1966 uninterning the symbol out of @code{obarray} or even setting
|
|
1967 @code{obarray} to a different value [although this is likely to make
|
|
1968 XEmacs crash!].)
|
|
1969
|
|
1970 @strong{Note:} It is potentially deadly if you declare a @samp{Q...}
|
|
1971 variable in two different modules. The two calls to @code{defsymbol()}
|
|
1972 are no problem, but some linkers will complain about multiply-defined
|
|
1973 symbols. The most insidious aspect of this is that often the link will
|
|
1974 succeed anyway, but then the resulting executable will sometimes crash
|
|
1975 in obscure ways during certain operations! To avoid this problem,
|
|
1976 declare any symbols with common names (such as @code{text}) that are not
|
|
1977 obviously associated with this particular module in the module
|
|
1978 @file{general.c}.
|
|
1979
|
|
1980 Global variables whose names begin with @samp{V} are variables that
|
|
1981 contain Lisp objects. The convention here is that all global variables
|
|
1982 of type @code{Lisp_Object} begin with @samp{V}, and all others don't
|
|
1983 (including integer and boolean variables that have Lisp
|
|
1984 equivalents). Most of the time, these variables have equivalents in
|
|
1985 Lisp, but some don't. Those that do are declared this way by a call to
|
|
1986 @code{DEFVAR_LISP()} in the @code{vars_of_*()} initializer for the
|
|
1987 module. What this does is create a special @dfn{symbol-value-forward}
|
|
1988 Lisp object that contains a pointer to the C variable, intern a symbol
|
|
1989 whose name is as specified in the call to @code{DEFVAR_LISP()}, and set
|
|
1990 its value to the symbol-value-forward Lisp object; it also calls
|
|
1991 @code{staticpro()} on the C variable to tell the garbage-collection
|
|
1992 mechanism about the variable. When @code{eval} (or actually
|
|
1993 @code{symbol-value}) encounters this special object in the process of
|
|
1994 retrieving a variable's value, it follows the indirection to the C
|
|
1995 variable and gets its value. @code{setq} does similar things so that
|
|
1996 the C variable gets changed.
|
|
1997
|
|
1998 Whether or not you @code{DEFVAR_LISP()} a variable, you need to
|
|
1999 initialize it in the @code{vars_of_*()} function; otherwise it will end
|
|
2000 up as all zeroes, which is the integer 0 (@emph{not} @code{nil}), and
|
|
2001 this is probably not what you want. Also, if the variable is not
|
|
2002 @code{DEFVAR_LISP()}ed, @strong{you must call} @code{staticpro()} on the
|
|
2003 C variable in the @code{vars_of_*()} function. Otherwise, the
|
|
2004 garbage-collection mechanism won't know that the object in this variable
|
|
2005 is in use, and will happily collect it and reuse its storage for another
|
|
2006 Lisp object, and you will be the one who's unhappy when you can't figure
|
|
2007 out how your variable got overwritten.
|
|
2008
|
2
|
2009 @node Techniques for XEmacs Developers
|
|
2010 @section Techniques for XEmacs Developers
|
|
2011
|
|
2012 To make a quantified XEmacs, do: @code{make quantmacs}.
|
|
2013
|
|
2014 You simply can't dump Quantified and Purified images. Run the image
|
|
2015 like so: @code{quantmacs -batch -l loadup.el run-temacs -q}.
|
|
2016
|
|
2017 Before you go through the trouble, are you compiling with all
|
|
2018 debugging and error-checking off? If not try that first. Be warned
|
|
2019 that while Quantify is directly responsible for quite a few
|
|
2020 optimizations which have been made to XEmacs, doing a run which
|
|
2021 generates results which can be acted upon is not necessarily a trivial
|
|
2022 task.
|
|
2023
|
|
2024 Also, if you're still willing to do some runs make sure you configure
|
|
2025 with the @samp{--quantify} flag. That will keep Quantify from starting
|
|
2026 to record data until after the loadup is completed and will shut off
|
|
2027 recording right before it shuts down (which generates enough bogus data
|
|
2028 to throw most results off). It also enables three additional elisp
|
|
2029 commands: @code{quantify-start-recording-data},
|
|
2030 @code{quantify-stop-recording-data} and @code{quantify-clear-data}.
|
|
2031
|
|
2032 To get started debugging XEmacs, take a look at the @file{gdbinit} and
|
|
2033 @file{dbxrc} files in the @file{src} directory.
|
|
2034
|
|
2035
|
0
|
2036 @node A Summary of the Various XEmacs Modules, Allocation of Objects in XEmacs Lisp, Rules When Writing New C Code, Top
|
|
2037 @chapter A Summary of the Various XEmacs Modules
|
|
2038
|
|
2039 This is accurate as of XEmacs 20.0.
|
|
2040
|
|
2041 @menu
|
|
2042 * Low-Level Modules::
|
|
2043 * Basic Lisp Modules::
|
|
2044 * Modules for Standard Editing Operations::
|
|
2045 * Editor-Level Control Flow Modules::
|
|
2046 * Modules for the Basic Displayable Lisp Objects::
|
|
2047 * Modules for other Display-Related Lisp Objects::
|
|
2048 * Modules for the Redisplay Mechanism::
|
|
2049 * Modules for Interfacing with the File System::
|
|
2050 * Modules for Other Aspects of the Lisp Interpreter and Object System::
|
|
2051 * Modules for Interfacing with the Operating System::
|
|
2052 * Modules for Interfacing with X Windows::
|
|
2053 * Modules for Internationalization::
|
|
2054 @end menu
|
|
2055
|
|
2056 @node Low-Level Modules
|
|
2057 @section Low-Level Modules
|
|
2058
|
|
2059 @example
|
|
2060 size name
|
|
2061 ------- ---------------------
|
|
2062 18150 config.h
|
|
2063 @end example
|
|
2064
|
|
2065 This is automatically generated from @file{config.h.in} based on the
|
|
2066 results of configure tests and user-selected optional features and
|
|
2067 contains preprocessor definitions specifying the nature of the
|
|
2068 environment in which XEmacs is being compiled.
|
|
2069
|
|
2070
|
|
2071
|
|
2072 @example
|
|
2073 2347 paths.h
|
|
2074 @end example
|
|
2075
|
|
2076 This is automatically generated from @file{paths.h.in} based on supplied
|
|
2077 configure values, and allows for non-standard installed configurations
|
|
2078 of the XEmacs directories. It's currently broken, though.
|
|
2079
|
|
2080
|
|
2081
|
|
2082 @example
|
|
2083 47878 emacs.c
|
|
2084 20239 signal.c
|
|
2085 @end example
|
|
2086
|
|
2087 @file{emacs.c} contains @code{main()} and other code that performs the most
|
|
2088 basic environment initializations and handles shutting down the XEmacs
|
|
2089 process (this includes @code{kill-emacs}, the normal way that XEmacs is
|
|
2090 exited; @code{dump-emacs}, which is used during the build process to
|
|
2091 write out the XEmacs executable; @code{run-emacs-from-temacs}, which can
|
|
2092 be used to start XEmacs directly when temacs has finished loading all
|
|
2093 the Lisp code; and emergency code to handle crashes [XEmacs tries to
|
|
2094 auto-save all files before it crashes]).
|
|
2095
|
|
2096 Low-level code that directly interacts with the Unix signal mechanism,
|
|
2097 however, is in @file{signal.c}. Note that this code does not handle system
|
|
2098 dependencies in interfacing to signals; that is handled using the
|
|
2099 @file{syssignal.h} header file, described in section J below.
|
|
2100
|
|
2101
|
|
2102
|
|
2103 @example
|
|
2104 23458 unexaix.c
|
|
2105 9893 unexalpha.c
|
|
2106 11302 unexapollo.c
|
|
2107 16544 unexconvex.c
|
|
2108 31967 unexec.c
|
|
2109 30959 unexelf.c
|
|
2110 35791 unexelfsgi.c
|
|
2111 3207 unexencap.c
|
|
2112 7276 unexenix.c
|
|
2113 20539 unexfreebsd.c
|
|
2114 1153 unexfx2800.c
|
|
2115 13432 unexhp9k3.c
|
|
2116 11049 unexhp9k800.c
|
|
2117 9165 unexmips.c
|
|
2118 8981 unexnext.c
|
|
2119 1673 unexsol2.c
|
|
2120 19261 unexsunos4.c
|
|
2121 @end example
|
|
2122
|
|
2123 These modules contain code dumping out the XEmacs executable on various
|
|
2124 different systems. (This process is highly machine-specific and
|
|
2125 requires intimate knowledge of the executable format and the memory map
|
|
2126 of the process.) Only one of these modules is actually used; this is
|
|
2127 chosen by @file{configure}.
|
|
2128
|
|
2129
|
|
2130
|
|
2131 @example
|
|
2132 15715 crt0.c
|
|
2133 1484 lastfile.c
|
|
2134 1115 pre-crt0.c
|
|
2135 @end example
|
|
2136
|
|
2137 These modules are used in conjunction with the dump mechanism. On some
|
|
2138 systems, an alternative version of the C startup code (the actual code
|
|
2139 that receives control from the operating system when the process is
|
|
2140 started, and which calls @code{main()}) is required so that the dumping
|
|
2141 process works properly; @file{crt0.c} provides this.
|
|
2142
|
|
2143 @file{pre-crt0.c} and @file{lastfile.c} should be the very first and
|
|
2144 very last file linked, respectively. (Actually, this is not really true.
|
|
2145 @file{lastfile.c} should be after all Emacs modules whose initialized
|
|
2146 data should be made constant, and before all other Emacs files and all
|
|
2147 libraries. In particular, the allocation modules @file{gmalloc.c},
|
|
2148 @file{alloca.c}, etc. are normally placed past @file{lastfile.c}, and
|
|
2149 all of the files that implement Xt widget classes @emph{must} be placed
|
|
2150 after @file{lastfile.c} because they contain various structures that
|
|
2151 must be statically initialized and into which Xt writes at various
|
|
2152 times.) @file{pre-crt0.c} and @file{lastfile.c} contain exported symbols
|
44
|
2153 that are used to determine the start and end of XEmacs' initialized
|
0
|
2154 data space when dumping.
|
|
2155
|
|
2156
|
|
2157
|
|
2158 @example
|
|
2159 14786 alloca.c
|
|
2160 16678 free-hook.c
|
|
2161 1692 getpagesize.h
|
|
2162 41936 gmalloc.c
|
|
2163 25141 malloc.c
|
|
2164 3802 mem-limits.h
|
|
2165 39011 ralloc.c
|
|
2166 3436 vm-limit.c
|
|
2167 @end example
|
|
2168
|
|
2169 These handle basic C allocation of memory. @file{alloca.c} is an emulation of
|
|
2170 the stack allocation function @code{alloca()} on machines that lack
|
|
2171 this. (XEmacs makes extensive use of @code{alloca()} in its code.)
|
|
2172
|
|
2173 @file{gmalloc.c} and @file{malloc.c} are two implementations of the standard C
|
|
2174 functions @code{malloc()}, @code{realloc()} and @code{free()}. They are
|
|
2175 often used in place of the standard system-provided @code{malloc()}
|
|
2176 because they usually provide a much faster implementation, at the
|
|
2177 expense of additional memory use. @file{gmalloc.c} is a newer implementation
|
|
2178 that is much more memory-efficient for large allocations than @file{malloc.c},
|
|
2179 and should always be preferred if it works. (At one point, @file{gmalloc.c}
|
|
2180 didn't work on some systems where @file{malloc.c} worked; but this should be
|
|
2181 fixed now.)
|
|
2182
|
|
2183 @cindex relocating allocator
|
|
2184 @file{ralloc.c} is the @dfn{relocating allocator}. It provides functions
|
|
2185 similar to @code{malloc()}, @code{realloc()} and @code{free()} that allocate
|
|
2186 memory that can be dynamically relocated in memory. The advantage of
|
|
2187 this is that allocated memory can be shuffled around to place all the
|
|
2188 free memory at the end of the heap, and the heap can then be shrunk,
|
|
2189 releasing the memory back to the operating system. The use of this can
|
|
2190 be controlled with the configure option @code{--rel-alloc}; if enabled, memory allocated for
|
|
2191 buffers will be relocatable, so that if a very large file is visited and
|
|
2192 the buffer is later killed, the memory can be released to the operating
|
|
2193 system. (The disadvantage of this mechanism is that it can be very
|
|
2194 slow. On systems with the @code{mmap()} system call, the XEmacs version
|
|
2195 of @file{ralloc.c} uses this to move memory around without actually having to
|
|
2196 block-copy it, which can speed things up; but it can still cause
|
|
2197 noticeable performance degradation.)
|
|
2198
|
|
2199 @file{free-hook.c} contains some debugging functions for checking for invalid
|
|
2200 arguments to @code{free()}.
|
|
2201
|
|
2202 @file{vm-limit.c} contains some functions that warn the user when memory is
|
|
2203 getting low. These are callback functions that are called by @file{gmalloc.c}
|
|
2204 and @file{malloc.c} at appropriate times.
|
|
2205
|
|
2206 @file{getpagesize.h} provides a uniform interface for retrieving the size of a
|
|
2207 page in virtual memory. @file{mem-limits.h} provides a uniform interface for
|
|
2208 retrieving the total amount of available virtual memory. Both are
|
|
2209 similar in spirit to the @file{sys*.h} files described in section J, below.
|
|
2210
|
|
2211
|
|
2212
|
|
2213 @example
|
|
2214 2659 blocktype.c
|
|
2215 1410 blocktype.h
|
|
2216 7194 dynarr.c
|
|
2217 2671 dynarr.h
|
|
2218 @end example
|
|
2219
|
|
2220 These implement a couple of basic C data types to facilitate memory
|
|
2221 allocation. The @code{Blocktype} type efficiently manages the
|
|
2222 allocation of fixed-size blocks by minimizing the number of times that
|
|
2223 @code{malloc()} and @code{free()} are called. It allocates memory in
|
|
2224 large chunks, subdivides the chunks into blocks of the proper size, and
|
|
2225 returns the blocks as requested. When blocks are freed, they are placed
|
|
2226 onto a linked list, so they can be efficiently reused. This data type
|
|
2227 is not much used in XEmacs currently, because it's a fairly new
|
|
2228 addition.
|
|
2229
|
|
2230 @cindex dynamic array
|
|
2231 The @code{Dynarr} type implements a @dfn{dynamic array}, which is
|
|
2232 similar to a standard C array but has no fixed limit on the number of
|
|
2233 elements it can contain. Dynamic arrays can hold elements of any type,
|
|
2234 and when you add a new element, the array automatically resizes itself
|
|
2235 if it isn't big enough. Dynarrs are extensively used in the redisplay
|
|
2236 mechanism.
|
|
2237
|
|
2238
|
|
2239
|
|
2240 @example
|
|
2241 2058 inline.c
|
|
2242 @end example
|
|
2243
|
|
2244 This module is used in connection with inline functions (available in
|
|
2245 some compilers). Often, inline functions need to have a corresponding
|
|
2246 non-inline function that does the same thing. This module is where they
|
|
2247 reside. It contains no actual code, but defines some special flags that
|
|
2248 cause inline functions defined in header files to be rendered as actual
|
|
2249 functions. It then includes all header files that contain any inline
|
|
2250 function definitions, so that each one gets a real function equivalent.
|
|
2251
|
|
2252
|
|
2253
|
|
2254 @example
|
|
2255 6489 debug.c
|
|
2256 2267 debug.h
|
|
2257 @end example
|
|
2258
|
|
2259 These functions provide a system for doing internal consistency checks
|
|
2260 during code development. This system is not currently used; instead the
|
|
2261 simpler @code{assert()} macro is used along with the various checks
|
|
2262 provided by the @samp{--error-check-*} configuration options.
|
|
2263
|
|
2264
|
|
2265
|
|
2266 @example
|
|
2267 1643 prefix-args.c
|
|
2268 @end example
|
|
2269
|
|
2270 This is actually the source for a small, self-contained program
|
|
2271 used during building.
|
|
2272
|
|
2273
|
|
2274 @example
|
|
2275 904 universe.h
|
|
2276 @end example
|
|
2277
|
|
2278 This is not currently used.
|
|
2279
|
|
2280
|
|
2281
|
|
2282 @node Basic Lisp Modules
|
|
2283 @section Basic Lisp Modules
|
|
2284
|
|
2285 @example
|
|
2286 size name
|
|
2287 ------- ---------------------
|
|
2288 70167 emacsfns.h
|
|
2289 6305 lisp-disunion.h
|
|
2290 7086 lisp-union.h
|
|
2291 54929 lisp.h
|
|
2292 14235 lrecord.h
|
|
2293 10728 symsinit.h
|
|
2294 @end example
|
|
2295
|
|
2296 These are the basic header files for all XEmacs modules. Each module
|
|
2297 includes @file{lisp.h}, which brings the other header files in.
|
|
2298 @file{lisp.h} contains the definitions of the structures and extractor
|
|
2299 and constructor macros for the basic Lisp objects and various other
|
|
2300 basic definitions for the Lisp environment, as well as some
|
|
2301 general-purpose definitions (e.g. @code{min()} and @code{max()}).
|
|
2302 @file{lisp.h} includes either @file{lisp-disunion.h} or
|
|
2303 @file{lisp-union.h}, depending on whether @code{NO_UNION_TYPE} is
|
|
2304 defined. These files define the typedef of the Lisp object itself (as
|
|
2305 described above) and the low-level macros that hide the actual
|
|
2306 implementation of the Lisp object. All extractor and constructor macros
|
|
2307 for particular types of Lisp objects are defined in terms of these
|
|
2308 low-level macros.
|
|
2309
|
|
2310 As a general rule, all typedefs should go into the typedefs section of
|
|
2311 @file{lisp.h} rather than into a module-specific header file even if the
|
|
2312 structure is defined elsewhere. This allows function prototypes that
|
|
2313 use the typedef to be placed into @file{emacsfns.h}. Forward structure
|
|
2314 declarations (i.e. a simple declaration like @code{struct foo;} where
|
|
2315 the structure itself is defined elsewhere) should be placed into the
|
|
2316 typedefs section as necessary.
|
|
2317
|
|
2318 @file{lrecord.h} contains the basic structures and macros that implement
|
|
2319 all record-type Lisp objects -- i.e. all objects whose type is a field
|
|
2320 in their C structure, which includes all objects except the few most
|
|
2321 basic ones.
|
|
2322
|
|
2323 @file{emacsfns.h} contains prototypes for most of the exported functions
|
|
2324 in the various modules. (In particular, prototypes for Lisp primitives
|
2
|
2325 should always go into this header file. Prototypes for other functions
|
0
|
2326 can either go here or in a module-specific header file, depending on how
|
|
2327 general-purpose the function is and whether it has special-purpose
|
|
2328 argument types requiring definitions not in @file{lisp.h}.) All
|
|
2329 initialization functions are prototyped in @file{symsinit.h}.
|
|
2330
|
|
2331
|
|
2332
|
|
2333 @example
|
|
2334 120478 alloc.c
|
|
2335 1029 pure.c
|
|
2336 2506 puresize.h
|
|
2337 @end example
|
|
2338
|
|
2339 The large module @file{alloc.c} implements all of the basic allocation and
|
|
2340 garbage collection for Lisp objects. The most commonly used Lisp
|
|
2341 objects are allocated in chunks, similar to the Blocktype data type
|
|
2342 described above; others are allocated in individually @code{malloc()}ed
|
|
2343 blocks. This module provides the foundation on which all other aspects
|
|
2344 of the Lisp environment sit, and is the first module initialized at
|
|
2345 startup.
|
|
2346
|
|
2347 Note that @file{alloc.c} provides a series of generic functions that are
|
|
2348 not dependent on any particular object type, and interfaces to
|
|
2349 particular types of objects using a standardized interface of
|
|
2350 type-specific methods. This scheme is a fundamental principle of
|
|
2351 object-oriented programming and is heavily used throughout XEmacs. The
|
|
2352 great advantage of this is that it allows for a clean separation of
|
|
2353 functionality into different modules -- new classes of Lisp objects, new
|
|
2354 event interfaces, new device types, new stream interfaces, etc. can be
|
|
2355 added transparently without affecting code anywhere else in XEmacs.
|
|
2356 Because the different subsystems are divided into general and specific
|
|
2357 code, adding a new subtype within a subsystem will in general not
|
|
2358 require changes to the generic subsystem code or affect any of the other
|
|
2359 subtypes in the subsystem; this provides a great deal of robustness to
|
|
2360 the XEmacs code.
|
|
2361
|
|
2362 @cindex pure space
|
|
2363 @file{pure.c} contains the declaration of the @dfn{purespace} array.
|
|
2364 Pure space is a hack used to place some constant Lisp data into the code
|
|
2365 segment of the XEmacs executable, even though the data needs to be
|
|
2366 initialized through function calls. (See above in section VIII for more
|
|
2367 info about this.) During startup, certain sorts of data is
|
|
2368 automatically copied into pure space, and other data is copied manually
|
|
2369 in some of the basic Lisp files by calling the function @code{purecopy},
|
|
2370 which copies the object if possible (this only works in temacs, of
|
|
2371 course) and returns the new object. In particular, while temacs is
|
|
2372 executing, the Lisp reader automatically copies all compiled-function
|
|
2373 objects that it reads into pure space. Since compiled-function objects
|
|
2374 are large, are never modified, and typically comprise the majority of
|
|
2375 the contents of a compiled-Lisp file, this works well. While XEmacs is
|
|
2376 running, any attempt to modify an object that resides in pure space
|
|
2377 causes an error. Objects in pure space are never garbage collected --
|
|
2378 almost all of the time, they're intended to be permanent, and in any
|
|
2379 case you can't write into pure space to set the mark bits.
|
|
2380
|
|
2381 @file{puresize.h} contains the declaration of the size of the pure space
|
|
2382 array. This depends on the optional features that are compiled in, any
|
|
2383 extra purespace requested by the user at compile time, and certain other
|
|
2384 factors (e.g. 64-bit machines need more pure space because their Lisp
|
|
2385 objects are larger). The smallest size that suffices should be used, so
|
|
2386 that there's no wasted space. If there's not enough pure space, you
|
|
2387 will get an error during the build process, specifying how much more
|
|
2388 pure space is needed.
|
|
2389
|
|
2390
|
|
2391
|
|
2392 @example
|
|
2393 122243 eval.c
|
|
2394 2305 backtrace.h
|
|
2395 @end example
|
|
2396
|
|
2397 This module contains all of the functions to handle the flow of control.
|
|
2398 This includes the mechanisms of defining functions, calling functions,
|
|
2399 traversing stack frames, and binding variables; the control primitives
|
|
2400 and other special forms such as @code{while}, @code{if}, @code{eval},
|
|
2401 @code{let}, @code{and}, @code{or}, @code{progn}, etc.; handling of
|
|
2402 non-local exits, unwind-protects, and exception handlers; entering the
|
|
2403 debugger; methods for the subr Lisp object type; etc. It does
|
|
2404 @emph{not} include the @code{read} function, the @code{print} function,
|
|
2405 or the handling of symbols and obarrays.
|
|
2406
|
|
2407 @file{backtrace.h} contains some structures related to stack frames and the
|
|
2408 flow of control.
|
|
2409
|
|
2410
|
|
2411
|
|
2412 @example
|
|
2413 64949 lread.c
|
|
2414 @end example
|
|
2415
|
|
2416 This module implements the Lisp reader and the @code{read} function,
|
|
2417 which converts text into Lisp objects, according to the read syntax of
|
|
2418 the objects, as described above. This is similar to the parser that is
|
|
2419 a part of all compilers.
|
|
2420
|
|
2421
|
|
2422
|
|
2423 @example
|
|
2424 40900 print.c
|
|
2425 @end example
|
|
2426
|
|
2427 This module implements the Lisp print mechanism and the @code{print}
|
|
2428 function and related functions. This is the inverse of the Lisp reader
|
|
2429 -- it converts Lisp objects to a printed, textual representation.
|
|
2430 (Hopefully something that can be read back in using @code{read} to get
|
|
2431 an equivalent object.)
|
|
2432
|
|
2433
|
|
2434
|
|
2435 @example
|
|
2436 4518 general.c
|
|
2437 60220 symbols.c
|
|
2438 9966 symeval.h
|
|
2439 @end example
|
|
2440
|
|
2441 @file{symbols.c} implements the handling of symbols, obarrays, and
|
|
2442 retrieving the values of symbols. Much of the code is devoted to
|
|
2443 handling the special @dfn{symbol-value-magic} objects that define
|
|
2444 special types of variables -- this includes buffer-local variables,
|
|
2445 variable aliases, variables that forward into C variables, etc. This
|
|
2446 module is initialized extremely early (right after @file{alloc.c}),
|
|
2447 because it is here that the basic symbols @code{t} and @code{nil} are
|
|
2448 created, and those symbols are used everywhere throughout XEmacs.
|
|
2449
|
|
2450 @file{symeval.h} contains the definitions of symbol structures and the
|
|
2451 @code{DEFVAR_LISP()} and related macros for declaring variables.
|
|
2452
|
|
2453
|
|
2454
|
|
2455 @example
|
|
2456 48973 data.c
|
|
2457 25694 floatfns.c
|
|
2458 71049 fns.c
|
|
2459 @end example
|
|
2460
|
|
2461 These modules implement the methods and standard Lisp primitives for all
|
|
2462 the basic Lisp object types other than symbols (which are described
|
|
2463 above). @file{data.c} contains all the predicates (primitives that return
|
|
2464 whether an object is of a particular type); the integer arithmetic
|
|
2465 functions; and the basic accessor and mutator primitives for the various
|
|
2466 object types. @file{fns.c} contains all the standard predicates for working
|
|
2467 with sequences (where, abstractly speaking, a sequence is an ordered set
|
|
2468 of objects, and can be represented by a list, string, vector, or
|
|
2469 bit-vector); it also contains @code{equal}, perhaps on the grounds that
|
|
2470 bulk of the operation of @code{equal} is comparing sequences.
|
|
2471 @file{floatfns.c} contains methods and primitives for floats and floating-point
|
|
2472 arithmetic.
|
|
2473
|
|
2474
|
|
2475
|
|
2476 @example
|
|
2477 23555 bytecode.c
|
|
2478 3358 bytecode.h
|
|
2479 @end example
|
|
2480
|
|
2481 @file{bytecode.c} implements the byte-code interpreter, and @file{bytecode.h} contains
|
|
2482 associated structures. Note that the byte-code @emph{compiler} is
|
|
2483 written in Lisp.
|
|
2484
|
|
2485
|
|
2486
|
|
2487
|
|
2488 @node Modules for Standard Editing Operations
|
|
2489 @section Modules for Standard Editing Operations
|
|
2490
|
|
2491 @example
|
|
2492 size name
|
|
2493 ------- ---------------------
|
|
2494 82900 buffer.c
|
|
2495 60964 buffer.h
|
|
2496 6059 bufslots.h
|
|
2497 @end example
|
|
2498
|
2
|
2499 @file{buffer.c} implements the @dfn{buffer} Lisp object type. This
|
|
2500 includes functions that create and destroy buffers; retrieve buffers by
|
|
2501 name or by other properties; manipulate lists of buffers (remember that
|
|
2502 buffers are permanent objects and stored in various ordered lists);
|
|
2503 retrieve or change buffer properties; etc. It also contains the
|
|
2504 definitions of all the built-in buffer-local variables (which can be
|
|
2505 viewed as buffer properties). It does @emph{not} contain code to
|
|
2506 manipulate buffer-local variables (that's in @file{symbols.c}, described
|
|
2507 above); or code to manipulate the text in a buffer.
|
0
|
2508
|
|
2509 @file{buffer.h} defines the structures associated with a buffer and the various
|
|
2510 macros for retrieving text from a buffer and special buffer positions
|
|
2511 (e.g. @code{point}, the default location for text insertion). It also
|
|
2512 contains macros for working with buffer positions and converting between
|
|
2513 their representations as character offsets and as byte offsets (under
|
|
2514 MULE, they are different, because characters can be multi-byte). It is
|
|
2515 one of the largest header files.
|
|
2516
|
|
2517 @file{bufslots.h} defines the fields in the buffer structure that correspond to
|
|
2518 the built-in buffer-local variables. It is its own header file because
|
|
2519 it is included many times in @file{buffer.c}, as a way of iterating over all
|
|
2520 the built-in buffer-local variables.
|
|
2521
|
|
2522
|
|
2523
|
|
2524 @example
|
|
2525 79888 insdel.c
|
|
2526 6103 insdel.h
|
|
2527 @end example
|
|
2528
|
|
2529 @file{insdel.c} contains low-level functions for inserting and deleting text in
|
|
2530 a buffer, keeping track of changed regions for use by redisplay, and
|
|
2531 calling any before-change and after-change functions that may have been
|
|
2532 registered for the buffer. It also contains the actual functions that
|
|
2533 convert between byte offsets and character offsets.
|
|
2534
|
|
2535 @file{insdel.h} contains associated headers.
|
|
2536
|
|
2537
|
|
2538
|
|
2539 @example
|
|
2540 10975 marker.c
|
|
2541 @end example
|
|
2542
|
2
|
2543 This module implements the @dfn{marker} Lisp object type, which
|
|
2544 conceptually is a pointer to a text position in a buffer that moves
|
|
2545 around as text is inserted and deleted, so as to remain in the same
|
|
2546 relative position. This module doesn't actually move the markers around
|
|
2547 -- that's handled in @file{insdel.c}. This module just creates them and
|
|
2548 implements the primitives for working with them. As markers are simple
|
|
2549 objects, this does not entail much.
|
0
|
2550
|
|
2551 Note that the standard arithmetic primitives (e.g. @code{+}) accept
|
|
2552 markers in place of integers and automatically substitute the value of
|
|
2553 @code{marker-position} for the marker, i.e. an integer describing the
|
|
2554 current buffer position of the marker.
|
|
2555
|
|
2556
|
|
2557
|
|
2558 @example
|
|
2559 193714 extents.c
|
|
2560 15686 extents.h
|
|
2561 @end example
|
|
2562
|
2
|
2563 This module implements the @dfn{extent} Lisp object type, which is like
|
|
2564 a marker that works over a range of text rather than a single position.
|
0
|
2565 Extents are also much more complex and powerful than markers and have a
|
|
2566 more efficient (and more algorithmically complex) implementation. The
|
|
2567 implementation is described in detail in comments in @file{extents.c}.
|
|
2568
|
|
2569 The code in @file{extents.c} works closely with @file{insdel.c} so that
|
|
2570 extents are properly moved around as text is inserted and deleted.
|
|
2571 There is also code in @file{extents.c} that provides information needed
|
|
2572 by the redisplay mechanism for efficient operation. (Remember that
|
|
2573 extents can have display properties that affect [sometimes drastically,
|
|
2574 as in the @code{invisible} property] the display of the text they
|
|
2575 cover.)
|
|
2576
|
|
2577
|
|
2578
|
|
2579 @example
|
|
2580 60155 editfns.c
|
|
2581 @end example
|
|
2582
|
|
2583 @file{editfns.c} contains the standard Lisp primitives for working with
|
|
2584 a buffer's text, and calls the low-level functions in @file{insdel.c}.
|
|
2585 It also contains primitives for working with @code{point} (the default
|
|
2586 buffer insertion location).
|
|
2587
|
|
2588 @file{editfns.c} also contains functions for retrieving various
|
|
2589 characteristics from the external environment: the current time, the
|
|
2590 process ID of the running XEmacs process, the name of the user who ran
|
|
2591 this XEmacs process, etc. It's not clear why this code is in
|
|
2592 @file{editfns.c}.
|
|
2593
|
|
2594
|
|
2595
|
|
2596 @example
|
|
2597 26081 callint.c
|
|
2598 12577 cmds.c
|
|
2599 2749 commands.h
|
|
2600 @end example
|
|
2601
|
|
2602 @cindex interactive
|
|
2603 These modules implement the basic @dfn{interactive} commands,
|
|
2604 i.e. user-callable functions. Commands, as opposed to other functions,
|
|
2605 have special ways of getting their parameters interactively (by querying
|
|
2606 the user), as opposed to having them passed in a normal function
|
|
2607 invocation. Many commands are not really meant to be called from other
|
|
2608 Lisp functions, because they modify global state in a way that's often
|
|
2609 undesired as part of other Lisp functions.
|
|
2610
|
|
2611 @file{callint.c} implements the mechanism for querying the user for
|
|
2612 parameters and calling interactive commands. The bulk of this module is
|
|
2613 code that parses the interactive spec that is supplied with an
|
|
2614 interactive command.
|
|
2615
|
|
2616 @file{cmds.c} implements the basic, most commonly used editing commands:
|
|
2617 commands to move around the current buffer and insert and delete
|
|
2618 characters. These commands are implemented using the Lisp primitives
|
|
2619 defined in @file{editfns.c}.
|
|
2620
|
|
2621 @file{commands.h} contains associated structure definitions and prototypes.
|
|
2622
|
|
2623
|
|
2624
|
|
2625 @example
|
|
2626 194863 regex.c
|
|
2627 18968 regex.h
|
|
2628 79800 search.c
|
|
2629 @end example
|
|
2630
|
|
2631 @file{search.c} implements the Lisp primitives for searching for text in
|
|
2632 a buffer, and some of the low-level algorithms for doing this. In
|
|
2633 particular, the fast fixed-string Boyer-Moore search algorithm is
|
|
2634 implemented in @file{search.c}. The low-level algorithms for doing
|
|
2635 regular-expression searching, however, are implemented in @file{regex.c}
|
|
2636 and @file{regex.h}. These two modules are largely independent of
|
|
2637 XEmacs, and are similar to (and based upon) the regular-expression
|
|
2638 routines used in @file{grep} and other GNU utilities.
|
|
2639
|
|
2640
|
|
2641
|
|
2642 @example
|
|
2643 20476 doprnt.c
|
|
2644 @end example
|
|
2645
|
|
2646 @file{doprnt.c} implements formatted-string processing, similar to
|
|
2647 @code{printf()} command in C.
|
|
2648
|
|
2649
|
|
2650
|
|
2651 @example
|
|
2652 15372 undo.c
|
|
2653 @end example
|
|
2654
|
|
2655 This module implements the undo mechanism for tracking buffer changes.
|
|
2656 Most of this could be implemented in Lisp.
|
|
2657
|
|
2658
|
|
2659
|
|
2660 @node Editor-Level Control Flow Modules
|
|
2661 @section Editor-Level Control Flow Modules
|
|
2662
|
|
2663 @example
|
|
2664 size name
|
|
2665 ------- ---------------------
|
|
2666 84546 event-Xt.c
|
|
2667 121483 event-stream.c
|
|
2668 6658 event-tty.c
|
|
2669 49271 events.c
|
|
2670 14459 events.h
|
|
2671 @end example
|
|
2672
|
|
2673 These implement the handling of events (user input and other system
|
|
2674 notifications).
|
|
2675
|
2
|
2676 @file{events.c} and @file{events.h} define the @dfn{event} Lisp object
|
|
2677 type and primitives for manipulating it.
|
0
|
2678
|
|
2679 @file{event-stream.c} implements the basic functions for working with
|
|
2680 event queues, dispatching an event by looking it up in relevant keymaps
|
|
2681 and such, and handling timeouts; this includes the primitives
|
|
2682 @code{next-event} and @code{dispatch-event}, as well as related
|
|
2683 primitives such as @code{sit-for}, @code{sleep-for}, and
|
|
2684 @code{accept-process-output}. (@file{event-stream.c} is one of the
|
|
2685 hairiest and trickiest modules in XEmacs. Beware! You can easily mess
|
|
2686 things up here.)
|
|
2687
|
|
2688 @file{event-Xt.c} and @file{event-tty.c} implement the low-level
|
|
2689 interfaces onto retrieving events from Xt (the X toolkit) and from TTY's
|
|
2690 (using @code{read()} and @code{select()}), respectively. The event
|
|
2691 interface enforces a clean separation between the specific code for
|
|
2692 interfacing with the operating system and the generic code for working
|
|
2693 with events, by defining an API of basic, low-level event methods;
|
|
2694 @file{event-Xt.c} and @file{event-tty.c} are two different
|
|
2695 implementations of this API. To add support for a new operating system
|
|
2696 (e.g. NeXTstep), one merely needs to provide another implementation of
|
|
2697 those API functions.
|
|
2698
|
|
2699 Note that the choice of whether to use @file{event-Xt.c} or
|
|
2700 @file{event-tty.c} is made at compile time! Or at the very latest, it
|
|
2701 is made at startup time. @file{event-Xt.c} handles events for
|
|
2702 @emph{both} X and TTY frames; @file{event-tty.c} is only used when X
|
|
2703 support is not compiled into XEmacs. The reason for this is that there
|
|
2704 is only one event loop in XEmacs: thus, it needs to be able to receive
|
|
2705 events from all different kinds of frames.
|
|
2706
|
|
2707
|
|
2708
|
|
2709 @example
|
|
2710 129583 keymap.c
|
|
2711 2621 keymap.h
|
|
2712 @end example
|
|
2713
|
2
|
2714 @file{keymap.c} and @file{keymap.h} define the @dfn{keymap} Lisp object
|
|
2715 type and associated methods and primitives. (Remember that keymaps are
|
0
|
2716 objects that associate event descriptions with functions to be called to
|
|
2717 ``execute'' those events; @code{dispatch-event} looks up events in the
|
|
2718 relevant keymaps.)
|
|
2719
|
|
2720
|
|
2721
|
|
2722 @example
|
|
2723 25212 keyboard.c
|
|
2724 @end example
|
|
2725
|
|
2726 @file{keyboard.c} contains functions that implement the actual editor
|
|
2727 command loop -- i.e. the event loop that cyclically retrieves and
|
|
2728 dispatches events. This code is also rather tricky, just like
|
|
2729 @file{event-stream.c}.
|
|
2730
|
|
2731
|
|
2732
|
|
2733 @example
|
|
2734 9973 macros.c
|
|
2735 1397 macros.h
|
|
2736 @end example
|
|
2737
|
|
2738 These two modules contain the basic code for defining keyboard macros.
|
|
2739 These functions don't actually do much; most of the code that handles keyboard
|
|
2740 macros is mixed in with the event-handling code in @file{event-stream.c}.
|
|
2741
|
|
2742
|
|
2743
|
|
2744 @example
|
|
2745 23234 minibuf.c
|
|
2746 @end example
|
|
2747
|
|
2748 This contains some miscellaneous code related to the minibuffer (most of
|
|
2749 the minibuffer code was moved into Lisp by Richard Mlynarik). This
|
|
2750 includes the primitives for completion (although filename completion is
|
|
2751 in @file{dired.c}), the lowest-level interface to the minibuffer (if the
|
|
2752 command loop were cleaned up, this too could be in Lisp), and code for
|
|
2753 dealing with the echo area (this, too, was mostly moved into Lisp, and
|
|
2754 the only code remaining is code to call out to Lisp or provide simple
|
|
2755 bootstrapping implementations early in temacs, before the echo-area Lisp
|
|
2756 code is loaded).
|
|
2757
|
|
2758
|
|
2759
|
|
2760 @node Modules for the Basic Displayable Lisp Objects
|
|
2761 @section Modules for the Basic Displayable Lisp Objects
|
|
2762
|
|
2763 @example
|
|
2764 size name
|
|
2765 ------- ---------------------
|
|
2766 985 device-ns.h
|
|
2767 6454 device-stream.c
|
|
2768 1196 device-stream.h
|
|
2769 9526 device-tty.c
|
|
2770 8660 device-tty.h
|
|
2771 43798 device-x.c
|
|
2772 11667 device-x.h
|
|
2773 26056 device.c
|
|
2774 22993 device.h
|
|
2775 @end example
|
|
2776
|
2
|
2777 These modules implement the @dfn{device} Lisp object type. This
|
|
2778 abstracts a particular screen or connection on which frames are
|
|
2779 displayed. As with Lisp objects, event interfaces, and other
|
|
2780 subsystems, the device code is separated into a generic component that
|
|
2781 contains a standardized interface (in the form of a set of methods) onto
|
|
2782 particular device types.
|
0
|
2783
|
|
2784 The device subsystem defines all the methods and provides method
|
|
2785 services for not only device operations but also for the frame, window,
|
|
2786 menubar, scrollbar, toolbar, and other displayable-object subsystems.
|
|
2787 The reason for this is that all of these subsystems have the same
|
|
2788 subtypes (X, TTY, NeXTstep, Microsoft Windows, etc.) as devices do.
|
|
2789
|
|
2790
|
|
2791
|
|
2792 @example
|
|
2793 934 frame-ns.h
|
|
2794 2303 frame-tty.c
|
|
2795 69205 frame-x.c
|
|
2796 5976 frame-x.h
|
|
2797 68175 frame.c
|
|
2798 15080 frame.h
|
|
2799 @end example
|
|
2800
|
|
2801 Each device contains one or more frames in which objects (e.g. text) are
|
|
2802 displayed. A frame corresponds to a window in the window system;
|
|
2803 usually this is a top-level window but it could potentially be one of a
|
|
2804 number of overlapping child windows within a top-level window, using the
|
|
2805 MDI (Multiple Document Interface) protocol in Microsoft Windows or a
|
|
2806 similar scheme.
|
|
2807
|
2
|
2808 The @file{frame-*} files implement the @dfn{frame} Lisp object type and
|
|
2809 provide the generic and device-type-specific operations on frames
|
|
2810 (e.g. raising, lowering, resizing, moving, etc.).
|
0
|
2811
|
|
2812
|
|
2813
|
|
2814 @example
|
|
2815 160783 window.c
|
|
2816 15974 window.h
|
|
2817 @end example
|
|
2818
|
|
2819 @cindex window (in Emacs)
|
|
2820 @cindex pane
|
|
2821 Each frame consists of one or more non-overlapping @dfn{windows} (better
|
|
2822 known as @dfn{panes} in standard window-system terminology) in which a
|
|
2823 buffer's text can be displayed. Windows can also have scrollbars
|
|
2824 displayed around their edges.
|
|
2825
|
2
|
2826 @file{window.c} and @file{window.h} implement the @dfn{window} Lisp
|
|
2827 object type and provide code to manage windows. Since windows have no
|
0
|
2828 associated resources in the window system (the window system knows only
|
|
2829 about the frame; no child windows or anything are used for XEmacs
|
|
2830 windows), there is no device-type-specific code here; all of that code
|
|
2831 is part of the redisplay mechanism or the code for particular object
|
|
2832 types such as scrollbars.
|
|
2833
|
|
2834
|
|
2835
|
|
2836 @node Modules for other Display-Related Lisp Objects
|
|
2837 @section Modules for other Display-Related Lisp Objects
|
|
2838
|
|
2839 @example
|
|
2840 size name
|
|
2841 ------- ---------------------
|
|
2842 54397 faces.c
|
|
2843 15173 faces.h
|
|
2844 @end example
|
|
2845
|
|
2846
|
|
2847
|
|
2848 @example
|
|
2849 4961 bitmaps.h
|
|
2850 954 glyphs-ns.h
|
|
2851 105345 glyphs-x.c
|
|
2852 4288 glyphs-x.h
|
|
2853 72102 glyphs.c
|
|
2854 16356 glyphs.h
|
|
2855 @end example
|
|
2856
|
|
2857
|
|
2858
|
|
2859 @example
|
|
2860 952 objects-ns.h
|
|
2861 9971 objects-tty.c
|
|
2862 1465 objects-tty.h
|
|
2863 32326 objects-x.c
|
|
2864 2806 objects-x.h
|
|
2865 31944 objects.c
|
|
2866 6809 objects.h
|
|
2867 @end example
|
|
2868
|
|
2869
|
|
2870
|
|
2871 @example
|
|
2872 57511 menubar-x.c
|
|
2873 11243 menubar.c
|
|
2874 @end example
|
|
2875
|
|
2876
|
|
2877
|
|
2878 @example
|
|
2879 25012 scrollbar-x.c
|
|
2880 2554 scrollbar-x.h
|
|
2881 26954 scrollbar.c
|
|
2882 2778 scrollbar.h
|
|
2883 @end example
|
|
2884
|
|
2885
|
|
2886
|
|
2887 @example
|
|
2888 23117 toolbar-x.c
|
|
2889 43456 toolbar.c
|
|
2890 4280 toolbar.h
|
|
2891 @end example
|
|
2892
|
|
2893
|
|
2894
|
|
2895 @example
|
|
2896 25070 font-lock.c
|
|
2897 @end example
|
|
2898
|
|
2899 This file provides C support for syntax highlighting -- i.e.
|
|
2900 highlighting different syntactic constructs of a source file in
|
|
2901 different colors, for easy reading. The C support is provided so that
|
|
2902 this is fast.
|
|
2903
|
|
2904
|
|
2905
|
|
2906 @example
|
|
2907 32180 dgif_lib.c
|
|
2908 3999 gif_err.c
|
|
2909 10697 gif_lib.h
|
|
2910 9371 gifalloc.c
|
|
2911 @end example
|
|
2912
|
|
2913 These modules decode GIF-format image files, for use with glyphs.
|
|
2914
|
|
2915
|
|
2916
|
|
2917 @node Modules for the Redisplay Mechanism
|
|
2918 @section Modules for the Redisplay Mechanism
|
|
2919
|
|
2920 @example
|
|
2921 size name
|
|
2922 ------- ---------------------
|
|
2923 38692 redisplay-output.c
|
|
2924 40835 redisplay-tty.c
|
|
2925 65069 redisplay-x.c
|
|
2926 234142 redisplay.c
|
|
2927 17026 redisplay.h
|
|
2928 @end example
|
|
2929
|
|
2930 These files provide the redisplay mechanism. As with many other
|
|
2931 subsystems in XEmacs, there is a clean separation between the general
|
|
2932 and device-specific support.
|
|
2933
|
|
2934 @file{redisplay.c} contains the bulk of the redisplay engine. These
|
|
2935 functions update the redisplay structures (which describe how the screen
|
|
2936 is to appear) to reflect any changes made to the state of any
|
|
2937 displayable objects (buffer, frame, window, etc.) since the last time
|
|
2938 that redisplay was called. These functions are highly optimized to
|
|
2939 avoid doing more work than necessary (since redisplay is called
|
|
2940 extremely often and is potentially a huge time sink), and depend heavily
|
|
2941 on notifications from the objects themselves that changes have occurred,
|
|
2942 so that redisplay doesn't explicitly have to check each possible object.
|
|
2943 The redisplay mechanism also contains a great deal of caching to further
|
|
2944 speed things up; some of this caching is contained within the various
|
|
2945 displayable objects.
|
|
2946
|
|
2947 @file{redisplay-output.c} goes through the redisplay structures and converts
|
|
2948 them into calls to device-specific methods to actually output the screen
|
|
2949 changes.
|
|
2950
|
|
2951 @file{redisplay-x.c} and @file{redisplay-tty.c} are two implementations
|
|
2952 of these redisplay output methods, for X frames and TTY frames,
|
|
2953 respectively.
|
|
2954
|
|
2955
|
|
2956
|
|
2957 @example
|
|
2958 14129 indent.c
|
|
2959 @end example
|
|
2960
|
|
2961 This module contains various functions and Lisp primitives for
|
|
2962 converting between buffer positions and screen positions. These
|
|
2963 functions call the redisplay mechanism to do most of the work, and then
|
|
2964 examine the redisplay structures to get the necessary information. This
|
|
2965 module needs work.
|
|
2966
|
|
2967
|
|
2968
|
|
2969 @example
|
|
2970 14754 termcap.c
|
|
2971 2141 terminfo.c
|
|
2972 7253 tparam.c
|
|
2973 @end example
|
|
2974
|
|
2975 These files contain functions for working with the termcap (BSD-style)
|
|
2976 and terminfo (System V style) databases of terminal capabilities and
|
|
2977 escape sequences, used when XEmacs is displaying in a TTY.
|
|
2978
|
|
2979
|
|
2980
|
|
2981 @example
|
|
2982 10869 cm.c
|
|
2983 5876 cm.h
|
|
2984 @end example
|
|
2985
|
|
2986 These files provide some miscellaneous TTY-output functions and should
|
|
2987 probably be merged into @file{redisplay-tty.c}.
|
|
2988
|
|
2989
|
|
2990
|
|
2991 @node Modules for Interfacing with the File System
|
|
2992 @section Modules for Interfacing with the File System
|
|
2993
|
|
2994 @example
|
|
2995 size name
|
|
2996 ------- ---------------------
|
|
2997 43362 lstream.c
|
|
2998 14240 lstream.h
|
|
2999 @end example
|
|
3000
|
2
|
3001 These modules implement the @dfn{stream} Lisp object type. This is an
|
0
|
3002 internal-only Lisp object that implements a generic buffering stream.
|
|
3003 The idea is to provide a uniform interface onto all sources and sinks of
|
|
3004 data, including file descriptors, stdio streams, chunks of memory, Lisp
|
|
3005 buffers, Lisp strings, etc. That way, I/O functions can be written to
|
|
3006 the stream interface and can transparently handle all possible sources
|
|
3007 and sinks. (For example, the @code{read} function can read data from a
|
|
3008 file, a string, a buffer, or even a function that is called repeatedly
|
|
3009 to return data, without worrying about where the data is coming from or
|
|
3010 what-size chunks it is returned in.)
|
|
3011
|
|
3012 @cindex lstream
|
|
3013 Note that in the C code, streams are called @dfn{lstreams} (for ``Lisp
|
|
3014 streams'') to distinguish them from other kinds of streams, e.g. stdio
|
|
3015 streams and C++ I/O streams.
|
|
3016
|
|
3017 Similar to other subsystems in XEmacs, lstreams are separated into
|
|
3018 generic functions and a set of methods for the different types of
|
|
3019 lstreams. @file{lstream.c} provides implementations of many different
|
|
3020 types of streams; others are provided, e.g., in @file{mule-coding.c}.
|
|
3021
|
|
3022
|
|
3023
|
|
3024 @example
|
|
3025 126926 fileio.c
|
|
3026 @end example
|
|
3027
|
|
3028 This implements the basic primitives for interfacing with the file
|
|
3029 system. This includes primitives for reading files into buffers,
|
|
3030 writing buffers into files, checking for the presence or accessibility
|
|
3031 of files, canonicalizing file names, etc. Note that these primitives
|
|
3032 are usually not invoked directly by the user: There is a great deal of
|
|
3033 higher-level Lisp code that implements the user commands such as
|
|
3034 @code{find-file} and @code{save-buffer}. This is similar to the
|
|
3035 distinction between the lower-level primitives in @file{editfns.c} and
|
|
3036 the higher-level user commands in @file{commands.c} and
|
|
3037 @file{simple.el}.
|
|
3038
|
|
3039
|
|
3040
|
|
3041 @example
|
|
3042 10960 filelock.c
|
|
3043 @end example
|
|
3044
|
|
3045 This file provides functions for detecting clashes between different
|
|
3046 processes (e.g. XEmacs and some external process, or two different
|
|
3047 XEmacs processes) modifying the same file. (XEmacs can optionally use
|
|
3048 the @file{lock/} subdirectory to provide a form of ``locking'' between
|
|
3049 different XEmacs processes.) This module is also used by the low-level
|
|
3050 functions in @file{insdel.c} to ensure that, if the first modification
|
|
3051 is being made to a buffer whose corresponding file has been externally
|
|
3052 modified, the user is made aware of this so that the buffer can be
|
|
3053 synched up with the external changes if necessary.
|
|
3054
|
|
3055
|
|
3056 @example
|
|
3057 4527 filemode.c
|
|
3058 @end example
|
|
3059
|
|
3060 This file provides some miscellaneous functions that construct a
|
|
3061 @samp{rwxr-xr-x}-type permissions string (as might appear in an
|
|
3062 @file{ls}-style directory listing) given the information returned by the
|
|
3063 @code{stat()} system call.
|
|
3064
|
|
3065
|
|
3066
|
|
3067 @example
|
|
3068 22855 dired.c
|
|
3069 2094 ndir.h
|
|
3070 @end example
|
|
3071
|
|
3072 These files implement the XEmacs interface to directory searching. This
|
|
3073 includes a number of primitives for determining the files in a directory
|
|
3074 and for doing filename completion. (Remember that generic completion is
|
|
3075 handled by a different mechanism, in @file{minibuf.c}.)
|
|
3076
|
|
3077 @file{ndir.h} is a header file used for the directory-searching
|
|
3078 emulation functions provided in @file{sysdep.c} (see section J below),
|
|
3079 for systems that don't provide any directory-searching functions. (On
|
|
3080 those systems, directories can be read directly as files, and parsed.)
|
|
3081
|
|
3082
|
|
3083
|
|
3084 @example
|
|
3085 4311 realpath.c
|
|
3086 @end example
|
|
3087
|
|
3088 This file provides an implementation of the @code{realpath()} function
|
|
3089 for expanding symbolic links, on systems that don't implement it or have
|
|
3090 a broken implementation.
|
|
3091
|
|
3092
|
|
3093
|
|
3094 @node Modules for Other Aspects of the Lisp Interpreter and Object System
|
|
3095 @section Modules for Other Aspects of the Lisp Interpreter and Object System
|
|
3096
|
|
3097 @example
|
|
3098 size name
|
|
3099 ------- ---------------------
|
|
3100 22290 elhash.c
|
|
3101 2454 elhash.h
|
|
3102 12169 hash.c
|
|
3103 3369 hash.h
|
|
3104 @end example
|
|
3105
|
2
|
3106 These files implement the @dfn{hashtable} Lisp object type.
|
|
3107 @file{hash.c} and @file{hash.h} provide a generic C implementation of
|
|
3108 hash tables (which can stand independently of XEmacs), and
|
|
3109 @file{elhash.c} and @file{elhash.h} provide a Lisp interface onto the C
|
|
3110 hash tables using the hashtable Lisp object type.
|
0
|
3111
|
|
3112
|
|
3113
|
|
3114 @example
|
|
3115 95691 specifier.c
|
|
3116 11167 specifier.h
|
|
3117 @end example
|
|
3118
|
2
|
3119 This module implements the @dfn{specifier} Lisp object type. This is
|
0
|
3120 primarily used for displayable properties, and allows for values that
|
|
3121 are specific to a particular buffer, window, frame, device, or device
|
|
3122 class, as well as a default value existing. This is used, for example,
|
|
3123 to control the height of the horizontal scrollbar or the appearance of
|
|
3124 the @code{default}, @code{bold}, or other faces. The specifier object
|
|
3125 consists of a number of specifications, each of which maps from a
|
|
3126 buffer, window, etc. to a value. The function @code{specifier-instance}
|
|
3127 looks up a value given a window (from which a buffer, frame, and device
|
|
3128 can be derived).
|
|
3129
|
|
3130
|
|
3131 @example
|
|
3132 43058 chartab.c
|
|
3133 6503 chartab.h
|
|
3134 9918 casetab.c
|
|
3135 @end example
|
|
3136
|
44
|
3137 @file{chartab.c} and @file{chartab.h} implement the @dfn{char table}
|
|
3138 Lisp object type, which maps from characters or certain sorts of
|
|
3139 character ranges to Lisp objects. The implementation of this object
|
|
3140 type is optimized for the internal representation of characters. Char
|
|
3141 tables come in different types, which affect the allowed object types to
|
|
3142 which a character can be mapped and also dictate certain other
|
|
3143 properties of the char table.
|
0
|
3144
|
|
3145 @cindex case table
|
|
3146 @file{casetab.c} implements one sort of char table, the @dfn{case
|
|
3147 table}, which maps characters to other characters of possibly different
|
|
3148 case. These are used by XEmacs to implement case-changing primitives
|
|
3149 and to do case-insensitive searching.
|
|
3150
|
|
3151
|
|
3152
|
|
3153 @example
|
|
3154 49593 syntax.c
|
|
3155 10200 syntax.h
|
|
3156 @end example
|
|
3157
|
|
3158 @cindex scanner
|
44
|
3159 This module implements @dfn{syntax tables}, another sort of char table
|
|
3160 that maps characters into syntax classes that define the syntax of these
|
|
3161 characters (e.g. a parenthesis belongs to a class of @samp{open}
|
|
3162 characters that have corresponding @samp{close} characters and can be
|
|
3163 nested). This module also implements the Lisp @dfn{scanner}, a set of
|
|
3164 primitives for scanning over text based on syntax tables. This is used,
|
|
3165 for example, to find the matching parenthesis in a command such as
|
0
|
3166 @code{forward-sexp}, and by @file{font-lock.c} to locate quoted strings,
|
|
3167 comments, etc.
|
|
3168
|
|
3169
|
|
3170
|
|
3171 @example
|
|
3172 10438 casefiddle.c
|
|
3173 @end example
|
|
3174
|
|
3175 This module implements various Lisp primitives for upcasing, downcasing
|
|
3176 and capitalizing strings or regions of buffers.
|
|
3177
|
|
3178
|
|
3179
|
|
3180 @example
|
|
3181 20234 rangetab.c
|
|
3182 @end example
|
|
3183
|
2
|
3184 This module implements the @dfn{range table} Lisp object type, which
|
|
3185 provides for a mapping from ranges of integers to arbitrary Lisp
|
|
3186 objects.
|
0
|
3187
|
|
3188
|
|
3189
|
|
3190 @example
|
|
3191 3201 opaque.c
|
|
3192 2206 opaque.h
|
|
3193 @end example
|
|
3194
|
2
|
3195 This module implements the @dfn{opaque} Lisp object type, an
|
|
3196 internal-only Lisp object that encapsulates an arbitrary block of memory
|
|
3197 so that it can be managed by the Lisp allocation system. To create an
|
|
3198 opaque object, you call @code{make_opaque()}, passing a pointer to a
|
|
3199 block of memory. An object is created that is big enough to hold the
|
|
3200 memory, which is copied into the object's storage. The object will then
|
|
3201 stick around as long as you keep pointers to it, after which it will be
|
0
|
3202 automatically reclaimed.
|
|
3203
|
|
3204 @cindex mark method
|
|
3205 Opaque objects can also have an arbitrary @dfn{mark method} associated
|
|
3206 with them, in case the block of memory contains other Lisp objects that
|
|
3207 need to be marked for garbage-collection purposes. (If you need other
|
|
3208 object methods, such as a finalize method, you should just go ahead and
|
|
3209 create a new Lisp object type -- it's not hard.)
|
|
3210
|
|
3211
|
|
3212
|
|
3213 @example
|
|
3214 8783 abbrev.c
|
|
3215 @end example
|
|
3216
|
|
3217 This function provides a few primitives for doing dynamic abbreviation
|
|
3218 expansion. In XEmacs, most of the code for this has been moved into
|
|
3219 Lisp. Some C code remains for speed and because the primitive
|
|
3220 @code{self-insert-command} (which is executed for all self-inserting
|
|
3221 characters) hooks into the abbrev mechanism. (@code{self-insert-command}
|
|
3222 is itself in C only for speed.)
|
|
3223
|
|
3224
|
|
3225
|
|
3226 @example
|
|
3227 21934 doc.c
|
|
3228 @end example
|
|
3229
|
|
3230 This function provides primitives for retrieving the documentation
|
|
3231 strings of functions and variables. These documentation strings contain
|
|
3232 certain special markers that get dynamically expanded (e.g. a
|
|
3233 reverse-lookup is performed on some named functions to retrieve their
|
|
3234 current key bindings). Some documentation strings (in particular, for
|
|
3235 the built-in primitives and pre-loaded Lisp functions) are stored
|
|
3236 externally in a file @file{DOC} in the @file{lib-src/} directory and
|
|
3237 need to be fetched from that file. (Part of the build stage involves
|
|
3238 building this file, and another part involves constructing an index for
|
|
3239 this file and embedding it into the executable, so that the functions in
|
|
3240 @file{doc.c} do not have to search the entire @file{DOC} file to find
|
|
3241 the appropriate documentation string.)
|
|
3242
|
|
3243
|
|
3244
|
|
3245 @example
|
|
3246 13197 md5.c
|
|
3247 @end example
|
|
3248
|
|
3249 This function provides a Lisp primitive that implements the MD5 secure
|
|
3250 hashing scheme, used to create a large hash value of a string of data such that
|
|
3251 the data cannot be derived from the hash value. This is used for
|
|
3252 various security applications on the Internet.
|
|
3253
|
|
3254
|
|
3255
|
|
3256 @example
|
|
3257 7000 mocklisp.c
|
|
3258 @end example
|
|
3259
|
|
3260 This function provides some emulation of MockLisp, a version of Lisp
|
|
3261 provided in Gosling Emacs (aka Unipress Emacs), from which some old
|
|
3262 versions of GNU Emacs were derived. You have to explicitly enable this
|
|
3263 code with a configure option and shouldn't normally, because it changes
|
|
3264 the semantics of XEmacs Lisp in ways that are not desirable for normal
|
|
3265 Lisp programs.
|
|
3266
|
|
3267
|
|
3268
|
|
3269 @node Modules for Interfacing with the Operating System
|
|
3270 @section Modules for Interfacing with the Operating System
|
|
3271
|
|
3272 @example
|
|
3273 size name
|
|
3274 ------- ---------------------
|
|
3275 33533 callproc.c
|
|
3276 89697 process.c
|
|
3277 4663 process.h
|
|
3278 @end example
|
|
3279
|
|
3280 These modules allow XEmacs to spawn and communicate with subprocesses
|
|
3281 and network connections.
|
|
3282
|
|
3283 @cindex synchronous subprocesses
|
|
3284 @cindex subprocesses, synchronous
|
|
3285 @file{callproc.c} implements (through the @code{call-process}
|
|
3286 primitive) what are called @dfn{synchronous subprocesses}. This means
|
|
3287 that XEmacs runs a program, waits till it's done, and retrieves its
|
|
3288 output. A typical example might be calling the @file{ls} program to get
|
|
3289 a directory listing.
|
|
3290
|
|
3291 @cindex asynchronous subprocesses
|
|
3292 @cindex subprocesses, asynchronous
|
|
3293 @file{process.c} and @file{process.h} implement @dfn{asynchronous
|
|
3294 subprocesses}. This means that XEmacs starts a program and then
|
|
3295 continues normally, not waiting for the process to finish. Data can be
|
|
3296 sent to the process or retrieved from it as it's running. This is used
|
|
3297 for the @code{shell} command (which provides a front end onto a shell
|
|
3298 program such as @file{csh}), the mail and news readers implemented in
|
|
3299 XEmacs, etc. The result of calling @code{start-process} to start a
|
|
3300 subprocess is a process object, a particular kind of object used to
|
|
3301 communicate with the subprocess. You can send data to the process by
|
|
3302 passing the process object and the data to @code{send-process}, and you
|
|
3303 can specify what happens to data retrieved from the process by setting
|
|
3304 properties of the process object. (When the process sends data, XEmacs
|
|
3305 receives a process event, which says that there is data ready. When
|
|
3306 @code{dispatch-event} is called on this event, it reads the data from
|
|
3307 the process and does something with it, as specified by the process
|
|
3308 object's properties. Typically, this means inserting the data into a
|
|
3309 buffer or calling a function.) Another property of the process object is
|
|
3310 called the @dfn{sentinel}, which is a function that is called when the
|
|
3311 process terminates.
|
|
3312
|
|
3313 @cindex network connections
|
|
3314 Process objects are also used for network connections (connections to a
|
|
3315 process running on another machine). Network connections are started
|
|
3316 with @code{open-network-stream} but otherwise work just like
|
|
3317 subprocesses.
|
|
3318
|
|
3319
|
|
3320
|
|
3321 @example
|
|
3322 136029 sysdep.c
|
|
3323 5986 sysdep.h
|
|
3324 @end example
|
|
3325
|
|
3326 These modules implement most of the low-level, messy operating-system
|
|
3327 interface code. This includes various device control (ioctl) operations
|
|
3328 for file descriptors, TTY's, pseudo-terminals, etc. (usually this stuff
|
|
3329 is fairly system-dependent; thus the name of this module), and emulation
|
|
3330 of standard library functions and system calls on systems that don't
|
|
3331 provide them or have broken versions.
|
|
3332
|
|
3333
|
|
3334
|
|
3335 @example
|
|
3336 3605 sysdir.h
|
|
3337 6708 sysfile.h
|
|
3338 2027 sysfloat.h
|
|
3339 2918 sysproc.h
|
|
3340 745 syspwd.h
|
|
3341 7643 syssignal.h
|
|
3342 6892 systime.h
|
|
3343 12477 systty.h
|
|
3344 3487 syswait.h
|
|
3345 @end example
|
|
3346
|
|
3347 These header files provide consistent interfaces onto system-dependent
|
|
3348 header files and system calls. The idea is that, instead of including a
|
|
3349 standard header file like @file{<sys/param.h>} (which may or may not
|
|
3350 exist on various systems) or having to worry about whether all system
|
|
3351 provide a particular preprocessor constant, or having to deal with the
|
|
3352 four different paradigms for manipulating signals, you just include the
|
|
3353 appropriate @file{sys*.h} header file, which includes all the right
|
|
3354 system header files, defines and missing preprocessor constants,
|
|
3355 provides a uniform interface onto system calls, etc.
|
|
3356
|
|
3357 @file{sysdir.h} provides a uniform interface onto directory-querying
|
|
3358 functions. (In some cases, this is in conjunction with emulation
|
|
3359 functions in @file{sysdep.c}.)
|
|
3360
|
|
3361 @file{sysfile.h} includes all the necessary header files for standard
|
|
3362 system calls (e.g. @code{read()}), ensures that all necessary
|
|
3363 @code{open()} and @code{stat()} preprocessor constants are defined, and
|
|
3364 possibly (usually) substitutes sugared versions of @code{read()},
|
|
3365 @code{write()}, etc. that automatically restart interrupted I/O
|
|
3366 operations.
|
|
3367
|
|
3368 @file{sysfloat.h} includes the necessary header files for floating-point
|
|
3369 operations.
|
|
3370
|
|
3371 @file{sysproc.h} includes the necessary header files for calling
|
|
3372 @code{select()}, @code{fork()}, @code{execve()}, socket operations, and
|
|
3373 the like, and ensures that the @code{FD_*()} macros for descriptor-set
|
|
3374 manipulations are available.
|
|
3375
|
|
3376 @file{syspwd.h} includes the necessary header files for obtaining
|
|
3377 information from @file{/etc/passwd} (the functions are emulated under
|
|
3378 VMS).
|
|
3379
|
|
3380 @file{syssignal.h} includes the necessary header files for
|
|
3381 signal-handling and provides a uniform interface onto the different
|
|
3382 signal-handling and signal-blocking paradigms.
|
|
3383
|
|
3384 @file{systime.h} includes the necessary header files and provides
|
|
3385 uniform interfaces for retrieving the time of day, setting file
|
|
3386 access/modification times, getting the amount of time used by the XEmacs
|
|
3387 process, etc.
|
|
3388
|
|
3389 @file{systty.h} buffers against the infinitude of different ways of
|
|
3390 controlling TTY's.
|
|
3391
|
|
3392 @file{syswait.h} provides a uniform way of retrieving the exit status
|
|
3393 from a @code{wait()}ed-on process (some systems use a union, others use
|
|
3394 an int).
|
|
3395
|
|
3396
|
|
3397
|
|
3398 @example
|
|
3399 7940 hpplay.c
|
|
3400 10920 libsst.c
|
|
3401 1480 libsst.h
|
|
3402 3260 libst.h
|
|
3403 15355 linuxplay.c
|
|
3404 15849 nas.c
|
|
3405 19133 sgiplay.c
|
|
3406 15411 sound.c
|
|
3407 7358 sunplay.c
|
|
3408 @end example
|
|
3409
|
|
3410 These files implement the ability to play various sounds on some types
|
|
3411 of computers. You have to configure your XEmacs with sound support in
|
|
3412 order to get this capability.
|
|
3413
|
|
3414 @file{sound.c} provides the generic interface. It implements various
|
|
3415 Lisp primitives and variables that let you specify which sounds should
|
|
3416 be played in certain conditions. (The conditions are identified by
|
|
3417 symbols, which are passed to @code{ding} to make a sound. Various
|
|
3418 standard functions call this function at certain times; if sound support
|
|
3419 does not exist, a simple beep results.
|
|
3420
|
|
3421 @cindex native sound
|
|
3422 @cindex sound, native
|
|
3423 @file{sgiplay.c}, @file{sunplay.c}, @file{hpplay.c}, and
|
|
3424 @file{linuxplay.c} interface to the machine's speaker for various
|
|
3425 different kind of machines. This is called @dfn{native} sound.
|
|
3426
|
|
3427 @cindex sound, network
|
|
3428 @cindex network sound
|
|
3429 @cindex NAS
|
|
3430 @file{nas.c} interfaces to a computer somewhere else on the network
|
|
3431 using the NAS (Network Audio Server) protocol, playing sounds on that
|
|
3432 machine. This allows you to run XEmacs on a remote machine, with its
|
|
3433 display set to your local machine, and have the sounds be made on your
|
|
3434 local machine, provided that you have a NAS server running on your local
|
|
3435 machine.
|
|
3436
|
|
3437 @file{libsst.c}, @file{libsst.h}, and @file{libst.h} provide some
|
|
3438 additional functions for playing sound on a Sun SPARC but are not
|
|
3439 currently in use.
|
|
3440
|
|
3441
|
|
3442
|
|
3443 @example
|
|
3444 44368 tooltalk.c
|
|
3445 2137 tooltalk.h
|
|
3446 @end example
|
|
3447
|
|
3448 These two modules implement an interface to the ToolTalk protocol, which
|
|
3449 is an interprocess communication protocol implemented on some versions
|
|
3450 of Unix. ToolTalk is a high-level protocol that allows processes to
|
|
3451 register themselves as providers of particular services; other processes
|
|
3452 can then request a service without knowing or caring exactly who is
|
|
3453 providing the service. It is similar in spirit to the DDE protocol
|
|
3454 provided under Microsoft Windows. ToolTalk is a part of the new CDE
|
|
3455 (Common Desktop Environment) specification and is used to connect the
|
|
3456 parts of the SPARCWorks development environment.
|
|
3457
|
|
3458
|
|
3459
|
|
3460 @example
|
|
3461 22695 getloadavg.c
|
|
3462 @end example
|
|
3463
|
|
3464 This module provides the ability to retrieve the system's current load
|
|
3465 average. (The way to do this is highly system-specific, unfortunately,
|
|
3466 and requires a lot of special-case code.)
|
|
3467
|
|
3468
|
|
3469
|
|
3470 @example
|
|
3471 148520 energize.c
|
|
3472 6896 energize.h
|
|
3473 @end example
|
|
3474
|
|
3475 This module provides code to interface to an Energize server (when
|
|
3476 XEmacs is used as part of Lucid's Energize development environment) and
|
|
3477 provides some other Energize-specific functions. Much of the code in
|
|
3478 this module should be made more general-purpose and moved elsewhere, but
|
|
3479 is no longer very relevant now that Lucid is defunct. It also hasn't
|
|
3480 worked since version 19.12, since nobody has been maintaining it.
|
|
3481
|
|
3482
|
|
3483
|
|
3484 @example
|
|
3485 2861 sunpro.c
|
|
3486 @end example
|
|
3487
|
|
3488 This module provides a small amount of code used internally at Sun to
|
|
3489 keep statistics on the usage of XEmacs.
|
|
3490
|
|
3491
|
|
3492
|
|
3493 @example
|
|
3494 5548 broken-sun.h
|
|
3495 3468 strcmp.c
|
|
3496 2179 strcpy.c
|
|
3497 1650 sunOS-fix.c
|
|
3498 @end example
|
|
3499
|
|
3500 These files provide replacement functions and prototypes to fix numerous
|
|
3501 bugs in early releases of SunOS 4.1.
|
|
3502
|
|
3503
|
|
3504
|
|
3505 @example
|
|
3506 11669 hftctl.c
|
|
3507 @end example
|
|
3508
|
|
3509 This module provides some terminal-control code necessary on versions of
|
|
3510 AIX prior to 4.1.
|
|
3511
|
|
3512
|
|
3513
|
|
3514 @example
|
|
3515 1776 acldef.h
|
|
3516 1602 chpdef.h
|
|
3517 9032 uaf.h
|
|
3518 105 vlimit.h
|
|
3519 7145 vms-pp.c
|
|
3520 1158 vms-pwd.h
|
|
3521 26532 vmsfns.c
|
|
3522 6038 vmsmap.c
|
|
3523 695 vmspaths.h
|
|
3524 17482 vmsproc.c
|
|
3525 469 vmsproc.h
|
|
3526 @end example
|
|
3527
|
|
3528 All of these files are used for VMS support, which has never worked in
|
|
3529 XEmacs.
|
|
3530
|
|
3531
|
|
3532
|
|
3533 @example
|
|
3534 28316 msdos.c
|
|
3535 1472 msdos.h
|
|
3536 @end example
|
|
3537
|
|
3538 These modules are used for MS-DOS support, which does not work in
|
|
3539 XEmacs.
|
|
3540
|
|
3541
|
|
3542
|
|
3543 @node Modules for Interfacing with X Windows
|
|
3544 @section Modules for Interfacing with X Windows
|
|
3545
|
|
3546 @example
|
|
3547 size name
|
|
3548 ------- ---------------------
|
|
3549 3196 Emacs.ad.h
|
|
3550 @end example
|
|
3551
|
|
3552 A file generated from @file{Emacs.ad}, which contains XEmacs-supplied
|
|
3553 fallback resources (so that XEmacs has pretty defaults).
|
|
3554
|
|
3555
|
|
3556
|
|
3557 @example
|
|
3558 24242 EmacsFrame.c
|
|
3559 6979 EmacsFrame.h
|
|
3560 3351 EmacsFrameP.h
|
|
3561 @end example
|
|
3562
|
|
3563 These modules implement an Xt widget class that encapsulates a frame.
|
|
3564 This is for ease in integrating with Xt. The EmacsFrame widget covers
|
|
3565 the entire X window except for the menubar; the scrollbars are
|
|
3566 positioned on top of the EmacsFrame widget.
|
|
3567
|
|
3568 @strong{Warning:} Abandon hope, all ye who enter here. This code took
|
|
3569 an ungodly amount of time to get right, and is likely to fall apart
|
|
3570 mercilessly at the slightest change. Such is life under Xt.
|
|
3571
|
|
3572
|
|
3573
|
|
3574 @example
|
|
3575 8178 EmacsManager.c
|
|
3576 1967 EmacsManager.h
|
|
3577 1895 EmacsManagerP.h
|
|
3578 @end example
|
|
3579
|
|
3580 These modules implement a simple Xt manager (i.e. composite) widget
|
|
3581 class that simply lets its children set whatever geometry they want.
|
|
3582 It's amazing that Xt doesn't provide this standardly, but on second
|
|
3583 thought, it makes sense, considering how amazingly broken Xt is.
|
|
3584
|
|
3585
|
|
3586 @example
|
|
3587 13188 EmacsShell-sub.c
|
|
3588 4588 EmacsShell.c
|
|
3589 2180 EmacsShell.h
|
|
3590 3133 EmacsShellP.h
|
|
3591 @end example
|
|
3592
|
|
3593 These modules implement two Xt widget classes that are subclasses of
|
|
3594 the TopLevelShell and TransientShell classes. This is necessary to deal
|
|
3595 with more brokenness that Xt has sadistically thrust onto the backs of
|
|
3596 developers.
|
|
3597
|
|
3598
|
|
3599
|
|
3600 @example
|
|
3601 9673 xgccache.c
|
|
3602 1111 xgccache.h
|
|
3603 @end example
|
|
3604
|
|
3605 These modules provide functions for maintenance and caching of GC's
|
|
3606 (graphics contexts) under the X Window System. This code is junky and
|
|
3607 needs to be rewritten.
|
|
3608
|
|
3609
|
|
3610
|
|
3611 @example
|
|
3612 69181 xselect.c
|
|
3613 @end example
|
|
3614
|
|
3615 @cindex selections
|
|
3616 This module provides an interface to the X Window System's concept of
|
|
3617 @dfn{selections}, the standard way for X applications to communicate
|
|
3618 with each other.
|
|
3619
|
|
3620
|
|
3621
|
|
3622 @example
|
|
3623 929 xintrinsic.h
|
|
3624 1038 xintrinsicp.h
|
|
3625 1579 xmmanagerp.h
|
|
3626 1585 xmprimitivep.h
|
|
3627 @end example
|
|
3628
|
|
3629 These header files are similar in spirit to the @file{sys*.h} files and buffer
|
|
3630 against different implementations of Xt and Motif.
|
|
3631
|
|
3632 @itemize @bullet
|
|
3633 @item
|
|
3634 @file{xintrinsic.h} should be included in place of @file{<Intrinsic.h>}.
|
|
3635 @item
|
|
3636 @file{xintrinsicp.h} should be included in place of @file{<IntrinsicP.h>}.
|
|
3637 @item
|
|
3638 @file{xmmanagerp.h} should be included in place of @file{<XmManagerP.h>}.
|
|
3639 @item
|
|
3640 @file{xmprimitivep.h} should be included in place of @file{<XmPrimitiveP.h>}.
|
|
3641 @end itemize
|
|
3642
|
|
3643
|
|
3644
|
|
3645 @example
|
|
3646 16930 xmu.c
|
|
3647 936 xmu.h
|
|
3648 @end example
|
|
3649
|
|
3650 These files provide an emulation of the Xmu library for those systems
|
|
3651 (i.e. HPUX) that don't provide it as a standard part of X.
|
|
3652
|
|
3653
|
|
3654
|
|
3655 @example
|
|
3656 4201 ExternalClient-Xlib.c
|
|
3657 18083 ExternalClient.c
|
|
3658 2035 ExternalClient.h
|
|
3659 2104 ExternalClientP.h
|
|
3660 22684 ExternalShell.c
|
|
3661 1709 ExternalShell.h
|
|
3662 1971 ExternalShellP.h
|
|
3663 2478 extw-Xlib.c
|
|
3664 1481 extw-Xlib.h
|
|
3665 6565 extw-Xt.c
|
|
3666 1430 extw-Xt.h
|
|
3667 @end example
|
|
3668
|
|
3669 @cindex external widget
|
|
3670 These files provide the @dfn{external widget} interface, which allows an
|
|
3671 XEmacs frame to appear as a widget in another application. To do this,
|
|
3672 you have to configure with @samp{--external-widget}.
|
|
3673
|
|
3674 @file{ExternalShell*} provides the server (XEmacs) side of the
|
|
3675 connection.
|
|
3676
|
|
3677 @file{ExternalClient*} provides the client (other application) side of
|
|
3678 the connection. These files are not compiled into XEmacs but are
|
|
3679 compiled into libraries that are then linked into your application.
|
|
3680
|
|
3681 @file{extw-*} is common code that is used for both the client and server.
|
|
3682
|
|
3683 Don't touch this code; something is liable to break if you do.
|
|
3684
|
|
3685
|
|
3686
|
|
3687 @example
|
|
3688 31014 epoch.c
|
|
3689 @end example
|
|
3690
|
|
3691 This file provides some additional, Epoch-compatible, functionality for
|
|
3692 interfacing to the X Window System.
|
|
3693
|
|
3694
|
|
3695
|
|
3696 @node Modules for Internationalization
|
|
3697 @section Modules for Internationalization
|
|
3698
|
|
3699 @example
|
|
3700 size name
|
|
3701 ------- ---------------------
|
|
3702 42836 mule-canna.c
|
|
3703 16737 mule-ccl.c
|
|
3704 41080 mule-charset.c
|
|
3705 30176 mule-charset.h
|
|
3706 146844 mule-coding.c
|
|
3707 16588 mule-coding.h
|
|
3708 6996 mule-mcpath.c
|
|
3709 2899 mule-mcpath.h
|
|
3710 57158 mule-wnnfns.c
|
|
3711 3351 mule.c
|
|
3712 @end example
|
|
3713
|
|
3714 These files implement the MULE (Asian-language) support. Note that MULE
|
|
3715 actually provides a general interface for all sorts of languages, not
|
|
3716 just Asian languages (although they are generally the most complicated
|
|
3717 to support). This code is still in beta.
|
|
3718
|
|
3719 @file{mule-charset.*} and @file{mule-coding.*} provide the heart of the
|
2
|
3720 XEmacs MULE support. @file{mule-charset.*} implements the @dfn{charset}
|
|
3721 Lisp object type, which encapsulates a character set (an ordered one- or
|
|
3722 two-dimensional set of characters, such as US ASCII or JISX0208 Japanese
|
|
3723 Kanji).
|
|
3724
|
|
3725 @file{mule-coding.*} implements the @dfn{coding-system} Lisp object
|
|
3726 type, which encapsulates a method of converting between different
|
44
|
3727 encodings. An encoding is a representation of a stream of characters,
|
|
3728 possibly from multiple character sets, using a stream of bytes or words,
|
|
3729 and defines (e.g.) which escape sequences are used to specify particular
|
2
|
3730 character sets, how the indices for a character are converted into bytes
|
|
3731 (sometimes this involves setting the high bit; sometimes complicated
|
|
3732 rearranging of the values takes place, as in the Shift-JIS encoding),
|
|
3733 etc.
|
0
|
3734
|
|
3735 @file{mule-ccl.c} provides the CCL (Code Conversion Language)
|
|
3736 interpreter. CCL is similar in spirit to Lisp byte code and is used to
|
|
3737 implement converters for custom encodings.
|
|
3738
|
|
3739 @file{mule-canna.c} and @file{mule-wnnfns.c} implement interfaces to
|
|
3740 external programs used to implement the Canna and WNN input methods,
|
44
|
3741 respectively. This is currently in beta.
|
|
3742
|
|
3743 @file{mule-mcpath.c} provides some functions to allow for pathnames
|
|
3744 containing extended characters. This code is fragmentary, obsolete, and
|
|
3745 completely non-working. Instead, @var{pathname-coding-system} is used
|
|
3746 to specify conversions of names of files and directories. The standard
|
|
3747 C I/O functions like @samp{open()} are wrapped so that conversion occurs
|
|
3748 automatically.
|
0
|
3749
|
|
3750 @file{mule.c} provides a few miscellaneous things that should probably
|
|
3751 be elsewhere.
|
|
3752
|
|
3753
|
|
3754
|
|
3755 @example
|
|
3756 9400 intl.c
|
|
3757 @end example
|
|
3758
|
|
3759 This provides some miscellaneous internationalization code for
|
|
3760 implementing message translation and interfacing to the Ximp input
|
|
3761 method. None of this code is currently working.
|
|
3762
|
|
3763
|
|
3764
|
|
3765 @example
|
|
3766 1764 iso-wide.h
|
|
3767 @end example
|
|
3768
|
|
3769 This contains leftover code from an earlier implementation of
|
|
3770 Asian-language support, and is not currently used.
|
|
3771
|
|
3772
|
|
3773
|
|
3774
|
|
3775 @node Allocation of Objects in XEmacs Lisp, Events and the Event Loop, A Summary of the Various XEmacs Modules, Top
|
|
3776 @chapter Allocation of Objects in XEmacs Lisp
|
|
3777
|
|
3778 @menu
|
|
3779 * Introduction to Allocation::
|
|
3780 * Garbage Collection::
|
|
3781 * GCPROing::
|
|
3782 * Integers and Characters::
|
|
3783 * Allocation from Frob Blocks::
|
|
3784 * lrecords::
|
|
3785 * Low-level allocation::
|
|
3786 * Pure Space::
|
|
3787 * Cons::
|
|
3788 * Vector::
|
|
3789 * Bit Vector::
|
|
3790 * Symbol::
|
|
3791 * Marker::
|
|
3792 * String::
|
|
3793 * Bytecode::
|
|
3794 @end menu
|
|
3795
|
|
3796 @node Introduction to Allocation
|
|
3797 @section Introduction to Allocation
|
|
3798
|
|
3799 Emacs Lisp, like all Lisps, has garbage collection. This means that
|
|
3800 the programmer never has to explicitly free (destroy) an object; it
|
|
3801 happens automatically when the object becomes inaccessible. Most
|
|
3802 experts agree that garbage collection is a necessity in a modern,
|
|
3803 high-level language. Its omission from C stems from the fact that C was
|
|
3804 originally designed to be a nice abstract layer on top of assembly
|
|
3805 language, for writing kernels and basic system utilities rather than
|
|
3806 large applications.
|
|
3807
|
|
3808 Lisp objects can be created by any of a number of Lisp primitives.
|
|
3809 Most object types have one or a small number of basic primitives
|
|
3810 for creating objects. For conses, the basic primitive is @code{cons};
|
|
3811 for vectors, the primitives are @code{make-vector} and @code{vector}; for
|
|
3812 symbols, the primitives are @code{make-symbol} and @code{intern}; etc.
|
|
3813 Some Lisp objects, especially those that are primarily used internally,
|
|
3814 have no corresponding Lisp primitives. Every Lisp object, though,
|
|
3815 has at least one C primitive for creating it.
|
|
3816
|
|
3817 Recall from section (VII) that a Lisp object, as stored in a 32-bit
|
|
3818 or 64-bit word, has a mark bit, a few tag bits, and a ``value'' that
|
|
3819 occupies the remainder of the bits. We can separate the different
|
|
3820 Lisp object types into four broad categories:
|
|
3821
|
|
3822 @itemize @bullet
|
|
3823 @item
|
|
3824 (a) Those for whom the value directly represents the contents of the
|
|
3825 Lisp object. Only two types are in this category: integers and
|
|
3826 characters. No special allocation or garbage collection is necessary
|
44
|
3827 for such objects. Lisp objects of these types do not need to be
|
|
3828 @code{GCPRO}ed.
|
0
|
3829 @end itemize
|
|
3830
|
|
3831 In the remaining three categories, the value is a pointer to a
|
|
3832 structure.
|
|
3833
|
|
3834 @itemize @bullet
|
|
3835 @item
|
|
3836 @cindex frob block
|
|
3837 (b) Those for whom the tag directly specifies the type. Recall that
|
|
3838 there are only three tag bits; this means that at most five types can be
|
|
3839 specified this way. The most commonly-used types are stored in this
|
|
3840 format; this includes conses, strings, vectors, and sometimes symbols.
|
|
3841 With the exception of vectors, objects in this category are allocated in
|
|
3842 @dfn{frob blocks}, i.e. large blocks of memory that are subdivided into
|
|
3843 individual objects. This saves a lot on malloc overhead, since there
|
|
3844 are typically quite a lot of these objects around, and the objects are
|
|
3845 small. (A cons, for example, occupies 8 bytes on 32-bit machines -- 4
|
|
3846 bytes for each of the two objects it contains.) Vectors are individually
|
|
3847 @code{malloc()}ed since they are of variable size. (It would be
|
|
3848 possible, and desirable, to allocate vectors of certain small sizes out
|
|
3849 of frob blocks, but it isn't currently done.) Strings are handled
|
|
3850 specially: Each string is allocated in two parts, a fixed size structure
|
|
3851 containing a length and a data pointer, and the actual data of the
|
|
3852 string. The former structure is allocated in frob blocks as usual, and
|
|
3853 the latter data is stored in @dfn{string chars blocks} and is relocated
|
|
3854 during garbage collection to eliminate holes.
|
|
3855 @end itemize
|
|
3856
|
|
3857 In the remaining two categories, the type is stored in the object
|
|
3858 itself. The tag for all such objects is the generic @dfn{lrecord}
|
|
3859 (Lisp_Record) tag. The first four bytes (or eight, for 64-bit machines)
|
|
3860 of the object's structure are a pointer to a structure that describes
|
|
3861 the object's type, which includes method pointers and a pointer to a
|
|
3862 string naming the type. Note that it's possible to save some space by
|
|
3863 using a one- or two-byte tag, rather than a four- or eight-byte pointer
|
|
3864 to store the type, but it's not clear it's worth making the change.
|
|
3865
|
|
3866 @itemize @bullet
|
|
3867 @item
|
|
3868 (c) Those lrecords that are allocated in frob blocks (see above). This
|
|
3869 includes the objects that are most common and relatively small, and
|
|
3870 includes floats, bytecodes, symbols (when not in category (b)), extents,
|
|
3871 events, and markers. With the cleanup of frob blocks done in 19.12,
|
|
3872 it's not terribly hard to add more objects to this category, but it's a
|
|
3873 bit trickier than adding an object type to type (d) (esp. if the object
|
|
3874 needs a finalization method), and is not likely to save much space
|
|
3875 unless the object is small and there are many of them. (In fact, if
|
|
3876 there are very few of them, it might actually waste space.)
|
|
3877 @item
|
|
3878 (d) Those lrecords that are individually @code{malloc()}ed. These are
|
|
3879 called @dfn{lcrecords}. All other types are in this category. Adding a
|
|
3880 new type to this category is comparatively easy, and all types added
|
|
3881 since 19.8 (when the current allocation scheme was devised, by Richard
|
|
3882 Mlynarik), with the exception of the character type, have been in this
|
|
3883 category.
|
|
3884 @end itemize
|
|
3885
|
|
3886 Note that bit vectors are a bit of a special case. They are
|
|
3887 simple lrecords as in category (c), but are individually @code{malloc()}ed
|
|
3888 like vectors. You can basically view them as exactly like vectors
|
|
3889 except that their type is stored in lrecord fashion rather than
|
|
3890 in directly-tagged fashion.
|
|
3891
|
|
3892 Note that FSF Emacs redesigned their object system in 19.29 to follow
|
|
3893 a similar scheme. However, given RMS's expressed dislike for data
|
|
3894 abstraction, the FSF scheme is not nearly as clean or as easy to
|
|
3895 extend. (FSF calls items of type (c) @code{Lisp_Misc} and items of type
|
|
3896 (d) @code{Lisp_Vectorlike}, with separate tags for each, although
|
|
3897 @code{Lisp_Vectorlike} is also used for vectors.)
|
|
3898
|
|
3899 @node Garbage Collection
|
|
3900 @section Garbage Collection
|
|
3901 @cindex garbage collection
|
|
3902
|
|
3903 @cindex mark and sweep
|
|
3904 Garbage collection is simple in theory but tricky to implement.
|
|
3905 Emacs Lisp uses the oldest garbage collection method, called
|
|
3906 @dfn{mark and sweep}. Garbage collection begins by starting with
|
|
3907 all accessible locations (i.e. all variables and other slots where
|
|
3908 Lisp objects might occur) and recursively traversing all objects
|
|
3909 accessible from those slots, marking each one that is found.
|
|
3910 We then go through all of memory and free each object that is
|
|
3911 not marked, and unmarking each object that is marked. Note
|
|
3912 that ``all of memory'' means all currently allocated objects.
|
|
3913 Traversing all these objects means traversing all frob blocks,
|
|
3914 all vectors (which are chained in one big list), and all
|
|
3915 lcrecords (which are likewise chained).
|
|
3916
|
|
3917 Note that, when an object is marked, the mark has to occur
|
|
3918 inside of the object's structure, rather than in the 32-bit
|
|
3919 @code{Lisp_Object} holding the object's pointer; i.e. you can't just
|
|
3920 set the pointer's mark bit. This is because there may be many
|
|
3921 pointers to the same object. This means that the method of
|
|
3922 marking an object can differ depending on the type. The
|
|
3923 different marking methods are approximately as follows:
|
|
3924
|
|
3925 @enumerate
|
|
3926 @item
|
|
3927 For conses, the mark bit of the car is set.
|
|
3928 @item
|
|
3929 For strings, the mark bit of the string's plist is set.
|
|
3930 @item
|
|
3931 For symbols when not lrecords, the mark bit of the
|
|
3932 symbol's plist is set.
|
|
3933 @item
|
|
3934 For vectors, the length is negated after adding 1.
|
|
3935 @item
|
|
3936 For lrecords, the pointer to the structure describing
|
|
3937 the type is changed (see below).
|
|
3938 @item
|
|
3939 Integers and characters do not need to be marked, since
|
|
3940 no allocation occurs for them.
|
|
3941 @end enumerate
|
|
3942
|
|
3943 The details of this are in the @code{mark_object()} function.
|
|
3944
|
|
3945 Note that any code that operates during garbage collection has
|
|
3946 to be especially careful because of the fact that some objects
|
|
3947 may be marked and as such may not look like they normally do.
|
|
3948 In particular:
|
|
3949
|
|
3950 @itemize @bullet
|
|
3951 Some object pointers may have their mark bit set. This will make
|
|
3952 @code{FOOBARP()} predicates fail. Use @code{GC_FOOBARP()} to deal with
|
|
3953 this.
|
|
3954 @item
|
|
3955 Even if you clear the mark bit, @code{FOOBARP()} will still fail
|
|
3956 for lrecords because the implementation pointer has been
|
|
3957 changed (see below). @code{GC_FOOBARP()} will correctly deal with
|
|
3958 this.
|
|
3959 @item
|
|
3960 Vectors have their size field munged, so anything that
|
|
3961 looks at this field will fail.
|
|
3962 @item
|
|
3963 Note that @code{XFOOBAR()} macros @emph{will} work correctly on object
|
|
3964 pointers with their mark bit set, because the logical shift operations
|
|
3965 that remove the tag also remove the mark bit.
|
|
3966 @end itemize
|
|
3967
|
|
3968 Finally, note that garbage collection can be invoked explicitly
|
|
3969 by calling @code{garbage-collect} but is also called automatically
|
|
3970 by @code{eval}, once a certain amount of memory has been allocated
|
|
3971 since the last garbage collection (according to @code{gc-cons-threshold}).
|
|
3972
|
|
3973 @node GCPROing
|
|
3974 @section @code{GCPRO}ing
|
|
3975
|
|
3976 @code{GCPRO}ing is one of the ugliest and trickiest parts of Emacs
|
|
3977 internals. The basic idea is that whenever garbage collection
|
|
3978 occurs, all in-use objects must be reachable somehow or
|
|
3979 other from one of the roots of accessibility. The roots
|
|
3980 of accessibility are:
|
|
3981
|
|
3982 @enumerate
|
|
3983 @item
|
|
3984 All objects that have been @code{staticpro()}d. This is used for
|
|
3985 any global C variables that hold Lisp objects. A call to
|
|
3986 @code{staticpro()} happens implicitly as a result of any symbols
|
|
3987 declared with @code{defsymbol()} and any variables declared with
|
|
3988 @code{DEFVAR_FOO()}. You need to explicitly call @code{staticpro()}
|
|
3989 (in the @code{vars_of_foo()} method of a module) for other global
|
|
3990 C variables holding Lisp objects. (This typically includes
|
|
3991 internal lists and such things.)
|
|
3992
|
|
3993 Note that @code{obarray} is one of the @code{staticpro()}d things.
|
|
3994 Therefore, all functions and variables get marked through this.
|
|
3995 @item
|
|
3996 Any shadowed bindings that are sitting on the specpdl stack.
|
|
3997 @item
|
44
|
3998 Any objects sitting in currently active (Lisp) stack frames,
|
0
|
3999 catches, and condition cases.
|
|
4000 @item
|
|
4001 A couple of special-case places where active objects are
|
|
4002 located.
|
|
4003 @item
|
|
4004 Anything currently marked with @code{GCPRO}.
|
|
4005 @end enumerate
|
|
4006
|
|
4007 Marking with @code{GCPRO} is necessary because some C functions (quite
|
|
4008 a lot, in fact), allocate objects during their operation. Quite
|
|
4009 frequently, there will be no other pointer to the object while the
|
|
4010 function is running, and if a garbage collection occurs and the object
|
|
4011 needs to be referenced again, bad things will happen. The solution is
|
|
4012 to mark those objects with @code{GCPRO}. Unfortunately this is easy to
|
|
4013 forget, and there is basically no way around this problem. Here are
|
|
4014 some rules, though:
|
|
4015
|
|
4016 @enumerate
|
|
4017 @item
|
|
4018 For every @code{GCPRO@var{n}}, there have to be declarations of
|
|
4019 @code{struct gcpro gcpro1, gcpro2}, etc.
|
|
4020
|
|
4021 @item
|
|
4022 You @emph{must} @code{UNGCPRO} anything that's @code{GCPRO}ed, and you
|
|
4023 @emph{must not} @code{UNGCPRO} if you haven't @code{GCPRO}ed. Getting
|
|
4024 either of these wrong will lead to crashes, often in completely random
|
|
4025 places unrelated to where the problem lies.
|
|
4026
|
|
4027 @item
|
|
4028 The way this actually works is that all currently active @code{GCPRO}s
|
|
4029 are chained through the @code{struct gcpro} local variables, with the
|
|
4030 variable @samp{gcprolist} pointing to the head of the list and the nth
|
|
4031 local @code{gcpro} variable pointing to the first @code{gcpro} variable
|
|
4032 in the next enclosing stack frame. Each @code{GCPRO}ed thing is an
|
|
4033 lvalue, and the @code{struct gcpro} local variable contains a pointer to
|
|
4034 this lvalue. This is why things will mess up badly if you don't pair up
|
|
4035 the @code{GCPRO}s and @code{UNGCPRO}s -- you will end up with
|
|
4036 @code{gcprolist}s containing pointers to @code{struct gcpro}s or local
|
|
4037 @code{Lisp_Object} variables in no-longer-active stack frames.
|
|
4038
|
|
4039 @item
|
|
4040 It is actually possible for a single @code{struct gcpro} to
|
|
4041 protect a contiguous array of any number of values, rather than
|
|
4042 just a single lvalue. To effect this, call @code{GCPRO@var{n}} as usual on
|
|
4043 the first object in the array and then set @code{gcpron.nvars}.
|
|
4044
|
|
4045 @item
|
|
4046 @strong{Strings are relocated.} What this means in practice is that the
|
44
|
4047 pointer obtained using @code{XSTRING_DATA()} is liable to change at any
|
0
|
4048 time, and you should never keep it around past any function call, or
|
|
4049 pass it as an argument to any function that might cause a garbage
|
|
4050 collection. This is why a number of functions accept either a
|
|
4051 ``non-relocatable'' @code{char *} pointer or a relocatable Lisp string,
|
|
4052 and only access the Lisp string's data at the very last minute. In some
|
|
4053 cases, you may end up having to @code{alloca()} some space and copy the
|
|
4054 string's data into it.
|
|
4055
|
|
4056 @item
|
|
4057 By convention, if you have to nest @code{GCPRO}'s, use @code{NGCPRO@var{n}}
|
|
4058 (along with @code{struct gcpro ngcpro1, ngcpro2}, etc.), @code{NNGCPRO@var{n}},
|
|
4059 etc. This avoids compiler warnings about shadowed locals.
|
|
4060
|
|
4061 @item
|
|
4062 It is @emph{always} better to err on the side of extra @code{GCPRO}s
|
|
4063 rather than too few. The extra cycles spent on this are
|
|
4064 almost never going to make a whit of difference in the
|
|
4065 speed of anything.
|
|
4066
|
|
4067 @item
|
|
4068 The general rule to follow is that caller, not callee, @code{GCPRO}s.
|
|
4069 That is, you should not have to explicitly @code{GCPRO} any Lisp objects
|
|
4070 that are passed in as parameters, but if you create any Lisp objects
|
|
4071 (remember, this happens in all sorts of circumstances, e.g. with
|
|
4072 @code{Fcons()}, etc.), you are responsible for @code{GCPRO}ing the
|
|
4073 objects unless you are @emph{absolutely sure} that there's no
|
|
4074 possibility that a garbage-collection can occur while you need to use
|
|
4075 the object. Even then, consider @code{GCPRO}ing.
|
|
4076
|
|
4077 @item
|
|
4078 A garbage collection can occur whenever anything calls @code{Feval}, or
|
|
4079 whenever a QUIT can occur where execution can continue past
|
|
4080 this. (Remember, this is almost anywhere.)
|
|
4081
|
|
4082 @item
|
|
4083 If you have the @emph{least smidgeon of doubt} about whether
|
|
4084 you need to @code{GCPRO}, you should @code{GCPRO}.
|
|
4085
|
|
4086 @item
|
|
4087 Beware of @code{GCPRO}ing something that is uninitialized. If you have
|
44
|
4088 any shade of doubt about this, initialize all your variables to @code{Qnil}.
|
0
|
4089
|
|
4090 @item
|
|
4091 Be careful of traps, like calling @code{Fcons()} in the argument to
|
|
4092 another function. By the ``caller protects'' law, you should be
|
|
4093 @code{GCPRO}ing the newly-created cons, but you aren't. A certain
|
|
4094 number of functions that are commonly called on freshly created stuff
|
|
4095 (e.g. @code{nconc2()}, @code{Fsignal()}), break the ``caller protects''
|
|
4096 law and go ahead and @code{GCPRO} their arguments so as to simplify
|
|
4097 things, but make sure and check if it's OK whenever doing something like
|
|
4098 this.
|
|
4099
|
|
4100 @item
|
|
4101 Once again, remember to @code{GCPRO}! Bugs resulting from insufficient
|
|
4102 @code{GCPRO}ing are intermittent and extremely difficult to track down,
|
|
4103 often showing up in crashes inside of @code{garbage-collect} or in
|
|
4104 weirdly corrupted objects or even in incorrect values in a totally
|
|
4105 different section of code.
|
|
4106 @end enumerate
|
|
4107
|
|
4108 @cindex garbage collection, conservative
|
|
4109 @cindex conservative garbage collection
|
|
4110 Given the extremely error-prone nature of the @code{GCPRO} scheme, and
|
|
4111 the difficulties in tracking down, it should be considered a deficiency
|
|
4112 in the XEmacs code. A solution to this problem would involve
|
|
4113 implementing so-called @dfn{conservative} garbage collection for the C
|
|
4114 stack. That involves looking through all of stack memory and treating
|
|
4115 anything that looks like a reference to an object as a reference. This
|
|
4116 will result in a few objects not getting collected when they should, but
|
|
4117 it obviates the need for @code{GCPRO}ing, and allows garbage collection
|
|
4118 to happen at any point at all, such as during object allocation.
|
|
4119
|
|
4120 @node Integers and Characters
|
|
4121 @section Integers and Characters
|
|
4122
|
|
4123 Integer and character Lisp objects are created from integers using the
|
|
4124 macros @code{XSETINT()} and @code{XSETCHAR()} or the equivalent
|
|
4125 functions @code{make_int()} and @code{make_char()}. (These are actually
|
|
4126 macros on most systems.) These functions basically just do some moving
|
|
4127 of bits around, since the integral value of the object is stored
|
|
4128 directly in the @code{Lisp_Object}.
|
|
4129
|
|
4130 @code{XSETINT()} and the like will truncate values given to them that
|
|
4131 are too big; i.e. you won't get the value you expected but the tag bits
|
|
4132 will at least be correct.
|
|
4133
|
|
4134 @node Allocation from Frob Blocks
|
|
4135 @section Allocation from Frob Blocks
|
|
4136
|
|
4137 The uninitialized memory required by a @code{Lisp_Object} of a particular type
|
|
4138 is allocated using
|
|
4139 @code{ALLOCATE_FIXED_TYPE()}. This only occurs inside of the
|
|
4140 lowest-level object-creating functions in @file{alloc.c}:
|
|
4141 @code{Fcons()}, @code{make_float()}, @code{Fmake_byte_code()},
|
|
4142 @code{Fmake_symbol()}, @code{allocate_extent()},
|
|
4143 @code{allocate_event()}, @code{Fmake_marker()}, and
|
|
4144 @code{make_uninit_string()}. The idea is that, for each type, there are
|
|
4145 a number of frob blocks (each 2K in size); each frob block is divided up
|
|
4146 into object-sized chunks. Each frob block will have some of these
|
|
4147 chunks that are currently assigned to objects, and perhaps some that are
|
|
4148 free. (If a frob block has nothing but free chunks, it is freed at the
|
|
4149 end of the garbage collection cycle.) The free chunks are stored in a
|
|
4150 free list, which is chained by storing a pointer in the first four bytes
|
|
4151 of the chunk. (Except for the free chunks at the end of the last frob
|
|
4152 block, which are handled using an index which points past the end of the
|
|
4153 last-allocated chunk in the last frob block.)
|
|
4154 @code{ALLOCATE_FIXED_TYPE()} first tries to retrieve a chunk from the
|
|
4155 free list; if that fails, it calls
|
|
4156 @code{ALLOCATE_FIXED_TYPE_FROM_BLOCK()}, which looks at the end of the
|
|
4157 last frob block for space, and creates a new frob block if there is
|
|
4158 none. (There are actually two versions of these macros, one of which is
|
|
4159 more defensive but less efficient and is used for error-checking.)
|
|
4160
|
|
4161 @node lrecords
|
|
4162 @section lrecords
|
|
4163
|
|
4164 [see @file{lrecord.h}]
|
|
4165
|
|
4166 All lrecords have at the beginning of their structure a @code{struct
|
|
4167 lrecord_header}. This just contains a pointer to a @code{struct
|
|
4168 lrecord_implementation}, which is a structure containing method pointers
|
|
4169 and such. There is one of these for each type, and it is a global,
|
|
4170 constant, statically-declared structure that is declared in the
|
|
4171 @code{DEFINE_LRECORD_IMPLEMENTATION()} macro. (This macro actually
|
|
4172 declares an array of two @code{struct lrecord_implementation}
|
|
4173 structures. The first one contains all the standard method pointers,
|
|
4174 and is used in all normal circumstances. During garbage collection,
|
|
4175 however, the lrecord is @dfn{marked} by bumping its implementation
|
|
4176 pointer by one, so that it points to the second structure in the array.
|
|
4177 This structure contains a special indication in it that it's a
|
|
4178 @dfn{marked-object} structure: the finalize method is the special
|
|
4179 function @code{this_marks_a_marked_record()}, and all other methods are
|
|
4180 null pointers. At the end of garbage collection, all lrecords will
|
|
4181 either be reclaimed or unmarked by decrementing their implementation
|
|
4182 pointers, so this second structure pointer will never remain past
|
|
4183 garbage collection.
|
|
4184
|
|
4185 Simple lrecords (of type (c) above) just have a @code{struct
|
|
4186 lrecord_header} at their beginning. lcrecords, however, actually have a
|
|
4187 @code{struct lcrecord_header}. This, in turn, has a @code{struct
|
|
4188 lrecord_header} at its beginning, so sanity is preserved; but it also
|
2
|
4189 has a pointer used to chain all lcrecords together, and a special ID
|
0
|
4190 field used to distinguish one lcrecord from another. (This field is used
|
|
4191 only for debugging and could be removed, but the space gain is not
|
|
4192 significant.)
|
|
4193
|
|
4194 Simple lrecords are created using @code{ALLOCATE_FIXED_TYPE()}, just
|
|
4195 like for other frob blocks. The only change is that the implementation
|
|
4196 pointer must be initialized correctly. (The implementation structure for
|
|
4197 an lrecord, or rather the pointer to it, is named @code{lrecord_float},
|
|
4198 @code{lrecord_extent}, @code{lrecord_buffer}, etc.)
|
|
4199
|
|
4200 lcrecords are created using @code{alloc_lcrecord()}. This takes a
|
|
4201 size to allocate and an implementation pointer. (The size needs to be
|
|
4202 passed because some lcrecords, such as window configurations, are of
|
|
4203 variable size.) This basically just @code{malloc()}s the storage,
|
|
4204 initializes the @code{struct lcrecord_header}, and chains the lcrecord
|
|
4205 onto the head of the list of all lcrecords, which is stored in the
|
|
4206 variable @code{all_lcrecords}. The calls to @code{alloc_lcrecord()}
|
|
4207 generally occur in the lowest-level allocation function for each lrecord
|
|
4208 type.
|
|
4209
|
|
4210 Whenever you create an lrecord, you need to call either
|
|
4211 @code{DEFINE_LRECORD_IMPLEMENTATION()} or
|
|
4212 @code{DEFINE_LRECORD_SEQUENCE_IMPLEMENTATION()}. This needs to be
|
|
4213 specified in a C file, at the top level. What this actually does is
|
|
4214 define and initialize the implementation structure for the lrecord. (And
|
|
4215 possibly declares a function @code{error_check_foo()} that implements
|
|
4216 the @code{XFOO()} macro when error-checking is enabled.) The arguments
|
|
4217 to the macros are the actual type name (this is used to construct the C
|
|
4218 variable name of the lrecord implementation structure and related
|
|
4219 structures using the @samp{##} macro concatenation operator), a string
|
|
4220 that names the type on the Lisp level (this may not be the same as the C
|
|
4221 type name; typically, the C type name has underscores, while the Lisp
|
|
4222 string has dashes), various method pointers, and the name of the C
|
|
4223 structure that contains the object. The methods are used to encapsulate
|
|
4224 type-specific information about the object, such as how to print it or
|
|
4225 mark it for garbage collection, so that it's easy to add new object
|
|
4226 types without having to add a specific case for each new type in a bunch
|
|
4227 of different places.
|
|
4228
|
|
4229 The difference between @code{DEFINE_LRECORD_IMPLEMENTATION()} and
|
|
4230 @code{DEFINE_LRECORD_SEQUENCE_IMPLEMENTATION()} is that the former is
|
|
4231 used for fixed-size object types and the latter is for variable-size
|
|
4232 object types. Most object types are fixed-size; some complex
|
|
4233 types, however (e.g. window configurations), are variable-size.
|
|
4234 Variable-size object types have an extra method, which is called
|
|
4235 to determine the actual size of a particular object of that type.
|
|
4236 (Currently this is only used for keeping allocation statistics.)
|
|
4237
|
|
4238 For the purpose of keeping allocation statistics, the allocation
|
|
4239 engine keeps a list of all the different types that exist. Note that,
|
|
4240 since @code{DEFINE_LRECORD_IMPLEMENTATION()} is a macro that is
|
|
4241 specified at top-level, there is no way for it to add to the list of all
|
|
4242 existing types. What happens instead is that each implementation
|
|
4243 structure contains in it a dynamically assigned number that is
|
|
4244 particular to that type. (Or rather, it contains a pointer to another
|
|
4245 structure that contains this number. This evasiveness is done so that
|
|
4246 the implementation structure can be declared const.) In the sweep stage
|
|
4247 of garbage collection, each lrecord is examined to see if its
|
|
4248 implementation structure has its dynamically-assigned number set. If
|
|
4249 not, it must be a new type, and it is added to the list of known types
|
|
4250 and a new number assigned. The number is used to index into an array
|
|
4251 holding the number of objects of each type and the total memory
|
|
4252 allocated for objects of that type. The statistics in this array are
|
|
4253 also computed during the sweep stage. These statistics are returned by
|
|
4254 the call to @code{garbage-collect} and are printed out at the end of the
|
|
4255 loadup phase.
|
|
4256
|
|
4257 Note that for every type defined with a @code{DEFINE_LRECORD_*()}
|
|
4258 macro, there needs to be a @code{DECLARE_LRECORD_IMPLEMENTATION()}
|
|
4259 somewhere in a @file{.h} file, and this @file{.h} file needs to be
|
|
4260 included by @file{inline.c}.
|
|
4261
|
|
4262 Furthermore, there should generally be a set of @code{XFOOBAR()},
|
|
4263 @code{FOOBARP()}, etc. macros in a @file{.h} (or occasionally @file{.c})
|
|
4264 file. To create one of these, copy an existing model and modify as
|
|
4265 necessary.
|
|
4266
|
|
4267 The various methods in the lrecord implementation structure are:
|
|
4268
|
|
4269 @enumerate
|
|
4270 @item
|
|
4271 @cindex mark method
|
|
4272 A @dfn{mark} method. This is called during the marking stage and passed
|
|
4273 a function pointer (usually the @code{mark_object()} function), which is
|
|
4274 used to mark an object. All Lisp objects that are contained within the
|
|
4275 object need to be marked by applying this function to them. The mark
|
|
4276 method should also return a Lisp object, which should be either nil or
|
|
4277 an object to mark. (This can be used in lieu of calling
|
|
4278 @code{mark_object()} on the object, to reduce the recursion depth, and
|
|
4279 consequently should be the most heavily nested sub-object, such as a
|
|
4280 long list.)
|
|
4281
|
|
4282 @strong{Note}: When the mark method is called, garbage collection
|
|
4283 is in progress, and special precautions need to be taken
|
|
4284 when accessing objects; see section (B) above.
|
|
4285
|
|
4286 If your mark method does not need to do anything, it can be
|
|
4287 @code{NULL}.
|
|
4288
|
|
4289 @item
|
|
4290 A @dfn{print} method. This is called to create a printed representation
|
|
4291 of the object, whenever @code{princ}, @code{prin1}, or the like is
|
|
4292 called. It is passed the object, a stream to which the output is to be
|
|
4293 directed, and an @code{escapeflag} which indicates whether the object's
|
|
4294 printed representation should be @dfn{escaped} so that it is
|
|
4295 readable. (This corresponds to the difference between @code{princ} and
|
|
4296 @code{prin1}.) Basically, @dfn{escaped} means that strings will have
|
|
4297 quotes around them and confusing characters in the strings such as
|
|
4298 quotes, backslashes, and newlines will be backslashed; and that special
|
|
4299 care will be taken to make symbols print in a readable fashion
|
|
4300 (e.g. symbols that look like numbers will be backslashed). Other
|
|
4301 readable objects should perhaps pass @code{escapeflag} on when
|
|
4302 sub-objects are printed, so that readability is preserved when necessary
|
|
4303 (or if not, always pass in a 1 for @code{escapeflag}). Non-readable
|
|
4304 objects should in general ignore @code{escapeflag}, except that some use
|
|
4305 it as an indication that more verbose output should be given.
|
|
4306
|
|
4307 Sub-objects are printed using @code{print_internal()}, which takes
|
|
4308 exactly the same arguments as are passed to the print method.
|
|
4309
|
|
4310 Literal C strings should be printed using @code{write_c_string()},
|
|
4311 or @code{write_string_1()} for non-null-terminated strings.
|
|
4312
|
|
4313 Functions that do not have a readable representation should check the
|
|
4314 @code{print_readably} flag and signal an error if it is set.
|
|
4315
|
|
4316 If you specify NULL for the print method, the
|
|
4317 @code{default_object_printer()} will be used.
|
|
4318
|
|
4319 @item
|
|
4320 A @dfn{finalize} method. This is called at the beginning of the sweep
|
|
4321 stage on lcrecords that are about to be freed, and should be used to
|
|
4322 perform any extra object cleanup. This typically involves freeing any
|
|
4323 extra @code{malloc()}ed memory associated with the object, releasing any
|
|
4324 operating-system and window-system resources associated with the object
|
|
4325 (e.g. pixmaps, fonts), etc.
|
|
4326
|
|
4327 The finalize method can be NULL if nothing needs to be done.
|
|
4328
|
|
4329 WARNING #1: The finalize method is also called at the end of the dump
|
|
4330 phase; this time with the for_disksave parameter set to non-zero. The
|
|
4331 object is @emph{not} about to disappear, so you have to make sure to
|
|
4332 @emph{not} free any extra @code{malloc()}ed memory if you're going to
|
|
4333 need it later. (Also, signal an error if there are any operating-system
|
|
4334 and window-system resources here, because they can't be dumped.)
|
|
4335
|
|
4336 Finalize methods should, as a rule, set to zero any pointers after
|
|
4337 they've been freed, and check to make sure pointers are not zero before
|
|
4338 freeing. Although I'm pretty sure that finalize methods are not called
|
|
4339 twice on the same object (except for the @code{for_disksave} proviso),
|
|
4340 we've gotten nastily burned in some cases by not doing this.
|
|
4341
|
|
4342 WARNING #2: The finalize method is @emph{only} called for
|
|
4343 lcrecords, @emph{not} for simply lrecords. If you need a
|
|
4344 finalize method for simple lrecords, you have to stick
|
|
4345 it in the @code{ADDITIONAL_FREE_foo()} macro in @file{alloc.c}.
|
|
4346
|
|
4347 WARNING #3: Things are in an @emph{extremely} bizarre state
|
|
4348 when @code{ADDITIONAL_FREE_foo()} is called, so you have to
|
|
4349 be incredibly careful when writing one of these functions.
|
|
4350 See the comment in @code{gc_sweep()}. If you ever have to add
|
|
4351 one of these, consider using an lcrecord or dealing with
|
|
4352 the problem in a different fashion.
|
|
4353
|
|
4354 @item
|
|
4355 An @dfn{equal} method. This compares the two objects for similarity,
|
|
4356 when @code{equal} is called. It should compare the contents of the
|
|
4357 objects in some reasonable fashion. It is passed the two objects and a
|
|
4358 @dfn{depth} value, which is used to catch circular objects. To compare
|
|
4359 sub-Lisp-objects, call @code{internal_equal()} and bump the depth value
|
|
4360 by one. If this value gets too high, a @code{circular-object} error
|
|
4361 will be signaled.
|
|
4362
|
|
4363 If this is NULL, objects are @code{equal} only when they are @code{eq},
|
|
4364 i.e. identical.
|
|
4365
|
|
4366 @item
|
|
4367 A @dfn{hash} method. This is used to hash objects when they are to be
|
|
4368 compared with @code{equal}. The rule here is that if two objects are
|
|
4369 @code{equal}, they @emph{must} hash to the same value; i.e. your hash
|
|
4370 function should use some subset of the sub-fields of the object that are
|
|
4371 compared in the ``equal'' method. If you specify this method as
|
|
4372 @code{NULL}, the object's pointer will be used as the hash, which will
|
|
4373 @emph{fail} if the object has an @code{equal} method, so don't do this.
|
|
4374
|
|
4375 To hash a sub-Lisp-object, call @code{internal_hash()}. Bump the
|
|
4376 depth by one, just like in the ``equal'' method.
|
|
4377
|
|
4378 To convert a Lisp object directly into a hash value (using
|
|
4379 its pointer), use @code{LISP_HASH()}. This is what happens when
|
|
4380 the hash method is NULL.
|
|
4381
|
|
4382 To hash two or more values together into a single value, use
|
|
4383 @code{HASH2()}, @code{HASH3()}, @code{HASH4()}, etc.
|
|
4384
|
|
4385 @item
|
|
4386 @dfn{getprop}, @dfn{putprop}, @dfn{remprop}, and @dfn{plist} methods.
|
|
4387 These are used for object types that have properties. I don't feel like
|
|
4388 documenting them here. If you create one of these objects, you have to
|
|
4389 use different macros to define them,
|
|
4390 i.e. @code{DEFINE_LRECORD_IMPLEMENTATION_WITH_PROPS()} or
|
|
4391 @code{DEFINE_LRECORD_SEQUENCE_IMPLEMENTATION_WITH_PROPS()}.
|
|
4392
|
|
4393 @item
|
|
4394 A @dfn{size_in_bytes} method, when the object is of variable-size.
|
|
4395 (i.e. declared with a @code{_SEQUENCE_IMPLEMENTATION} macro.) This should
|
|
4396 simply return the object's size in bytes, exactly as you might expect.
|
|
4397 For an example, see the methods for window configurations and opaques.
|
|
4398 @end enumerate
|
|
4399
|
|
4400 @node Low-level allocation
|
|
4401 @section Low-level allocation
|
|
4402
|
|
4403 Memory that you want to allocate directly should be allocated using
|
|
4404 @code{xmalloc()} rather than @code{malloc()}. This implements
|
|
4405 error-checking on the return value, and once upon a time did some more
|
|
4406 vital stuff (i.e. @code{BLOCK_INPUT}, which is no longer necessary).
|
|
4407 Free using @code{xfree()}, and realloc using @code{xrealloc()}. Note
|
|
4408 that @code{xmalloc()} will do a non-local exit if the memory can't be
|
|
4409 allocated. (Many functions, however, do not expect this, and thus XEmacs
|
|
4410 will likely crash if this happens. @strong{This is a bug.} If you can,
|
|
4411 you should strive to make your function handle this OK. However, it's
|
|
4412 difficult in the general circumstance, perhaps requiring extra
|
|
4413 unwind-protects and such.)
|
|
4414
|
|
4415 Note that XEmacs provides two separate replacements for the standard
|
|
4416 @code{malloc()} library function. These are called @dfn{old GNU malloc}
|
|
4417 (@file{malloc.c}) and @dfn{new GNU malloc} (@file{gmalloc.c}),
|
|
4418 respectively. New GNU malloc is better in pretty much every way than
|
|
4419 old GNU malloc, and should be used if possible. (It used to be that on
|
|
4420 some systems, the old one worked but the new one didn't. I think this
|
|
4421 was due specifically to a bug in SunOS, which the new one now works
|
|
4422 around; so I don't think the old one ever has to be used any more.) The
|
|
4423 primary difference between both of these mallocs and the standard system
|
|
4424 malloc is that they are much faster, at the expense of increased space.
|
|
4425 The basic idea is that memory is allocated in fixed chunks of powers of
|
|
4426 two. This allows for basically constant malloc time, since the various
|
|
4427 chunks can just be kept on a number of free lists. (The standard system
|
|
4428 malloc typically allocates arbitrary-sized chunks and has to spend some
|
|
4429 time, sometimes a significant amount of time, walking the heap looking
|
|
4430 for a free block to use and cleaning things up.) The new GNU malloc
|
|
4431 improves on things by allocating large objects in chunks of 4096 bytes
|
|
4432 rather than in ever larger powers of two, which results in ever larger
|
|
4433 wastage. There is a slight speed loss here, but it's of doubtful
|
|
4434 significance.
|
|
4435
|
|
4436 NOTE: Apparently there is a third-generation GNU malloc that is
|
|
4437 significantly better than the new GNU malloc, and should probably
|
|
4438 be included in XEmacs.
|
|
4439
|
|
4440 There is also the relocating allocator, @file{ralloc.c}. This actually
|
|
4441 moves blocks of memory around so that the @code{sbrk()} pointer shrunk
|
|
4442 and virtual memory released back to the system. On some systems,
|
|
4443 this is a big win. On all systems, it causes a noticeable (and
|
|
4444 sometimes huge) speed penalty, so I turn it off by default.
|
|
4445 @file{ralloc.c} only works with the new GNU malloc in @file{gmalloc.c}.
|
|
4446 There are also two versions of @file{ralloc.c}, one that uses @code{mmap()}
|
|
4447 rather than block copies to move data around. This purports to
|
|
4448 be faster, although that depends on the amount of data that would
|
|
4449 have had to be block copied and the system-call overhead for
|
|
4450 @code{mmap()}. I don't know exactly how this works, except that the
|
|
4451 relocating-allocation routines are pretty much used only for
|
|
4452 the memory allocated for a buffer, which is the biggest consumer
|
|
4453 of space, esp. of space that may get freed later.
|
|
4454
|
|
4455 Note that the GNU mallocs have some ``memory warning'' facilities.
|
|
4456 XEmacs taps into them and issues a warning through the standard
|
|
4457 warning system, when memory gets to 75%, 85%, and 95% full.
|
|
4458 (On some systems, the memory warnings are not functional.)
|
|
4459
|
|
4460 Allocated memory that is going to be used to make a Lisp object
|
|
4461 is created using @code{allocate_lisp_storage()}. This calls @code{xmalloc()}
|
|
4462 but also verifies that the pointer to the memory can fit into
|
|
4463 a Lisp word (remember that some bits are taken away for a type
|
|
4464 tag and a mark bit). If not, an error is issued through @code{memory_full()}.
|
|
4465 @code{allocate_lisp_storage()} is called by @code{alloc_lcrecord()},
|
|
4466 @code{ALLOCATE_FIXED_TYPE()}, and the vector and bit-vector creation
|
|
4467 routines. These routines also call @code{INCREMENT_CONS_COUNTER()} at the
|
|
4468 appropriate times; this keeps statistics on how much memory is
|
|
4469 allocated, so that garbage-collection can be invoked when the
|
|
4470 threshold is reached.
|
|
4471
|
|
4472 @node Pure Space
|
|
4473 @section Pure Space
|
|
4474
|
|
4475 Not yet documented.
|
|
4476
|
|
4477 @node Cons
|
|
4478 @section Cons
|
|
4479
|
|
4480 Conses are allocated in standard frob blocks. The only thing to
|
|
4481 note is that conses can be explicitly freed using @code{free_cons()}
|
|
4482 and associated functions @code{free_list()} and @code{free_alist()}. This
|
|
4483 immediately puts the conses onto the cons free list, and decrements
|
|
4484 the statistics on memory allocation appropriately. This is used
|
|
4485 to good effect by some extremely commonly-used code, to avoid
|
|
4486 generating extra objects and thereby triggering GC sooner.
|
|
4487 However, you have to be @emph{extremely} careful when doing this.
|
|
4488 If you mess this up, you will get BADLY BURNED, and it has happened
|
|
4489 before.
|
|
4490
|
|
4491 @node Vector
|
|
4492 @section Vector
|
|
4493
|
|
4494 As mentioned above, each vector is @code{malloc()}ed individually, and
|
|
4495 all are threaded through the variable @code{all_vectors}. Vectors are
|
|
4496 marked strangely during garbage collection, by kludging the size field.
|
44
|
4497 Note that the @code{struct Lisp_Vector} is declared with its
|
|
4498 @code{contents} field being a @emph{stretchy} array of one element. It
|
|
4499 is actually @code{malloc()}ed with the right size, however, and access
|
|
4500 to any element through the @code{contents} array works fine.
|
0
|
4501
|
|
4502 @node Bit Vector
|
|
4503 @section Bit Vector
|
|
4504
|
|
4505 Bit vectors work exactly like vectors, except for more complicated
|
|
4506 code to access an individual bit, and except for the fact that bit
|
|
4507 vectors are lrecords while vectors are not. (The only difference here is
|
|
4508 that there's an lrecord implementation pointer at the beginning and the
|
|
4509 tag field in bit vector Lisp words is ``lrecord'' rather than
|
|
4510 ``vector''.)
|
|
4511
|
|
4512 @node Symbol
|
|
4513 @section Symbol
|
|
4514
|
|
4515 Symbols are also allocated in frob blocks. Note that the code
|
|
4516 exists for symbols to be either lrecords (category (c) above)
|
|
4517 or simple types (category (b) above), and are lrecords by
|
|
4518 default (I think), although there is no good reason for this.
|
|
4519
|
|
4520 Note that symbols in the awful horrible obarray structure are
|
|
4521 chained through their @code{next} field.
|
|
4522
|
|
4523 Remember that @code{intern} looks up a symbol in an obarray, creating
|
|
4524 one if necessary.
|
|
4525
|
|
4526 @node Marker
|
|
4527 @section Marker
|
|
4528
|
|
4529 Markers are allocated in frob blocks, as usual. They are kept
|
|
4530 in a buffer unordered, but in a doubly-linked list so that they
|
|
4531 can easily be removed. (Formerly this was a singly-linked list,
|
|
4532 but in some cases garbage collection took an extraordinarily
|
|
4533 long time due to the O(N^2) time required to remove lots of
|
|
4534 markers from a buffer.) Markers are removed from a buffer in
|
|
4535 the finalize stage, in @code{ADDITIONAL_FREE_marker()}.
|
|
4536
|
|
4537 @node String
|
|
4538 @section String
|
|
4539
|
|
4540 As mentioned above, strings are a special case. A string is logically
|
|
4541 two parts, a fixed-size object (containing the length, property list,
|
|
4542 and a pointer to the actual data), and the actual data in the string.
|
|
4543 The fixed-size object is a @code{struct Lisp_String} and is allocated in
|
|
4544 frob blocks, as usual. The actual data is stored in special
|
|
4545 @dfn{string-chars blocks}, which are 8K blocks of memory.
|
|
4546 Currently-allocated strings are simply laid end to end in these
|
|
4547 string-chars blocks, with a pointer back to the @code{struct Lisp_String}
|
|
4548 stored before each string in the string-chars block. When a new string
|
|
4549 needs to be allocated, the remaining space at the end of the last
|
|
4550 string-chars block is used if there's enough, and a new string-chars
|
|
4551 block is created otherwise.
|
|
4552
|
|
4553 There are never any holes in the string-chars blocks due to the string
|
|
4554 compaction and relocation that happens at the end of garbage collection.
|
|
4555 During the sweep stage of garbage collection, when objects are
|
|
4556 reclaimed, the garbage collector goes through all string-chars blocks,
|
|
4557 looking for unused strings. Each chunk of string data is preceded by a
|
|
4558 pointer to the corresponding @code{struct Lisp_String}, which indicates
|
|
4559 both whether the string is used and how big the string is, i.e. how to
|
2
|
4560 get to the next chunk of string data. Holes are compressed by
|
0
|
4561 block-copying the next string into the empty space and relocating the
|
|
4562 pointer stored in the corresponding @code{struct Lisp_String}.
|
|
4563 @strong{This means you have to be careful with strings in your code.}
|
|
4564 See the section above on @code{GCPRO}ing.
|
|
4565
|
|
4566 Note that there is one situation not handled: a string that is too big
|
|
4567 to fit into a string-chars block. Such strings, called @dfn{big
|
|
4568 strings}, are all @code{malloc()}ed as their own block. (#### Although it
|
|
4569 would make more sense for the threshold for big strings to be somewhat
|
|
4570 lower, e.g. 1/2 or 1/4 the size of a string-chars block. It seems that
|
|
4571 this was indeed the case formerly -- indeed, the threshold was set at
|
|
4572 1/8 -- but Mly forgot about this when rewriting things for 19.8.)
|
|
4573
|
|
4574 Note also that the string data in string-chars blocks is padded as
|
|
4575 necessary so that proper alignment constraints on the @code{struct
|
|
4576 Lisp_String} back pointers are maintained.
|
|
4577
|
|
4578 Finally, strings can be resized. This happens in Mule when a
|
|
4579 character is substituted with a different-length character, or during
|
|
4580 modeline frobbing. (You could also export this to Lisp, but it's not
|
|
4581 done so currently.) Resizing a string is a potentially tricky process.
|
|
4582 If the change is small enough that the padding can absorb it, nothing
|
|
4583 other than a simple memory move needs to be done. Keep in mind,
|
|
4584 however, that the string can't shrink too much because the offset to the
|
|
4585 next string in the string-chars block is computed by looking at the
|
|
4586 length and rounding to the nearest multiple of four or eight. If the
|
|
4587 string would shrink or expand beyond the correct padding, new string
|
|
4588 data needs to be allocated at the end of the last string-chars block and
|
|
4589 the data moved appropriately. This leaves some dead string data, which
|
|
4590 is marked by putting a special marker of 0xFFFFFFFF in the @code{struct
|
|
4591 Lisp_String} pointer before the data (there's no real @code{struct
|
|
4592 Lisp_String} to point to and relocate), and storing the size of the dead
|
|
4593 string data (which would normally be obtained from the now-non-existent
|
|
4594 @code{struct Lisp_String}) at the beginning of the dead string data gap.
|
|
4595 The string compactor recognizes this special 0xFFFFFFFF marker and
|
|
4596 handles it correctly.
|
|
4597
|
|
4598 @node Bytecode
|
|
4599 @section Bytecode
|
|
4600
|
|
4601 Not yet documented.
|
|
4602
|
|
4603 @node Events and the Event Loop, Evaluation; Stack Frames; Bindings, Allocation of Objects in XEmacs Lisp, Top
|
|
4604 @chapter Events and the Event Loop
|
|
4605
|
|
4606 @menu
|
|
4607 * Introduction to Events::
|
|
4608 * Main Loop::
|
|
4609 * Specifics of the Event Gathering Mechanism::
|
|
4610 * Specifics About the Emacs Event::
|
|
4611 * The Event Stream Callback Routines::
|
|
4612 * Other Event Loop Functions::
|
|
4613 * Converting Events::
|
|
4614 * Dispatching Events; The Command Builder::
|
|
4615 @end menu
|
|
4616
|
|
4617 @node Introduction to Events
|
|
4618 @section Introduction to Events
|
|
4619
|
|
4620 An event is an object that encapsulates information about an
|
|
4621 interesting occurrence in the operating system. Events are
|
|
4622 generated either by user action, direct (e.g. typing on the
|
|
4623 keyboard or moving the mouse) or indirect (moving another
|
|
4624 window, thereby generating an expose event on an Emacs frame),
|
|
4625 or as a result of some other typically asynchronous action happening,
|
|
4626 such as output from a subprocess being ready or a timer expiring.
|
|
4627 Events come into the system in an asynchronous fashion (typically
|
|
4628 through a callback being called) and are converted into a
|
|
4629 synchronous event queue (first-in, first-out) in a process that
|
|
4630 we will call @dfn{collection}.
|
|
4631
|
2
|
4632 Note that each application has its own event queue. (It is
|
0
|
4633 immaterial whether the collection process directly puts the
|
|
4634 events in the proper application's queue, or puts them into
|
|
4635 a single system queue, which is later split up.)
|
|
4636
|
|
4637 The most basic level of event collection is done by the
|
|
4638 operating system or window system. Typically, XEmacs does
|
|
4639 its own event collection as well. Often there are multiple
|
|
4640 layers of collection in XEmacs, with events from various
|
|
4641 sources being collected into a queue, which is then combined
|
|
4642 with other sources to go into another queue (i.e. a second
|
|
4643 level of collection), with perhaps another level on top of
|
|
4644 this, etc.
|
|
4645
|
|
4646 XEmacs has its own types of events (called @dfn{Emacs events}),
|
|
4647 which provides an abstract layer on top of the system-dependent
|
|
4648 nature of the most basic events that are received. Part of the
|
|
4649 complex nature of the XEmacs event collection process involves
|
|
4650 converting from the operating-system events into the proper
|
|
4651 Emacs events -- there may not be a one-to-one correspondence.
|
|
4652
|
|
4653 Emacs events are documented in @file{events.h}; I'll discuss them
|
|
4654 later.
|
|
4655
|
|
4656 @node Main Loop
|
|
4657 @section Main Loop
|
|
4658
|
|
4659 The @dfn{command loop} is the top-level loop that the editor is always
|
|
4660 running. It loops endlessly, calling @code{next-event} to retrieve an
|
|
4661 event and @code{dispatch-event} to execute it. @code{dispatch-event} does
|
|
4662 the appropriate thing with non-user events (process, timeout,
|
|
4663 magic, eval, mouse motion); this involves calling a Lisp handler
|
|
4664 function, redrawing a newly-exposed part of a frame, reading
|
|
4665 subprocess output, etc. For user events, @code{dispatch-event}
|
|
4666 looks up the event in relevant keymaps or menubars; when a
|
|
4667 full key sequence or menubar selection is reached, the appropriate
|
|
4668 function is executed. @code{dispatch-event} may have to keep state
|
|
4669 across calls; this is done in the ``command-builder'' structure
|
|
4670 associated with each console (remember, there's usually only
|
|
4671 one console), and the engine that looks up keystrokes and
|
|
4672 constructs full key sequences is called the @dfn{command builder}.
|
|
4673 This is documented elsewhere.
|
|
4674
|
|
4675 The guts of the command loop are in @code{command_loop_1()}. This
|
|
4676 function doesn't catch errors, though -- that's the job of
|
|
4677 @code{command_loop_2()}, which is a condition-case (i.e. error-trapping)
|
|
4678 wrapper around @code{command_loop_1()}. @code{command_loop_1()} never
|
|
4679 returns, but may get thrown out of.
|
|
4680
|
|
4681 When an error occurs, @code{cmd_error()} is called, which usually
|
|
4682 invokes the Lisp error handler in @code{command-error}; however, a
|
|
4683 default error handler is provided if @code{command-error} is @code{nil}
|
|
4684 (e.g. during startup). The purpose of the error handler is simply to
|
|
4685 display the error message and do associated cleanup; it does not need to
|
|
4686 throw anywhere. When the error handler finishes, the condition-case in
|
|
4687 @code{command_loop_2()} will finish and @code{command_loop_2()} will
|
|
4688 reinvoke @code{command_loop_1()}.
|
|
4689
|
|
4690 @code{command_loop_2()} is invoked from three places: from
|
|
4691 @code{initial_command_loop()} (called from @code{main()} at the end of
|
|
4692 internal initialization), from the Lisp function @code{recursive-edit},
|
|
4693 and from @code{call_command_loop()}.
|
|
4694
|
|
4695 @code{call_command_loop()} is called when a macro is started and when
|
|
4696 the minibuffer is entered; normal termination of the macro or minibuffer
|
|
4697 causes a throw out of the recursive command loop. (To
|
|
4698 @code{execute-kbd-macro} for macros and @code{exit} for minibuffers.
|
|
4699 Note also that the low-level minibuffer-entering function,
|
|
4700 @code{read-minibuffer-internal}, provides its own error handling and
|
|
4701 does not need @code{command_loop_2()}'s error encapsulation; so it tells
|
|
4702 @code{call_command_loop()} to invoke @code{command_loop_1()} directly.)
|
|
4703
|
|
4704 Note that both read-minibuffer-internal and recursive-edit set up a
|
|
4705 catch for @code{exit}; this is why @code{abort-recursive-edit}, which
|
|
4706 throws to this catch, exits out of either one.
|
|
4707
|
|
4708 @code{initial_command_loop()}, called from @code{main()}, sets up a
|
|
4709 catch for @code{top-level} when invoking @code{command_loop_2()},
|
|
4710 allowing functions to throw all the way to the top level if they really
|
|
4711 need to. Before invoking @code{command_loop_2()},
|
|
4712 @code{initial_command_loop()} calls @code{top_level_1()}, which handles
|
|
4713 all of the startup stuff (creating the initial frame, handling the
|
|
4714 command-line options, loading the user's @file{.emacs} file, etc.). The
|
|
4715 function that actually does this is in Lisp and is pointed to by the
|
|
4716 variable @code{top-level}; normally this function is
|
|
4717 @code{normal-top-level}. @code{top_level_1()} is just an error-handling
|
|
4718 wrapper similar to @code{command_loop_2()}. Note also that
|
|
4719 @code{initial_command_loop()} sets up a catch for @code{top-level} when
|
|
4720 invoking @code{top_level_1()}, just like when it invokes
|
|
4721 @code{command_loop_2()}.
|
|
4722
|
|
4723 @node Specifics of the Event Gathering Mechanism
|
|
4724 @section Specifics of the Event Gathering Mechanism
|
|
4725
|
|
4726 Here is an approximate diagram of the collection processes
|
|
4727 at work in XEmacs, under TTY's (TTY's are simpler than X
|
|
4728 so we'll look at this first):
|
|
4729
|
|
4730 @noindent
|
|
4731 @example
|
|
4732 asynch. asynch. asynch. asynch. [Collectors in
|
|
4733 kbd events kbd events process process the OS]
|
|
4734 | | output output
|
|
4735 | | | |
|
|
4736 | | | | SIGINT, [signal handlers
|
|
4737 | | | | SIGQUIT, in XEmacs]
|
|
4738 V V V V SIGWINCH,
|
|
4739 file file file file SIGALRM
|
|
4740 desc. desc. desc. desc. |
|
|
4741 (TTY) (TTY) (pipe) (pipe) |
|
|
4742 | | | | fake timeouts
|
|
4743 | | | | file |
|
|
4744 | | | | desc. |
|
|
4745 | | | | (pipe) |
|
|
4746 | | | | | |
|
|
4747 | | | | | |
|
|
4748 | | | | | |
|
|
4749 V V V V V V
|
|
4750 ------>-----------<----------------<----------------
|
|
4751 |
|
|
4752 |
|
|
4753 | [collected using select() in emacs_tty_next_event()
|
|
4754 | and converted to the appropriate Emacs event]
|
|
4755 |
|
|
4756 |
|
|
4757 V (above this line is TTY-specific)
|
|
4758 Emacs ------------------------------------------------
|
|
4759 event (below this line is the generic event mechanism)
|
|
4760 |
|
|
4761 |
|
|
4762 was there if not, call
|
|
4763 a SIGINT? emacs_tty_next_event()
|
|
4764 | |
|
|
4765 | |
|
|
4766 | |
|
|
4767 V V
|
|
4768 --->-------<----
|
|
4769 |
|
|
4770 | [collected in event_stream_next_event();
|
|
4771 | SIGINT is converted using maybe_read_quit_event()]
|
|
4772 V
|
|
4773 Emacs
|
|
4774 event
|
|
4775 |
|
|
4776 \---->------>----- maybe_kbd_translate() ---->---\
|
|
4777 |
|
|
4778 |
|
|
4779 |
|
|
4780 command event queue |
|
|
4781 if not from command
|
|
4782 (contains events that were event queue, call
|
|
4783 read earlier but not processed, event_stream_next_event()
|
|
4784 typically when waiting in a |
|
|
4785 sit-for, sleep-for, etc. for |
|
|
4786 a particular event to be received) |
|
|
4787 | |
|
|
4788 | |
|
|
4789 V V
|
|
4790 ---->------------------------------------<----
|
|
4791 |
|
|
4792 | [collected in
|
|
4793 | next_event_internal()]
|
|
4794 |
|
|
4795 unread- unread- event from |
|
|
4796 command- command- keyboard else, call
|
|
4797 events event macro next_event_internal()
|
|
4798 | | | |
|
|
4799 | | | |
|
|
4800 | | | |
|
|
4801 V V V V
|
|
4802 --------->----------------------<------------
|
|
4803 |
|
|
4804 | [collected in `next-event', which may loop
|
|
4805 | more than once if the event it gets is on
|
|
4806 | a dead frame, device, etc.]
|
|
4807 |
|
|
4808 |
|
|
4809 V
|
|
4810 feed into top-level event loop,
|
|
4811 which repeatedly calls `next-event'
|
|
4812 and then dispatches the event
|
|
4813 using `dispatch-event'
|
|
4814 @end example
|
|
4815
|
|
4816 Notice the separation between TTY-specific and generic event mechanism.
|
|
4817 When using the Xt-based event loop, the TTY-specific stuff is replaced
|
|
4818 but the rest stays the same.
|
|
4819
|
|
4820 It's also important to realize that only one different kind of
|
|
4821 system-specific event loop can be operating at a time, and must be able
|
|
4822 to receive all kinds of events simultaneously. For the two existing
|
|
4823 event loops (implemented in @file{event-tty.c} and @file{event-Xt.c},
|
|
4824 respectively), the TTY event loop @emph{only} handles TTY consoles,
|
|
4825 while the Xt event loop handles @emph{both} TTY and X consoles. This
|
|
4826 situation is different from all of the output handlers, where you simply
|
|
4827 have one per console type.
|
|
4828
|
|
4829 Here's the Xt Event Loop Diagram (notice that below a certain point,
|
|
4830 it's the same as the above diagram):
|
|
4831
|
|
4832 @example
|
|
4833 asynch. asynch. asynch. asynch. [Collectors in
|
|
4834 kbd kbd process process the OS]
|
|
4835 events events output output
|
|
4836 | | | |
|
|
4837 | | | | asynch. asynch. [Collectors in the
|
|
4838 | | | | X X OS and X Window System]
|
|
4839 | | | | events events
|
|
4840 | | | | | |
|
|
4841 | | | | | |
|
|
4842 | | | | | | SIGINT, [signal handlers
|
|
4843 | | | | | | SIGQUIT, in XEmacs]
|
|
4844 | | | | | | SIGWINCH,
|
|
4845 | | | | | | SIGALRM
|
|
4846 | | | | | | |
|
|
4847 | | | | | | |
|
|
4848 | | | | | | | timeouts
|
|
4849 | | | | | | | |
|
|
4850 | | | | | | | |
|
|
4851 | | | | | | V |
|
|
4852 V V V V V V fake |
|
|
4853 file file file file file file file |
|
|
4854 desc. desc. desc. desc. desc. desc. desc. |
|
|
4855 (TTY) (TTY) (pipe) (pipe) (socket) (socket) (pipe) |
|
|
4856 | | | | | | | |
|
|
4857 | | | | | | | |
|
|
4858 | | | | | | | |
|
|
4859 V V V V V V V V
|
|
4860 --->----------------------------------------<---------<------
|
|
4861 | | |
|
|
4862 | | | [collected using select() in
|
|
4863 | | | _XtWaitForSomething(), called
|
|
4864 | | | from XtAppProcessEvent(), called
|
|
4865 | | | in emacs_Xt_next_event();
|
|
4866 | | | dispatched to various callbacks]
|
|
4867 | | |
|
|
4868 | | |
|
|
4869 emacs_Xt_ p_s_callback(), | [popup_selection_callback]
|
|
4870 event_handler() x_u_v_s_callback(),| [x_update_vertical_scrollbar_
|
|
4871 | x_u_h_s_callback(),| callback]
|
|
4872 | search_callback() | [x_update_horizontal_scrollbar_
|
|
4873 | | | callback]
|
|
4874 | | |
|
|
4875 | | |
|
|
4876 enqueue_Xt_ signal_special_ |
|
|
4877 dispatch_event() Xt_user_event() |
|
|
4878 [maybe multiple | |
|
|
4879 times, maybe 0 | |
|
|
4880 times] | |
|
|
4881 | enqueue_Xt_ |
|
|
4882 | dispatch_event() |
|
|
4883 | | |
|
|
4884 | | |
|
|
4885 V V |
|
|
4886 -->----------<-- |
|
|
4887 | |
|
|
4888 | |
|
|
4889 dispatch Xt_what_callback()
|
|
4890 event sets flags
|
|
4891 queue |
|
|
4892 | |
|
|
4893 | |
|
|
4894 | |
|
|
4895 | |
|
|
4896 ---->-----------<--------
|
|
4897 |
|
|
4898 |
|
|
4899 | [collected and converted as appropriate in
|
|
4900 | emacs_Xt_next_event()]
|
|
4901 |
|
|
4902 |
|
|
4903 V (above this line is Xt-specific)
|
|
4904 Emacs ------------------------------------------------
|
|
4905 event (below this line is the generic event mechanism)
|
|
4906 |
|
|
4907 |
|
|
4908 was there if not, call
|
|
4909 a SIGINT? emacs_Xt_next_event()
|
|
4910 | |
|
|
4911 | |
|
|
4912 | |
|
|
4913 V V
|
|
4914 --->-------<----
|
|
4915 |
|
|
4916 | [collected in event_stream_next_event();
|
|
4917 | SIGINT is converted using maybe_read_quit_event()]
|
|
4918 V
|
|
4919 Emacs
|
|
4920 event
|
|
4921 |
|
|
4922 \---->------>----- maybe_kbd_translate() -->-----\
|
|
4923 |
|
|
4924 |
|
|
4925 |
|
|
4926 command event queue |
|
|
4927 if not from command
|
|
4928 (contains events that were event queue, call
|
|
4929 read earlier but not processed, event_stream_next_event()
|
|
4930 typically when waiting in a |
|
|
4931 sit-for, sleep-for, etc. for |
|
|
4932 a particular event to be received) |
|
|
4933 | |
|
|
4934 | |
|
|
4935 V V
|
|
4936 ---->----------------------------------<------
|
|
4937 |
|
|
4938 | [collected in
|
|
4939 | next_event_internal()]
|
|
4940 |
|
|
4941 unread- unread- event from |
|
|
4942 command- command- keyboard else, call
|
|
4943 events event macro next_event_internal()
|
|
4944 | | | |
|
|
4945 | | | |
|
|
4946 | | | |
|
|
4947 V V V V
|
|
4948 --------->----------------------<------------
|
|
4949 |
|
|
4950 | [collected in `next-event', which may loop
|
|
4951 | more than once if the event it gets is on
|
|
4952 | a dead frame, device, etc.]
|
|
4953 |
|
|
4954 |
|
|
4955 V
|
|
4956 feed into top-level event loop,
|
|
4957 which repeatedly calls `next-event'
|
|
4958 and then dispatches the event
|
|
4959 using `dispatch-event'
|
|
4960 @end example
|
|
4961
|
|
4962 @node Specifics About the Emacs Event
|
|
4963 @section Specifics About the Emacs Event
|
|
4964
|
|
4965 @node The Event Stream Callback Routines
|
|
4966 @section The Event Stream Callback Routines
|
|
4967
|
|
4968 @node Other Event Loop Functions
|
|
4969 @section Other Event Loop Functions
|
|
4970
|
|
4971 @code{detect_input_pending()} and @code{input-pending-p} look for
|
|
4972 input by calling @code{event_stream->event_pending_p} and looking in
|
|
4973 @code{[V]unread-command-event} and the @code{command_event_queue} (they
|
|
4974 do not check for an executing keyboard macro, though).
|
|
4975
|
|
4976 @code{discard-input} cancels any command events pending (and any
|
|
4977 keyboard macros currently executing), and puts the others onto the
|
|
4978 @code{command_event_queue}. There is a comment about a ``race
|
|
4979 condition'', which is not a good sign.
|
|
4980
|
|
4981 @code{next-command-event} and @code{read-char} are higher-level
|
|
4982 interfaces to @code{next-event}. @code{next-command-event} gets the
|
44
|
4983 next @dfn{command} event (i.e. keypress, mouse event, menu selection,
|
|
4984 or scrollbar action), calling @code{dispatch-event} on any others.
|
|
4985 @code{read-char} calls @code{next-command-event} and uses
|
|
4986 @code{event_to_character()} to return the character equivalent. With
|
|
4987 the right kind of input method support, it is possible for (read-char)
|
|
4988 to return a Kanji character.
|
0
|
4989
|
|
4990 @node Converting Events
|
|
4991 @section Converting Events
|
|
4992
|
|
4993 @code{character_to_event()}, @code{event_to_character()},
|
|
4994 @code{event-to-character}, and @code{character-to-event} convert between
|
44
|
4995 characters and keypress events corresponding to the characters. If the
|
0
|
4996 event was not a keypress, @code{event_to_character()} returns -1 and
|
|
4997 @code{event-to-character} returns @code{nil}. These functions convert
|
44
|
4998 between character representation and the split-up event representation
|
0
|
4999 (keysym plus mod keys).
|
|
5000
|
|
5001 @node Dispatching Events; The Command Builder
|
|
5002 @section Dispatching Events; The Command Builder
|
|
5003
|
|
5004 Not yet documented.
|
|
5005
|
|
5006 @node Evaluation; Stack Frames; Bindings, Symbols and Variables, Events and the Event Loop, Top
|
|
5007 @chapter Evaluation; Stack Frames; Bindings
|
|
5008
|
|
5009 @menu
|
|
5010 * Evaluation::
|
|
5011 * Dynamic Binding; The specbinding Stack; Unwind-Protects::
|
|
5012 * Simple Special Forms::
|
|
5013 * Catch and Throw::
|
|
5014 @end menu
|
|
5015
|
|
5016 @node Evaluation
|
|
5017 @section Evaluation
|
|
5018
|
|
5019 @code{Feval()} evaluates the form (a Lisp object) that is passed to
|
|
5020 it. Note that evaluation is only non-trivial for two types of objects:
|
|
5021 symbols and conses. Under normal circumstances (i.e. not mocklisp) a
|
|
5022 symbol is evaluated simply by calling symbol-value on it and returning
|
|
5023 the value.
|
|
5024
|
|
5025 Evaluating a cons means calling a function. First, @code{eval} checks
|
|
5026 to see if garbage-collection is necessary, and calls
|
|
5027 @code{Fgarbage_collect()} if so. It then increases the evaluation depth
|
|
5028 by 1 (@code{lisp_eval_depth}, which is always less than @code{max_lisp_eval_depth}) and adds an
|
|
5029 element to the linked list of @code{struct backtrace}'s
|
|
5030 (@code{backtrace_list}). Each such structure contains a pointer to the
|
|
5031 function being called plus a list of the function's arguments.
|
|
5032 Originally these values are stored unevalled, and as they are evaluated,
|
|
5033 the backtrace structure is updated. Garbage collection pays attention
|
|
5034 to the objects pointed to in the backtrace structures (garbage
|
|
5035 collection might happen while a function is being called or while an
|
|
5036 argument is being evaluated, and there could easily be no other
|
|
5037 references to the arguments in the argument list; once an argument is
|
|
5038 evaluated, however, the unevalled version is not needed by eval, and so
|
|
5039 the backtrace structure is changed).
|
|
5040
|
|
5041 At this point, the function to be called is determined by looking at
|
|
5042 the car of the cons (if this is a symbol, its function definition is
|
|
5043 retrieved and the process repeated). The function should then consist
|
44
|
5044 of either a @code{Lisp_Subr} (built-in function), a
|
|
5045 @code{Lisp_Compiled_Function} object, or a cons whose car is the symbol
|
|
5046 @code{autoload}, @code{macro}, @code{lambda}, or @code{mocklisp}.
|
|
5047
|
|
5048 If the function is a @code{Lisp_Subr}, the lisp object points to a
|
|
5049 @code{struct Lisp_Subr} (created by @code{DEFUN()}), which contains a
|
|
5050 pointer to the C function, a minimum and maximum number of arguments
|
|
5051 (possibly the special constants @code{MANY} or @code{UNEVALLED}), a
|
|
5052 pointer to the symbol referring to that subr, and a couple of other
|
|
5053 things. If the subr wants its arguments @code{UNEVALLED}, they are
|
|
5054 passed raw as a list. Otherwise, an array of evaluated arguments is
|
|
5055 created and put into the backtrace structure, and either passed whole
|
|
5056 (@code{MANY}) or each argument is passed as a C argument.
|
|
5057
|
|
5058 If the function is a @code{Lisp_Compiled_Function} object or a lambda,
|
0
|
5059 @code{apply_lambda()} is called. If the function is a macro,
|
|
5060 [..... fill in] is done. If the function is an autoload,
|
|
5061 @code{do_autoload()} is called to load the definition and then eval
|
|
5062 starts over [explain this more]. If the function is a mocklisp,
|
|
5063 @code{ml_apply()} is called.
|
|
5064
|
|
5065 When @code{Feval} exits, the evaluation depth is reduced by one, the
|
|
5066 debugger is called if appropriate, and the current backtrace structure
|
|
5067 is removed from the list.
|
|
5068
|
|
5069 @code{apply_lambda()} is passed a function, a list of arguments, and a
|
|
5070 flag indicating whether to evaluate the arguments. It creates an array
|
|
5071 of (possibly) evaluated arguments and fixes up the backtrace structure,
|
|
5072 just like eval does. Then it calls @code{funcall_lambda()}.
|
|
5073
|
|
5074 @code{funcall_lambda()} goes through the formal arguments to the
|
|
5075 function and binds them to the actual arguments, checking for
|
|
5076 @code{&rest} and @code{&optional} symbols in the formal arguments and
|
|
5077 making sure the number of actual arguments is correct. Then either
|
44
|
5078 @code{progn} or @code{byte-code} is called to actually execute the body
|
|
5079 and return a value.
|
0
|
5080
|
|
5081 @code{Ffuncall()} implements Lisp @code{funcall}. @code{(funcall fun
|
|
5082 x1 x2 x3 ...)} is equivalent to @code{(eval (list fun (quote x1) (quote
|
|
5083 x2) (quote x3) ...))}. @code{Ffuncall()} contains its own code to do
|
|
5084 the evaluation, however, and is almost identical to eval.
|
|
5085
|
|
5086 @code{Fapply()} implements Lisp @code{apply}, which is very similar to
|
|
5087 funcall except that if the last argument is a list, the result is the
|
|
5088 same as if each of the arguments in the list had been passed separately.
|
|
5089 @code{Fapply()} does some business to expand the last argument if it's a
|
|
5090 list, then calls @code{Ffuncall()} to do the work.
|
|
5091
|
|
5092 @code{apply1()}, @code{call0()}, @code{call1()}, @code{call2()}, and
|
|
5093 @code{call3()} call a function, passing it the argument(s) given (the
|
|
5094 arguments are given as separate C arguments rather than being passed as
|
|
5095 an array). @code{apply1()} uses @code{apply} while the others use
|
|
5096 @code{funcall}.
|
|
5097
|
|
5098 @node Dynamic Binding; The specbinding Stack; Unwind-Protects
|
|
5099 @section Dynamic Binding; The specbinding Stack; Unwind-Protects
|
|
5100
|
|
5101 @example
|
|
5102 struct specbinding
|
|
5103 @{
|
|
5104 Lisp_Object symbol, old_value;
|
2
|
5105 Lisp_Object (*func) (Lisp_Object); /* for unwind-protect */
|
0
|
5106 @};
|
|
5107 @end example
|
|
5108
|
|
5109 @code{struct specbinding} is used for local-variable bindings and
|
|
5110 unwind-protects. @code{specpdl} holds an array of @code{struct specbinding}'s,
|
|
5111 @code{specpdl_ptr} points to the beginning of the free bindings in the
|
|
5112 array, @code{specpdl_size} specifies the total number of binding slots
|
|
5113 in the array, and @code{max_specpdl_size} specifies the maximum number
|
|
5114 of bindings the array can be expanded to hold. @code{grow_specpdl()}
|
|
5115 increases the size of the specpdl array, multiplying its size by 2 but
|
|
5116 never exceeding max_specpdl_size (except that if this number is less
|
|
5117 than 400, it is first set to 400).
|
|
5118
|
|
5119 @code{specbind()} binds a symbol to a value and is used for local
|
|
5120 variables and @code{let} forms. The symbol and its old value (which
|
|
5121 might be @code{Qunbound}, indicating no prior value) are recorded in the
|
|
5122 specpdl array, and @code{specpdl_size} is increased by 1.
|
|
5123
|
|
5124 @code{record_unwind_protect()} implements an @dfn{unwind-protect},
|
|
5125 which, when placed around a section of code, ensures that some specified
|
|
5126 cleanup routine will be executed even if the code exits abnormally
|
44
|
5127 (e.g. through a @code{throw} or quit). @code{record_unwind_protect()}
|
|
5128 simply adds a new specbinding to the specpdl array and stores the
|
|
5129 appropriate information in it. The cleanup routine can either be a C
|
|
5130 function, which is stored in the @code{func} field, or a @code{progn}
|
|
5131 form, which is stored in the @code{old_value} field.
|
0
|
5132
|
|
5133 @code{unbind_to()} removes specbindings from the specpdl array until
|
44
|
5134 the specified position is reached. Each specbinding can be one of three
|
0
|
5135 types:
|
|
5136
|
|
5137 @enumerate
|
|
5138 @item
|
44
|
5139 an unwind-protect with a C cleanup function (@code{func} is not 0, and
|
0
|
5140 @code{old_value} holds an argument to be passed to the function);
|
|
5141 @item
|
44
|
5142 an unwind-protect with a Lisp form (@code{func} is 0, @code{symbol}
|
|
5143 is @code{nil}, and @code{old_value} holds the form to be executed with
|
0
|
5144 @code{Fprogn()}); or
|
|
5145 @item
|
44
|
5146 a local-variable binding (@code{func} is 0, @code{symbol} is not
|
|
5147 @code{nil}, and @code{old_value} holds the old value, which is stored as
|
0
|
5148 the symbol's value).
|
|
5149 @end enumerate
|
|
5150
|
|
5151 @node Simple Special Forms
|
|
5152 @section Simple Special Forms
|
|
5153
|
|
5154 @code{or}, @code{and}, @code{if}, @code{cond}, @code{progn},
|
|
5155 @code{prog1}, @code{prog2}, @code{setq}, @code{quote}, @code{function},
|
|
5156 @code{let*}, @code{let}, @code{while}
|
|
5157
|
|
5158 All of these are very simple and work as expected, calling
|
|
5159 @code{Feval()} or @code{Fprogn()} as necessary and (in the case of
|
|
5160 @code{let} and @code{let*}) using @code{specbind()} to create bindings
|
|
5161 and @code{unbind_to()} to undo the bindings when finished. Note that
|
|
5162 these functions do a lot of @code{GCPRO}ing to protect their arguments
|
|
5163 from garbage collection because they call @code{Feval()} (@pxref{Garbage
|
|
5164 Collection}).
|
|
5165
|
|
5166 @node Catch and Throw
|
|
5167 @section Catch and Throw
|
|
5168
|
|
5169 @example
|
|
5170 struct catchtag
|
|
5171 @{
|
|
5172 Lisp_Object tag;
|
|
5173 Lisp_Object val;
|
|
5174 struct catchtag *next;
|
|
5175 struct gcpro *gcpro;
|
|
5176 jmp_buf jmp;
|
|
5177 struct backtrace *backlist;
|
|
5178 int lisp_eval_depth;
|
|
5179 int pdlcount;
|
|
5180 @};
|
|
5181 @end example
|
|
5182
|
|
5183 @code{catch} is a Lisp function that places a catch around a body of
|
|
5184 code. A catch is a means of non-local exit from the code. When a catch
|
|
5185 is created, a tag is specified, and executing a @code{throw} to this tag
|
|
5186 will exit from the body of code caught with this tag, and its value will
|
|
5187 be the value given in the call to @code{throw}. If there is no such
|
|
5188 call, the code will be executed normally.
|
|
5189
|
|
5190 Information pertaining to a catch is held in a @code{struct catchtag},
|
|
5191 which is placed at the head of a linked list pointed to by
|
|
5192 @code{catchlist}. @code{internal_catch()} is passed a C function to
|
|
5193 call (@code{Fprogn()} when Lisp @code{catch} is called) and arguments to
|
|
5194 give it, and places a catch around the function. Each @code{struct
|
|
5195 catchtag} is held in the stack frame of the @code{internal_catch()}
|
|
5196 instance that created the catch.
|
|
5197
|
|
5198 @code{internal_catch()} is fairly straightforward. It stores into the
|
|
5199 @code{struct catchtag} the tag name and the current values of
|
|
5200 @code{backtrace_list}, @code{lisp_eval_depth}, @code{gcprolist}, and the
|
|
5201 offset into the specpdl array, sets a jump point with @code{_setjmp()}
|
|
5202 (storing the jump point into the @code{struct catchtag}), and calls the
|
|
5203 function. Control will return to @code{internal_catch()} either when
|
|
5204 the function exits normally or through a @code{_longjmp()} to this jump
|
|
5205 point. In the latter case, @code{throw} will store the value to be
|
|
5206 returned into the @code{struct catchtag} before jumping. When it's
|
|
5207 done, @code{internal_catch()} removes the @code{struct catchtag} from
|
|
5208 the catchlist and returns the proper value.
|
|
5209
|
|
5210 @code{Fthrow()} goes up through the catchlist until it finds one with
|
|
5211 a matching tag. It then calls @code{unbind_catch()} to restore
|
|
5212 everything to what it was when the appropriate catch was set, stores the
|
|
5213 return value in the @code{struct catchtag}, and jumps (with
|
|
5214 @code{_longjmp()}) to its jump point.
|
|
5215
|
|
5216 @code{unbind_catch()} removes all catches from the catchlist until it
|
|
5217 finds the correct one. Some of the catches might have been placed for
|
|
5218 error-trapping, and if so, the appropriate entries on the handlerlist
|
|
5219 must be removed (see ``errors''). @code{unbind_catch()} also restores
|
|
5220 the values of @code{gcprolist}, @code{backtrace_list}, and
|
|
5221 @code{lisp_eval}, and calls @code{unbind_to()} to undo any specbindings
|
|
5222 created since the catch.
|
|
5223
|
|
5224
|
|
5225 @node Symbols and Variables, Buffers and Textual Representation, Evaluation; Stack Frames; Bindings, Top
|
|
5226 @chapter Symbols and Variables
|
|
5227
|
|
5228 @menu
|
|
5229 * Introduction to Symbols::
|
|
5230 * Obarrays::
|
|
5231 * Symbol Values::
|
|
5232 @end menu
|
|
5233
|
|
5234 @node Introduction to Symbols
|
|
5235 @section Introduction to Symbols
|
|
5236
|
|
5237 A symbol is basically just an object with four fields: a name (a
|
|
5238 string), a value (some Lisp object), a function (some Lisp object), and
|
|
5239 a property list (usually a list of alternating keyword/value pairs).
|
|
5240 What makes symbols special is that there is usually only one symbol with
|
|
5241 a given name, and the symbol is referred to by name. This makes a
|
|
5242 symbol a convenient way of calling up data by name, i.e. of implementing
|
|
5243 variables. (The variable's value is stored in the @dfn{value slot}.)
|
|
5244 Similarly, functions are referenced by name, and the definition of the
|
|
5245 function is stored in a symbol's @dfn{function slot}. This means that
|
|
5246 there can be a distinct function and variable with the same name. The
|
|
5247 property list is used as a more general mechanism of associating
|
|
5248 additional values with particular names, and once again the namespace is
|
|
5249 independent of the function and variable namespaces.
|
|
5250
|
|
5251 @node Obarrays
|
|
5252 @section Obarrays
|
|
5253
|
|
5254 The identity of symbols with their names is accomplished through a
|
|
5255 structure called an obarray, which is just a poorly-implemented hash
|
|
5256 table mapping from strings to symbols whose name is that string. (I say
|
|
5257 ``poorly implemented'' because an obarray appears in Lisp as a vector
|
|
5258 with some hidden fields rather than as its own opaque type. This is an
|
|
5259 Emacs Lisp artifact that should be fixed.)
|
|
5260
|
|
5261 Obarrays are implemented as a vector of some fixed size (which should
|
|
5262 be a prime for best results), where each ``bucket'' of the vector
|
|
5263 contains one or more symbols, threaded through a hidden @code{next}
|
|
5264 field in the symbol. Lookup of a symbol in an obarray, and adding a
|
|
5265 symbol to an obarray, is accomplished through standard hash-table
|
|
5266 techniques.
|
|
5267
|
|
5268 The standard Lisp function for working with symbols and obarrays is
|
|
5269 @code{intern}. This looks up a symbol in an obarray given its name; if
|
|
5270 it's not found, a new symbol is automatically created with the specified
|
|
5271 name, added to the obarray, and returned. This is what happens when the
|
|
5272 Lisp reader encounters a symbol (or more precisely, encounters the name
|
|
5273 of a symbol) in some text that it is reading. There is a standard
|
|
5274 obarray called @code{obarray} that is used for this purpose, although
|
|
5275 the Lisp programmer is free to create his own obarrays and @code{intern}
|
|
5276 symbols in them.
|
|
5277
|
|
5278 Note that, once a symbol is in an obarray, it stays there until
|
|
5279 something is done about it, and the standard obarray @code{obarray}
|
|
5280 always stays around, so once you use any particular variable name, a
|
|
5281 corresponding symbol will stay around in @code{obarray} until you exit
|
|
5282 XEmacs.
|
|
5283
|
|
5284 Note that @code{obarray} itself is a variable, and as such there is a
|
|
5285 symbol in @code{obarray} whose name is @code{"obarray"} and which
|
|
5286 contains @code{obarray} as its value.
|
|
5287
|
|
5288 Note also that this call to @code{intern} occurs only when in the Lisp
|
|
5289 reader, not when the code is executed (at which point the symbol is
|
|
5290 already around, stored as such in the definition of the function).
|
|
5291
|
|
5292 You can create your own obarray using @code{make-vector} (this is
|
|
5293 horrible but is an artifact) and intern symbols into that obarray.
|
|
5294 Doing that will result in two or more symbols with the same name.
|
|
5295 However, at most one of these symbols is in the standard @code{obarray}:
|
|
5296 You cannot have two symbols of the same name in any particular obarray.
|
|
5297 Note that you cannot add a symbol to an obarray in any fashion other
|
|
5298 than using @code{intern}: i.e. you can't take an existing symbol and put
|
|
5299 it in an existing obarray. Nor can you change the name of an existing
|
|
5300 symbol. (Since obarrays are vectors, you can violate the consistency of
|
|
5301 things by storing directly into the vector, but let's ignore that
|
|
5302 possibility.)
|
|
5303
|
|
5304 Usually symbols are created by @code{intern}, but if you really want,
|
|
5305 you can explicitly create a symbol using @code{make-symbol}, giving it
|
|
5306 some name. The resulting symbol is not in any obarray (i.e. it is
|
|
5307 @dfn{uninterned}), and you can't add it to any obarray. Therefore its
|
44
|
5308 primary purpose is as a symbol to use in macros to avoid namespace
|
|
5309 pollution. It can also be used as a carrier of information, but cons
|
|
5310 cells could probably be used just as well.
|
0
|
5311
|
|
5312 You can also use @code{intern-soft} to look up a symbol but not create
|
|
5313 a new one, and @code{unintern} to remove a symbol from an obarray. This
|
|
5314 returns the removed symbol. (Remember: You can't put the symbol back
|
|
5315 into any obarray.) Finally, @code{mapatoms} maps over all of the symbols
|
|
5316 in an obarray.
|
|
5317
|
|
5318 @node Symbol Values
|
|
5319 @section Symbol Values
|
|
5320
|
|
5321 The value field of a symbol normally contains a Lisp object. However,
|
|
5322 a symbol can be @dfn{unbound}, meaning that it logically has no value.
|
|
5323 This is internally indicated by storing a special Lisp object, called
|
|
5324 @dfn{the unbound marker} and stored in the global variable
|
|
5325 @code{Qunbound}. The unbound marker is of a special Lisp object type
|
|
5326 called @dfn{symbol-value-magic}. It is impossible for the Lisp
|
|
5327 programmer to directly create or access any object of this type.
|
|
5328
|
|
5329 @strong{You must not let any ``symbol-value-magic'' object escape to
|
|
5330 the Lisp level.} Printing any of these objects will cause the message
|
|
5331 @samp{INTERNAL EMACS BUG} to appear as part of the print representation.
|
|
5332 (You may see this normally when you call @code{debug_print()} from the
|
|
5333 debugger on a Lisp object.) If you let one of these objects escape to
|
|
5334 the Lisp level, you will violate a number of assumptions contained in
|
|
5335 the C code and make the unbound marker not function right.
|
|
5336
|
|
5337 When a symbol is created, its value field (and function field) are set
|
|
5338 to @code{Qunbound}. The Lisp programmer can restore these conditions
|
|
5339 later using @code{makunbound} or @code{fmakunbound}, and can query to
|
|
5340 see whether the value of function fields are @dfn{bound} (i.e. have a
|
|
5341 value other than @code{Qunbound}) using @code{boundp} and
|
|
5342 @code{fboundp}. The fields are set to a normal Lisp object using
|
|
5343 @code{set} (or @code{setq}) and @code{fset}.
|
|
5344
|
|
5345 Other symbol-value-magic objects are used as special markers to
|
|
5346 indicate variables that have non-normal properties. This includes any
|
|
5347 variables that are tied into C variables (setting the variable magically
|
|
5348 sets some global variable in the C code, and likewise for retrieving the
|
|
5349 variable's value), variables that magically tie into slots in the
|
|
5350 current buffer, variables that are buffer-local, etc. The
|
|
5351 symbol-value-magic object is stored in the value cell in place of
|
|
5352 a normal object, and the code to retrieve a symbol's value
|
|
5353 (i.e. @code{symbol-value}) knows how to do special things with them.
|
|
5354 This means that you should not just fetch the value cell directly if you
|
|
5355 want a symbol's value.
|
|
5356
|
|
5357 The exact workings of this are rather complex and involved and are
|
|
5358 well-documented in comments in @file{buffer.c}, @file{symbols.c}, and
|
|
5359 @file{lisp.h}.
|
|
5360
|
|
5361 @node Buffers and Textual Representation, MULE Character Sets and Encodings, Symbols and Variables, Top
|
|
5362 @chapter Buffers and Textual Representation
|
|
5363
|
|
5364 @menu
|
|
5365 * Introduction to Buffers:: A buffer holds a block of text such as a file.
|
58
|
5366 * The Text in a Buffer:: Representation of the text in a buffer.
|
0
|
5367 * Buffer Lists:: Keeping track of all buffers.
|
|
5368 * Markers and Extents:: Tagging locations within a buffer.
|
|
5369 * Bufbytes and Emchars:: Representation of individual characters.
|
|
5370 * The Buffer Object:: The Lisp object corresponding to a buffer.
|
|
5371 @end menu
|
|
5372
|
|
5373 @node Introduction to Buffers
|
|
5374 @section Introduction to Buffers
|
|
5375
|
|
5376 A buffer is logically just a Lisp object that holds some text.
|
|
5377 In this, it is like a string, but a buffer is optimized for
|
|
5378 frequent insertion and deletion, while a string is not. Furthermore:
|
|
5379
|
|
5380 @enumerate
|
|
5381 @item
|
44
|
5382 Buffers are @dfn{permanent} objects, i.e. once you create them, they
|
0
|
5383 remain around, and need to be explicitly deleted before they go away.
|
|
5384 @item
|
|
5385 Each buffer has a unique name, which is a string. Buffers are
|
|
5386 normally referred to by name. In this respect, they are like
|
|
5387 symbols.
|
|
5388 @item
|
|
5389 Buffers have a default insertion position, called @dfn{point}.
|
|
5390 Inserting text (unless you explicitly give a position) goes at point,
|
|
5391 and moves point forward past the text. This is what is going on when
|
|
5392 you type text into Emacs.
|
|
5393 @item
|
|
5394 Buffers have lots of extra properties associated with them.
|
|
5395 @item
|
|
5396 Buffers can be @dfn{displayed}. What this means is that there
|
|
5397 exist a number of @dfn{windows}, which are objects that correspond
|
|
5398 to some visible section of your display, and each window has
|
|
5399 an associated buffer, and the current contents of the buffer
|
|
5400 are shown in that section of the display. The redisplay mechanism
|
|
5401 (which takes care of doing this) knows how to look at the
|
|
5402 text of a buffer and come up with some reasonable way of displaying
|
|
5403 this. Many of the properties of a buffer control how the
|
|
5404 buffer's text is displayed.
|
|
5405 @item
|
|
5406 One buffer is distinguished and called the @dfn{current buffer}. It is
|
|
5407 stored in the variable @code{current_buffer}. Buffer operations operate
|
|
5408 on this buffer by default. When you are typing text into a buffer, the
|
|
5409 buffer you are typing into is always @code{current_buffer}. Switching
|
|
5410 to a different window changes the current buffer. Note that Lisp code
|
|
5411 can temporarily change the current buffer using @code{set-buffer} (often
|
|
5412 enclosed in a @code{save-excursion} so that the former current buffer
|
|
5413 gets restored when the code is finished). However, calling
|
|
5414 @code{set-buffer} will NOT cause a permanent change in the current
|
|
5415 buffer. The reason for this is that the top-level event loop sets
|
44
|
5416 @code{current_buffer} to the buffer of the selected window, each time
|
|
5417 it finishes executing a user command.
|
0
|
5418 @end enumerate
|
|
5419
|
|
5420 Make sure you understand the distinction between @dfn{current buffer}
|
|
5421 and @dfn{buffer of the selected window}, and the distinction between
|
|
5422 @dfn{point} of the current buffer and @dfn{window-point} of the selected
|
|
5423 window. (This latter distinction is explained in detail in the section
|
|
5424 on windows.)
|
|
5425
|
58
|
5426 @node The Text in a Buffer
|
|
5427 @section The Text in a Buffer
|
0
|
5428
|
|
5429 The text in a buffer consists of a sequence of zero or more
|
|
5430 characters. A @dfn{character} is an integer that logically represents
|
|
5431 a letter, number, space, or other unit of text. Most of the characters
|
|
5432 that you will typically encounter belong to the ASCII set of characters,
|
|
5433 but there are also characters for various sorts of accented letters,
|
|
5434 special symbols, Chinese and Japanese ideograms (i.e. Kanji, Katakana,
|
|
5435 etc.), Cyrillic and Greek letters, etc. The actual number of possible
|
|
5436 characters is quite large.
|
|
5437
|
|
5438 For now, we can view a character as some non-negative integer that
|
|
5439 has some shape that defines how it typically appears (e.g. as an
|
44
|
5440 uppercase A). (The exact way in which a character appears depends on the
|
|
5441 font used to display the character.) The internal type of characters in
|
|
5442 the C code is an @code{Emchar}; this is just an @code{int}, but using a
|
|
5443 symbolic type makes the code clearer.
|
0
|
5444
|
|
5445 Between every character in a buffer is a @dfn{buffer position} or
|
|
5446 @dfn{character position}. We can speak of the character before or after
|
|
5447 a particular buffer position, and when you insert a character at a
|
|
5448 particular position, all characters after that position end up at new
|
|
5449 positions. When we speak of the character @dfn{at} a position, we
|
|
5450 really mean the character after the position. (This schizophrenia
|
|
5451 between a buffer position being ``between'' a character and ``on'' a
|
|
5452 character is rampant in Emacs.)
|
|
5453
|
|
5454 Buffer positions are numbered starting at 1. This means that
|
|
5455 position 1 is before the first character, and position 0 is not
|
|
5456 valid. If there are N characters in a buffer, then buffer
|
|
5457 position N+1 is after the last one, and position N+2 is not valid.
|
|
5458
|
|
5459 The internal makeup of the Emchar integer varies depending on whether
|
|
5460 we have compiled with MULE support. If not, the Emchar integer is an
|
|
5461 8-bit integer with possible values from 0 - 255. 0 - 127 are the
|
|
5462 standard ASCII characters, while 128 - 255 are the characters from the
|
|
5463 ISO-8859-1 character set. If we have compiled with MULE support, an
|
|
5464 Emchar is a 19-bit integer, with the various bits having meanings
|
|
5465 according to a complex scheme that will be detailed later. The
|
|
5466 characters numbered 0 - 255 still have the same meanings as for the
|
|
5467 non-MULE case, though.
|
|
5468
|
|
5469 Internally, the text in a buffer is represented in a fairly simple
|
|
5470 fashion: as a contiguous array of bytes, with a @dfn{gap} of some size
|
|
5471 in the middle. Although the gap is of some substantial size in bytes,
|
|
5472 there is no text contained within it: From the perspective of the text
|
|
5473 in the buffer, it does not exist. The gap logically sits at some buffer
|
|
5474 position, between two characters (or possibly at the beginning or end of
|
|
5475 the buffer). Insertion of text in a buffer at a particular position is
|
|
5476 always accomplished by first moving the gap to that position
|
|
5477 (i.e. through some block moving of text), then writing the text into the
|
|
5478 beginning of the gap, thereby shrinking the gap. If the gap shrinks
|
|
5479 down to nothing, a new gap is created. (What actually happens is that a
|
|
5480 new gap is ``created'' at the end of the buffer's text, which requires
|
|
5481 nothing more than changing a couple of indices; then the gap is
|
|
5482 ``moved'' to the position where the insertion needs to take place by
|
|
5483 moving up in memory all the text after that position.) Similarly,
|
|
5484 deletion occurs by moving the gap to the place where the text is to be
|
|
5485 deleted, and then simply expanding the gap to include the deleted text.
|
|
5486 (@dfn{Expanding} and @dfn{shrinking} the gap as just described means
|
|
5487 just that the internal indices that keep track of where the gap is
|
|
5488 located are changed.)
|
|
5489
|
|
5490 Note that the total amount of memory allocated for a buffer text never
|
|
5491 decreases while the buffer is live. Therefore, if you load up a
|
|
5492 20-megabyte file and then delete all but one character, there will be a
|
|
5493 20-megabyte gap, which won't get any smaller (except by inserting
|
|
5494 characters back again). Once the buffer is killed, the memory allocated
|
|
5495 for the buffer text will be freed, but it will still be sitting on the
|
|
5496 heap, taking up virtual memory, and will not be released back to the
|
|
5497 operating system. (However, if you have compiled XEmacs with rel-alloc,
|
|
5498 the situation is different. In this case, the space @emph{will} be
|
44
|
5499 released back to the operating system. However, this tends to result in a
|
0
|
5500 noticeable speed penalty.)
|
|
5501
|
|
5502 Astute readers may notice that the text in a buffer is represented as
|
|
5503 an array of @emph{bytes}, while (at least in the MULE case) an Emchar is
|
|
5504 a 19-bit integer, which clearly cannot fit in a byte. This means (of
|
|
5505 course) that the text in a buffer uses a different representation from
|
|
5506 an Emchar: specifically, the 19-bit Emchar becomes a series of one to
|
|
5507 four bytes. The conversion between these two representations is complex
|
|
5508 and will be described later.
|
|
5509
|
|
5510 In the non-MULE case, everything is very simple: An Emchar
|
|
5511 is an 8-bit value, which fits neatly into one byte.
|
|
5512
|
|
5513 If we are given a buffer position and want to retrieve the
|
|
5514 character at that position, we need to follow these steps:
|
|
5515
|
|
5516 @enumerate
|
|
5517 @item
|
|
5518 Pretend there's no gap, and convert the buffer position into a @dfn{byte
|
|
5519 index} that indexes to the appropriate byte in the buffer's stream of
|
|
5520 textual bytes. By convention, byte indices begin at 1, just like buffer
|
|
5521 positions. In the non-MULE case, byte indices and buffer positions are
|
|
5522 identical, since one character equals one byte.
|
|
5523 @item
|
|
5524 Convert the byte index into a @dfn{memory index}, which takes the gap
|
|
5525 into account. The memory index is a direct index into the block of
|
|
5526 memory that stores the text of a buffer. This basically just involves
|
|
5527 checking to see if the byte index is past the gap, and if so, adding the
|
|
5528 size of the gap to it. By convention, memory indices begin at 1, just
|
|
5529 like buffer positions and byte indices, and when referring to the
|
|
5530 position that is @dfn{at} the gap, we always use the memory position at
|
|
5531 the @emph{beginning}, not at the end, of the gap.
|
|
5532 @item
|
|
5533 Fetch the appropriate bytes at the determined memory position.
|
|
5534 @item
|
|
5535 Convert these bytes into an Emchar.
|
|
5536 @end enumerate
|
|
5537
|
|
5538 In the non-Mule case, (3) and (4) boil down to a simple one-byte
|
|
5539 memory access.
|
|
5540
|
|
5541 Note that we have defined three types of positions in a buffer:
|
|
5542
|
|
5543 @enumerate
|
|
5544 @item
|
|
5545 @dfn{buffer positions} or @dfn{character positions}, typedef @code{Bufpos}
|
|
5546 @item
|
|
5547 @dfn{byte indices}, typedef @code{Bytind}
|
|
5548 @item
|
|
5549 @dfn{memory indices}, typedef @code{Memind}
|
|
5550 @end enumerate
|
|
5551
|
44
|
5552 All three typedefs are just @code{int}s, but defining them this way makes
|
0
|
5553 things a lot clearer.
|
|
5554
|
|
5555 Most code works with buffer positions. In particular, all Lisp code
|
|
5556 that refers to text in a buffer uses buffer positions. Lisp code does
|
|
5557 not know that byte indices or memory indices exist.
|
|
5558
|
|
5559 Finally, we have a typedef for the bytes in a buffer. This is a
|
|
5560 @code{Bufbyte}, which is an unsigned char. Referring to them as
|
|
5561 Bufbytes underscores the fact that we are working with a string of bytes
|
|
5562 in the internal Emacs buffer representation rather than in one of a
|
44
|
5563 number of possible alternative representations (e.g. EUC-encoded text,
|
0
|
5564 etc.).
|
|
5565
|
|
5566 @node Buffer Lists
|
|
5567 @section Buffer Lists
|
|
5568
|
|
5569 Recall earlier that buffers are @dfn{permanent} objects, i.e. that
|
|
5570 they remain around until explicitly deleted. This entails that there is
|
|
5571 a list of all the buffers in existence. This list is actually an
|
|
5572 assoc-list (mapping from the buffer's name to the buffer) and is stored
|
|
5573 in the global variable @code{Vbuffer_alist}.
|
|
5574
|
|
5575 The order of the buffers in the list is important: the buffers are
|
|
5576 ordered approximately from most-recently-used to least-recently-used.
|
|
5577 Switching to a buffer using @code{switch-to-buffer},
|
|
5578 @code{pop-to-buffer}, etc. and switching windows using
|
|
5579 @code{other-window}, etc. usually brings the new current buffer to the
|
|
5580 front of the list. @code{switch-to-buffer}, @code{other-buffer},
|
|
5581 etc. look at the beginning of the list to find an alternative buffer to
|
|
5582 suggest. You can also explicitly move a buffer to the end of the list
|
|
5583 using @code{bury-buffer}.
|
|
5584
|
|
5585 In addition to the global ordering in @code{Vbuffer_alist}, each frame
|
|
5586 has its own ordering of the list. These lists always contain the same
|
|
5587 elements as in @code{Vbuffer_alist} although possibly in a different
|
|
5588 order. @code{buffer-list} normally returns the list for the selected
|
|
5589 frame. This allows you to work in separate frames without things
|
|
5590 interfering with each other.
|
|
5591
|
|
5592 The standard way to look up a buffer given a name is
|
|
5593 @code{get-buffer}, and the standard way to create a new buffer is
|
|
5594 @code{get-buffer-create}, which looks up a buffer with a given name,
|
|
5595 creating a new one if necessary. These operations correspond exactly
|
|
5596 with the symbol operations @code{intern-soft} and @code{intern},
|
|
5597 respectively. You can also force a new buffer to be created using
|
|
5598 @code{generate-new-buffer}, which takes a name and (if necessary) makes
|
|
5599 a unique name from this by appending a number, and then creates the
|
|
5600 buffer. This is basically like the symbol operation @code{gensym}.
|
|
5601
|
|
5602 @node Markers and Extents
|
|
5603 @section Markers and Extents
|
|
5604
|
|
5605 Among the things associated with a buffer are things that are
|
|
5606 logically attached to certain buffer positions. This can be used to
|
|
5607 keep track of a buffer position when text is inserted and deleted, so
|
|
5608 that it remains at the same spot relative to the text around it; to
|
|
5609 assign properties to particular sections of text; etc. There are two
|
|
5610 such objects that are useful in this regard: they are @dfn{markers} and
|
|
5611 @dfn{extents}.
|
|
5612
|
|
5613 A @dfn{marker} is simply a flag placed at a particular buffer
|
|
5614 position, which is moved around as text is inserted and deleted.
|
|
5615 Markers are used for all sorts of purposes, such as the @code{mark} that
|
|
5616 is the other end of textual regions to be cut, copied, etc.
|
|
5617
|
|
5618 An @dfn{extent} is similar to two markers plus some associated
|
|
5619 properties, and is used to keep track of regions in a buffer as text is
|
|
5620 inserted and deleted, and to add properties (e.g. fonts) to particular
|
|
5621 regions of text. The external interface of extents is explained
|
|
5622 elsewhere.
|
|
5623
|
|
5624 The important thing here is that markers and extents simply contain
|
|
5625 buffer positions in them as integers, and every time text is inserted or
|
|
5626 deleted, these positions must be updated. In order to minimize the
|
|
5627 amount of shuffling that needs to be done, the positions in markers and
|
|
5628 extents (there's one per marker, two per extent) and stored in Meminds.
|
|
5629 This means that they only need to be moved when the text is physically
|
|
5630 moved in memory; since the gap structure tries to minimize this, it also
|
|
5631 minimizes the number of marker and extent indices that need to be
|
|
5632 adjusted. Look in @file{insdel.c} for the details of how this works.
|
|
5633
|
|
5634 One other important distinction is that markers are @dfn{temporary}
|
|
5635 while extents are @dfn{permanent}. This means that markers disappear as
|
|
5636 soon as there are no more pointers to them, and correspondingly, there
|
|
5637 is no way to determine what markers are in a buffer if you are just
|
|
5638 given the buffer. Extents remain in a buffer until they are detached
|
|
5639 (which could happen as a result of text being deleted) or the buffer is
|
|
5640 deleted, and primitives do exist to enumerate the extents in a buffer.
|
|
5641
|
|
5642 @node Bufbytes and Emchars
|
|
5643 @section Bufbytes and Emchars
|
|
5644
|
|
5645 Not yet documented.
|
|
5646
|
|
5647 @node The Buffer Object
|
|
5648 @section The Buffer Object
|
|
5649
|
|
5650 Buffers contain fields not directly accessible by the Lisp programmer.
|
|
5651 We describe them here, naming them by the names used in the C code.
|
|
5652 Many are accessible indirectly in Lisp programs via Lisp primitives.
|
|
5653
|
|
5654 @table @code
|
|
5655 @item name
|
|
5656 The buffer name is a string that names the buffer. It is guaranteed to
|
|
5657 be unique. @xref{Buffer Names,,, lispref, XEmacs Lisp Programmer's
|
|
5658 Manual}.
|
|
5659
|
|
5660 @item save_modified
|
|
5661 This field contains the time when the buffer was last saved, as an
|
|
5662 integer. @xref{Buffer Modification,,, lispref, XEmacs Lisp Programmer's
|
|
5663 Manual}.
|
|
5664
|
|
5665 @item modtime
|
|
5666 This field contains the modification time of the visited file. It is
|
|
5667 set when the file is written or read. Every time the buffer is written
|
|
5668 to the file, this field is compared to the modification time of the
|
|
5669 file. @xref{Buffer Modification,,, lispref, XEmacs Lisp Programmer's
|
|
5670 Manual}.
|
|
5671
|
|
5672 @item auto_save_modified
|
|
5673 This field contains the time when the buffer was last auto-saved.
|
|
5674
|
|
5675 @item last_window_start
|
|
5676 This field contains the @code{window-start} position in the buffer as of
|
|
5677 the last time the buffer was displayed in a window.
|
|
5678
|
|
5679 @item undo_list
|
|
5680 This field points to the buffer's undo list. @xref{Undo,,, lispref,
|
|
5681 XEmacs Lisp Programmer's Manual}.
|
|
5682
|
|
5683 @item syntax_table_v
|
|
5684 This field contains the syntax table for the buffer. @xref{Syntax
|
|
5685 Tables,,, lispref, XEmacs Lisp Programmer's Manual}.
|
|
5686
|
|
5687 @item downcase_table
|
|
5688 This field contains the conversion table for converting text to lower
|
|
5689 case. @xref{Case Tables,,, lispref, XEmacs Lisp Programmer's Manual}.
|
|
5690
|
|
5691 @item upcase_table
|
|
5692 This field contains the conversion table for converting text to upper
|
|
5693 case. @xref{Case Tables,,, lispref, XEmacs Lisp Programmer's Manual}.
|
|
5694
|
|
5695 @item case_canon_table
|
|
5696 This field contains the conversion table for canonicalizing text for
|
|
5697 case-folding search. @xref{Case Tables,,, lispref, XEmacs Lisp
|
|
5698 Programmer's Manual}.
|
|
5699
|
|
5700 @item case_eqv_table
|
|
5701 This field contains the equivalence table for case-folding search.
|
|
5702 @xref{Case Tables,,, lispref, XEmacs Lisp Programmer's Manual}.
|
|
5703
|
|
5704 @item display_table
|
|
5705 This field contains the buffer's display table, or @code{nil} if it
|
|
5706 doesn't have one. @xref{Display Tables,,, lispref, XEmacs Lisp
|
|
5707 Programmer's Manual}.
|
|
5708
|
|
5709 @item markers
|
|
5710 This field contains the chain of all markers that currently point into
|
|
5711 the buffer. Deletion of text in the buffer, and motion of the buffer's
|
|
5712 gap, must check each of these markers and perhaps update it.
|
|
5713 @xref{Markers,,, lispref, XEmacs Lisp Programmer's Manual}.
|
|
5714
|
|
5715 @item backed_up
|
|
5716 This field is a flag that tells whether a backup file has been made for
|
|
5717 the visited file of this buffer.
|
|
5718
|
|
5719 @item mark
|
|
5720 This field contains the mark for the buffer. The mark is a marker,
|
|
5721 hence it is also included on the list @code{markers}. @xref{The Mark,,,
|
|
5722 lispref, XEmacs Lisp Programmer's Manual}.
|
|
5723
|
|
5724 @item mark_active
|
|
5725 This field is non-@code{nil} if the buffer's mark is active.
|
|
5726
|
|
5727 @item local_var_alist
|
|
5728 This field contains the association list describing the variables local
|
|
5729 in this buffer, and their values, with the exception of local variables
|
|
5730 that have special slots in the buffer object. (Those slots are omitted
|
|
5731 from this table.) @xref{Buffer-Local Variables,,, lispref, XEmacs Lisp
|
|
5732 Programmer's Manual}.
|
|
5733
|
|
5734 @item modeline_format
|
|
5735 This field contains a Lisp object which controls how to display the mode
|
|
5736 line for this buffer. @xref{Modeline Format,,, lispref, XEmacs Lisp
|
|
5737 Programmer's Manual}.
|
|
5738
|
|
5739 @item base_buffer
|
|
5740 This field holds the buffer's base buffer (if it is an indirect buffer),
|
|
5741 or @code{nil}.
|
|
5742 @end table
|
|
5743
|
|
5744 @node MULE Character Sets and Encodings, The Lisp Reader and Compiler, Buffers and Textual Representation, Top
|
|
5745 @chapter MULE Character Sets and Encodings
|
|
5746
|
|
5747 Recall that there are two primary ways that text is represented in
|
|
5748 XEmacs. The @dfn{buffer} representation sees the text as a series of
|
|
5749 bytes (Bufbytes), with a variable number of bytes used per character.
|
|
5750 The @dfn{character} representation sees the text as a series of integers
|
|
5751 (Emchars), one per character. The character representation is a cleaner
|
|
5752 representation from a theoretical standpoint, and is thus used in many
|
|
5753 cases when lots of manipulations on a string need to be done. However,
|
|
5754 the buffer representation is the standard representation used in both
|
|
5755 Lisp strings and buffers, and because of this, it is the ``default''
|
|
5756 representation that text comes in. The reason for using this
|
|
5757 representation is that it's compact and is compatible with ASCII.
|
|
5758
|
|
5759 @menu
|
|
5760 * Character Sets::
|
|
5761 * Encodings::
|
|
5762 * Internal Mule Encodings::
|
|
5763 * CCL::
|
|
5764 @end menu
|
|
5765
|
|
5766 @node Character Sets
|
|
5767 @section Character Sets
|
|
5768
|
|
5769 A character set (or @dfn{charset}) is an ordered set of characters. A
|
|
5770 particular character in a charset is indexed using one or more
|
|
5771 @dfn{position codes}, which are non-negative integers. The number of
|
|
5772 position codes needed to identify a particular character in a charset is
|
|
5773 called the @dfn{dimension} of the charset. In XEmacs/Mule, all charsets
|
|
5774 have dimension 1 or 2, and the size of all charsets (except for a few
|
|
5775 special cases) is either 94, 96, 94 by 94, or 96 by 96. The range of
|
|
5776 position codes used to index characters from any of these types of
|
|
5777 character sets is as follows:
|
|
5778
|
|
5779 @example
|
|
5780 Charset type Position code 1 Position code 2
|
|
5781 ------------------------------------------------------------
|
|
5782 94 33 - 126 N/A
|
|
5783 96 32 - 127 N/A
|
|
5784 94x94 33 - 126 33 - 126
|
|
5785 96x96 32 - 127 32 - 127
|
|
5786 @end example
|
|
5787
|
|
5788 Note that in the above cases position codes do not start at an
|
|
5789 expected value such as 0 or 1. The reason for this will become clear
|
|
5790 later.
|
|
5791
|
|
5792 For example, Latin-1 is a 96-character charset, and JISX0208 (the
|
|
5793 Japanese national character set) is a 94x94-character charset.
|
|
5794
|
|
5795 [Note that, although the ranges above define the @emph{valid} position
|
|
5796 codes for a charset, some of the slots in a particular charset may in
|
|
5797 fact be empty. This is the case for JISX0208, for example, where (e.g.)
|
|
5798 all the slots whose first position code is in the range 118 - 127 are
|
|
5799 empty.]
|
|
5800
|
|
5801 There are three charsets that do not follow the above rules. All of
|
|
5802 them have one dimension, and have ranges of position codes as follows:
|
|
5803
|
|
5804 @example
|
|
5805 Charset name Position code 1
|
|
5806 ------------------------------------
|
|
5807 ASCII 0 - 127
|
|
5808 Control-1 0 - 31
|
|
5809 Composite 0 - some large number
|
|
5810 @end example
|
|
5811
|
|
5812 (The upper bound of the position code for composite characters has not
|
|
5813 yet been determined, but it will probably be at least 16,383).
|
|
5814
|
|
5815 ASCII is the union of two subsidiary character sets: Printing-ASCII
|
|
5816 (the printing ASCII character set, consisting of position codes 33 -
|
|
5817 126, like for a standard 94-character charset) and Control-ASCII (the
|
|
5818 non-printing characters that would appear in a binary file with codes 0
|
|
5819 - 32 and 127).
|
|
5820
|
|
5821 Control-1 contains the non-printing characters that would appear in a
|
|
5822 binary file with codes 128 - 159.
|
|
5823
|
|
5824 Composite contains characters that are generated by overstriking one
|
|
5825 or more characters from other charsets.
|
|
5826
|
|
5827 Note that some characters in ASCII, and all characters in Control-1,
|
|
5828 are @dfn{control} (non-printing) characters. These have no printed
|
|
5829 representation but instead control some other function of the printing
|
|
5830 (e.g. TAB or 8 moves the current character position to the next tab
|
|
5831 stop). All other characters in all charsets are @dfn{graphic}
|
|
5832 (printing) characters.
|
|
5833
|
|
5834 When a binary file is read in, the bytes in the file are assigned to
|
|
5835 character sets as follows:
|
|
5836
|
|
5837 @example
|
|
5838 Bytes Character set Range
|
|
5839 --------------------------------------------------
|
|
5840 0 - 127 ASCII 0 - 127
|
|
5841 128 - 159 Control-1 0 - 31
|
|
5842 160 - 255 Latin-1 32 - 127
|
|
5843 @end example
|
|
5844
|
|
5845 This is a bit ad-hoc but gets the job done.
|
|
5846
|
|
5847 @node Encodings
|
|
5848 @section Encodings
|
|
5849
|
|
5850 An @dfn{encoding} is a way of numerically representing characters from
|
|
5851 one or more character sets. If an encoding only encompasses one
|
|
5852 character set, then the position codes for the characters in that
|
|
5853 character set could be used directly. This is not possible, however, if
|
|
5854 more than one character set is to be used in the encoding.
|
|
5855
|
|
5856 For example, the conversion detailed above between bytes in a binary
|
|
5857 file and characters is effectively an encoding that encompasses the
|
|
5858 three character sets ASCII, Control-1, and Latin-1 in a stream of 8-bit
|
|
5859 bytes.
|
|
5860
|
|
5861 Thus, an encoding can be viewed as a way of encoding characters from a
|
|
5862 specified group of character sets using a stream of bytes, each of which
|
|
5863 contains a fixed number of bits (but not necessarily 8, as in the common
|
|
5864 usage of ``byte'').
|
|
5865
|
|
5866 Here are descriptions of a couple of common
|
|
5867 encodings:
|
|
5868
|
|
5869 @menu
|
|
5870 * Japanese EUC (Extended Unix Code)::
|
|
5871 * JIS7::
|
|
5872 @end menu
|
|
5873
|
|
5874 @node Japanese EUC (Extended Unix Code)
|
|
5875 @subsection Japanese EUC (Extended Unix Code)
|
|
5876
|
44
|
5877 This encompasses the character sets Printing-ASCII, Japanese-JISSX0201,
|
|
5878 and Japanese-JISX0208-Kana (half-width katakana, the right half of
|
0
|
5879 JISX0201). It uses 8-bit bytes.
|
|
5880
|
44
|
5881 Note that Printing-ASCII and Japanese-JISX0201-Kana are 94-character
|
|
5882 charsets, while Japanese-JISX0208 is a 94x94-character charset.
|
|
5883
|
|
5884 The encoding is as follows:
|
0
|
5885
|
|
5886 @example
|
44
|
5887 Character set Representation (PC=position-code)
|
|
5888 ------------- --------------
|
|
5889 Printing-ASCII PC1
|
|
5890 Japanese-JISX0201-Kana 0x8E | PC1 + 0x80
|
|
5891 Japanese-JISX0208 PC1 + 0x80 | PC2 + 0x80
|
|
5892 Japanese-JISX0212 PC1 + 0x80 | PC2 + 0x80
|
0
|
5893 @end example
|
|
5894
|
|
5895
|
|
5896 @node JIS7
|
|
5897 @subsection JIS7
|
|
5898
|
44
|
5899 This encompasses the character sets Printing-ASCII,
|
|
5900 Japanese-JISX0201-Roman (the left half of JISX0201; this character set
|
|
5901 is very similar to Printing-ASCII and is a 94-character charset),
|
|
5902 Japanese-JISX0208, and Japanese-JISX0201-Kana. It uses 7-bit bytes.
|
|
5903
|
|
5904 Unlike Japanese EUC, this is a @dfn{modal} encoding, which
|
0
|
5905 means that there are multiple states that the encoding can
|
|
5906 be in, which affect how the bytes are to be interpreted.
|
|
5907 Special sequences of bytes (called @dfn{escape sequences})
|
|
5908 are used to change states.
|
|
5909
|
|
5910 The encoding is as follows:
|
|
5911
|
|
5912 @example
|
44
|
5913 Character set Representation (PC=position-code)
|
|
5914 ------------- --------------
|
|
5915 Printing-ASCII PC1
|
|
5916 Japanese-JISX0201-Roman PC1
|
|
5917 Japanese-JISX0201-Kana PC1
|
|
5918 Japanese-JISX0208 PC1 PC2
|
0
|
5919
|
|
5920
|
|
5921 Escape sequence ASCII equivalent Meaning
|
|
5922 --------------- ---------------- -------
|
44
|
5923 0x1B 0x28 0x4A ESC ( J invoke Japanese-JISX0201-Roman
|
|
5924 0x1B 0x28 0x49 ESC ( I invoke Japanese-JISX0201-Kana
|
|
5925 0x1B 0x24 0x42 ESC $ B invoke Japanese-JISX0208
|
0
|
5926 0x1B 0x28 0x42 ESC ( B invoke Printing-ASCII
|
|
5927 @end example
|
|
5928
|
|
5929 Initially, Printing-ASCII is invoked.
|
|
5930
|
|
5931 @node Internal Mule Encodings
|
|
5932 @section Internal Mule Encodings
|
|
5933
|
44
|
5934 In XEmacs/Mule, each character set is assigned a unique number, called a
|
|
5935 @dfn{leading byte}. This is used in the encodings of a character.
|
|
5936 Leading bytes are in the range 0x80 - 0xFF (except for ASCII, which has
|
|
5937 a leading byte of 0), although some leading bytes are reserved.
|
|
5938
|
|
5939 Charsets whose leading byte is in the range 0x80 - 0x9F are called
|
|
5940 @dfn{official} and are used for built-in charsets. Other charsets are
|
|
5941 called @dfn{private} and have leading bytes in the range 0xA0 - 0xFF;
|
|
5942 these are user-defined charsets.
|
0
|
5943
|
|
5944 More specifically:
|
|
5945
|
|
5946 @example
|
|
5947 Character set Leading byte
|
|
5948 ------------- ------------
|
|
5949 ASCII 0
|
|
5950 Composite 0x80
|
|
5951 Dimension-1 Official 0x81 - 0x8D
|
|
5952 (0x8E is free)
|
|
5953 Control-1 0x8F
|
|
5954 Dimension-2 Official 0x90 - 0x99
|
|
5955 (0x9A - 0x9D are free;
|
|
5956 0x9E and 0x9F are reserved)
|
|
5957 Dimension-1 Private 0xA0 - 0xEF
|
|
5958 Dimension-2 Private 0xF0 - 0xFF
|
|
5959 @end example
|
|
5960
|
44
|
5961 There are two internal encodings for characters in XEmacs/Mule. One is
|
|
5962 called @dfn{string encoding} and is an 8-bit encoding that is used for
|
|
5963 representing characters in a buffer or string. It uses 1 to 4 bytes per
|
|
5964 character. The other is called @dfn{character encoding} and is a 19-bit
|
|
5965 encoding that is used for representing characters individually in a
|
|
5966 variable.
|
|
5967
|
|
5968 (In the following descriptions, we'll ignore composite characters for
|
|
5969 the moment. We also give a general (structural) overview first,
|
|
5970 followed later by the exact details.)
|
0
|
5971
|
|
5972 @menu
|
|
5973 * Internal String Encoding::
|
|
5974 * Internal Character Encoding::
|
|
5975 @end menu
|
|
5976
|
|
5977 @node Internal String Encoding
|
|
5978 @subsection Internal String Encoding
|
|
5979
|
44
|
5980 ASCII characters are encoded using their position code directly. Other
|
|
5981 characters are encoded using their leading byte followed by their
|
|
5982 position code(s) with the high bit set. Characters in private character
|
|
5983 sets have their leading byte prefixed with a @dfn{leading byte prefix},
|
|
5984 which is either 0x9E or 0x9F. (No character sets are ever assigned these
|
|
5985 leading bytes.) Specifically:
|
0
|
5986
|
|
5987 @example
|
|
5988 Character set Encoding (PC=position-code, LB=leading-byte)
|
|
5989 ------------- --------
|
|
5990 ASCII PC-1 |
|
|
5991 Control-1 LB | PC1 + 0xA0 |
|
|
5992 Dimension-1 official LB | PC1 + 0x80 |
|
|
5993 Dimension-1 private 0x9E | LB | PC1 + 0x80 |
|
|
5994 Dimension-2 official LB | PC1 + 0x80 | PC2 + 0x80 |
|
|
5995 Dimension-2 private 0x9F | LB | PC1 + 0x80 | PC2 + 0x80
|
|
5996 @end example
|
|
5997
|
|
5998 The basic characteristic of this encoding is that the first byte
|
|
5999 of all characters is in the range 0x00 - 0x9F, and the second and
|
|
6000 following bytes of all characters is in the range 0xA0 - 0xFF.
|
|
6001 This means that it is impossible to get out of sync, or more
|
|
6002 specifically:
|
|
6003
|
|
6004 @enumerate
|
|
6005 @item
|
|
6006 Given any byte position, the beginning of the character it is
|
|
6007 within can be determined in constant time.
|
|
6008 @item
|
|
6009 Given any byte position at the beginning of a character, the
|
|
6010 beginning of the next character can be determined in constant
|
|
6011 time.
|
|
6012 @item
|
|
6013 Given any byte position at the beginning of a character, the
|
|
6014 beginning of the previous character can be determined in constant
|
|
6015 time.
|
|
6016 @item
|
|
6017 Textual searches can simply treat encoded strings as if they
|
|
6018 were encoded in a one-byte-per-character fashion rather than
|
|
6019 the actual multi-byte encoding.
|
|
6020 @end enumerate
|
|
6021
|
|
6022 None of the standard non-modal encodings meet all of these
|
|
6023 conditions. For example, EUC satisfies only (2) and (3), while
|
|
6024 Shift-JIS and Big5 (not yet described) satisfy only (2). (All
|
|
6025 non-modal encodings must satisfy (2), in order to be unambiguous.)
|
|
6026
|
|
6027 @node Internal Character Encoding
|
|
6028 @subsection Internal Character Encoding
|
|
6029
|
|
6030 One 19-bit word represents a single character. The word is
|
|
6031 separated into three fields:
|
|
6032
|
|
6033 @example
|
|
6034 Bit number: 18 17 16 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
|
|
6035 <------------> <------------------> <------------------>
|
|
6036 Field: 1 2 3
|
|
6037 @end example
|
|
6038
|
|
6039 Note that fields 2 and 3 hold 7 bits each, while field 1 holds 5 bits.
|
|
6040
|
|
6041 @example
|
|
6042 Character set Field 1 Field 2 Field 3
|
|
6043 ------------- ------- ------- -------
|
|
6044 ASCII 0 0 PC1
|
|
6045 range: (00 - 7F)
|
|
6046 Control-1 0 1 PC1
|
|
6047 range: (00 - 1F)
|
|
6048 Dimension-1 official 0 LB - 0x80 PC1
|
|
6049 range: (01 - 0D) (20 - 7F)
|
|
6050 Dimension-1 private 0 LB - 0x80 PC1
|
|
6051 range: (20 - 6F) (20 - 7F)
|
|
6052 Dimension-2 official LB - 0x8F PC1 PC2
|
|
6053 range: (01 - 0A) (20 - 7F) (20 - 7F)
|
|
6054 Dimension-2 private LB - 0xE1 PC1 PC2
|
|
6055 range: (0F - 1E) (20 - 7F) (20 - 7F)
|
|
6056 Composite 0x1F ? ?
|
|
6057 @end example
|
|
6058
|
|
6059 Note that character codes 0 - 255 are the same as the ``binary encoding''
|
|
6060 described above.
|
|
6061
|
|
6062 @node CCL
|
|
6063 @section CCL
|
|
6064
|
|
6065 @example
|
|
6066 CCL PROGRAM SYNTAX:
|
|
6067 CCL_PROGRAM := (CCL_MAIN_BLOCK
|
|
6068 [ CCL_EOF_BLOCK ])
|
|
6069
|
|
6070 CCL_MAIN_BLOCK := CCL_BLOCK
|
|
6071 CCL_EOF_BLOCK := CCL_BLOCK
|
|
6072
|
|
6073 CCL_BLOCK := STATEMENT | (STATEMENT [STATEMENT ...])
|
|
6074 STATEMENT :=
|
|
6075 SET | IF | BRANCH | LOOP | REPEAT | BREAK
|
|
6076 | READ | WRITE
|
|
6077
|
|
6078 SET := (REG = EXPRESSION) | (REG SELF_OP EXPRESSION)
|
|
6079 | INT-OR-CHAR
|
|
6080
|
|
6081 EXPRESSION := ARG | (EXPRESSION OP ARG)
|
|
6082
|
|
6083 IF := (if EXPRESSION CCL_BLOCK CCL_BLOCK)
|
|
6084 BRANCH := (branch EXPRESSION CCL_BLOCK [CCL_BLOCK ...])
|
|
6085 LOOP := (loop STATEMENT [STATEMENT ...])
|
|
6086 BREAK := (break)
|
|
6087 REPEAT := (repeat)
|
|
6088 | (write-repeat [REG | INT-OR-CHAR | string])
|
|
6089 | (write-read-repeat REG [INT-OR-CHAR | string | ARRAY]?)
|
|
6090 READ := (read REG) | (read REG REG)
|
|
6091 | (read-if REG ARITH_OP ARG CCL_BLOCK CCL_BLOCK)
|
|
6092 | (read-branch REG CCL_BLOCK [CCL_BLOCK ...])
|
|
6093 WRITE := (write REG) | (write REG REG)
|
|
6094 | (write INT-OR-CHAR) | (write STRING) | STRING
|
|
6095 | (write REG ARRAY)
|
|
6096 END := (end)
|
|
6097
|
|
6098 REG := r0 | r1 | r2 | r3 | r4 | r5 | r6 | r7
|
|
6099 ARG := REG | INT-OR-CHAR
|
|
6100 OP := + | - | * | / | % | & | '|' | ^ | << | >> | <8 | >8 | //
|
|
6101 | < | > | == | <= | >= | !=
|
|
6102 SELF_OP :=
|
|
6103 += | -= | *= | /= | %= | &= | '|=' | ^= | <<= | >>=
|
|
6104 ARRAY := '[' INT-OR-CHAR ... ']'
|
|
6105 INT-OR-CHAR := INT | CHAR
|
|
6106
|
|
6107 MACHINE CODE:
|
|
6108
|
|
6109 The machine code consists of a vector of 32-bit words.
|
|
6110 The first such word specifies the start of the EOF section of the code;
|
|
6111 this is the code executed to handle any stuff that needs to be done
|
|
6112 (e.g. designating back to ASCII and left-to-right mode) after all
|
|
6113 other encoded/decoded data has been written out. This is not used for
|
|
6114 charset CCL programs.
|
|
6115
|
|
6116 REGISTER: 0..7 -- refered by RRR or rrr
|
|
6117
|
|
6118 OPERATOR BIT FIELD (27-bit): XXXXXXXXXXXXXXX RRR TTTTT
|
|
6119 TTTTT (5-bit): operator type
|
|
6120 RRR (3-bit): register number
|
|
6121 XXXXXXXXXXXXXXXX (15-bit):
|
|
6122 CCCCCCCCCCCCCCC: constant or address
|
|
6123 000000000000rrr: register number
|
|
6124
|
|
6125 AAAA: 00000 +
|
|
6126 00001 -
|
|
6127 00010 *
|
|
6128 00011 /
|
|
6129 00100 %
|
|
6130 00101 &
|
|
6131 00110 |
|
|
6132 00111 ~
|
|
6133
|
|
6134 01000 <<
|
|
6135 01001 >>
|
|
6136 01010 <8
|
|
6137 01011 >8
|
|
6138 01100 //
|
|
6139 01101 not used
|
|
6140 01110 not used
|
|
6141 01111 not used
|
|
6142
|
|
6143 10000 <
|
|
6144 10001 >
|
|
6145 10010 ==
|
|
6146 10011 <=
|
|
6147 10100 >=
|
|
6148 10101 !=
|
|
6149
|
|
6150 OPERATORS: TTTTT RRR XX..
|
|
6151
|
|
6152 SetCS: 00000 RRR C...C RRR = C...C
|
|
6153 SetCL: 00001 RRR ..... RRR = c...c
|
|
6154 c.............c
|
|
6155 SetR: 00010 RRR ..rrr RRR = rrr
|
|
6156 SetA: 00011 RRR ..rrr RRR = array[rrr]
|
|
6157 C.............C size of array = C...C
|
|
6158 c.............c contents = c...c
|
|
6159
|
|
6160 Jump: 00100 000 c...c jump to c...c
|
|
6161 JumpCond: 00101 RRR c...c if (!RRR) jump to c...c
|
|
6162 WriteJump: 00110 RRR c...c Write1 RRR, jump to c...c
|
|
6163 WriteReadJump: 00111 RRR c...c Write1, Read1 RRR, jump to c...c
|
|
6164 WriteCJump: 01000 000 c...c Write1 C...C, jump to c...c
|
|
6165 C...C
|
|
6166 WriteCReadJump: 01001 RRR c...c Write1 C...C, Read1 RRR,
|
|
6167 C.............C and jump to c...c
|
|
6168 WriteSJump: 01010 000 c...c WriteS, jump to c...c
|
|
6169 C.............C
|
|
6170 S.............S
|
|
6171 ...
|
|
6172 WriteSReadJump: 01011 RRR c...c WriteS, Read1 RRR, jump to c...c
|
|
6173 C.............C
|
|
6174 S.............S
|
|
6175 ...
|
|
6176 WriteAReadJump: 01100 RRR c...c WriteA, Read1 RRR, jump to c...c
|
|
6177 C.............C size of array = C...C
|
|
6178 c.............c contents = c...c
|
|
6179 ...
|
|
6180 Branch: 01101 RRR C...C if (RRR >= 0 && RRR < C..)
|
|
6181 c.............c branch to (RRR+1)th address
|
|
6182 Read1: 01110 RRR ... read 1-byte to RRR
|
|
6183 Read2: 01111 RRR ..rrr read 2-byte to RRR and rrr
|
|
6184 ReadBranch: 10000 RRR C...C Read1 and Branch
|
|
6185 c.............c
|
|
6186 ...
|
|
6187 Write1: 10001 RRR ..... write 1-byte RRR
|
|
6188 Write2: 10010 RRR ..rrr write 2-byte RRR and rrr
|
|
6189 WriteC: 10011 000 ..... write 1-char C...CC
|
|
6190 C.............C
|
|
6191 WriteS: 10100 000 ..... write C..-byte of string
|
|
6192 C.............C
|
|
6193 S.............S
|
|
6194 ...
|
|
6195 WriteA: 10101 RRR ..... write array[RRR]
|
|
6196 C.............C size of array = C...C
|
|
6197 c.............c contents = c...c
|
|
6198 ...
|
|
6199 End: 10110 000 ..... terminate the execution
|
|
6200
|
|
6201 SetSelfCS: 10111 RRR C...C RRR AAAAA= C...C
|
|
6202 ..........AAAAA
|
|
6203 SetSelfCL: 11000 RRR ..... RRR AAAAA= c...c
|
|
6204 c.............c
|
|
6205 ..........AAAAA
|
|
6206 SetSelfR: 11001 RRR ..Rrr RRR AAAAA= rrr
|
|
6207 ..........AAAAA
|
|
6208 SetExprCL: 11010 RRR ..Rrr RRR = rrr AAAAA c...c
|
|
6209 c.............c
|
|
6210 ..........AAAAA
|
|
6211 SetExprR: 11011 RRR ..rrr RRR = rrr AAAAA Rrr
|
|
6212 ............Rrr
|
|
6213 ..........AAAAA
|
|
6214 JumpCondC: 11100 RRR c...c if !(RRR AAAAA C..) jump to c...c
|
|
6215 C.............C
|
|
6216 ..........AAAAA
|
|
6217 JumpCondR: 11101 RRR c...c if !(RRR AAAAA rrr) jump to c...c
|
|
6218 ............rrr
|
|
6219 ..........AAAAA
|
|
6220 ReadJumpCondC: 11110 RRR c...c Read1 and JumpCondC
|
|
6221 C.............C
|
|
6222 ..........AAAAA
|
|
6223 ReadJumpCondR: 11111 RRR c...c Read1 and JumpCondR
|
|
6224 ............rrr
|
|
6225 ..........AAAAA
|
|
6226 @end example
|
|
6227
|
|
6228 @node The Lisp Reader and Compiler, Lstreams, MULE Character Sets and Encodings, Top
|
|
6229 @chapter The Lisp Reader and Compiler
|
|
6230
|
|
6231 Not yet documented.
|
|
6232
|
|
6233 @node Lstreams, Consoles; Devices; Frames; Windows, The Lisp Reader and Compiler, Top
|
|
6234 @chapter Lstreams
|
|
6235
|
|
6236 An @dfn{lstream} is an internal Lisp object that provides a generic
|
|
6237 buffering stream implementation. Conceptually, you send data to the
|
|
6238 stream or read data from the stream, not caring what's on the other end
|
|
6239 of the stream. The other end could be another stream, a file
|
|
6240 descriptor, a stdio stream, a fixed block of memory, a reallocating
|
|
6241 block of memory, etc. The main purpose of the stream is to provide a
|
|
6242 standard interface and to do buffering. Macros are defined to read or
|
|
6243 write characters, so the calling functions do not have to worry about
|
|
6244 blocking data together in order to achieve efficiency.
|
|
6245
|
|
6246 @menu
|
|
6247 * Creating an Lstream:: Creating an lstream object.
|
|
6248 * Lstream Types:: Different sorts of things that are streamed.
|
|
6249 * Lstream Functions:: Functions for working with lstreams.
|
|
6250 * Lstream Methods:: Creating new lstream types.
|
|
6251 @end menu
|
|
6252
|
|
6253 @node Creating an Lstream
|
|
6254 @section Creating an Lstream
|
|
6255
|
|
6256 Lstreams come in different types, depending on what is being interfaced
|
|
6257 to. Although the primitive for creating new lstreams is
|
|
6258 @code{Lstream_new()}, generally you do not call this directly. Instead,
|
|
6259 you call some type-specific creation function, which creates the lstream
|
|
6260 and initializes it as appropriate for the particular type.
|
|
6261
|
|
6262 All lstream creation functions take a @var{mode} argument, specifying
|
|
6263 what mode the lstream should be opened as. This controls whether the
|
|
6264 lstream is for input and output, and optionally whether data should be
|
|
6265 blocked up in units of MULE characters. Note that some types of
|
|
6266 lstreams can only be opened for input; others only for output; and
|
|
6267 others can be opened either way. #### Richard Mlynarik thinks that
|
|
6268 there should be a strict separation between input and output streams,
|
|
6269 and he's probably right.
|
|
6270
|
|
6271 @var{mode} is a string, one of
|
|
6272
|
|
6273 @table @code
|
|
6274 @item "r"
|
|
6275 Open for reading.
|
|
6276 @item "w"
|
|
6277 Open for writing.
|
|
6278 @item "rc"
|
|
6279 Open for reading, but ``read'' never returns partial MULE characters.
|
|
6280 @item "wc"
|
|
6281 Open for writing, but never writes partial MULE characters.
|
|
6282 @end table
|
|
6283
|
|
6284 @node Lstream Types
|
|
6285 @section Lstream Types
|
|
6286
|
|
6287 @table @asis
|
|
6288 @item stdio
|
|
6289
|
|
6290 @item filedesc
|
|
6291
|
|
6292 @item lisp-string
|
|
6293
|
|
6294 @item fixed-buffer
|
|
6295
|
|
6296 @item resizing-buffer
|
|
6297
|
|
6298 @item dynarr
|
|
6299
|
|
6300 @item lisp-buffer
|
|
6301
|
|
6302 @item print
|
|
6303
|
|
6304 @item decoding
|
|
6305
|
|
6306 @item encoding
|
|
6307 @end table
|
|
6308
|
|
6309 @node Lstream Functions
|
|
6310 @section Lstream Functions
|
|
6311
|
|
6312 @deftypefun {Lstream *} Lstream_new (Lstream_implementation *@var{imp}, CONST char *@var{mode})
|
|
6313 Allocate and return a new Lstream. This function is not really meant to
|
|
6314 be called directly; rather, each stream type should provide its own
|
|
6315 stream creation function, which creates the stream and does any other
|
|
6316 necessary creation stuff (e.g. opening a file).
|
|
6317 @end deftypefun
|
|
6318
|
|
6319 @deftypefun void Lstream_set_buffering (Lstream *@var{lstr}, Lstream_buffering @var{buffering}, int @var{buffering_size})
|
|
6320 Change the buffering of a stream. See @file{lstream.h}. By default the
|
|
6321 buffering is @code{STREAM_BLOCK_BUFFERED}.
|
|
6322 @end deftypefun
|
|
6323
|
|
6324 @deftypefun int Lstream_flush (Lstream *@var{lstr})
|
|
6325 Flush out any pending unwritten data in the stream. Clear any buffered
|
|
6326 input data. Returns 0 on success, -1 on error.
|
|
6327 @end deftypefun
|
|
6328
|
|
6329 @deftypefn Macro int Lstream_putc (Lstream *@var{stream}, int @var{c})
|
|
6330 Write out one byte to the stream. This is a macro and so it is very
|
|
6331 efficient. The @var{c} argument is only evaluated once but the @var{stream}
|
|
6332 argument is evaluated more than once. Returns 0 on success, -1 on
|
|
6333 error.
|
|
6334 @end deftypefn
|
|
6335
|
|
6336 @deftypefn Macro int Lstream_getc (Lstream *@var{stream})
|
|
6337 Read one byte from the stream. This is a macro and so it is very
|
|
6338 efficient. The @var{stream} argument is evaluated more than once. Return
|
|
6339 value is -1 for EOF or error.
|
|
6340 @end deftypefn
|
|
6341
|
|
6342 @deftypefn Macro void Lstream_ungetc (Lstream *@var{stream}, int @var{c})
|
|
6343 Push one byte back onto the input queue. This will be the next byte
|
|
6344 read from the stream. Any number of bytes can be pushed back and will
|
|
6345 be read in the reverse order they were pushed back -- most recent
|
|
6346 first. (This is necessary for consistency -- if there are a number of
|
|
6347 bytes that have been unread and I read and unread a byte, it needs to be
|
|
6348 the first to be read again.) This is a macro and so it is very
|
|
6349 efficient. The @var{c} argument is only evaluated once but the @var{stream}
|
|
6350 argument is evaluated more than once.
|
|
6351 @end deftypefn
|
|
6352
|
|
6353 @deftypefun int Lstream_fputc (Lstream *@var{stream}, int @var{c})
|
|
6354 @deftypefunx int Lstream_fgetc (Lstream *@var{stream})
|
|
6355 @deftypefunx void Lstream_fungetc (Lstream *@var{stream}, int @var{c})
|
|
6356 Function equivalents of the above macros.
|
|
6357 @end deftypefun
|
|
6358
|
|
6359 @deftypefun int Lstream_read (Lstream *@var{stream}, void *@var{data}, int @var{size})
|
|
6360 Read @var{size} bytes of @var{data} from the stream. Return the number
|
|
6361 of bytes read. 0 means EOF. -1 means an error occurred and no bytes
|
|
6362 were read.
|
|
6363 @end deftypefun
|
|
6364
|
|
6365 @deftypefun int Lstream_write (Lstream *@var{stream}, void *@var{data}, int @var{size})
|
|
6366 Write @var{size} bytes of @var{data} to the stream. Return the number
|
|
6367 of bytes written. -1 means an error occurred and no bytes were written.
|
|
6368 @end deftypefun
|
|
6369
|
|
6370 @deftypefun void Lstream_unread (Lstream *@var{stream}, void *@var{data}, int @var{size})
|
|
6371 Push back @var{size} bytes of @var{data} onto the input queue. The next
|
|
6372 call to @code{Lstream_read()} with the same size will read the same
|
|
6373 bytes back. Note that this will be the case even if there is other
|
|
6374 pending unread data.
|
|
6375 @end deftypefun
|
|
6376
|
|
6377 @deftypefun int Lstream_close (Lstream *@var{stream})
|
|
6378 Close the stream. All data will be flushed out.
|
|
6379 @end deftypefun
|
|
6380
|
|
6381 @deftypefun void Lstream_reopen (Lstream *@var{stream})
|
|
6382 Reopen a closed stream. This enables I/O on it again. This is not
|
|
6383 meant to be called except from a wrapper routine that reinitializes
|
|
6384 variables and such -- the close routine may well have freed some
|
|
6385 necessary storage structures, for example.
|
|
6386 @end deftypefun
|
|
6387
|
|
6388 @deftypefun void Lstream_rewind (Lstream *@var{stream})
|
|
6389 Rewind the stream to the beginning.
|
|
6390 @end deftypefun
|
|
6391
|
|
6392 @node Lstream Methods
|
|
6393 @section Lstream Methods
|
|
6394
|
|
6395 @deftypefn {Lstream Method} int reader (Lstream *@var{stream}, unsigned char *@var{data}, int @var{size})
|
|
6396 Read some data from the stream's end and store it into @var{data}, which
|
|
6397 can hold @var{size} bytes. Return the number of bytes read. A return
|
|
6398 value of 0 means no bytes can be read at this time. This may be because
|
|
6399 of an EOF, or because there is a granularity greater than one byte that
|
|
6400 the stream imposes on the returned data, and @var{size} is less than
|
|
6401 this granularity. (This will happen frequently for streams that need to
|
|
6402 return whole characters, because @code{Lstream_read()} calls the reader
|
|
6403 function repeatedly until it has the number of bytes it wants or until 0
|
|
6404 is returned.) The lstream functions do not treat a 0 return as EOF or
|
|
6405 do anything special; however, the calling function will interpret any 0
|
|
6406 it gets back as EOF. This will normally not happen unless the caller
|
|
6407 calls @code{Lstream_read()} with a very small size.
|
|
6408
|
|
6409 This function can be @code{NULL} if the stream is output-only.
|
|
6410 @end deftypefn
|
|
6411
|
|
6412 @deftypefn {Lstream Method} int writer (Lstream *@var{stream}, CONST unsigned char *@var{data}, int @var{size})
|
|
6413 Send some data to the stream's end. Data to be sent is in @var{data}
|
|
6414 and is @var{size} bytes. Return the number of bytes sent. This
|
|
6415 function can send and return fewer bytes than is passed in; in that
|
|
6416 case, the function will just be called again until there is no data left
|
|
6417 or 0 is returned. A return value of 0 means that no more data can be
|
|
6418 currently stored, but there is no error; the data will be squirreled
|
|
6419 away until the writer can accept data. (This is useful, e.g., if you're
|
|
6420 dealing with a non-blocking file descriptor and are getting
|
|
6421 @code{EWOULDBLOCK} errors.) This function can be @code{NULL} if the
|
|
6422 stream is input-only.
|
|
6423 @end deftypefn
|
|
6424
|
|
6425 @deftypefn {Lstream Method} int rewinder (Lstream *@var{stream})
|
|
6426 Rewind the stream. If this is @code{NULL}, the stream is not seekable.
|
|
6427 @end deftypefn
|
|
6428
|
|
6429 @deftypefn {Lstream Method} int seekable_p (Lstream *@var{stream})
|
|
6430 Indicate whether this stream is seekable -- i.e. it can be rewound.
|
|
6431 This method is ignored if the stream does not have a rewind method. If
|
|
6432 this method is not present, the result is determined by whether a rewind
|
|
6433 method is present.
|
|
6434 @end deftypefn
|
|
6435
|
|
6436 @deftypefn {Lstream Method} int flusher (Lstream *@var{stream})
|
|
6437 Perform any additional operations necessary to flush the data in this
|
|
6438 stream.
|
|
6439 @end deftypefn
|
|
6440
|
|
6441 @deftypefn {Lstream Method} int pseudo_closer (Lstream *@var{stream})
|
|
6442 @end deftypefn
|
|
6443
|
|
6444 @deftypefn {Lstream Method} int closer (Lstream *@var{stream})
|
|
6445 Perform any additional operations necessary to close this stream down.
|
|
6446 May be @code{NULL}. This function is called when @code{Lstream_close()}
|
|
6447 is called or when the stream is garbage-collected. When this function
|
|
6448 is called, all pending data in the stream will already have been written
|
|
6449 out.
|
|
6450 @end deftypefn
|
|
6451
|
|
6452 @deftypefn {Lstream Method} Lisp_Object marker (Lisp_Object @var{lstream}, void (*@var{markfun}) (Lisp_Object))
|
|
6453 Mark this object for garbage collection. Same semantics as a standard
|
|
6454 @code{Lisp_Object} marker. This function can be @code{NULL}.
|
|
6455 @end deftypefn
|
|
6456
|
|
6457 @node Consoles; Devices; Frames; Windows, The Redisplay Mechanism, Lstreams, Top
|
|
6458 @chapter Consoles; Devices; Frames; Windows
|
|
6459
|
|
6460 @menu
|
|
6461 * Introduction to Consoles; Devices; Frames; Windows::
|
|
6462 * Point::
|
|
6463 * Window Hierarchy::
|
|
6464 * The Window Object::
|
|
6465 @end menu
|
|
6466
|
|
6467 @node Introduction to Consoles; Devices; Frames; Windows
|
|
6468 @section Introduction to Consoles; Devices; Frames; Windows
|
|
6469
|
|
6470 A window-system window that you see on the screen is called a
|
|
6471 @dfn{frame} in Emacs terminology. Each frame is subdivided into one or
|
|
6472 more non-overlapping panes, called (confusingly) @dfn{windows}. Each
|
|
6473 window displays the text of a buffer in it. (See above on Buffers.) Note
|
|
6474 that buffers and windows are independent entities: Two or more windows
|
|
6475 can be displaying the same buffer (potentially in different locations),
|
|
6476 and a buffer can be displayed in no windows.
|
|
6477
|
|
6478 A single display screen that contains one or more frames is called
|
|
6479 a @dfn{display}. Under most circumstances, there is only one display.
|
|
6480 However, more than one display can exist, for example if you have
|
|
6481 a @dfn{multi-headed} console, i.e. one with a single keyboard but
|
|
6482 multiple displays. (Typically in such a situation, the various
|
|
6483 displays act like one large display, in that the mouse is only
|
|
6484 in one of them at a time, and moving the mouse off of one moves
|
|
6485 it into another.) In some cases, the different displays will
|
|
6486 have different characteristics, e.g. one color and one mono.
|
|
6487
|
|
6488 XEmacs can display frames on multiple displays. It can even deal
|
|
6489 simultaneously with frames on multiple keyboards (called @dfn{consoles} in
|
|
6490 XEmacs terminology). Here is one case where this might be useful: You
|
|
6491 are using XEmacs on your workstation at work, and leave it running.
|
|
6492 Then you go home and dial in on a TTY line, and you can use the
|
|
6493 already-running XEmacs process to display another frame on your local
|
|
6494 TTY.
|
|
6495
|
|
6496 Thus, there is a hierarchy console -> display -> frame -> window.
|
|
6497 There is a separate Lisp object type for each of these four concepts.
|
2
|
6498 Furthermore, there is logically a @dfn{selected console},
|
0
|
6499 @dfn{selected display}, @dfn{selected frame}, and @dfn{selected window}.
|
2
|
6500 Each of these objects is distinguished in various ways, such as being the
|
|
6501 default object for various functions that act on objects of that type.
|
|
6502 Note that every containing object rememembers the ``selected'' object
|
|
6503 among the objects that it contains: e.g. not only is there a selected
|
|
6504 window, but every frame remembers the last window in it that was
|
|
6505 selected, and changing the selected frame causes the remembered window
|
|
6506 within it to become the selected window. Similar relationships apply
|
|
6507 for consoles to devices and devices to frames.
|
0
|
6508
|
|
6509 @node Point
|
|
6510 @section Point
|
|
6511
|
|
6512 Recall that every buffer has a current insertion position, called
|
|
6513 @dfn{point}. Now, two or more windows may be displaying the same buffer,
|
|
6514 and the text cursor in the two windows (i.e. @code{point}) can be in
|
|
6515 two different places. You may ask, how can that be, since each
|
|
6516 buffer has only one value of @code{point}? The answer is that each window
|
|
6517 also has a value of @code{point} that is squirreled away in it. There
|
|
6518 is only one selected window, and the value of ``point'' in that buffer
|
|
6519 corresponds to that window. When the selected window is changed
|
|
6520 from one window to another displaying the same buffer, the old
|
|
6521 value of @code{point} is stored into the old window's ``point'' and the
|
|
6522 value of @code{point} from the new window is retrieved and made the
|
|
6523 value of @code{point} in the buffer. This means that @code{window-point}
|
|
6524 for the selected window is potentially inaccurate, and if you
|
|
6525 want to retrieve the correct value of @code{point} for a window,
|
|
6526 you must special-case on the selected window and retrieve the
|
|
6527 buffer's point instead. This is related to why @code{save-window-excursion}
|
|
6528 does not save the selected window's value of @code{point}.
|
|
6529
|
|
6530 @node Window Hierarchy
|
|
6531 @section Window Hierarchy
|
|
6532 @cindex window hierarchy
|
|
6533 @cindex hierarchy of windows
|
|
6534
|
|
6535 If a frame contains multiple windows (panes), they are always created
|
|
6536 by splitting an existing window along the horizontal or vertical axis.
|
|
6537 Terminology is a bit confusing here: to @dfn{split a window
|
|
6538 horizontally} means to create two side-by-side windows, i.e. to make a
|
|
6539 @emph{vertical} cut in a window. Likewise, to @dfn{split a window
|
|
6540 vertically} means to create two windows, one above the other, by making
|
|
6541 a @emph{horizontal} cut.
|
|
6542
|
|
6543 If you split a window and then split again along the same axis, you
|
|
6544 will end up with a number of panes all arranged along the same axis.
|
|
6545 The precise way in which the splits were made should not be important,
|
|
6546 and this is reflected internally. Internally, all windows are arranged
|
|
6547 in a tree, consisting of two types of windows, @dfn{combination} windows
|
|
6548 (which have children, and are covered completely by those children) and
|
|
6549 @dfn{leaf} windows, which have no children and are visible. Every
|
|
6550 combination window has two or more children, all arranged along the same
|
|
6551 axis. There are (logically) two subtypes of windows, depending on
|
|
6552 whether their children are horizontally or vertically arrayed. There is
|
|
6553 always one root window, which is either a leaf window (if the frame
|
|
6554 contains only one window) or a combination window (if the frame contains
|
|
6555 more than one window). In the latter case, the root window will have
|
|
6556 two or more children, either horizontally or vertically arrayed, and
|
|
6557 each of those children will be either a leaf window or another
|
|
6558 combination window.
|
|
6559
|
|
6560 Here are some rules:
|
|
6561
|
|
6562 @enumerate
|
|
6563 @item
|
2
|
6564 Horizontal combination windows can never have children that are
|
|
6565 horizontal combination windows; same for vertical.
|
0
|
6566
|
|
6567 @item
|
|
6568 Only leaf windows can be split (obviously) and this splitting does one
|
|
6569 of two things: (a) turns the leaf window into a combination window and
|
|
6570 creates two new leaf children, or (b) turns the leaf window into one of
|
|
6571 the two new leaves and creates the other leaf. Rule (1) dictates which
|
|
6572 of these two outcomes happens.
|
|
6573
|
|
6574 @item
|
|
6575 Every combination window must have at least two children.
|
|
6576
|
|
6577 @item
|
|
6578 Leaf windows can never become combination windows. They can be deleted,
|
|
6579 however. If this results in a violation of (3), the parent combination
|
|
6580 window also gets deleted.
|
|
6581
|
|
6582 @item
|
|
6583 All functions that accept windows must be prepared to accept combination
|
|
6584 windows, and do something sane (e.g. signal an error if so).
|
|
6585 Combination windows @emph{do} escape to the Lisp level.
|
|
6586
|
|
6587 @item
|
|
6588 All windows have three fields governing their contents:
|
|
6589 these are @dfn{hchild} (a list of horizontally-arrayed children),
|
|
6590 @dfn{vchild} (a list of vertically-arrayed children), and @dfn{buffer}
|
|
6591 (the buffer contained in a leaf window). Exactly one of
|
|
6592 these will be non-nil. Remember that @dfn{horizontally-arrayed}
|
|
6593 means ``side-by-side'' and @dfn{vertically-arrayed} means
|
|
6594 @dfn{one above the other}.
|
|
6595
|
|
6596 @item
|
|
6597 Leaf windows also have markers in their @code{start} (the
|
|
6598 first buffer position displayed in the window) and @code{pointm}
|
|
6599 (the window's stashed value of @code{point} -- see above) fields,
|
|
6600 while combination windows have nil in these fields.
|
|
6601
|
|
6602 @item
|
|
6603 The list of children for a window is threaded through the
|
|
6604 @code{next} and @code{prev} fields of each child window.
|
|
6605
|
|
6606 @item
|
|
6607 @strong{Deleted windows can be undeleted}. This happens as a result of
|
|
6608 restoring a window configuration, and is unlike frames, displays, and
|
|
6609 consoles, which, once deleted, can never be restored. Deleting a window
|
|
6610 does nothing except set a special @code{dead} bit to 1 and clear out the
|
|
6611 @code{next}, @code{prev}, @code{hchild}, and @code{vchild} fields, for
|
|
6612 GC purposes.
|
|
6613
|
|
6614 @item
|
|
6615 Most frames actually have two top-level windows -- one for the
|
|
6616 minibuffer and one (the @dfn{root}) for everything else. The modeline
|
|
6617 (if present) separates these two. The @code{next} field of the root
|
|
6618 points to the minibuffer, and the @code{prev} field of the minibuffer
|
|
6619 points to the root. The other @code{next} and @code{prev} fields are
|
|
6620 @code{nil}, and the frame points to both of these windows.
|
|
6621 Minibuffer-less frames have no minibuffer window, and the @code{next}
|
|
6622 and @code{prev} of the root window are @code{nil}. Minibuffer-only
|
|
6623 frames have no root window, and the @code{next} of the minibuffer window
|
|
6624 is @code{nil} but the @code{prev} points to itself. (#### This is an
|
|
6625 artifact that should be fixed.)
|
|
6626 @end enumerate
|
|
6627
|
|
6628 @node The Window Object
|
|
6629 @section The Window Object
|
|
6630
|
|
6631 Windows have the following accessible fields:
|
|
6632
|
|
6633 @table @code
|
|
6634 @item frame
|
|
6635 The frame that this window is on.
|
|
6636
|
|
6637 @item mini_p
|
|
6638 Non-@code{nil} if this window is a minibuffer window.
|
|
6639
|
|
6640 @item buffer
|
|
6641 The buffer that the window is displaying. This may change often during
|
|
6642 the life of the window.
|
|
6643
|
|
6644 @item dedicated
|
|
6645 Non-@code{nil} if this window is dedicated to its buffer.
|
|
6646
|
|
6647 @item pointm
|
|
6648 @cindex window point internals
|
|
6649 This is the value of point in the current buffer when this window is
|
|
6650 selected; when it is not selected, it retains its previous value.
|
|
6651
|
|
6652 @item start
|
|
6653 The position in the buffer that is the first character to be displayed
|
|
6654 in the window.
|
|
6655
|
|
6656 @item force_start
|
|
6657 If this flag is non-@code{nil}, it says that the window has been
|
|
6658 scrolled explicitly by the Lisp program. This affects what the next
|
|
6659 redisplay does if point is off the screen: instead of scrolling the
|
|
6660 window to show the text around point, it moves point to a location that
|
|
6661 is on the screen.
|
|
6662
|
|
6663 @item last_modified
|
|
6664 The @code{modified} field of the window's buffer, as of the last time
|
|
6665 a redisplay completed in this window.
|
|
6666
|
|
6667 @item last_point
|
|
6668 The buffer's value of point, as of the last time
|
|
6669 a redisplay completed in this window.
|
|
6670
|
|
6671 @item left
|
|
6672 This is the left-hand edge of the window, measured in columns. (The
|
|
6673 leftmost column on the screen is @w{column 0}.)
|
|
6674
|
|
6675 @item top
|
|
6676 This is the top edge of the window, measured in lines. (The top line on
|
|
6677 the screen is @w{line 0}.)
|
|
6678
|
|
6679 @item height
|
|
6680 The height of the window, measured in lines.
|
|
6681
|
|
6682 @item width
|
|
6683 The width of the window, measured in columns.
|
|
6684
|
|
6685 @item next
|
|
6686 This is the window that is the next in the chain of siblings. It is
|
|
6687 @code{nil} in a window that is the rightmost or bottommost of a group of
|
|
6688 siblings.
|
|
6689
|
|
6690 @item prev
|
|
6691 This is the window that is the previous in the chain of siblings. It is
|
|
6692 @code{nil} in a window that is the leftmost or topmost of a group of
|
|
6693 siblings.
|
|
6694
|
|
6695 @item parent
|
|
6696 Internally, XEmacs arranges windows in a tree; each group of siblings has
|
|
6697 a parent window whose area includes all the siblings. This field points
|
|
6698 to a window's parent.
|
|
6699
|
|
6700 Parent windows do not display buffers, and play little role in display
|
|
6701 except to shape their child windows. Emacs Lisp programs usually have
|
|
6702 no access to the parent windows; they operate on the windows at the
|
|
6703 leaves of the tree, which actually display buffers.
|
|
6704
|
|
6705 @item hscroll
|
|
6706 This is the number of columns that the display in the window is scrolled
|
|
6707 horizontally to the left. Normally, this is 0.
|
|
6708
|
|
6709 @item use_time
|
|
6710 This is the last time that the window was selected. The function
|
|
6711 @code{get-lru-window} uses this field.
|
|
6712
|
|
6713 @item display_table
|
|
6714 The window's display table, or @code{nil} if none is specified for it.
|
|
6715
|
|
6716 @item update_mode_line
|
|
6717 Non-@code{nil} means this window's mode line needs to be updated.
|
|
6718
|
|
6719 @item base_line_number
|
|
6720 The line number of a certain position in the buffer, or @code{nil}.
|
|
6721 This is used for displaying the line number of point in the mode line.
|
|
6722
|
|
6723 @item base_line_pos
|
|
6724 The position in the buffer for which the line number is known, or
|
|
6725 @code{nil} meaning none is known.
|
|
6726
|
|
6727 @item region_showing
|
|
6728 If the region (or part of it) is highlighted in this window, this field
|
|
6729 holds the mark position that made one end of that region. Otherwise,
|
|
6730 this field is @code{nil}.
|
|
6731 @end table
|
|
6732
|
|
6733 @node The Redisplay Mechanism, Extents, Consoles; Devices; Frames; Windows, Top
|
|
6734 @chapter The Redisplay Mechanism
|
|
6735
|
|
6736 The redisplay mechanism is one of the most complicated sections of
|
|
6737 XEmacs, especially from a conceptual standpoint. This is doubly so
|
|
6738 because, unlike for the basic aspects of the Lisp interpreter, the
|
|
6739 computer science theories of how to efficiently handle redisplay are not
|
|
6740 well-developed.
|
|
6741
|
|
6742 When working with the redisplay mechanism, remember the Golden Rules
|
|
6743 of Redisplay:
|
|
6744
|
|
6745 @enumerate
|
|
6746 @item
|
|
6747 It Is Better To Be Correct Than Fast.
|
|
6748 @item
|
|
6749 Thou Shalt Not Run Elisp From Within Redisplay.
|
|
6750 @item
|
|
6751 It Is Better To Be Fast Than Not To Be.
|
|
6752 @end enumerate
|
|
6753
|
|
6754 @menu
|
|
6755 * Critical Redisplay Sections::
|
|
6756 * Line Start Cache::
|
|
6757 @end menu
|
|
6758
|
|
6759 @node Critical Redisplay Sections
|
|
6760 @section Critical Redisplay Sections
|
|
6761 @cindex critical redisplay sections
|
|
6762
|
|
6763 Within this section, we are defenseless and assume that the
|
|
6764 following cannot happen:
|
|
6765
|
|
6766 @enumerate
|
|
6767 @item
|
|
6768 garbage collection
|
|
6769 @item
|
|
6770 Lisp code evaluation
|
|
6771 @item
|
|
6772 frame size changes
|
|
6773 @end enumerate
|
|
6774
|
|
6775 We ensure (3) by calling @code{hold_frame_size_changes()}, which
|
|
6776 will cause any pending frame size changes to get put on hold
|
|
6777 till after the end of the critical section. (1) follows
|
|
6778 automatically if (2) is met. #### Unfortunately, there are
|
|
6779 some places where Lisp code can be called within this section.
|
|
6780 We need to remove them.
|
|
6781
|
|
6782 If @code{Fsignal()} is called during this critical section, we
|
|
6783 will @code{abort()}.
|
|
6784
|
|
6785 If garbage collection is called during this critical section,
|
|
6786 we simply return. #### We should abort instead.
|
|
6787
|
|
6788 #### If a frame-size change does occur we should probably
|
|
6789 actually be preempting redisplay.
|
|
6790
|
|
6791 @node Line Start Cache
|
|
6792 @section Line Start Cache
|
|
6793 @cindex line start cache
|
|
6794
|
|
6795 The traditional scrolling code in Emacs breaks in a variable height
|
|
6796 world. It depends on the key assumption that the number of lines that
|
|
6797 can be displayed at any given time is fixed. This led to a complete
|
|
6798 separation of the scrolling code from the redisplay code. In order to
|
|
6799 fully support variable height lines, the scrolling code must actually be
|
|
6800 tightly integrated with redisplay. Only redisplay can determine how
|
|
6801 many lines will be displayed on a screen for any given starting point.
|
|
6802
|
|
6803 What is ideally wanted is a complete list of the starting buffer
|
|
6804 position for every possible display line of a buffer along with the
|
|
6805 height of that display line. Maintaining such a full list would be very
|
|
6806 expensive. We settle for having it include information for all areas
|
|
6807 which we happen to generate anyhow (i.e. the region currently being
|
|
6808 displayed) and for those areas we need to work with.
|
|
6809
|
|
6810 In order to ensure that the cache accurately represents what redisplay
|
|
6811 would actually show, it is necessary to invalidate it in many
|
|
6812 situations. If the buffer changes, the starting positions may no longer
|
|
6813 be correct. If a face or an extent has changed then the line heights
|
|
6814 may have altered. These events happen frequently enough that the cache
|
|
6815 can end up being constantly disabled. With this potentially constant
|
|
6816 invalidation when is the cache ever useful?
|
|
6817
|
|
6818 Even if the cache is invalidated before every single usage, it is
|
|
6819 necessary. Scrolling often requires knowledge about display lines which
|
|
6820 are actually above or below the visible region. The cache provides a
|
|
6821 convenient light-weight method of storing this information for multiple
|
|
6822 display regions. This knowledge is necessary for the scrolling code to
|
|
6823 always obey the First Golden Rule of Redisplay.
|
|
6824
|
|
6825 If the cache already contains all of the information that the scrolling
|
|
6826 routines happen to need so that it doesn't have to go generate it, then
|
|
6827 we are able to obey the Third Golden Rule of Redisplay. The first thing
|
|
6828 we do to help out the cache is to always add the displayed region. This
|
|
6829 region had to be generated anyway, so the cache ends up getting the
|
|
6830 information basically for free. In those cases where a user is simply
|
|
6831 scrolling around viewing a buffer there is a high probability that this
|
|
6832 is sufficient to always provide the needed information. The second
|
|
6833 thing we can do is be smart about invalidating the cache.
|
|
6834
|
|
6835 TODO -- Be smart about invalidating the cache. Potential places:
|
|
6836
|
|
6837 @itemize @bullet
|
|
6838 @item
|
|
6839 Insertions at end-of-line which don't cause line-wraps do not alter the
|
|
6840 starting positions of any display lines. These types of buffer
|
|
6841 modifications should not invalidate the cache. This is actually a large
|
|
6842 optimization for redisplay speed as well.
|
|
6843 @item
|
|
6844 Buffer modifications frequently only affect the display of lines at and
|
|
6845 below where they occur. In these situations we should only invalidate
|
|
6846 the part of the cache starting at where the modification occurs.
|
|
6847 @end itemize
|
|
6848
|
|
6849 In case you're wondering, the Second Golden Rule of Redisplay is not
|
|
6850 applicable.
|
|
6851
|
|
6852 @node Extents, Faces and Glyphs, The Redisplay Mechanism, Top
|
|
6853 @chapter Extents
|
|
6854
|
|
6855 @menu
|
|
6856 * Introduction to Extents:: Extents are ranges over text, with properties.
|
|
6857 * Extent Ordering:: How extents are ordered internally.
|
|
6858 * Format of the Extent Info:: The extent information in a buffer or string.
|
|
6859 * Zero-Length Extents:: A weird special case.
|
|
6860 * Mathematics of Extent Ordering:: A rigorous foundation.
|
|
6861 * Extent Fragments:: Cached information useful for redisplay.
|
|
6862 @end menu
|
|
6863
|
|
6864 @node Introduction to Extents
|
|
6865 @section Introduction to Extents
|
|
6866
|
|
6867 Extents are regions over a buffer, with a start and an end position
|
|
6868 denoting the region of the buffer included in the extent. In
|
|
6869 addition, either end can be closed or open, meaning that the endpoint
|
|
6870 is or is not logically included in the extent. Insertion of a character
|
|
6871 at a closed endpoint causes the character to go inside the extent;
|
|
6872 insertion at an open endpoint causes the character to go outside.
|
|
6873
|
|
6874 Extent endpoints are stored using memory indices (see @file{insdel.c}),
|
|
6875 to minimize the amount of adjusting that needs to be done when
|
|
6876 characters are inserted or deleted.
|
|
6877
|
|
6878 (Formerly, extent endpoints at the gap could be either before or
|
|
6879 after the gap, depending on the open/closedness of the endpoint.
|
|
6880 The intent of this was to make it so that insertions would
|
|
6881 automatically go inside or out of extents as necessary with no
|
|
6882 further work needing to be done. It didn't work out that way,
|
|
6883 however, and just ended up complexifying and buggifying all the
|
|
6884 rest of the code.)
|
|
6885
|
|
6886 @node Extent Ordering
|
|
6887 @section Extent Ordering
|
|
6888
|
|
6889 Extents are compared using memory indices. There are two orderings
|
|
6890 for extents and both orders are kept current at all times. The normal
|
|
6891 or @dfn{display} order is as follows:
|
|
6892
|
|
6893 @example
|
|
6894 Extent A is ``less than'' extent B, that is, earlier in the display order,
|
|
6895 if: A-start < B-start,
|
|
6896 or if: A-start = B-start, and A-end > B-end
|
|
6897 @end example
|
|
6898
|
|
6899 So if two extents begin at the same position, the larger of them is the
|
|
6900 earlier one in the display order (@code{EXTENT_LESS} is true).
|
|
6901
|
|
6902 For the e-order, the same thing holds:
|
|
6903
|
|
6904 @example
|
|
6905 Extent A is ``less than'' extent B in e-order, that is, later in the buffer,
|
|
6906 if: A-end < B-end,
|
|
6907 or if: A-end = B-end, and A-start > B-start
|
|
6908 @end example
|
|
6909
|
|
6910 So if two extents end at the same position, the smaller of them is the
|
|
6911 earlier one in the e-order (@code{EXTENT_E_LESS} is true).
|
|
6912
|
|
6913 The display order and the e-order are complementary orders: any
|
|
6914 theorem about the display order also applies to the e-order if you swap
|
|
6915 all occurrences of ``display order'' and ``e-order'', ``less than'' and
|
|
6916 ``greater than'', and ``extent start'' and ``extent end''.
|
|
6917
|
|
6918 @node Format of the Extent Info
|
|
6919 @section Format of the Extent Info
|
|
6920
|
|
6921 An extent-info structure consists of a list of the buffer or string's
|
|
6922 extents and a @dfn{stack of extents} that lists all of the extents over
|
|
6923 a particular position. The stack-of-extents info is used for
|
|
6924 optimization purposes -- it basically caches some info that might
|
|
6925 be expensive to compute. Certain otherwise hard computations are easy
|
|
6926 given the stack of extents over a particular position, and if the
|
|
6927 stack of extents over a nearby position is known (because it was
|
|
6928 calculated at some prior point in time), it's easy to move the stack
|
|
6929 of extents to the proper position.
|
|
6930
|
|
6931 Given that the stack of extents is an optimization, and given that
|
|
6932 it requires memory, a string's stack of extents is wiped out each
|
|
6933 time a garbage collection occurs. Therefore, any time you retrieve
|
|
6934 the stack of extents, it might not be there. If you need it to
|
|
6935 be there, use the @code{_force} version.
|
|
6936
|
|
6937 Similarly, a string may or may not have an extent_info structure.
|
|
6938 (Generally it won't if there haven't been any extents added to the
|
|
6939 string.) So use the @code{_force} version if you need the extent_info
|
|
6940 structure to be there.
|
|
6941
|
|
6942 A list of extents is maintained as a double gap array: one gap array
|
|
6943 is ordered by start index (the @dfn{display order}) and the other is
|
|
6944 ordered by end index (the @dfn{e-order}). Note that positions in an
|
|
6945 extent list should logically be conceived of as referring @emph{to} a
|
|
6946 particular extent (as is the norm in programs) rather than sitting
|
|
6947 between two extents. Note also that callers of these functions should
|
|
6948 not be aware of the fact that the extent list is implemented as an
|
|
6949 array, except for the fact that positions are integers (this should be
|
|
6950 generalized to handle integers and linked list equally well).
|
|
6951
|
|
6952 @node Zero-Length Extents
|
|
6953 @section Zero-Length Extents
|
|
6954
|
|
6955 Extents can be zero-length, and will end up that way if their endpoints
|
|
6956 are explicitly set that way or if their detachable property is nil
|
|
6957 and all the text in the extent is deleted. (The exception is open-open
|
|
6958 zero-length extents, which are barred from existing because there is
|
|
6959 no sensible way to define their properties. Deletion of the text in
|
|
6960 an open-open extent causes it to be converted into a closed-open
|
|
6961 extent.) Zero-length extents are primarily used to represent
|
|
6962 annotations, and behave as follows:
|
|
6963
|
|
6964 @enumerate
|
|
6965 @item
|
|
6966 Insertion at the position of a zero-length extent expands the extent
|
|
6967 if both endpoints are closed; goes after the extent if it is closed-open;
|
|
6968 and goes before the extent if it is open-closed.
|
|
6969
|
|
6970 @item
|
|
6971 Deletion of a character on a side of a zero-length extent whose
|
|
6972 corresponding endpoint is closed causes the extent to be detached if
|
|
6973 it is detachable; if the extent is not detachable or the corresponding
|
|
6974 endpoint is open, the extent remains in the buffer, moving as necessary.
|
|
6975 @end enumerate
|
|
6976
|
|
6977 Note that closed-open, non-detachable zero-length extents behave
|
|
6978 exactly like markers and that open-closed, non-detachable zero-length
|
|
6979 extents behave like the ``point-type'' marker in Mule.
|
|
6980
|
|
6981 @node Mathematics of Extent Ordering
|
|
6982 @section Mathematics of Extent Ordering
|
|
6983 @cindex extent mathematics
|
|
6984 @cindex mathematics of extents
|
|
6985 @cindex extent ordering
|
|
6986
|
|
6987 @cindex display order of extents
|
|
6988 @cindex extents, display order
|
|
6989 The extents in a buffer are ordered by ``display order'' because that
|
|
6990 is that order that the redisplay mechanism needs to process them in.
|
|
6991 The e-order is an auxiliary ordering used to facilitate operations
|
|
6992 over extents. The operations that can be performed on the ordered
|
|
6993 list of extents in a buffer are
|
|
6994
|
|
6995 @enumerate
|
|
6996 @item
|
|
6997 Locate where an extent would go if inserted into the list.
|
|
6998 @item
|
|
6999 Insert an extent into the list.
|
|
7000 @item
|
|
7001 Remove an extent from the list.
|
|
7002 @item
|
|
7003 Map over all the extents that overlap a range.
|
|
7004 @end enumerate
|
|
7005
|
|
7006 (4) requires being able to determine the first and last extents
|
|
7007 that overlap a range.
|
|
7008
|
|
7009 NOTE: @dfn{overlap} is used as follows:
|
|
7010
|
|
7011 @itemize @bullet
|
|
7012 @item
|
|
7013 two ranges overlap if they have at least one point in common.
|
|
7014 Whether the endpoints are open or closed makes a difference here.
|
|
7015 @item
|
|
7016 a point overlaps a range if the point is contained within the
|
|
7017 range; this is equivalent to treating a point @math{P} as the range
|
|
7018 @math{[P, P]}.
|
|
7019 @item
|
|
7020 In the case of an @emph{extent} overlapping a point or range, the extent
|
|
7021 is normally treated as having closed endpoints. This applies
|
|
7022 consistently in the discussion of stacks of extents and such below.
|
|
7023 Note that this definition of overlap is not necessarily consistent with
|
|
7024 the extents that @code{map-extents} maps over, since @code{map-extents}
|
|
7025 sometimes pays attention to whether the endpoints of an extents are open
|
|
7026 or closed. But for our purposes, it greatly simplifies things to treat
|
|
7027 all extents as having closed endpoints.
|
|
7028 @end itemize
|
|
7029
|
|
7030 First, define @math{>}, @math{<}, @math{<=}, etc. as applied to extents
|
|
7031 to mean comparison according to the display order. Comparison between
|
|
7032 an extent @math{E} and an index @math{I} means comparison between
|
|
7033 @math{E} and the range @math{[I, I]}.
|
|
7034
|
|
7035 Also define @math{e>}, @math{e<}, @math{e<=}, etc. to mean comparison
|
|
7036 according to the e-order.
|
|
7037
|
|
7038 For any range @math{R}, define @math{R(0)} to be the starting index of
|
|
7039 the range and @math{R(1)} to be the ending index of the range.
|
|
7040
|
|
7041 For any extent @math{E}, define @math{E(next)} to be the extent directly
|
|
7042 following @math{E}, and @math{E(prev)} to be the extent directly
|
|
7043 preceding @math{E}. Assume @math{E(next)} and @math{E(prev)} can be
|
|
7044 determined from @math{E} in constant time. (This is because we store
|
|
7045 the extent list as a doubly linked list.)
|
|
7046
|
|
7047 Similarly, define @math{E(e-next)} and @math{E(e-prev)} to be the
|
|
7048 extents directly following and preceding @math{E} in the e-order.
|
|
7049
|
|
7050 Now:
|
|
7051
|
|
7052 Let @math{R} be a range.
|
|
7053 Let @math{F} be the first extent overlapping @math{R}.
|
|
7054 Let @math{L} be the last extent overlapping @math{R}.
|
|
7055
|
|
7056 Theorem 1: @math{R(1)} lies between @math{L} and @math{L(next)},
|
|
7057 i.e. @math{L <= R(1) < L(next)}.
|
|
7058
|
|
7059 This follows easily from the definition of display order. The
|
|
7060 basic reason that this theorem applies is that the display order
|
|
7061 sorts by increasing starting index.
|
|
7062
|
|
7063 Therefore, we can determine @math{L} just by looking at where we would
|
|
7064 insert @math{R(1)} into the list, and if we know @math{F} and are moving
|
|
7065 forward over extents, we can easily determine when we've hit @math{L} by
|
|
7066 comparing the extent we're at to @math{R(1)}.
|
|
7067
|
|
7068 @example
|
|
7069 Theorem 2: @math{F(e-prev) e< [1, R(0)] e<= F}.
|
|
7070 @end example
|
|
7071
|
|
7072 This is the analog of Theorem 1, and applies because the e-order
|
|
7073 sorts by increasing ending index.
|
|
7074
|
|
7075 Therefore, @math{F} can be found in the same amount of time as
|
|
7076 operation (1), i.e. the time that it takes to locate where an extent
|
|
7077 would go if inserted into the e-order list.
|
|
7078
|
|
7079 If the lists were stored as balanced binary trees, then operation (1)
|
|
7080 would take logarithmic time, which is usually quite fast. However,
|
|
7081 currently they're stored as simple doubly-linked lists, and instead we
|
|
7082 do some caching to try to speed things up.
|
|
7083
|
|
7084 Define a @dfn{stack of extents} (or @dfn{SOE}) as the set of extents
|
|
7085 (ordered in the display order) that overlap an index @math{I}, together
|
|
7086 with the SOE's @dfn{previous} extent, which is an extent that precedes
|
|
7087 @math{I} in the e-order. (Hopefully there will not be very many extents
|
|
7088 between @math{I} and the previous extent.)
|
|
7089
|
|
7090 Now:
|
|
7091
|
|
7092 Let @math{I} be an index, let @math{S} be the stack of extents on
|
|
7093 @math{I}, let @math{F} be the first extent in @math{S}, and let @math{P}
|
|
7094 be @math{S}'s previous extent.
|
|
7095
|
|
7096 Theorem 3: The first extent in @math{S} is the first extent that overlaps
|
|
7097 any range @math{[I, J]}.
|
|
7098
|
|
7099 Proof: Any extent that overlaps @math{[I, J]} but does not include
|
|
7100 @math{I} must have a start index @math{> I}, and thus be greater than
|
|
7101 any extent in @math{S}.
|
|
7102
|
|
7103 Therefore, finding the first extent that overlaps a range @math{R} is
|
|
7104 the same as finding the first extent that overlaps @math{R(0)}.
|
|
7105
|
|
7106 Theorem 4: Let @math{I2} be an index such that @math{I2 > I}, and let
|
|
7107 @math{F2} be the first extent that overlaps @math{I2}. Then, either
|
|
7108 @math{F2} is in @math{S} or @math{F2} is greater than any extent in
|
|
7109 @math{S}.
|
|
7110
|
|
7111 Proof: If @math{F2} does not include @math{I} then its start index is
|
|
7112 greater than @math{I} and thus it is greater than any extent in
|
|
7113 @math{S}, including @math{F}. Otherwise, @math{F2} includes @math{I}
|
|
7114 and thus is in @math{S}, and thus @math{F2 >= F}.
|
|
7115
|
|
7116 @node Extent Fragments
|
|
7117 @section Extent Fragments
|
|
7118 @cindex extent fragment
|
|
7119
|
|
7120 Imagine that the buffer is divided up into contiguous, non-overlapping
|
|
7121 @dfn{runs} of text such that no extent starts or ends within a run
|
|
7122 (extents that abut the run don't count).
|
|
7123
|
|
7124 An extent fragment is a structure that holds data about the run that
|
|
7125 contains a particular buffer position (if the buffer position is at the
|
|
7126 junction of two runs, the run after the position is used) -- the
|
|
7127 beginning and end of the run, a list of all of the extents in that run,
|
|
7128 the @dfn{merged face} that results from merging all of the faces
|
|
7129 corresponding to those extents, the begin and end glyphs at the
|
|
7130 beginning of the run, etc. This is the information that redisplay needs
|
|
7131 in order to display this run.
|
|
7132
|
|
7133 Extent fragments have to be very quick to update to a new buffer
|
|
7134 position when moving linearly through the buffer. They rely on the
|
|
7135 stack-of-extents code, which does the heavy-duty algorithmic work of
|
|
7136 determining which extents overly a particular position.
|
|
7137
|
|
7138 @node Faces and Glyphs, Specifiers, Extents, Top
|
|
7139 @chapter Faces and Glyphs
|
|
7140
|
|
7141 Not yet documented.
|
|
7142
|
|
7143 @node Specifiers, Menus, Faces and Glyphs, Top
|
|
7144 @chapter Specifiers
|
|
7145
|
|
7146 Not yet documented.
|
|
7147
|
|
7148 @node Menus, Subprocesses, Specifiers, Top
|
|
7149 @chapter Menus
|
|
7150
|
|
7151 A menu is set by setting the value of the variable
|
|
7152 @code{current-menubar} (which may be buffer-local) and then calling
|
|
7153 @code{set-menubar-dirty-flag} to signal a change. This will cause the
|
|
7154 menu to be redrawn at the next redisplay. The format of the data in
|
|
7155 @code{current-menubar} is described in @file{menubar.c}.
|
|
7156
|
|
7157 Internally the data in current-menubar is parsed into a tree of
|
|
7158 @code{widget_value's} (defined in @file{lwlib.h}); this is accomplished
|
|
7159 by the recursive function @code{menu_item_descriptor_to_widget_value()},
|
|
7160 called by @code{compute_menubar_data()}. Such a tree is deallocated
|
|
7161 using @code{free_widget_value()}.
|
|
7162
|
|
7163 @code{update_screen_menubars()} is one of the external entry points.
|
|
7164 This checks to see, for each screen, if that screen's menubar needs to
|
|
7165 be updated. This is the case if
|
|
7166
|
|
7167 @enumerate
|
|
7168 @item
|
|
7169 @code{set-menubar-dirty-flag} was called since the last redisplay. (This
|
|
7170 function sets the C variable menubar_has_changed.)
|
|
7171 @item
|
|
7172 The buffer displayed in the screen has changed.
|
|
7173 @item
|
|
7174 The screen has no menubar currently displayed.
|
|
7175 @end enumerate
|
|
7176
|
|
7177 @code{set_screen_menubar()} is called for each such screen. This
|
|
7178 function calls @code{compute_menubar_data()} to create the tree of
|
|
7179 widget_value's, then calls @code{lw_create_widget()},
|
|
7180 @code{lw_modify_all_widgets()}, and/or @code{lw_destroy_all_widgets()}
|
|
7181 to create the X-Toolkit widget associated with the menu.
|
|
7182
|
|
7183 @code{update_psheets()}, the other external entry point, actually
|
|
7184 changes the menus being displayed. It uses the widgets fixed by
|
|
7185 @code{update_screen_menubars()} and calls various X functions to ensure
|
|
7186 that the menus are displayed properly.
|
|
7187
|
|
7188 The menubar widget is set up so that @code{pre_activate_callback()} is
|
|
7189 called when the menu is first selected (i.e. mouse button goes down),
|
|
7190 and @code{menubar_selection_callback()} is called when an item is
|
|
7191 selected. @code{pre_activate_callback()} calls the function in
|
|
7192 activate-menubar-hook, which can change the menubar (this is described
|
|
7193 in @file{menubar.c}). If the menubar is changed,
|
|
7194 @code{set_screen_menubars()} is called.
|
|
7195 @code{menubar_selection_callback()} enqueues a menu event, putting in it
|
|
7196 a function to call (either @code{eval} or @code{call-interactively}) and
|
|
7197 its argument, which is the callback function or form given in the menu's
|
|
7198 description.
|
|
7199
|
|
7200 @node Subprocesses, Interface to X Windows, Menus, Top
|
|
7201 @chapter Subprocesses
|
|
7202
|
|
7203 The fields of a process are:
|
|
7204
|
|
7205 @table @code
|
|
7206 @item name
|
|
7207 A string, the name of the process.
|
|
7208
|
|
7209 @item command
|
|
7210 A list containing the command arguments that were used to start this
|
|
7211 process.
|
|
7212
|
|
7213 @item filter
|
|
7214 A function used to accept output from the process instead of a buffer,
|
|
7215 or @code{nil}.
|
|
7216
|
|
7217 @item sentinel
|
|
7218 A function called whenever the process receives a signal, or @code{nil}.
|
|
7219
|
|
7220 @item buffer
|
|
7221 The associated buffer of the process.
|
|
7222
|
|
7223 @item pid
|
|
7224 An integer, the Unix process @sc{id}.
|
|
7225
|
|
7226 @item childp
|
|
7227 A flag, non-@code{nil} if this is really a child process.
|
|
7228 It is @code{nil} for a network connection.
|
|
7229
|
|
7230 @item mark
|
|
7231 A marker indicating the position of the end of the last output from this
|
|
7232 process inserted into the buffer. This is often but not always the end
|
|
7233 of the buffer.
|
|
7234
|
|
7235 @item kill_without_query
|
|
7236 If this is non-@code{nil}, killing XEmacs while this process is still
|
|
7237 running does not ask for confirmation about killing the process.
|
|
7238
|
|
7239 @item raw_status_low
|
|
7240 @itemx raw_status_high
|
|
7241 These two fields record 16 bits each of the process status returned by
|
|
7242 the @code{wait} system call.
|
|
7243
|
|
7244 @item status
|
|
7245 The process status, as @code{process-status} should return it.
|
|
7246
|
|
7247 @item tick
|
|
7248 @itemx update_tick
|
|
7249 If these two fields are not equal, a change in the status of the process
|
|
7250 needs to be reported, either by running the sentinel or by inserting a
|
|
7251 message in the process buffer.
|
|
7252
|
|
7253 @item pty_flag
|
|
7254 Non-@code{nil} if communication with the subprocess uses a @sc{pty};
|
|
7255 @code{nil} if it uses a pipe.
|
|
7256
|
|
7257 @item infd
|
|
7258 The file descriptor for input from the process.
|
|
7259
|
|
7260 @item outfd
|
|
7261 The file descriptor for output to the process.
|
|
7262
|
|
7263 @item subtty
|
|
7264 The file descriptor for the terminal that the subprocess is using. (On
|
|
7265 some systems, there is no need to record this, so the value is
|
|
7266 @code{-1}.)
|
|
7267
|
|
7268 @item tty_name
|
|
7269 The name of the terminal that the subprocess is using,
|
|
7270 or @code{nil} if it is using pipes.
|
|
7271 @end table
|
|
7272
|
|
7273 @node Interface to X Windows, Index, Subprocesses, Top
|
|
7274 @chapter Interface to X Windows
|
|
7275
|
|
7276 Not yet documented.
|
|
7277
|
|
7278 @include index.texi
|
|
7279
|
|
7280 @c Print the tables of contents
|
|
7281 @summarycontents
|
|
7282 @contents
|
|
7283 @c That's all
|
|
7284
|
|
7285 @bye
|
|
7286
|