annotate man/internals/internals.texi @ 347:7c94d56991e1 r21-1-3

Import from CVS: tag r21-1-3
author cvs
date Mon, 13 Aug 2007 10:53:48 +0200
parents 8bec6624d99b
children 182f72e8cd0d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 \input texinfo @c -*-texinfo-*-
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 @c %**start of header
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 @setfilename ../../info/internals.info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 @settitle XEmacs Internals Manual
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 @c %**end of header
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 @ifinfo
343
8bec6624d99b Import from CVS: tag r21-1-1
cvs
parents: 318
diff changeset
8 @dircategory XEmacs Editor
8bec6624d99b Import from CVS: tag r21-1-1
cvs
parents: 318
diff changeset
9 @direntry
8bec6624d99b Import from CVS: tag r21-1-1
cvs
parents: 318
diff changeset
10 * Internals: (internals). XEmacs Internals Manual.
8bec6624d99b Import from CVS: tag r21-1-1
cvs
parents: 318
diff changeset
11 @end direntry
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 Copyright @copyright{} 1992 - 1996 Ben Wing.
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
14 Copyright @copyright{} 1996, 1997 Sun Microsystems.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 Copyright @copyright{} 1994, 1995 Free Software Foundation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 Copyright @copyright{} 1994, 1995 Board of Trustees, University of Illinois.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 Permission is granted to make and distribute verbatim copies of this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 manual provided the copyright notice and this permission notice are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 preserved on all copies.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 @ignore
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 Permission is granted to process this file through TeX and print the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 results, provided the printed document carries copying permission notice
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 identical to this one except for the removal of this paragraph (this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 paragraph not being relevant to the printed manual).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 @end ignore
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 Permission is granted to copy and distribute modified versions of this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 manual under the conditions for verbatim copying, provided that the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 entire resulting derived work is distributed under the terms of a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 permission notice identical to this one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 Permission is granted to copy and distribute translations of this manual
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 into another language, under the above conditions for modified versions,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 except that this permission notice may be stated in a translation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 approved by the Foundation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 Permission is granted to copy and distribute modified versions of this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 manual under the conditions for verbatim copying, provided also that the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 section entitled ``GNU General Public License'' is included exactly as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 in the original, and provided that the entire resulting derived work is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 distributed under the terms of a permission notice identical to this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 Permission is granted to copy and distribute translations of this manual
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 into another language, under the above conditions for modified versions,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 except that the section entitled ``GNU General Public License'' may be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 included in a translation approved by the Free Software Foundation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 instead of in the original English.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 @end ifinfo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 @c Combine indices.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 @synindex cp fn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 @syncodeindex vr fn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 @syncodeindex ky fn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 @syncodeindex pg fn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 @syncodeindex tp fn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 @setchapternewpage odd
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 @finalout
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 @titlepage
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 @title XEmacs Internals Manual
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
66 @subtitle Version 1.1, March 1997
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 @author Ben Wing
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
69 @author Martin Buchholz
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 @page
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 @vskip 0pt plus 1fill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 Copyright @copyright{} 1992 - 1996 Ben Wing. @*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 Copyright @copyright{} 1996 Sun Microsystems, Inc. @*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 Copyright @copyright{} 1994 Free Software Foundation. @*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 Copyright @copyright{} 1994, 1995 Board of Trustees, University of Illinois.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 @sp 2
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
80 Version 1.1 @*
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
81 March, 1997.@*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 Permission is granted to make and distribute verbatim copies of this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 manual provided the copyright notice and this permission notice are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 preserved on all copies.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 Permission is granted to copy and distribute modified versions of this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 manual under the conditions for verbatim copying, provided also that the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 section entitled ``GNU General Public License'' is included
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 exactly as in the original, and provided that the entire resulting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 derived work is distributed under the terms of a permission notice
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 identical to this one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 Permission is granted to copy and distribute translations of this manual
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 into another language, under the above conditions for modified versions,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 except that the section entitled ``GNU General Public License'' may be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 included in a translation approved by the Free Software Foundation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 instead of in the original English.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 @end titlepage
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 @page
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 @node Top, A History of Emacs, (dir), (dir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 @ifinfo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 This Info file contains v1.0 of the XEmacs Internals Manual.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 @end ifinfo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 @menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 * A History of Emacs:: Times, dates, important events.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 * XEmacs From the Outside:: A broad conceptual overview.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 * The Lisp Language:: An overview.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 * XEmacs From the Perspective of Building::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 * XEmacs From the Inside::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 * The XEmacs Object System (Abstractly Speaking)::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 * How Lisp Objects Are Represented in C::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 * Rules When Writing New C Code::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 * A Summary of the Various XEmacs Modules::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 * Allocation of Objects in XEmacs Lisp::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 * Events and the Event Loop::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 * Evaluation; Stack Frames; Bindings::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 * Symbols and Variables::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 * Buffers and Textual Representation::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 * MULE Character Sets and Encodings::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 * The Lisp Reader and Compiler::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 * Lstreams::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 * Consoles; Devices; Frames; Windows::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 * The Redisplay Mechanism::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 * Extents::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 * Faces and Glyphs::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 * Specifiers::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 * Menus::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 * Subprocesses::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 * Interface to X Windows::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 * Index:: Index including concepts, functions, variables,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 and other terms.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 --- The Detailed Node Listing ---
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 Here are other nodes that are inferiors of those already listed,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 mentioned here so you can get to them in one step:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 A History of Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 * Through Version 18:: Unification prevails.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 * Lucid Emacs:: One version 19 Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 * GNU Emacs 19:: The other version 19 Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 * XEmacs:: The continuation of Lucid Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 Rules When Writing New C Code
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 * General Coding Rules::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 * Writing Lisp Primitives::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 * Adding Global Lisp Variables::
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
154 * Techniques for XEmacs Developers::
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 A Summary of the Various XEmacs Modules
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 * Low-Level Modules::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 * Basic Lisp Modules::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 * Modules for Standard Editing Operations::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 * Editor-Level Control Flow Modules::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 * Modules for the Basic Displayable Lisp Objects::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 * Modules for other Display-Related Lisp Objects::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 * Modules for the Redisplay Mechanism::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 * Modules for Interfacing with the File System::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 * Modules for Other Aspects of the Lisp Interpreter and Object System::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 * Modules for Interfacing with the Operating System::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 * Modules for Interfacing with X Windows::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 * Modules for Internationalization::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 Allocation of Objects in XEmacs Lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 * Introduction to Allocation::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 * Garbage Collection::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 * GCPROing::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 * Integers and Characters::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 * Allocation from Frob Blocks::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 * lrecords::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 * Low-level allocation::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 * Pure Space::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 * Cons::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 * Vector::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 * Bit Vector::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 * Symbol::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 * Marker::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 * String::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 * Bytecode::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 Events and the Event Loop
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 * Introduction to Events::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 * Main Loop::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 * Specifics of the Event Gathering Mechanism::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 * Specifics About the Emacs Event::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 * The Event Stream Callback Routines::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 * Other Event Loop Functions::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 * Converting Events::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 * Dispatching Events; The Command Builder::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 Evaluation; Stack Frames; Bindings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 * Evaluation::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 * Dynamic Binding; The specbinding Stack; Unwind-Protects::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 * Simple Special Forms::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 * Catch and Throw::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 Symbols and Variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 * Introduction to Symbols::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 * Obarrays::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 * Symbol Values::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 Buffers and Textual Representation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 * Introduction to Buffers:: A buffer holds a block of text such as a file.
193
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 175
diff changeset
216 * The Text in a Buffer:: Representation of the text in a buffer.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 * Buffer Lists:: Keeping track of all buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 * Markers and Extents:: Tagging locations within a buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 * Bufbytes and Emchars:: Representation of individual characters.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 * The Buffer Object:: The Lisp object corresponding to a buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 MULE Character Sets and Encodings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 * Character Sets::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 * Encodings::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 * Internal Mule Encodings::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 Encodings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 * Japanese EUC (Extended Unix Code)::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 * JIS7::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 Internal Mule Encodings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 * Internal String Encoding::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 * Internal Character Encoding::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 The Lisp Reader and Compiler
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 Lstreams
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 Consoles; Devices; Frames; Windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 * Introduction to Consoles; Devices; Frames; Windows::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 * Point::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 * Window Hierarchy::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 The Redisplay Mechanism
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 * Critical Redisplay Sections::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 * Line Start Cache::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 Extents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 * Introduction to Extents:: Extents are ranges over text, with properties.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 * Extent Ordering:: How extents are ordered internally.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 * Format of the Extent Info:: The extent information in a buffer or string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 * Zero-Length Extents:: A weird special case.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 * Mathematics of Extent Ordering:: A rigorous foundation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 * Extent Fragments:: Cached information useful for redisplay.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 Faces and Glyphs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 Specifiers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 Menus
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 Subprocesses
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 Interface to X Windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 @end menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 @node A History of Emacs, XEmacs From the Outside, Top, Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 @chapter A History of Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 @cindex history of Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 @cindex Hackers (Steven Levy)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 @cindex Levy, Steven
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 @cindex ITS (Incompatible Timesharing System)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 @cindex Stallman, Richard
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 @cindex RMS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 @cindex MIT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 @cindex TECO
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 @cindex FSF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 @cindex Free Software Foundation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 XEmacs is a powerful, customizable text editor and development
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 environment. It began as Lucid Emacs, which was in turn derived from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 GNU Emacs, a program written by Richard Stallman of the Free Software
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 Foundation. GNU Emacs dates back to the 1970's, and was modelled
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 after a package called ``Emacs'', written in 1976, that was a set of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 macros on top of TECO, an old, old text editor written at MIT on the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 DEC PDP 10 under one of the earliest time-sharing operating systems,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 ITS (Incompatible Timesharing System). (ITS dates back well before
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 Unix.) ITS, TECO, and Emacs were products of a group of people at MIT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 who called themselves ``hackers'', who shared an idealistic belief
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 system about the free exchange of information and were fanatical in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 their devotion to and time spent with computers. (The hacker
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 subculture dates back to the late 1950's at MIT and is described in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 detail in Steven Levy's book @cite{Hackers}. This book also includes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 a lot of information about Stallman himself and the development of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 Lisp, a programming language developed at MIT that underlies Emacs.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 @menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 * Through Version 18:: Unification prevails.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 * Lucid Emacs:: One version 19 Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 * GNU Emacs 19:: The other version 19 Emacs.
193
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 175
diff changeset
308 * GNU Emacs 20:: The other version 20 Emacs.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 * XEmacs:: The continuation of Lucid Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 @end menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 @node Through Version 18
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 @section Through Version 18
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 @cindex Gosling, James
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 @cindex Great Usenet Renaming
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 Although the history of the early versions of GNU Emacs is unclear,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 the history is well-known from the middle of 1985. A time line is:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 @itemize @bullet
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 GNU Emacs version 15 (15.34) was released sometime in 1984 or 1985 and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 shared some code with a version of Emacs written by James Gosling (the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 same James Gosling who later created the Java language).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 GNU Emacs version 16 (first released version was 16.56) was released on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 July 15, 1985. All Gosling code was removed due to potential copyright
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 problems with the code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 version 16.57: released on September 16, 1985.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 versions 16.58, 16.59: released on September 17, 1985.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 version 16.60: released on September 19, 1985. These later version 16's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 incorporated patches from the net, esp. for getting Emacs to work under
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 System V.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 version 17.36 (first official v17 release) released on December 20,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 1985. Included a TeX-able user manual. First official unpatched
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 version that worked on vanilla System V machines.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 version 17.43 (second official v17 release) released on January 25,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 1986.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 version 17.45 released on January 30, 1986.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 version 17.46 released on February 4, 1986.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 version 17.48 released on February 10, 1986.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 version 17.49 released on February 12, 1986.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 version 17.55 released on March 18, 1986.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 version 17.57 released on March 27, 1986.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 version 17.58 released on April 4, 1986.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 version 17.61 released on April 12, 1986.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 version 17.63 released on May 7, 1986.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 version 17.64 released on May 12, 1986.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 version 18.24 (a beta version) released on October 2, 1986.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 version 18.30 (a beta version) released on November 15, 1986.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 version 18.31 (a beta version) released on November 23, 1986.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 version 18.32 (a beta version) released on December 7, 1986.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 version 18.33 (a beta version) released on December 12, 1986.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 version 18.35 (a beta version) released on January 5, 1987.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 version 18.36 (a beta version) released on January 21, 1987.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 @item
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
379 January 27, 1987: The Great Usenet Renaming. net.emacs is now
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
380 comp.emacs.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
381 @item
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 version 18.37 (a beta version) released on February 12, 1987.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 version 18.38 (a beta version) released on March 3, 1987.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 version 18.39 (a beta version) released on March 14, 1987.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 version 18.40 (a beta version) released on March 18, 1987.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 version 18.41 (the first ``official'' release) released on March 22,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 1987.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 version 18.45 released on June 2, 1987.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 version 18.46 released on June 9, 1987.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 version 18.47 released on June 18, 1987.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 version 18.48 released on September 3, 1987.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 version 18.49 released on September 18, 1987.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 version 18.50 released on February 13, 1988.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 version 18.51 released on May 7, 1988.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 version 18.52 released on September 1, 1988.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 version 18.53 released on February 24, 1989.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 version 18.54 released on April 26, 1989.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 version 18.55 released on August 23, 1989. This is the earliest version
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 that is still available by FTP.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 version 18.56 released on January 17, 1991.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 version 18.57 released late January, 1991.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 version 18.58 released ?????.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 version 18.59 released October 31, 1992.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 @end itemize
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 @node Lucid Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 @section Lucid Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 @cindex Lucid Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 @cindex Lucid Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 @cindex Energize
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 @cindex Epoch
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 Lucid Emacs was developed by the (now-defunct) Lucid Inc., a maker of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 C++ and Lisp development environments. It began when Lucid decided they
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 wanted to use Emacs as the editor and cornerstone of their C++
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 development environment (called ``Energize''). They needed many features
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 that were not available in the existing version of GNU Emacs (version
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 18.5something), in particular good and integrated support for GUI
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 elements such as mouse support, multiple fonts, multiple window-system
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 windows, etc. A branch of GNU Emacs called Epoch, written at the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 University of Illinois, existed that supplied many of these features;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 however, Lucid needed more than what existed in Epoch. At the time, the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 Free Software Foundation was working on version 19 of Emacs (this was
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 sometime around 1991), which was planned to have similar features, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 so Lucid decided to work with the Free Software Foundation. Their plan
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 was to add features that they needed, and coordinate with the FSF so
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 that the features would get included back into Emacs version 19.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 Delays in the release of version 19 occurred, however (resulting in it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 finally being released more than a year after what was initially
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 planned), and Lucid encountered unexpected technical resistance in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 getting their changes merged back into version 19, so they decided to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 release their own version of Emacs, which became Lucid Emacs 19.0.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 @cindex Zawinski, Jamie
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 @cindex Sexton, Harlan
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 @cindex Benson, Eric
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 @cindex Devin, Matthieu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 The initial authors of Lucid Emacs were Matthieu Devin, Harlan Sexton,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 and Eric Benson, and the work was later taken over by Jamie Zawinski,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 who became ``Mr. Lucid Emacs'' for many releases.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 A time line for Lucid Emacs/XEmacs is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 @itemize @bullet
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 version 19.0 shipped with Energize 1.0, April 1992.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 version 19.1 released June 4, 1992.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 version 19.2 released June 19, 1992.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 version 19.3 released September 9, 1992.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 version 19.4 released January 21, 1993.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 version 19.5 was a repackaging of 19.4 with a few bug fixes and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 shipped with Energize 2.0. Never released to the net.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 version 19.6 released April 9, 1993.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 version 19.7 was a repackaging of 19.6 with a few bug fixes and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 shipped with Energize 2.1. Never released to the net.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 version 19.8 released September 6, 1993.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 version 19.9 released January 12, 1994.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 version 19.10 released May 27, 1994.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 version 19.11 (first XEmacs) released September 13, 1994.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 version 19.12 released June 23, 1995.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 version 19.13 released September 1, 1995.
112
48d667d6f17f Import from CVS: tag r20-1b8
cvs
parents: 70
diff changeset
495 @item
48d667d6f17f Import from CVS: tag r20-1b8
cvs
parents: 70
diff changeset
496 version 19.14 released June 23, 1996.
48d667d6f17f Import from CVS: tag r20-1b8
cvs
parents: 70
diff changeset
497 @item
48d667d6f17f Import from CVS: tag r20-1b8
cvs
parents: 70
diff changeset
498 version 20.0 released February 9, 1997.
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 116
diff changeset
499 @item
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 116
diff changeset
500 version 19.15 released March 28, 1997.
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 120
diff changeset
501 @item
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 120
diff changeset
502 version 20.1 (not released to the net) April 15, 1997.
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 120
diff changeset
503 @item
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 120
diff changeset
504 version 20.2 released May 16, 1997.
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 195
diff changeset
505 @item
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 195
diff changeset
506 version 19.16 released October 31, 1997.
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 209
diff changeset
507 @item
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 209
diff changeset
508 version 20.3 (the first stable version of XEmacs 20.x) released November 30,
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 209
diff changeset
509 1997.
259
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 253
diff changeset
510 version 20.4 released February 28, 1998.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 @end itemize
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 @node GNU Emacs 19
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 @section GNU Emacs 19
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 @cindex GNU Emacs 19
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 @cindex FSF Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 About a year after the initial release of Lucid Emacs, the FSF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 released a beta of their version of Emacs 19 (referred to here as ``GNU
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 Emacs''). By this time, the current version of Lucid Emacs was
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 19.6. (Strangely, the first released beta from the FSF was GNU Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 19.7.) A time line for GNU Emacs version 19 is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 @itemize @bullet
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 version 19.8 (beta) released May 27, 1993.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 version 19.9 (beta) released May 27, 1993.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 version 19.10 (beta) released May 30, 1993.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 version 19.11 (beta) released June 1, 1993.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 version 19.12 (beta) released June 2, 1993.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 version 19.13 (beta) released June 8, 1993.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 version 19.14 (beta) released June 17, 1993.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 version 19.15 (beta) released June 19, 1993.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 version 19.16 (beta) released July 6, 1993.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 version 19.17 (beta) released late July, 1993.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 version 19.18 (beta) released August 9, 1993.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 version 19.19 (beta) released August 15, 1993.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 version 19.20 (beta) released November 17, 1993.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 version 19.21 (beta) released November 17, 1993.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 version 19.22 (beta) released November 28, 1993.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 version 19.23 (beta) released May 17, 1994.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 version 19.24 (beta) released May 16, 1994.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 version 19.25 (beta) released June 3, 1994.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 version 19.26 (beta) released September 11, 1994.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 version 19.27 (beta) released September 14, 1994.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 version 19.28 (first ``official'' release) released November 1, 1994.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 version 19.29 released June 21, 1995.
112
48d667d6f17f Import from CVS: tag r20-1b8
cvs
parents: 70
diff changeset
569 @item
48d667d6f17f Import from CVS: tag r20-1b8
cvs
parents: 70
diff changeset
570 version 19.30 released November 24, 1995.
48d667d6f17f Import from CVS: tag r20-1b8
cvs
parents: 70
diff changeset
571 @item
48d667d6f17f Import from CVS: tag r20-1b8
cvs
parents: 70
diff changeset
572 version 19.31 released May 25, 1996.
48d667d6f17f Import from CVS: tag r20-1b8
cvs
parents: 70
diff changeset
573 @item
48d667d6f17f Import from CVS: tag r20-1b8
cvs
parents: 70
diff changeset
574 version 19.32 released July 31, 1996.
48d667d6f17f Import from CVS: tag r20-1b8
cvs
parents: 70
diff changeset
575 @item
48d667d6f17f Import from CVS: tag r20-1b8
cvs
parents: 70
diff changeset
576 version 19.33 released August 11, 1996.
48d667d6f17f Import from CVS: tag r20-1b8
cvs
parents: 70
diff changeset
577 @item
48d667d6f17f Import from CVS: tag r20-1b8
cvs
parents: 70
diff changeset
578 version 19.34 released August 21, 1996.
48d667d6f17f Import from CVS: tag r20-1b8
cvs
parents: 70
diff changeset
579 @item
48d667d6f17f Import from CVS: tag r20-1b8
cvs
parents: 70
diff changeset
580 version 19.34b released September 6, 1996.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 @end itemize
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 @cindex Mlynarik, Richard
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 In some ways, GNU Emacs 19 was better than Lucid Emacs; in some ways,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 worse. Lucid soon began incorporating features from GNU Emacs 19 into
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 Lucid Emacs; the work was mostly done by Richard Mlynarik, who had been
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 working on and using GNU Emacs for a long time (back as far as version
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 16 or 17).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589
193
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 175
diff changeset
590 @node GNU Emacs 20
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 175
diff changeset
591 @section GNU Emacs 20
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 175
diff changeset
592 @cindex GNU Emacs 20
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 175
diff changeset
593 @cindex FSF Emacs
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 175
diff changeset
594
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 175
diff changeset
595 On February 2, 1997 work began on GNU Emacs to integrate Mule. The first
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 175
diff changeset
596 release was made in September of that year.
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 175
diff changeset
597
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 175
diff changeset
598 A timeline for Emacs 20 is
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 175
diff changeset
599
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 175
diff changeset
600 @itemize @bullet
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 175
diff changeset
601 @item
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 175
diff changeset
602 version 20.1 released September 17, 1997.
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
603 @item
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 193
diff changeset
604 version 20.2 released September 20, 1997.
318
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
605 @item
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
606 version 20.3 released August 19, 1998.
193
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 175
diff changeset
607 @end itemize
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 175
diff changeset
608
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 @node XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 @section XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 @cindex XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 @cindex Sun Microsystems
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 @cindex University of Illinois
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 @cindex Illinois, University of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 @cindex SPARCWorks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 @cindex Andreessen, Marc
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 116
diff changeset
618 @cindex Baur, Steve
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 116
diff changeset
619 @cindex Buchholz, Martin
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 @cindex Kaplan, Simon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 @cindex Wing, Ben
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 @cindex Thompson, Chuck
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 @cindex Win-Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 @cindex Epoch
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 @cindex Amdahl Corporation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 Around the time that Lucid was developing Energize, Sun Microsystems
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 was developing their own development environment (called ``SPARCWorks'')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 and also decided to use Emacs. They joined forces with the Epoch team
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 at the University of Illinois and later with Lucid. The maintainer of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 the last-released version of Epoch was Marc Andreessen, but he dropped
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 out and the Epoch project, headed by Simon Kaplan, lured Chuck Thompson
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 away from a system administration job to become the primary Lucid Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 author for Epoch and Sun. Chuck's area of specialty became the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 redisplay engine (he replaced the old Lucid Emacs redisplay engine with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 a ported version from Epoch and then later rewrote it from scratch).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 Sun also hired Ben Wing (the author of Win-Emacs, a port of Lucid Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 to Microsoft Windows 3.1) in 1993, for what was initially a one-month
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 contract to fix some event problems but later became a many-year
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 involvement, punctuated by a six-month contract with Amdahl Corporation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 @cindex rename to XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 In 1994, Sun and Lucid agreed to rename Lucid Emacs to XEmacs (a name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 not favorable to either company); the first release called XEmacs was
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 version 19.11. In June 1994, Lucid folded and Jamie quit to work for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 the newly formed Mosaic Communications Corp., later Netscape
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 Communications Corp. (co-founded by the same Marc Andreessen, who had
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 quit his Epoch job to work on a graphical browser for the World Wide
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 Web). Chuck then become the primary maintainer of XEmacs, and put out
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 116
diff changeset
649 versions 19.11 through 19.14 in conjunction with Ben. For 19.12 and
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 19.13, Chuck added the new redisplay and many other display improvements
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 and Ben added MULE support (support for Asian and other languages) and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 redesigned most of the internal Lisp subsystems to better support the
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 116
diff changeset
653 MULE work and the various other features being added to XEmacs. After
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 116
diff changeset
654 19.14 Chuck retired as primary maintainer and Steve Baur stepped in.
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 116
diff changeset
655
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 116
diff changeset
656 @cindex MULE merged XEmacs appears
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 116
diff changeset
657 Soon after 19.13 was released, work began in earnest on the MULE
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 116
diff changeset
658 internationalization code and the source tree was divided into two
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 116
diff changeset
659 development paths. The MULE version was initially called 19.20, but was
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 116
diff changeset
660 soon renamed to 20.0. In 1996 Martin Buchholz of Sun Microsystems took
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 116
diff changeset
661 over the care and feeding of it and worked on it in parallel with the
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 116
diff changeset
662 19.14 development that was occurring at the same time. After much work
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 116
diff changeset
663 by Martin, it was decided to release 20.0 ahead of 19.15 in February
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 209
diff changeset
664 1997. The source tree remained divided until 20.2 when the version 19
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 209
diff changeset
665 source was finally retired at version 19.16.
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 209
diff changeset
666
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 209
diff changeset
667 @cindex Baur, Steve
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 209
diff changeset
668 @cindex Buchholz, Martin
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 209
diff changeset
669 @cindex Jones, Kyle
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 209
diff changeset
670 @cindex Niksic, Hrvoje
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 209
diff changeset
671 @cindex XEmacs goes it alone
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 209
diff changeset
672 In 1997, Sun finally dropped all pretense of support for XEmacs and
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 209
diff changeset
673 Martin Buchholz left the company in November. Since then, and mostly
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 209
diff changeset
674 for the previous year, because Steve Baur was never paid to work on
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 209
diff changeset
675 XEmacs, XEmacs has existed solely on the contributions of volunteers
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 209
diff changeset
676 from the Free Software Community. Starting from 1997, Hrvoje Niksic and
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 209
diff changeset
677 Kyle Jones have figured prominently in XEmacs development.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 @cindex merging attempts
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 Many attempts have been made to merge XEmacs and GNU Emacs, but they
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 209
diff changeset
681 have consistently failed.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 A more detailed history is contained in the XEmacs About page.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 @node XEmacs From the Outside, The Lisp Language, A History of Emacs, Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 @chapter XEmacs From the Outside
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 @cindex read-eval-print
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 XEmacs appears to the outside world as an editor, but it is really a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 Lisp environment. At its heart is a Lisp interpreter; it also
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 ``happens'' to contain many specialized object types (e.g. buffers,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 windows, frames, events) that are useful for implementing an editor.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 Some of these objects (in particular windows and frames) have
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 displayable representations, and XEmacs provides a function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 @code{redisplay()} that ensures that the display of all such objects
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 matches their internal state. Most of the time, a standard Lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 environment is in a @dfn{read-eval-print} loop -- i.e. ``read some Lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 code, execute it, and print the results''. XEmacs has a similar loop:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 @itemize @bullet
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 read an event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 dispatch the event (i.e. ``do it'')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 redisplay
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 @end itemize
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 Reading an event is done using the Lisp function @code{next-event},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 which waits for something to happen (typically, the user presses a key
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 or moves the mouse) and returns an event object describing this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 Dispatching an event is done using the Lisp function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 @code{dispatch-event}, which looks up the event in a keymap object (a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 particular kind of object that associates an event with a Lisp function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 and calls that function. The function ``does'' what the user has
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 requested by changing the state of particular frame objects, buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 objects, etc. Finally, @code{redisplay()} is called, which updates the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 display to reflect those changes just made. Thus is an ``editor'' born.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 @cindex bridge, playing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 @cindex taxes, doing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 @cindex pi, calculating
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 Note that you do not have to use XEmacs as an editor; you could just
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 as well make it do your taxes, compute pi, play bridge, etc. You'd just
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 have to write functions to do those operations in Lisp.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 @node The Lisp Language, XEmacs From the Perspective of Building, XEmacs From the Outside, Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 @chapter The Lisp Language
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 @cindex Lisp vs. C
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 @cindex C vs. Lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 @cindex Lisp vs. Java
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 @cindex Java vs. Lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 @cindex dynamic scoping
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 @cindex scoping, dynamic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 @cindex dynamic types
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 @cindex types, dynamic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 @cindex Java
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 @cindex Common Lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 @cindex Gosling, James
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 Lisp is a general-purpose language that is higher-level than C and in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 many ways more powerful than C. Powerful dialects of Lisp such as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 Common Lisp are probably much better languages for writing very large
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 applications than is C. (Unfortunately, for many non-technical
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 reasons C and its successor C++ have become the dominant languages for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 application development. These languages are both inadequate for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 extremely large applications, which is evidenced by the fact that newer,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 larger programs are becoming ever harder to write and are requiring ever
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 more programmers despite great increases in C development environments;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 and by the fact that, although hardware speeds and reliability have been
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 growing at an exponential rate, most software is still generally
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 considered to be slow and buggy.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 The new Java language holds promise as a better general-purpose
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 development language than C. Java has many features in common with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 Lisp that are not shared by C (this is not a coincidence, since
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 Java was designed by James Gosling, a former Lisp hacker). This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 will be discussed more later.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 For those used to C, here is a summary of the basic differences between
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 C and Lisp:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 @enumerate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 Lisp has an extremely regular syntax. Every function, expression,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 and control statement is written in the form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 (@var{func} @var{arg1} @var{arg2} ...)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 This is as opposed to C, which writes functions as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 func(@var{arg1}, @var{arg2}, ...)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 but writes expressions involving operators as (e.g.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 @var{arg1} + @var{arg2}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 and writes control statements as (e.g.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 while (@var{expr}) @{ @var{statement1}; @var{statement2}; ... @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 Lisp equivalents of the latter two would be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 (+ @var{arg1} @var{arg2} ...)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 (while @var{expr} @var{statement1} @var{statement2} ...)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 Lisp is a safe language. Assuming there are no bugs in the Lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 interpreter/compiler, it is impossible to write a program that ``core
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 dumps'' or otherwise causes the machine to execute an illegal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 instruction. This is very different from C, where perhaps the most
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 common outcome of a bug is exactly such a crash. A corollary of this is that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 the C operation of casting a pointer is impossible (and unnecessary) in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 Lisp, and that it is impossible to access memory outside the bounds of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 an array.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 Programs and data are written in the same form. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 parenthesis-enclosing form described above for statements is the same
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 form used for the most common data type in Lisp, the list. Thus, it is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 possible to represent any Lisp program using Lisp data types, and for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 one program to construct Lisp statements and then dynamically
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 @dfn{evaluate} them, or cause them to execute.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 All objects are @dfn{dynamically typed}. This means that part of every
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 object is an indication of what type it is. A Lisp program can
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 manipulate an object without knowing what type it is, and can query an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 object to determine its type. This means that, correspondingly,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 variables and function parameters can hold objects of any type and are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 not normally declared as being of any particular type. This is opposed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 to the @dfn{static typing} of C, where variables can hold exactly one
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 type of object and must be declared as such, and objects do not contain
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 an indication of their type because it's implicit in the variables they
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 are stored in. It is possible in C to have a variable hold different
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 types of objects (e.g. through the use of @code{void *} pointers or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 variable-argument functions), but the type information must then be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 passed explicitly in some other fashion, leading to additional program
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 complexity.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 Allocated memory is automatically reclaimed when it is no longer in use.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 This operation is called @dfn{garbage collection} and involves looking
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 through all variables to see what memory is being pointed to, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 reclaiming any memory that is not pointed to and is thus
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 ``inaccessible'' and out of use. This is as opposed to C, in which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 allocated memory must be explicitly reclaimed using @code{free()}. If
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 you simply drop all pointers to memory without freeing it, it becomes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 ``leaked'' memory that still takes up space. Over a long period of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 time, this can cause your program to grow and grow until it runs out of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 memory.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 Lisp has built-in facilities for handling errors and exceptions. In C,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 when an error occurs, usually either the program exits entirely or the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 routine in which the error occurs returns a value indicating this. If
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 an error occurs in a deeply-nested routine, then every routine currently
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 called must unwind itself normally and return an error value back up to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 the next routine. This means that every routine must explicitly check
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 for an error in all the routines it calls; if it does not do so,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 unexpected and often random behavior results. This is an extremely
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 common source of bugs in C programs. An alternative would be to do a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 non-local exit using @code{longjmp()}, but that is often very dangerous
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 because the routines that were exited past had no opportunity to clean
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 up after themselves and may leave things in an inconsistent state,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 causing a crash shortly afterwards.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 Lisp provides mechanisms to make such non-local exits safe. When an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 error occurs, a routine simply signals that an error of a particular
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 class has occurred, and a non-local exit takes place. Any routine can
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 trap errors occurring in routines it calls by registering an error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 handler for some or all classes of errors. (If no handler is registered,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 a default handler, generally installed by the top-level event loop, is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 executed; this prints out the error and continues.) Routines can also
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 specify cleanup code (called an @dfn{unwind-protect}) that will be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 called when control exits from a block of code, no matter how that exit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 occurs -- i.e. even if a function deeply nested below it causes a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 non-local exit back to the top level.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 Note that this facility has appeared in some recent vintages of C, in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 particular Visual C++ and other PC compilers written for the Microsoft
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 Win32 API.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 In Emacs Lisp, local variables are @dfn{dynamically scoped}. This means
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 that if you declare a local variable in a particular function, and then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 call another function, that subfunction can ``see'' the local variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 you declared. This is actually considered a bug in Emacs Lisp and in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 all other early dialects of Lisp, and was corrected in Common Lisp. (In
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 Common Lisp, you can still declare dynamically scoped variables if you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886 want to -- they are sometimes useful -- but variables by default are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 @dfn{lexically scoped} as in C.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 @end enumerate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 For those familiar with Lisp, Emacs Lisp is modelled after MacLisp, an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 early dialect of Lisp developed at MIT (no relation to the Macintosh
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 computer). There is a Common Lisp compatibility package available for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 Emacs that provides many of the features of Common Lisp.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 The Java language is derived in many ways from C, and shares a similar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 syntax, but has the following features in common with Lisp (and different
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 from C):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 @enumerate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 Java is a safe language, like Lisp.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903 Java provides garbage collection, like Lisp.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905 Java has built-in facilities for handling errors and exceptions, like
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 Lisp.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908 Java has a type system that combines the best advantages of both static
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909 and dynamic typing. Objects (except very simple types) are explicitly
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910 marked with their type, as in dynamic typing; but there is a hierarchy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911 of types and functions are declared to accept only certain types, thus
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912 providing the increased compile-time error-checking of static typing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913 @end enumerate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 @node XEmacs From the Perspective of Building, XEmacs From the Inside, The Lisp Language, Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916 @chapter XEmacs From the Perspective of Building
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918 The heart of XEmacs is the Lisp environment, which is written in C.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919 This is contained in the @file{src/} subdirectory. Underneath
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920 @file{src/} are two subdirectories of header files: @file{s/} (header
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921 files for particular operating systems) and @file{m/} (header files for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922 particular machine types). In practice the distinction between the two
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923 types of header files is blurred. These header files define or undefine
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924 certain preprocessor constants and macros to indicate particular
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925 characteristics of the associated machine or operating system. As part
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926 of the configure process, one @file{s/} file and one @file{m/} file is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 identified for the particular environment in which XEmacs is being
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928 built.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 XEmacs also contains a great deal of Lisp code. This implements the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 operations that make XEmacs useful as an editor as well as just a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932 Lisp environment, and also contains many add-on packages that allow
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933 XEmacs to browse directories, act as a mail and Usenet news reader,
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
934 compile Lisp code, etc. There is actually more Lisp code than
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935 C code associated with XEmacs, but much of the Lisp code is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936 peripheral to the actual operation of the editor. The Lisp code
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937 all lies in subdirectories underneath the @file{lisp/} directory.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939 The @file{lwlib/} directory contains C code that implements a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940 generalized interface onto different X widget toolkits and also
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941 implements some widgets of its own that behave like Motif widgets but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942 are faster, free, and in some cases more powerful. The code in this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943 directory compiles into a library and is mostly independent from XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945 The @file{etc/} directory contains various data files associated with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946 XEmacs. Some of them are actually read by XEmacs at startup; others
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 merely contain useful information of various sorts.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 The @file{lib-src/} directory contains C code for various auxiliary
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950 programs that are used in connection with XEmacs. Some of them are used
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951 during the build process; others are used to perform certain functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952 that cannot conveniently be placed in the XEmacs executable (e.g. the
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
953 @file{movemail} program for fetching mail out of @file{/var/spool/mail},
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
954 which must be setgid to @file{mail} on many systems; and the
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
955 @file{gnuclient} program, which allows an external script to communicate
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
956 with a running XEmacs process).
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958 The @file{man/} directory contains the sources for the XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959 documentation. It is mostly in a form called Texinfo, which can be
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
960 converted into either a printed document (by passing it through @TeX{})
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
961 or into on-line documentation called @dfn{info files}.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963 The @file{info/} directory contains the results of formatting the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964 XEmacs documentation as @dfn{info files}, for on-line use. These files
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965 are used when you enter the Info system using @kbd{C-h i} or through the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966 Help menu.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968 The @file{dynodump/} directory contains auxiliary code used to build
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969 XEmacs on Solaris platforms.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971 The other directories contain various miscellaneous code and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972 information that is not normally used or needed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974 The first step of building involves running the @file{configure}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975 program and passing it various parameters to specify any optional
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976 features you want and compiler arguments and such, as described in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977 @file{INSTALL} file. This determines what the build environment is,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978 chooses the appropriate @file{s/} and @file{m/} file, and runs a series
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979 of tests to determine many details about your environment, such as which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980 library functions are available and exactly how they work. (The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981 @file{s/} and @file{m/} files only contain information that cannot be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
982 conveniently detected in this fashion.) The reason for running these
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
983 tests is that it allows XEmacs to be compiled on a much wider variety of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
984 platforms than those that the XEmacs developers happen to be familiar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
985 with, including various sorts of hybrid platforms. This is especially
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
986 important now that many operating systems give you a great deal of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
987 control over exactly what features you want installed, and allow for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
988 easy upgrading of parts of a system without upgrading the rest. It
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
989 would be impossible to pre-determine and pre-specify the information for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
990 all possible configurations.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
991
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
992 When configure is done running, it generates @file{Makefile}s and the
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 265
diff changeset
993 file @file{src/config.h} (which describes the features of your system)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 265
diff changeset
994 from template files. You then run @file{make}, which compiles the
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 265
diff changeset
995 auxiliary code and programs in @file{lib-src/} and @file{lwlib/} and the
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 265
diff changeset
996 main XEmacs executable in @file{src/}. The result of compiling and
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 265
diff changeset
997 linking is an executable called @file{temacs}, which is @emph{not} the
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 265
diff changeset
998 final XEmacs executable. @file{temacs} by itself is not intended to
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 265
diff changeset
999 function as an editor or even display any windows on the screen, and if
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 265
diff changeset
1000 you simply run it, it will exit immediately. The @file{Makefile} runs
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 265
diff changeset
1001 @file{temacs} with certain options that cause it to initialize itself,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 265
diff changeset
1002 read in a number of basic Lisp files, and then dump itself out into a
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 265
diff changeset
1003 new executable called @file{xemacs}. This new executable has been
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 265
diff changeset
1004 pre-initialized and contains pre-digested Lisp code that is necessary
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 265
diff changeset
1005 for the editor to function (this includes most basic Lisp functions,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 265
diff changeset
1006 e.g. @code{not}, that can be defined in terms of other Lisp primitives;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 265
diff changeset
1007 some initialization code that is called when certain objects, such as
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 265
diff changeset
1008 frames, are created; and all of the standard keybindings and code for
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 265
diff changeset
1009 the actions they result in). This executable, @file{xemacs}, is the
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 265
diff changeset
1010 executable that you run to use the XEmacs editor.
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 265
diff changeset
1011
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 265
diff changeset
1012 Although @file{temacs} is not intended to be run as an editor, it can,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 265
diff changeset
1013 by using the incantation @code{temacs -batch -l loadup.el run-temacs}.
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 265
diff changeset
1014 This is useful when the dumping procedure described above is broken, or
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 265
diff changeset
1015 when using certain program debugging tools such as Purify. These tools
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 265
diff changeset
1016 get mighty confused by the tricks played by the XEmacs build process,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 265
diff changeset
1017 such as allocation memory in one process, and freeing it in the next.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1018
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1019 @node XEmacs From the Inside, The XEmacs Object System (Abstractly Speaking), XEmacs From the Perspective of Building, Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1020 @chapter XEmacs From the Inside
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1021
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022 Internally, XEmacs is quite complex, and can be very confusing. To
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1023 simplify things, it can be useful to think of XEmacs as containing an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1024 event loop that ``drives'' everything, and a number of other subsystems,
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
1025 such as a Lisp engine and a redisplay mechanism. Each of these other
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1026 subsystems exists simultaneously in XEmacs, and each has a certain
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1027 state. The flow of control continually passes in and out of these
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1028 different subsystems in the course of normal operation of the editor.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1029
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1030 It is important to keep in mind that, most of the time, the editor is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031 ``driven'' by the event loop. Except during initialization and batch
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1032 mode, all subsystems are entered directly or indirectly through the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1033 event loop, and ultimately, control exits out of all subsystems back up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1034 to the event loop. This cycle of entering a subsystem, exiting back out
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1035 to the event loop, and starting another iteration of the event loop
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1036 occurs once each keystroke, mouse motion, etc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1037
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1038 If you're trying to understand a particular subsystem (other than the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1039 event loop), think of it as a ``daemon'' process or ``servant'' that is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1040 responsible for one particular aspect of a larger system, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1041 periodically receives commands or environment changes that cause it to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1042 do something. Ultimately, these commands and environment changes are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1043 always triggered by the event loop. For example:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1044
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1045 @itemize @bullet
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1046 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1047 The window and frame mechanism is responsible for keeping track of what
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1048 windows and frames exist, what buffers are in them, etc. It is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1049 periodically given commands (usually from the user) to make a change to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1050 the current window/frame state: i.e. create a new frame, delete a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1051 window, etc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1052
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1053 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1054 The buffer mechanism is responsible for keeping track of what buffers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1055 exist and what text is in them. It is periodically given commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1056 (usually from the user) to insert or delete text, create a buffer, etc.
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
1057 When it receives a text-change command, it notifies the redisplay
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
1058 mechanism.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1059
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1060 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1061 The redisplay mechanism is responsible for making sure that windows and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1062 frames are displayed correctly. It is periodically told (by the event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1063 loop) to actually ``do its job'', i.e. snoop around and see what the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1064 current state of the environment (mostly of the currently-existing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1065 windows, frames, and buffers) is, and make sure that that state matches
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1066 what's actually displayed. It keeps lots and lots of information around
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1067 (such as what is actually being displayed currently, and what the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1068 environment was last time it checked) so that it can minimize the work
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1069 it has to do. It is also helped along in that whenever a relevant
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1070 change to the environment occurs, the redisplay mechanism is told about
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1071 this, so it has a pretty good idea of where it has to look to find
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1072 possible changes and doesn't have to look everywhere.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1073
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1074 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1075 The Lisp engine is responsible for executing the Lisp code in which most
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1076 user commands are written. It is entered through a call to @code{eval}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1077 or @code{funcall}, which occurs as a result of dispatching an event from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1078 the event loop. The functions it calls issue commands to the buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1079 mechanism, the window/frame subsystem, etc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1080
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1081 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1082 The Lisp allocation subsystem is responsible for keeping track of Lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1083 objects. It is given commands from the Lisp engine to allocate objects,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1084 garbage collect, etc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1085 @end itemize
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1086
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1087 etc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1088
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1089 The important idea here is that there are a number of independent
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1090 subsystems each with its own responsibility and persistent state, just
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1091 like different employees in a company, and each subsystem is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1092 periodically given commands from other subsystems. Commands can flow
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1093 from any one subsystem to any other, but there is usually some sort of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1094 hierarchy, with all commands originating from the event subsystem.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1095
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1096 XEmacs is entered in @code{main()}, which is in @file{emacs.c}. When
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1097 this is called the first time (in a properly-invoked @file{temacs}), it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1098 does the following:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1099
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1100 @enumerate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1101 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1102 It does some very basic environment initializations, such as determining
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1103 where it and its directories (e.g. @file{lisp/} and @file{etc/}) reside
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1104 and setting up signal handlers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1105 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1106 It initializes the entire Lisp interpreter.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1107 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1108 It sets the initial values of many built-in variables (including many
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1109 variables that are visible to Lisp programs), such as the global keymap
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1110 object and the built-in faces (a face is an object that describes the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1111 display characteristics of text). This involves creating Lisp objects
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1112 and thus is dependent on step (2).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1113 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1114 It performs various other initializations that are relevant to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1115 particular environment it is running in, such as retrieving environment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1116 variables, determining the current date and the user who is running the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1117 program, examining its standard input, creating any necessary file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1118 descriptors, etc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1119 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1120 At this point, the C initialization is complete. A Lisp program that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1121 was specified on the command line (usually @file{loadup.el}) is called
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1122 (temacs is normally invoked as @code{temacs -batch -l loadup.el dump}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1123 @file{loadup.el} loads all of the other Lisp files that are needed for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1124 the operation of the editor, calls the @code{dump-emacs} function to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1125 write out @file{xemacs}, and then kills the temacs process.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1126 @end enumerate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1127
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1128 When @file{xemacs} is then run, it only redoes steps (1) and (4)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1129 above; all variables already contain the values they were set to when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1130 the executable was dumped, and all memory that was allocated with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1131 @code{malloc()} is still around. (XEmacs knows whether it is being run
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1132 as @file{xemacs} or @file{temacs} because it sets the global variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1133 @code{initialized} to 1 after step (4) above.) At this point,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1134 @file{xemacs} calls a Lisp function to do any further initialization,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1135 which includes parsing the command-line (the C code can only do limited
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1136 command-line parsing, which includes looking for the @samp{-batch} and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1137 @samp{-l} flags and a few other flags that it needs to know about before
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1138 initialization is complete), creating the first frame (or @dfn{window}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1139 in standard window-system parlance), running the user's init file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1140 (usually the file @file{.emacs} in the user's home directory), etc. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1141 function to do this is usually called @code{normal-top-level};
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1142 @file{loadup.el} tells the C code about this function by setting its
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1143 name as the value of the Lisp variable @code{top-level}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1144
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1145 When the Lisp initialization code is done, the C code enters the event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1146 loop, and stays there for the duration of the XEmacs process. The code
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1147 for the event loop is contained in @file{keyboard.c}, and is called
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1148 @code{Fcommand_loop_1()}. Note that this event loop could very well be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1149 written in Lisp, and in fact a Lisp version exists; but apparently,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1150 doing this makes XEmacs run noticeably slower.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1151
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1152 Notice how much of the initialization is done in Lisp, not in C.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1153 In general, XEmacs tries to move as much code as is possible
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1154 into Lisp. Code that remains in C is code that implements the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1155 Lisp interpreter itself, or code that needs to be very fast, or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1156 code that needs to do system calls or other such stuff that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1157 needs to be done in C, or code that needs to have access to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1158 ``forbidden'' structures. (One conscious aspect of the design of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1159 Lisp under XEmacs is a clean separation between the external
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1160 interface to a Lisp object's functionality and its internal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1161 implementation. Part of this design is that Lisp programs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1162 are forbidden from accessing the contents of the object other
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1163 than through using a standard API. In this respect, XEmacs Lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1164 is similar to modern Lisp dialects but differs from GNU Emacs,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1165 which tends to expose the implementation and allow Lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1166 programs to look at it directly. The major advantage of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1167 hiding the implementation is that it allows the implementation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1168 to be redesigned without affecting any Lisp programs, including
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1169 those that might want to be ``clever'' by looking directly at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1170 the object's contents and possibly manipulating them.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1171
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1172 Moving code into Lisp makes the code easier to debug and maintain and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1173 makes it much easier for people who are not XEmacs developers to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1174 customize XEmacs, because they can make a change with much less chance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1175 of obscure and unwanted interactions occurring than if they were to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1176 change the C code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1177
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1178 @node The XEmacs Object System (Abstractly Speaking), How Lisp Objects Are Represented in C, XEmacs From the Inside, Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1179 @chapter The XEmacs Object System (Abstractly Speaking)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1180
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1181 At the heart of the Lisp interpreter is its management of objects.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1182 XEmacs Lisp contains many built-in objects, some of which are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1183 simple and others of which can be very complex; and some of which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1184 are very common, and others of which are rarely used or are only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1185 used internally. (Since the Lisp allocation system, with its
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1186 automatic reclamation of unused storage, is so much more convenient
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1187 than @code{malloc()} and @code{free()}, the C code makes extensive use of it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1188 in its internal operations.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1189
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1190 The basic Lisp objects are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1191
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1192 @table @code
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1193 @item integer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1194 28 bits of precision, or 60 bits on 64-bit machines; the reason for this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1195 is described below when the internal Lisp object representation is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1196 described.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1197 @item float
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1198 Same precision as a double in C.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1199 @item cons
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1200 A simple container for two Lisp objects, used to implement lists and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1201 most other data structures in Lisp.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1202 @item char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1203 An object representing a single character of text; chars behave like
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1204 integers in many ways but are logically considered text rather than
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1205 numbers and have a different read syntax. (the read syntax for a char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1206 contains the char itself or some textual encoding of it -- for example,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1207 a Japanese Kanji character might be encoded as @samp{^[$(B#&^[(B} using the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1208 ISO-2022 encoding standard -- rather than the numerical representation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1209 of the char; this way, if the mapping between chars and integers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1210 changes, which is quite possible for Kanji characters and other extended
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1211 characters, the same character will still be created. Note that some
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1212 primitives confuse chars and integers. The worst culprit is @code{eq},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1213 which makes a special exception and considers a char to be @code{eq} to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1214 its integer equivalent, even though in no other case are objects of two
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1215 different types @code{eq}. The reason for this monstrosity is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1216 compatibility with existing code; the separation of char from integer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1217 came fairly recently.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1218 @item symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1219 An object that contains Lisp objects and is referred to by name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1220 symbols are used to implement variables and named functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1221 and to provide the equivalent of preprocessor constants in C.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1222 @item vector
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1223 A one-dimensional array of Lisp objects providing constant-time access
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1224 to any of the objects; access to an arbitrary object in a vector is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1225 faster than for lists, but the operations that can be done on a vector
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1226 are more limited.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1227 @item string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1228 Self-explanatory; behaves much like a vector of chars
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1229 but has a different read syntax and is stored and manipulated
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1230 more compactly and efficiently.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1231 @item bit-vector
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1232 A vector of bits; similar to a string in spirit.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1233 @item compiled-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1234 An object describing compiled Lisp code, known as @dfn{byte code}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1235 @item subr
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1236 An object describing a Lisp primitive.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1237 @end table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1238
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1239 @cindex closure
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1240 Note that there is no basic ``function'' type, as in more powerful
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1241 versions of Lisp (where it's called a @dfn{closure}). XEmacs Lisp does
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1242 not provide the closure semantics implemented by Common Lisp and Scheme.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1243 The guts of a function in XEmacs Lisp are represented in one of four
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1244 ways: a symbol specifying another function (when one function is an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1245 alias for another), a list containing the function's source code, a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1246 bytecode object, or a subr object. (In other words, given a symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1247 specifying the name of a function, calling @code{symbol-function} to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1248 retrieve the contents of the symbol's function cell will return one of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1249 these types of objects.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1250
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1251 XEmacs Lisp also contains numerous specialized objects used to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1252 implement the editor:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1253
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
1254 @table @code
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1255 @item buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1256 Stores text like a string, but is optimized for insertion and deletion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1257 and has certain other properties that can be set.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1258 @item frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1259 An object with various properties whose displayable representation is a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1260 @dfn{window} in window-system parlance.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1261 @item window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1262 A section of a frame that displays the contents of a buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1263 often called a @dfn{pane} in window-system parlance.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1264 @item window-configuration
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1265 An object that represents a saved configuration of windows in a frame.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1266 @item device
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1267 An object representing a screen on which frames can be displayed;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1268 equivalent to a @dfn{display} in the X Window System and a @dfn{TTY} in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1269 character mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1270 @item face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1271 An object specifying the appearance of text or graphics; it contains
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1272 characteristics such as font, foreground color, and background color.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1273 @item marker
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1274 An object that refers to a particular position in a buffer and moves
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1275 around as text is inserted and deleted to stay in the same relative
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1276 position to the text around it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1277 @item extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1278 Similar to a marker but covers a range of text in a buffer; can also
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1279 specify properties of the text, such as a face in which the text is to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1280 be displayed, whether the text is invisible or unmodifiable, etc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1281 @item event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1282 Generated by calling @code{next-event} and contains information
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1283 describing a particular event happening in the system, such as the user
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1284 pressing a key or a process terminating.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1285 @item keymap
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1286 An object that maps from events (described using lists, vectors, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1287 symbols rather than with an event object because the mapping is for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1288 classes of events, rather than individual events) to functions to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1289 execute or other events to recursively look up; the functions are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1290 described by name, using a symbol, or using lists to specify the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1291 function's code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1292 @item glyph
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1293 An object that describes the appearance of an image (e.g. pixmap) on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1294 the screen; glyphs can be attached to the beginning or end of extents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1295 and in some future version of XEmacs will be able to be inserted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1296 directly into a buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1297 @item process
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1298 An object that describes a connection to an externally-running process.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1299 @end table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1300
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1301 There are some other, less-commonly-encountered general objects:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1302
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
1303 @table @code
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1304 @item hashtable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1305 An object that maps from an arbitrary Lisp object to another arbitrary
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1306 Lisp object, using hashing for fast lookup.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1307 @item obarray
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1308 A limited form of hashtable that maps from strings to symbols; obarrays
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1309 are used to look up a symbol given its name and are not actually their
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1310 own object type but are kludgily represented using vectors with hidden
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1311 fields (this representation derives from GNU Emacs).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1312 @item specifier
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1313 A complex object used to specify the value of a display property; a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1314 default value is given and different values can be specified for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1315 particular frames, buffers, windows, devices, or classes of device.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1316 @item char-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1317 An object that maps from chars or classes of chars to arbitrary Lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1318 objects; internally char tables use a complex nested-vector
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1319 representation that is optimized to the way characters are represented
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1320 as integers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1321 @item range-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1322 An object that maps from ranges of integers to arbitrary Lisp objects.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1323 @end table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1324
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1325 And some strange special-purpose objects:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1326
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
1327 @table @code
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1328 @item charset
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1329 @itemx coding-system
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1330 Objects used when MULE, or multi-lingual/Asian-language, support is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1331 enabled.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1332 @item color-instance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1333 @itemx font-instance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1334 @itemx image-instance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1335 An object that encapsulates a window-system resource; instances are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1336 mostly used internally but are exposed on the Lisp level for cleanness
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1337 of the specifier model and because it's occasionally useful for Lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1338 program to create or query the properties of instances.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1339 @item subwindow
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1340 An object that encapsulate a @dfn{subwindow} resource, i.e. a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1341 window-system child window that is drawn into by an external process;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1342 this object should be integrated into the glyph system but isn't yet,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1343 and may change form when this is done.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1344 @item tooltalk-message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1345 @itemx tooltalk-pattern
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1346 Objects that represent resources used in the ToolTalk interprocess
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1347 communication protocol.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1348 @item toolbar-button
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1349 An object used in conjunction with the toolbar.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1350 @item x-resource
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1351 An object that encapsulates certain miscellaneous resources in the X
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1352 window system, used only when Epoch support is enabled.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1353 @end table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1354
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1355 And objects that are only used internally:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1356
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1357 @table @asis
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1358 @item opaque
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1359 A generic object for encapsulating arbitrary memory; this allows you the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1360 generality of @code{malloc()} and the convenience of the Lisp object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1361 system.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1362 @item lstream
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1363 A buffering I/O stream, used to provide a unified interface to anything
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1364 that can accept output or provide input, such as a file descriptor, a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1365 stdio stream, a chunk of memory, a Lisp buffer, a Lisp string, etc.;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1366 it's a Lisp object to make its memory management more convenient.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1367 @item char-table-entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1368 Subsidiary objects in the internal char-table representation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1369 @item extent-auxiliary
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1370 @itemx menubar-data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1371 @itemx toolbar-data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1372 Various special-purpose objects that are basically just used to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1373 encapsulate memory for particular subsystems, similar to the more
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1374 general ``opaque'' object.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1375 @item symbol-value-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1376 @itemx symbol-value-buffer-local
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1377 @itemx symbol-value-varalias
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1378 @itemx symbol-value-lisp-magic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1379 Special internal-only objects that are placed in the value cell of a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1380 symbol to indicate that there is something special with this variable --
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1381 e.g. it has no value, it mirrors another variable, or it mirrors some C
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1382 variable; there is really only one kind of object, called a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1383 @dfn{symbol-value-magic}, but it is sort-of halfway kludged into
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1384 semi-different object types.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1385 @end table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1386
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1387 @cindex permanent objects
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1388 @cindex temporary objects
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1389 Some types of objects are @dfn{permanent}, meaning that once created,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1390 they do not disappear until explicitly destroyed, using a function such
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1391 as @code{delete-buffer}, @code{delete-window}, @code{delete-frame}, etc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1392 Others will disappear once they are not longer used, through the garbage
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1393 collection mechanism. Buffers, frames, windows, devices, and processes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1394 are among the objects that are permanent. Note that some objects can go
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1395 both ways: Faces can be created either way; extents are normally
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1396 permanent, but detached extents (extents not referring to any text, as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1397 happens to some extents when the text they are referring to is deleted)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1398 are temporary. Note that some permanent objects, such as faces and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1399 coding systems, cannot be deleted. Note also that windows are unique in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1400 that they can be @emph{undeleted} after having previously been
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1401 deleted. (This happens as a result of restoring a window configuration.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1402
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1403 @cindex read syntax
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1404 Note that many types of objects have a @dfn{read syntax}, i.e. a way of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1405 specifying an object of that type in Lisp code. When you load a Lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1406 file, or type in code to be evaluated, what really happens is that the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1407 function @code{read} is called, which reads some text and creates an object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1408 based on the syntax of that text; then @code{eval} is called, which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1409 possibly does something special; then this loop repeats until there's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1410 no more text to read. (@code{eval} only actually does something special
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1411 with symbols, which causes the symbol's value to be returned,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1412 similar to referencing a variable; and with conses [i.e. lists],
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1413 which cause a function invocation. All other values are returned
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1414 unchanged.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1415
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1416 The read syntax
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1417
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1418 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1419 17297
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1420 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1421
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1422 converts to an integer whose value is 17297.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1423
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1424 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1425 1.983e-4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1426 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1427
347
7c94d56991e1 Import from CVS: tag r21-1-3
cvs
parents: 343
diff changeset
1428 converts to a float whose value is 1.983e-4, or .0001983.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1429
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1430 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1431 ?b
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1432 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1433
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1434 converts to a char that represents the lowercase letter b.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1435
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1436 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1437 ?^[$(B#&^[(B
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1438 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1439
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1440 (where @samp{^[} actually is an @samp{ESC} character) converts to a
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
1441 particular Kanji character when using an ISO2022-based coding system for
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
1442 input. (To decode this gook: @samp{ESC} begins an escape sequence;
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
1443 @samp{ESC $ (} is a class of escape sequences meaning ``switch to a
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
1444 94x94 character set''; @samp{ESC $ ( B} means ``switch to Japanese
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
1445 Kanji''; @samp{#} and @samp{&} collectively index into a 94-by-94 array
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
1446 of characters [subtract 33 from the ASCII value of each character to get
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
1447 the corresponding index]; @samp{ESC (} is a class of escape sequences
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
1448 meaning ``switch to a 94 character set''; @samp{ESC (B} means ``switch
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
1449 to US ASCII''. It is a coincidence that the letter @samp{B} is used to
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
1450 denote both Japanese Kanji and US ASCII. If the first @samp{B} were
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
1451 replaced with an @samp{A}, you'd be requesting a Chinese Hanzi character
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
1452 from the GB2312 character set.)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1453
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1454 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1455 "foobar"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1456 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1457
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1458 converts to a string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1459
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1460 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1461 foobar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1462 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1463
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1464 converts to a symbol whose name is @code{"foobar"}. This is done by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1465 looking up the string equivalent in the global variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1466 @code{obarray}, whose contents should be an obarray. If no symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1467 is found, a new symbol with the name @code{"foobar"} is automatically
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 265
diff changeset
1468 created and added to @code{obarray}; this process is called
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 265
diff changeset
1469 @dfn{interning} the symbol.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1470 @cindex interning
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1471
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1472 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1473 (foo . bar)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1474 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1475
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1476 converts to a cons cell containing the symbols @code{foo} and @code{bar}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1477
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1478 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1479 (1 a 2.5)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1480 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1481
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1482 converts to a three-element list containing the specified objects
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1483 (note that a list is actually a set of nested conses; see the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1484 XEmacs Lisp Reference).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1485
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1486 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1487 [1 a 2.5]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1488 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1489
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1490 converts to a three-element vector containing the specified objects.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1491
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1492 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1493 #[... ... ... ...]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1494 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1495
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1496 converts to a compiled-function object (the actual contents are not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1497 shown since they are not relevant here; look at a file that ends with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1498 @file{.elc} for examples).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1499
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1500 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1501 #*01110110
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1502 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1503
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1504 converts to a bit-vector.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1505
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1506 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1507 #s(range-table ... ...)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1508 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1509
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1510 converts to a range table (the actual contents are not shown).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1511
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1512 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1513 #s(char-table ... ...)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1514 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1515
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1516 converts to a char table (the actual contents are not shown).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1517 (Note that the #s syntax is the general syntax for structures,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1518 which are not really implemented in XEmacs Lisp but should be.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1519
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1520 When an object is printed out (using @code{print} or a related
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1521 function), the read syntax is used, so that the same object can be read
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1522 in again.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1523
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1524 The other objects do not have read syntaxes, usually because it does
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1525 not really make sense to create them in this fashion (i.e. processes,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1526 where it doesn't make sense to have a subprocess created as a side
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1527 effect of reading some Lisp code), or because they can't be created at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1528 all (e.g. subrs). Permanent objects, as a rule, do not have a read
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1529 syntax; nor do most complex objects, which contain too much state to be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1530 easily initialized through a read syntax.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1531
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1532 @node How Lisp Objects Are Represented in C, Rules When Writing New C Code, The XEmacs Object System (Abstractly Speaking), Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1533 @chapter How Lisp Objects Are Represented in C
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1534
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1535 Lisp objects are represented in C using a 32- or 64-bit machine word
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1536 (depending on the processor; i.e. DEC Alphas use 64-bit Lisp objects and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1537 most other processors use 32-bit Lisp objects). The representation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1538 stuffs a pointer together with a tag, as follows:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1539
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1540 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1541 [ 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 ]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1542 [ 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 ]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1543
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1544 ^ <---> <------------------------------------------------------>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1545 | tag a pointer to a structure, or an integer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1546 |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1547 `---> mark bit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1548 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1549
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1550 The tag describes the type of the Lisp object. For integers and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1551 chars, the lower 28 bits contain the value of the integer or char; for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1552 all others, the lower 28 bits contain a pointer. The mark bit is used
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1553 during garbage-collection, and is always 0 when garbage collection is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1554 not happening. Many macros that extract out parts of a Lisp object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1555 expect that the mark bit is 0, and will produce incorrect results if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1556 it's not. (The way that garbage collection works, basically, is that it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1557 loops over all places where Lisp objects could exist -- this includes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1558 all global variables in C that contain Lisp objects [including
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1559 @code{Vobarray}, the C equivalent of @code{obarray}; through this, all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1560 Lisp variables will get marked], plus various other places -- and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1561 recursively scans through the Lisp objects, marking each object it finds
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1562 by setting the mark bit. Then it goes through the lists of all objects
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1563 allocated, freeing the ones that are not marked and turning off the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1564 mark bit of the ones that are marked.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1565
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1566 Lisp objects use the typedef @code{Lisp_Object}, but the actual C type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1567 used for the Lisp object can vary. It can be either a simple type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1568 (@code{long} on the DEC Alpha, @code{int} on other machines) or a
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 265
diff changeset
1569 structure whose fields are bit fields that line up properly (actually, a
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 265
diff changeset
1570 union of structures that's used). Generally the simple integral type is
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 265
diff changeset
1571 preferable because it ensures that the compiler will actually use a
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 265
diff changeset
1572 machine word to represent the object (some compilers will use more
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1573 general and less efficient code for unions and structs even if they can
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1574 fit in a machine word). The union type, however, has the advantage of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1575 stricter type checking (if you accidentally pass an integer where a Lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1576 object is desired, you get a compile error), and it makes it easier to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1577 decode Lisp objects when debugging. The choice of which type to use is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1578 determined by the presence or absence of the preprocessor constant
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 265
diff changeset
1579 @code{USE_UNION_TYPE}.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1580
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1581 @cindex record type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1582 Note that there are only eight types that the tag can represent,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1583 but many more actual types than this. This is handled by having
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
1584 one of the tag types specify a meta-type called a @dfn{record};
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1585 for all such objects, the first four bytes of the pointed-to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1586 structure indicate what the actual type is.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1587
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1588 Note also that having 28 bits for pointers and integers restricts a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1589 lot of things to 256 megabytes of memory. (Basically, enough pointers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1590 and indices and whatnot get stuffed into Lisp objects that the total
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1591 amount of memory used by XEmacs can't grow above 256 megabytes. In
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1592 older versions of XEmacs and GNU Emacs, the tag was 5 bits wide,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1593 allowing for 32 types, which was more than the actual number of types
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1594 that existed at the time, and no ``record'' type was necessary.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1595 However, this limited the editor to 64 megabytes total, which some users
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1596 who edited large files might conceivably exceed.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1597
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1598 Also, note that there is an implicit assumption here that all pointers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1599 are low enough that the top bits are all zero and can just be chopped
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1600 off. On standard machines that allocate memory from the bottom up (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1601 give each process its own address space), this works fine. Some
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1602 machines, however, put the data space somewhere else in memory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1603 (e.g. beginning at 0x80000000). Those machines cope by defining
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1604 @code{DATA_SEG_BITS} in the corresponding @file{m/} or @file{s/} file to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1605 the proper mask. Then, pointers retrieved from Lisp objects are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1606 automatically OR'ed with this value prior to being used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1607
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
1608 A corollary of the previous paragraph is that @strong{(pointers to)
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
1609 stack-allocated structures cannot be put into Lisp objects}. The stack
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
1610 is generally located near the top of memory; if you put such a pointer
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
1611 into a Lisp object, it will get its top bits chopped off, and you will
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
1612 lose.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1613
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1614 Various macros are used to construct Lisp objects and extract the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1615 components. Macros of the form @code{XINT()}, @code{XCHAR()},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1616 @code{XSTRING()}, @code{XSYMBOL()}, etc. mask out the pointer/integer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1617 field and cast it to the appropriate type. All of the macros that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1618 construct pointers will @code{OR} with @code{DATA_SEG_BITS} if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1619 necessary. @code{XINT()} needs to be a bit tricky so that negative
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1620 numbers are properly sign-extended: Usually it does this by shifting the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1621 number four bits to the left and then four bits to the right. This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1622 assumes that the right-shift operator does an arithmetic shift (i.e. it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1623 leaves the most-significant bit as-is rather than shifting in a zero, so
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1624 that it mimics a divide-by-two even for negative numbers). Not all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1625 machines/compilers do this, and on the ones that don't, a more
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1626 complicated definition is selected by defining
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1627 @code{EXPLICIT_SIGN_EXTEND}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1628
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1629 Note that when @code{ERROR_CHECK_TYPECHECK} is defined, the extractor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1630 macros become more complicated -- they check the tag bits and/or the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1631 type field in the first four bytes of a record type to ensure that the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1632 object is really of the correct type. This is great for catching places
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1633 where an incorrect type is being dereferenced -- this typically results
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1634 in a pointer being dereferenced as the wrong type of structure, with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1635 unpredictable (and sometimes not easily traceable) results.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1636
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
1637 There are similar @code{XSET@var{TYPE}()} macros that construct a Lisp object.
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
1638 These macros are of the form @code{XSET@var{TYPE} (@var{lvalue}, @var{result})},
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1639 i.e. they have to be a statement rather than just used in an expression.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1640 The reason for this is that standard C doesn't let you ``construct'' a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1641 structure (but GCC does). Granted, this sometimes isn't too convenient;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1642 for the case of integers, at least, you can use the function
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 265
diff changeset
1643 @code{make_int()}, which constructs and @emph{returns} an integer
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
1644 Lisp object. Note that the @code{XSET@var{TYPE}()} macros are also
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
1645 affected by @code{ERROR_CHECK_TYPECHECK} and make sure that the
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
1646 structure is of the right type in the case of record types, where the
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
1647 type is contained in the structure.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1648
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1649 @node Rules When Writing New C Code, A Summary of the Various XEmacs Modules, How Lisp Objects Are Represented in C, Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1650 @chapter Rules When Writing New C Code
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1651
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1652 The XEmacs C Code is extremely complex and intricate, and there are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1653 many rules that are more or less consistently followed throughout the code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1654 Many of these rules are not obvious, so they are explained here. It is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1655 of the utmost importance that you follow them. If you don't, you may get
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1656 something that appears to work, but which will crash in odd situations,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1657 often in code far away from where the actual breakage is.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1658
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1659 @menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1660 * General Coding Rules::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1661 * Writing Lisp Primitives::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1662 * Adding Global Lisp Variables::
318
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
1663 * Coding for Mule::
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1664 * Techniques for XEmacs Developers::
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1665 @end menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1666
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1667 @node General Coding Rules
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1668 @section General Coding Rules
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1669
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1670 Almost every module contains a @code{syms_of_*()} function and a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1671 @code{vars_of_*()} function. The former declares any Lisp primitives
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1672 you have defined and defines any symbols you will be using. The latter
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1673 declares any global Lisp variables you have added and initializes global
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1674 C variables in the module. For each such function, declare it in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1675 @file{symsinit.h} and make sure it's called in the appropriate place in
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
1676 @file{emacs.c}. @strong{Important}: There are stringent requirements on
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1677 exactly what can go into these functions. See the comment in
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
1678 @file{emacs.c}. The reason for this is to avoid obscure unwanted
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1679 interactions during initialization. If you don't follow these rules,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1680 you'll be sorry! If you want to do anything that isn't allowed, create
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1681 a @code{complex_vars_of_*()} function for it. Doing this is tricky,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1682 though: You have to make sure your function is called at the right time
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1683 so that all the initialization dependencies work out.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1684
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1685 Every module includes @file{<config.h>} (angle brackets so that
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
1686 @samp{--srcdir} works correctly; @file{config.h} may or may not be in
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
1687 the same directory as the C sources) and @file{lisp.h}. @file{config.h}
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1688 should always be included before any other header files (including
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1689 system header files) to ensure that certain tricks played by various
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1690 @file{s/} and @file{m/} files work out correctly.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1691
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1692 @strong{All global and static variables that are to be modifiable must
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1693 be declared uninitialized.} This means that you may not use the ``declare
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1694 with initializer'' form for these variables, such as @code{int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1695 some_variable = 0;}. The reason for this has to do with some kludges
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1696 done during the dumping process: If possible, the initialized data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1697 segment is re-mapped so that it becomes part of the (unmodifiable) code
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1698 segment in the dumped executable. This allows this memory to be shared
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1699 among multiple running XEmacs processes. XEmacs is careful to place as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1700 much constant data as possible into initialized variables (in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1701 particular, into what's called the @dfn{pure space} -- see below) during
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1702 the @file{temacs} phase.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1703
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1704 @cindex copy-on-write
298
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 282
diff changeset
1705 @strong{Please note:} This kludge only works on a few systems
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 282
diff changeset
1706 nowadays, and is rapidly becoming irrelevant because most modern
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 282
diff changeset
1707 operating systems provide @dfn{copy-on-write} semantics. All data is
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 282
diff changeset
1708 initially shared between processes, and a private copy is automatically
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 282
diff changeset
1709 made (on a page-by-page basis) when a process first attempts to write to
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 282
diff changeset
1710 a page of memory.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1711
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1712 Formerly, there was a requirement that static variables not be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1713 declared inside of functions. This had to do with another hack along
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1714 the same vein as what was just described: old USG systems put
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1715 statically-declared variables in the initialized data space, so those
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1716 header files had a @code{#define static} declaration. (That way, the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1717 data-segment remapping described above could still work.) This fails
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1718 badly on static variables inside of functions, which suddenly become
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1719 automatic variables; therefore, you weren't supposed to have any of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1720 them. This awful kludge has been removed in XEmacs because
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1721
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1722 @enumerate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1723 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1724 almost all of the systems that used this kludge ended up having
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1725 to disable the data-segment remapping anyway;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1726 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1727 the only systems that didn't were extremely outdated ones;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1728 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1729 this hack completely messed up inline functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1730 @end enumerate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1731
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1732 @node Writing Lisp Primitives
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1733 @section Writing Lisp Primitives
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1734
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1735 Lisp primitives are Lisp functions implemented in C. The details of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1736 interfacing the C function so that Lisp can call it are handled by a few
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1737 C macros. The only way to really understand how to write new C code is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1738 to read the source, but we can explain some things here.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1739
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1740 An example of a special form is the definition of @code{or}, from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1741 @file{eval.c}. (An ordinary function would have the same general
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1742 appearance.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1743
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1744 @cindex garbage collection protection
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1745 @smallexample
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1746 @group
44
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
1747 DEFUN ("or", For, 0, UNEVALLED, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1748 Eval args until one of them yields non-nil, then return that value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1749 The remaining args are not evalled at all.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1750 If all args return nil, return nil.
44
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
1751 */
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
1752 (args))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1753 @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1754 /* This function can GC */
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents: 259
diff changeset
1755 Lisp_Object val = Qnil;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1756 struct gcpro gcpro1;
44
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
1757
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents: 259
diff changeset
1758 GCPRO1 (args);
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents: 259
diff changeset
1759
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents: 259
diff changeset
1760 while (!NILP (args))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1761 @{
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents: 259
diff changeset
1762 val = Feval (XCAR (args));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1763 if (!NILP (val))
318
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
1764 break;
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents: 259
diff changeset
1765 args = XCDR (args);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1766 @}
44
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
1767
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1768 UNGCPRO;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1769 return val;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1770 @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1771 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1772 @end smallexample
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1773
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1774 Let's start with a precise explanation of the arguments to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1775 @code{DEFUN} macro. Here is a template for them:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1776
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1777 @example
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
1778 DEFUN (@var{lname}, @var{fname}, @var{min}, @var{max}, @var{interactive}, /*
44
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
1779 @var{docstring}
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
1780 */
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
1781 (@var{arglist}) )
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1782 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1783
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1784 @table @var
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1785 @item lname
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
1786 This string is the name of the Lisp symbol to define as the function
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
1787 name; in the example above, it is @code{"or"}.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1788
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1789 @item fname
44
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
1790 This is the C function name for this function. This is the name that is
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
1791 used in C code for calling the function. The name is, by convention,
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
1792 @samp{F} prepended to the Lisp name, with all dashes (@samp{-}) in the
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
1793 Lisp name changed to underscores. Thus, to call this function from C
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
1794 code, call @code{For}. Remember that the arguments are of type
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
1795 @code{Lisp_Object}; various macros and functions for creating values of
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
1796 type @code{Lisp_Object} are declared in the file @file{lisp.h}.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1797
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1798 Primitives whose names are special characters (e.g. @code{+} or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1799 @code{<}) are named by spelling out, in some fashion, the special
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1800 character: e.g. @code{Fplus()} or @code{Flss()}. Primitives whose names
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1801 begin with normal alphanumeric characters but also contain special
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1802 characters are spelled out in some creative way, e.g. @code{let*}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1803 becomes @code{FletX()}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1804
44
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
1805 Each function also has an associated structure that holds the data for
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1806 the subr object that represents the function in Lisp. This structure
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1807 conveys the Lisp symbol name to the initialization routine that will
44
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
1808 create the symbol and store the subr object as its definition. The C
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
1809 variable name of this structure is always @samp{S} prepended to the
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
1810 @var{fname}. You hardly ever need to be aware of the existence of this
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
1811 structure.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1812
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1813 @item min
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1814 This is the minimum number of arguments that the function requires. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1815 function @code{or} allows a minimum of zero arguments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1816
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1817 @item max
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1818 This is the maximum number of arguments that the function accepts, if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1819 there is a fixed maximum. Alternatively, it can be @code{UNEVALLED},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1820 indicating a special form that receives unevaluated arguments, or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1821 @code{MANY}, indicating an unlimited number of evaluated arguments (the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1822 equivalent of @code{&rest}). Both @code{UNEVALLED} and @code{MANY} are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1823 macros. If @var{max} is a number, it may not be less than @var{min} and
44
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
1824 it may not be greater than 8. (If you need to add a function with
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
1825 more than 8 arguments, either use the @code{MANY} form or edit the
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1826 definition of @code{DEFUN} in @file{lisp.h}. If you do the latter,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1827 make sure to also add another clause to the switch statement in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1828 @code{primitive_funcall().})
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1829
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1830 @item interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1831 This is an interactive specification, a string such as might be used as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1832 the argument of @code{interactive} in a Lisp function. In the case of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1833 @code{or}, it is 0 (a null pointer), indicating that @code{or} cannot be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1834 called interactively. A value of @code{""} indicates a function that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1835 should receive no arguments when called interactively.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1836
44
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
1837 @item docstring
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1838 This is the documentation string. It is written just like a
44
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
1839 documentation string for a function defined in Lisp; in particular, the
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
1840 first line should be a single sentence. Note how the documentation
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
1841 string is enclosed in a comment, none of the documentation is placed on
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
1842 the same lines as the comment-start and comment-end characters, and the
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
1843 comment-start characters are on the same line as the interactive
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1844 specification. @file{make-docfile}, which scans the C files for
44
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
1845 documentation strings, is very particular about what it looks for, and
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
1846 will not properly extract the doc string if it's not in this exact format.
44
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
1847
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
1848 You are free to put the various arguments to @code{DEFUN} on separate
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1849 lines to avoid overly long lines. However, make sure to put the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1850 comment-start characters for the doc string on the same line as the
44
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
1851 interactive specification, and put a newline directly after them (and
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
1852 before the comment-end characters).
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
1853
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
1854 @item arglist
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
1855 This is the comma-separated list of arguments to the C function. For a
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
1856 function with a fixed maximum number of arguments, provide a C argument
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
1857 for each Lisp argument. In this case, unlike regular C functions, the
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
1858 types of the arguments are not declared; they are simply always of type
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
1859 @code{Lisp_Object}.
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
1860
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
1861 The names of the C arguments will be used as the names of the arguments
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
1862 to the Lisp primitive as displayed in its documentation, modulo the same
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
1863 concerns described above for @code{F...} names (in particular,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1864 underscores in the C arguments become dashes in the Lisp arguments).
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 149
diff changeset
1865
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 149
diff changeset
1866 There is one additional kludge: A trailing `_' on the C argument is
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 149
diff changeset
1867 discarded when forming the Lisp argument. This allows C language
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 149
diff changeset
1868 reserved words (like @code{default}) or global symbols (like
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 149
diff changeset
1869 @code{dirname}) to be used as argument names without compiler warnings
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 149
diff changeset
1870 or errors.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1871
44
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
1872 A Lisp function with @w{@var{max} = @code{UNEVALLED}} is a
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
1873 @w{@dfn{special form}}; its arguments are not evaluated. Instead it
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
1874 receives one argument of type @code{Lisp_Object}, a (Lisp) list of the
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
1875 unevaluated arguments, conventionally named @code{(args)}.
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
1876
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
1877 When a Lisp function has no upper limit on the number of arguments,
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
1878 specify @w{@var{max} = @code{MANY}}. In this case its implementation in
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
1879 C actually receives exactly two arguments: the number of Lisp arguments
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
1880 (an @code{int}) and the address of a block containing their values (a
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
1881 @w{@code{Lisp_Object *}}). In this case only are the C types specified
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
1882 in the @var{arglist}: @w{@code{(int nargs, Lisp_Object *args)}}.
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
1883
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
1884 @end table
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1885
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1886 Within the function @code{For} itself, note the use of the macros
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1887 @code{GCPRO1} and @code{UNGCPRO}. @code{GCPRO1} is used to ``protect''
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1888 a variable from garbage collection---to inform the garbage collector
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1889 that it must look in that variable and regard its contents as an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1890 accessible object. This is necessary whenever you call @code{Feval} or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1891 anything that can directly or indirectly call @code{Feval} (this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1892 includes the @code{QUIT} macro!). At such a time, any Lisp object that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1893 you intend to refer to again must be protected somehow. @code{UNGCPRO}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1894 cancels the protection of the variables that are protected in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1895 current function. It is necessary to do this explicitly.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1896
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1897 The macro @code{GCPRO1} protects just one local variable. If you want
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1898 to protect two, use @code{GCPRO2} instead; repeating @code{GCPRO1} will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1899 not work. Macros @code{GCPRO3} and @code{GCPRO4} also exist.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1900
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1901 These macros implicitly use local variables such as @code{gcpro1}; you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1902 must declare these explicitly, with type @code{struct gcpro}. Thus, if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1903 you use @code{GCPRO2}, you must declare @code{gcpro1} and @code{gcpro2}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1904
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1905 @cindex caller-protects (@code{GCPRO} rule)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1906 Note also that the general rule is @dfn{caller-protects}; i.e. you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1907 are only responsible for protecting those Lisp objects that you create.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1908 Any objects passed to you as parameters should have been protected
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1909 by whoever created them, so you don't in general have to protect them.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1910 @code{For} is an exception; it protects its parameters to provide
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1911 extra assurance against Lisp primitives elsewhere that are incorrectly
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1912 written, and against malicious self-modifying code. There are a few
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1913 other standard functions that also do this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1914
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1915 @code{GCPRO}ing is perhaps the trickiest and most error-prone part
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1916 of XEmacs coding. It is @strong{extremely} important that you get this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1917 right and use a great deal of discipline when writing this code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1918 @xref{GCPROing, ,@code{GCPRO}ing}, for full details on how to do this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1919
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1920 What @code{DEFUN} actually does is declare a global structure of
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
1921 type @code{Lisp_Subr} whose name begins with capital @samp{SF} and
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1922 which contains information about the primitive (e.g. a pointer to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1923 function, its minimum and maximum allowed arguments, a string describing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1924 its Lisp name); @code{DEFUN} then begins a normal C function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1925 declaration using the @code{F...} name. The Lisp subr object that is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1926 the function definition of a primitive (i.e. the object in the function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1927 slot of the symbol that names the primitive) actually points to this
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
1928 @samp{SF} structure; when @code{Feval} encounters a subr, it looks in the
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1929 structure to find out how to call the C function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1930
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1931 Defining the C function is not enough to make a Lisp primitive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1932 available; you must also create the Lisp symbol for the primitive (the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1933 symbol is @dfn{interned}; @pxref{Obarrays}) and store a suitable subr
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1934 object in its function cell. (If you don't do this, the primitive won't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1935 be seen by Lisp code.) The code looks like this:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1936
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1937 @example
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
1938 DEFSUBR (@var{fname});
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1939 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1940
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
1941 @noindent
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
1942 Here @var{fname} is the name you used as the second argument to
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
1943 @code{DEFUN}.
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
1944
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
1945 This call to @code{DEFSUBR} should go in the @code{syms_of_*()}
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1946 function at the end of the module. If no such function exists, create
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1947 it and make sure to also declare it in @file{symsinit.h} and call it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1948 from the appropriate spot in @code{main()}. @xref{General Coding
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1949 Rules}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1950
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1951 Note that C code cannot call functions by name unless they are defined
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
1952 in C. The way to call a function written in Lisp from C is to use
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1953 @code{Ffuncall}, which embodies the Lisp function @code{funcall}. Since
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1954 the Lisp function @code{funcall} accepts an unlimited number of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1955 arguments, in C it takes two: the number of Lisp-level arguments, and a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1956 one-dimensional array containing their values. The first Lisp-level
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1957 argument is the Lisp function to call, and the rest are the arguments to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1958 pass to it. Since @code{Ffuncall} can call the evaluator, you must
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1959 protect pointers from garbage collection around the call to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1960 @code{Ffuncall}. (However, @code{Ffuncall} explicitly protects all of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1961 its parameters, so you don't have to protect any pointers passed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1962 as parameters to it.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1963
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1964 The C functions @code{call0}, @code{call1}, @code{call2}, and so on,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1965 provide handy ways to call a Lisp function conveniently with a fixed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1966 number of arguments. They work by calling @code{Ffuncall}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1967
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1968 @file{eval.c} is a very good file to look through for examples;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1969 @file{lisp.h} contains the definitions for some important macros and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1970 functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1971
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1972 @node Adding Global Lisp Variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1973 @section Adding Global Lisp Variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1974
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1975 Global variables whose names begin with @samp{Q} are constants whose
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1976 value is a symbol of a particular name. The name of the variable should
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1977 be derived from the name of the symbol using the same rules as for Lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1978 primitives. These variables are initialized using a call to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1979 @code{defsymbol()} in the @code{syms_of_*()} function. (This call
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1980 interns a symbol, sets the C variable to the resulting Lisp object, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1981 calls @code{staticpro()} on the C variable to tell the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1982 garbage-collection mechanism about this variable. What
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1983 @code{staticpro()} does is add a pointer to the variable to a large
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1984 global array; when garbage-collection happens, all pointers listed in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1985 the array are used as starting points for marking Lisp objects. This is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1986 important because it's quite possible that the only current reference to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1987 the object is the C variable. In the case of symbols, the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1988 @code{staticpro()} doesn't matter all that much because the symbol is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1989 contained in @code{obarray}, which is itself @code{staticpro()}ed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1990 However, it's possible that a naughty user could do something like
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1991 uninterning the symbol out of @code{obarray} or even setting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1992 @code{obarray} to a different value [although this is likely to make
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1993 XEmacs crash!].)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1994
298
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 282
diff changeset
1995 @strong{Please note:} It is potentially deadly if you declare a
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 282
diff changeset
1996 @samp{Q...} variable in two different modules. The two calls to
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 282
diff changeset
1997 @code{defsymbol()} are no problem, but some linkers will complain about
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 282
diff changeset
1998 multiply-defined symbols. The most insidious aspect of this is that
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 282
diff changeset
1999 often the link will succeed anyway, but then the resulting executable
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 282
diff changeset
2000 will sometimes crash in obscure ways during certain operations! To
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 282
diff changeset
2001 avoid this problem, declare any symbols with common names (such as
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 282
diff changeset
2002 @code{text}) that are not obviously associated with this particular
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 282
diff changeset
2003 module in the module @file{general.c}.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2004
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2005 Global variables whose names begin with @samp{V} are variables that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2006 contain Lisp objects. The convention here is that all global variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2007 of type @code{Lisp_Object} begin with @samp{V}, and all others don't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2008 (including integer and boolean variables that have Lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2009 equivalents). Most of the time, these variables have equivalents in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2010 Lisp, but some don't. Those that do are declared this way by a call to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2011 @code{DEFVAR_LISP()} in the @code{vars_of_*()} initializer for the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2012 module. What this does is create a special @dfn{symbol-value-forward}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2013 Lisp object that contains a pointer to the C variable, intern a symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2014 whose name is as specified in the call to @code{DEFVAR_LISP()}, and set
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2015 its value to the symbol-value-forward Lisp object; it also calls
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2016 @code{staticpro()} on the C variable to tell the garbage-collection
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2017 mechanism about the variable. When @code{eval} (or actually
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2018 @code{symbol-value}) encounters this special object in the process of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2019 retrieving a variable's value, it follows the indirection to the C
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2020 variable and gets its value. @code{setq} does similar things so that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2021 the C variable gets changed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2022
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2023 Whether or not you @code{DEFVAR_LISP()} a variable, you need to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2024 initialize it in the @code{vars_of_*()} function; otherwise it will end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2025 up as all zeroes, which is the integer 0 (@emph{not} @code{nil}), and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2026 this is probably not what you want. Also, if the variable is not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2027 @code{DEFVAR_LISP()}ed, @strong{you must call} @code{staticpro()} on the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2028 C variable in the @code{vars_of_*()} function. Otherwise, the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2029 garbage-collection mechanism won't know that the object in this variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2030 is in use, and will happily collect it and reuse its storage for another
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2031 Lisp object, and you will be the one who's unhappy when you can't figure
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2032 out how your variable got overwritten.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2033
318
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2034 @node Coding for Mule
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2035 @section Coding for Mule
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2036 @cindex Coding for Mule
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2037
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2038 Although Mule support is not compiled by default in XEmacs, many people
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2039 are using it, and we consider it crucial that new code works correctly
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2040 with multibyte characters. This is not hard; it is only a matter of
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2041 following several simple user-interface guidelines. Even if you never
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2042 compile with Mule, with a little practice you will find it quite easy
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2043 to code Mule-correctly.
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2044
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2045 Note that these guidelines are not necessarily tied to the current Mule
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2046 implementation; they are also a good idea to follow on the grounds of
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2047 code generalization for future I18N work.
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2048
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2049 @menu
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2050 * Character-Related Data Types::
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2051 * Working With Character and Byte Positions::
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2052 * Conversion of External Data::
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2053 * General Guidelines for Writing Mule-Aware Code::
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2054 * An Example of Mule-Aware Code::
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2055 @end menu
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2056
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2057 @node Character-Related Data Types
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2058 @subsection Character-Related Data Types
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2059
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2060 First, we will list the basic character-related datatypes used by
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2061 XEmacs. Note that the separate @code{typedef}s are not required for the
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2062 code to work (all of them boil down to @code{unsigned char} or
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2063 @code{int}), but they improve clarity of code a great deal, because one
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2064 glance at the declaration can tell the intended use of the variable.
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2065
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2066 @table @code
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2067 @item Emchar
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2068 @cindex Emchar
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2069 An @code{Emchar} holds a single Emacs character.
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2070
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2071 Obviously, the equality between characters and bytes is lost in the Mule
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2072 world. Characters can be represented by one or more bytes in the
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2073 buffer, and @code{Emchar} is the C type large enough to hold any
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2074 character.
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2075
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2076 Without Mule support, an @code{Emchar} is equivalent to an
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2077 @code{unsigned char}.
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2078
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2079 @item Bufbyte
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2080 @cindex Bufbyte
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2081 The data representing the text in a buffer or string is logically a set
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2082 of @code{Bufbyte}s.
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2083
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2084 XEmacs does not work with character formats all the time; when reading
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2085 characters from the outside, it decodes them to an internal format, and
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2086 likewise encodes them when writing. @code{Bufbyte} (in fact
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2087 @code{unsigned char}) is the basic unit of XEmacs internal buffers and
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2088 strings format.
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2089
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2090 One character can correspond to one or more @code{Bufbyte}s. In the
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2091 current implementation, an ASCII character is represented by the same
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2092 @code{Bufbyte}, and extended characters are represented by a sequence of
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2093 @code{Bufbyte}s.
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2094
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2095 Without Mule support, a @code{Bufbyte} is equivalent to an
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2096 @code{Emchar}.
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2097
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2098 @item Bufpos
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2099 @itemx Charcount
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2100 A @code{Bufpos} represents a character position in a buffer or string.
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2101 A @code{Charcount} represents a number (count) of characters.
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2102 Logically, subtracting two @code{Bufpos} values yields a
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2103 @code{Charcount} value. Although all of these are @code{typedef}ed to
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2104 @code{int}, we use them in preference to @code{int} to make it clear
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2105 what sort of position is being used.
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2106
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2107 @code{Bufpos} and @code{Charcount} values are the only ones that are
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2108 ever visible to Lisp.
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2109
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2110 @item Bytind
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2111 @itemx Bytecount
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2112 A @code{Bytind} represents a byte position in a buffer or string. A
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2113 @code{Bytecount} represents the distance between two positions in bytes.
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2114 The relationship between @code{Bytind} and @code{Bytecount} is the same
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2115 as the relationship between @code{Bufpos} and @code{Charcount}.
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2116
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2117 @item Extbyte
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2118 @itemx Extcount
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2119 When dealing with the outside world, XEmacs works with @code{Extbyte}s,
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2120 which are equivalent to @code{unsigned char}. Obviously, an
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2121 @code{Extcount} is the distance between two @code{Extbyte}s. Extbytes
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2122 and Extcounts are not all that frequent in XEmacs code.
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2123 @end table
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2124
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2125 @node Working With Character and Byte Positions
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2126 @subsection Working With Character and Byte Positions
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2127
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2128 Now that we have defined the basic character-related types, we can look
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2129 at the macros and functions designed for work with them and for
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2130 conversion between them. Most of these macros are defined in
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2131 @file{buffer.h}, and we don't discuss all of them here, but only the
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2132 most important ones. Examining the existing code is the best way to
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2133 learn about them.
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2134
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2135 @table @code
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2136 @item MAX_EMCHAR_LEN
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2137 This preprocessor constant is the maximum number of buffer bytes per
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2138 Emacs character, i.e. the byte length of an @code{Emchar}. It is useful
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2139 when allocating temporary strings to keep a known number of characters.
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2140 For instance:
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2141
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2142 @example
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2143 @group
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2144 @{
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2145 Charcount cclen;
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2146 ...
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2147 @{
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2148 /* Allocate place for @var{cclen} characters. */
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2149 Bufbyte *tmp_buf = (Bufbyte *)alloca (cclen * MAX_EMCHAR_LEN);
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2150 ...
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2151 @end group
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2152 @end example
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2153
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2154 If you followed the previous section, you can guess that, logically,
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2155 multiplying a @code{Charcount} value with @code{MAX_EMCHAR_LEN} produces
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2156 a @code{Bytecount} value.
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2157
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2158 In the current Mule implementation, @code{MAX_EMCHAR_LEN} equals 4.
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2159 Without Mule, it is 1.
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2160
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2161 @item charptr_emchar
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2162 @item set_charptr_emchar
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2163 @code{charptr_emchar} macro takes a @code{Bufbyte} pointer and returns
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2164 the underlying @code{Emchar}. If it were a function, its prototype
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2165 would be:
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2166
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2167 @example
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2168 Emchar charptr_emchar (Bufbyte *p);
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2169 @end example
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2170
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2171 @code{set_charptr_emchar} stores an @code{Emchar} to the specified byte
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2172 position. It returns the number of bytes stored:
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2173
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2174 @example
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2175 Bytecount set_charptr_emchar (Bufbyte *p, Emchar c);
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2176 @end example
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2177
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2178 It is important to note that @code{set_charptr_emchar} is safe only for
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2179 appending a character at the end of a buffer, not for overwriting a
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2180 character in the middle. This is because the width of characters
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2181 varies, and @code{set_charptr_emchar} cannot resize the string if it
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2182 writes, say, a two-byte character where a single-byte character used to
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2183 reside.
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2184
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2185 A typical use of @code{set_charptr_emchar} can be demonstrated by this
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2186 example, which copies characters from buffer @var{buf} to a temporary
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2187 string of Bufbytes.
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2188
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2189 @example
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2190 @group
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2191 @{
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2192 Bufpos pos;
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2193 for (pos = beg; pos < end; pos++)
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2194 @{
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2195 Emchar c = BUF_FETCH_CHAR (buf, pos);
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2196 p += set_charptr_emchar (buf, c);
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2197 @}
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2198 @}
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2199 @end group
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2200 @end example
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2201
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2202 Note how @code{set_charptr_emchar} is used to store the @code{Emchar}
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2203 and increment the counter, at the same time.
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2204
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2205 @item INC_CHARPTR
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2206 @itemx DEC_CHARPTR
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2207 These two macros increment and decrement a @code{Bufbyte} pointer,
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2208 respectively. The pointer needs to be correctly positioned at the
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2209 beginning of a valid character position.
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2210
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2211 Without Mule support, @code{INC_CHARPTR (p)} and @code{DEC_CHARPTR (p)}
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2212 simply expand to @code{p++} and @code{p--}, respectively.
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2213
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2214 @item bytecount_to_charcount
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2215 Given a pointer to a text string and a length in bytes, return the
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2216 equivalent length in characters.
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2217
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2218 @example
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2219 Charcount bytecount_to_charcount (Bufbyte *p, Bytecount bc);
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2220 @end example
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2221
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2222 @item charcount_to_bytecount
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2223 Given a pointer to a text string and a length in characters, return the
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2224 equivalent length in bytes.
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2225
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2226 @example
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2227 Bytecount charcount_to_bytecount (Bufbyte *p, Charcount cc);
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2228 @end example
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2229
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2230 @item charptr_n_addr
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2231 Return a pointer to the beginning of the character offset @var{cc} (in
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2232 characters) from @var{p}.
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2233
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2234 @example
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2235 Bufbyte *charptr_n_addr (Bufbyte *p, Charcount cc);
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2236 @end example
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2237 @end table
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2238
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2239 @node Conversion of External Data
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2240 @subsection Conversion of External Data
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2241
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2242 When an external function, such as a C library function, returns a
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2243 @code{char} pointer, you should never treat it as @code{Bufbyte}. This
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2244 is because these returned strings may contain 8bit characters which can
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2245 be misinterpreted by XEmacs, and cause a crash. Instead, you should use
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2246 a conversion macro. Many different conversion macros are defined in
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2247 @file{buffer.h}, so I will try to order them logically, by direction and
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2248 by format.
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2249
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2250 Thus the basic conversion macros are @code{GET_CHARPTR_INT_DATA_ALLOCA}
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2251 and @code{GET_CHARPTR_EXT_DATA_ALLOCA}. The former is used to convert
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2252 external data to internal format, and the latter is used to convert the
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2253 other way around. The arguments each of these receives are @var{ptr}
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2254 (pointer to the text in external format), @var{len} (length of texts in
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2255 bytes), @var{fmt} (format of the external text), @var{ptr_out} (lvalue
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2256 to which new text should be copied), and @var{len_out} (lvalue which
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2257 will be assigned the length of the internal text in bytes). The
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2258 resulting text is stored to a stack-allocated buffer. If the text
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2259 doesn't need changing, these macros will do nothing, except for setting
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2260 @var{len_out}.
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2261
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2262 Currently meaningful formats are @code{FORMAT_BINARY},
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2263 @code{FORMAT_FILENAME}, @code{FORMAT_OS}, and @code{FORMAT_CTEXT}.
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2264
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2265 The two macros above take many arguments which makes them unwieldy. For
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2266 this reason, several convenience macros are defined with obvious
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2267 functionality, but accepting less arguments:
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2268
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2269 @table @code
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2270 @item GET_C_CHARPTR_EXT_DATA_ALLOCA
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2271 @itemx GET_C_CHARPTR_INT_DATA_ALLOCA
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2272 These two macros work on ``C char pointers'', which are zero-terminated,
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2273 and thus do not need @var{len} or @var{len_out} parameters.
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2274
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2275 @item GET_STRING_EXT_DATA_ALLOCA
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2276 @itemx GET_C_STRING_EXT_DATA_ALLOCA
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2277 These two macros work on Lisp strings, thus also not needing a @var{len}
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2278 parameter. However, @code{GET_STRING_EXT_DATA_ALLOCA} still provides a
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2279 @var{len_out} parameter. Note that for Lisp strings only one conversion
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2280 direction makes sense.
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2281
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2282 @item GET_C_CHARPTR_EXT_BINARY_DATA_ALLOCA
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2283 @itemx GET_C_CHARPTR_EXT_FILENAME_DATA_ALLOCA
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2284 @itemx GET_C_CHARPTR_EXT_CTEXT_DATA_ALLOCA
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2285 @itemx ...
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2286 These macros are a combination of the above, but with the @var{fmt}
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2287 argument encoded into the name of the macro.
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2288 @end table
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2289
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2290 @node General Guidelines for Writing Mule-Aware Code
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2291 @subsection General Guidelines for Writing Mule-Aware Code
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2292
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2293 This section contains some general guidance on how to write Mule-aware
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2294 code, as well as some pitfalls you should avoid.
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2295
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2296 @table @emph
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2297 @item Never use @code{char} and @code{char *}.
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2298 In XEmacs, the use of @code{char} and @code{char *} is almost always a
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2299 mistake. If you want to manipulate an Emacs character from ``C'', use
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2300 @code{Emchar}. If you want to examine a specific octet in the internal
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2301 format, use @code{Bufbyte}. If you want a Lisp-visible character, use a
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2302 @code{Lisp_Object} and @code{make_char}. If you want a pointer to move
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2303 through the internal text, use @code{Bufbyte *}. Also note that you
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2304 almost certainly do not need @code{Emchar *}.
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2305
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2306 @item Be careful not to confuse @code{Charcount}, @code{Bytecount}, and @code{Bufpos}.
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2307 The whole point of using different types is to avoid confusion about the
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2308 use of certain variables. Lest this effect be nullified, you need to be
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2309 careful about using the right types.
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2310
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2311 @item Always convert external data
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2312 It is extremely important to always convert external data, because
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2313 XEmacs can crash if unexpected 8bit sequences are copied to its internal
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2314 buffers literally.
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2315
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2316 This means that when a system function, such as @code{readdir}, returns
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2317 a string, you need to convert it using one of the conversion macros
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2318 described in the previous chapter, before passing it further to Lisp.
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2319 In the case of @code{readdir}, you would use the
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2320 @code{GET_C_CHARPTR_INT_FILENAME_DATA_ALLOCA} macro.
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2321
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2322 Also note that many internal functions, such as @code{make_string},
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2323 accept Bufbytes, which removes the need for them to convert the data
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2324 they receive. This increases efficiency because that way external data
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2325 needs to be decoded only once, when it is read. After that, it is
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2326 passed around in internal format.
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2327 @end table
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2328
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2329 @node An Example of Mule-Aware Code
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2330 @subsection An Example of Mule-Aware Code
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2331
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2332 As an example of Mule-aware code, we shall will analyze the
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2333 @code{string} function, which conses up a Lisp string from the character
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2334 arguments it receives. Here is the definition, pasted from
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2335 @code{alloc.c}:
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2336
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2337 @example
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2338 @group
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2339 DEFUN ("string", Fstring, 0, MANY, 0, /*
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2340 Concatenate all the argument characters and make the result a string.
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2341 */
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2342 (int nargs, Lisp_Object *args))
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2343 @{
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2344 Bufbyte *storage = alloca_array (Bufbyte, nargs * MAX_EMCHAR_LEN);
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2345 Bufbyte *p = storage;
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2346
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2347 for (; nargs; nargs--, args++)
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2348 @{
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2349 Lisp_Object lisp_char = *args;
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2350 CHECK_CHAR_COERCE_INT (lisp_char);
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2351 p += set_charptr_emchar (p, XCHAR (lisp_char));
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2352 @}
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2353 return make_string (storage, p - storage);
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2354 @}
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2355 @end group
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2356 @end example
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2357
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2358 Now we can analyze the source line by line.
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2359
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2360 Obviously, string will be as long as there are arguments to the
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2361 function. This is why we allocate @code{MAX_EMCHAR_LEN} * @var{nargs}
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2362 bytes on the stack, i.e. the worst-case number of bytes for @var{nargs}
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2363 @code{Emchar}s to fit in the string.
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2364
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2365 Then, the loop checks that each element is a character, converting
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2366 integers in the process. Like many other functions in XEmacs, this
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2367 function silently accepts integers where characters are expected, for
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2368 historical and compatibility reasons. Unless you know what you are
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2369 doing, @code{CHECK_CHAR} will also suffice. @code{XCHAR (lisp_char)}
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2370 extracts the @code{Emchar} from the @code{Lisp_Object}, and
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2371 @code{set_charptr_emchar} stores it to storage, increasing @code{p} in
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2372 the process.
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2373
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2374 Other instructing examples of correct coding under Mule can be found all
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2375 over XEmacs code. For starters, I recommend
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2376 @code{Fnormalize_menu_item_name} in @file{menubar.c}. After you have
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2377 understood this section of the manual and studied the examples, you can
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2378 proceed writing new Mule-aware code.
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 298
diff changeset
2379
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2380 @node Techniques for XEmacs Developers
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2381 @section Techniques for XEmacs Developers
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2382
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2383 To make a quantified XEmacs, do: @code{make quantmacs}.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2384
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2385 You simply can't dump Quantified and Purified images. Run the image
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2386 like so: @code{quantmacs -batch -l loadup.el run-temacs -q}.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2387
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2388 Before you go through the trouble, are you compiling with all
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2389 debugging and error-checking off? If not try that first. Be warned
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2390 that while Quantify is directly responsible for quite a few
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2391 optimizations which have been made to XEmacs, doing a run which
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2392 generates results which can be acted upon is not necessarily a trivial
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2393 task.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2394
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2395 Also, if you're still willing to do some runs make sure you configure
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2396 with the @samp{--quantify} flag. That will keep Quantify from starting
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2397 to record data until after the loadup is completed and will shut off
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2398 recording right before it shuts down (which generates enough bogus data
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2399 to throw most results off). It also enables three additional elisp
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2400 commands: @code{quantify-start-recording-data},
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2401 @code{quantify-stop-recording-data} and @code{quantify-clear-data}.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2402
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2403 To get started debugging XEmacs, take a look at the @file{gdbinit} and
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 272
diff changeset
2404 @file{dbxrc} files in the @file{src} directory.
298
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 282
diff changeset
2405 @xref{Q2.1.15 - How to Debug an XEmacs problem with a debugger,,,
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 272
diff changeset
2406 xemacs-faq, XEmacs FAQ}.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 272
diff changeset
2407
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 272
diff changeset
2408
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 272
diff changeset
2409 Here are things to know when you create a new source file:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 272
diff changeset
2410
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 272
diff changeset
2411 @itemize @bullet
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 272
diff changeset
2412 @item
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 272
diff changeset
2413 All .c files should @code{#include <config.h>} first. Almost all .c
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 272
diff changeset
2414 files should @code{#include "lisp.h"} second.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 272
diff changeset
2415
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 272
diff changeset
2416 @item
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 272
diff changeset
2417 Generated header files should be included using the @code{<>} syntax,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 272
diff changeset
2418 not the @code{""} syntax. The generated headers are:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 272
diff changeset
2419
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 272
diff changeset
2420 config.h puresize-adjust.h sheap-adjust.h paths.h Emacs.ad.h
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 272
diff changeset
2421
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 272
diff changeset
2422 The basic rule is that you should assume builds using @code{--srcdir}
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 272
diff changeset
2423 and the @code{<>} syntax needs to be used when the to-be-included
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 272
diff changeset
2424 generated file is in a potentially different directory
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 272
diff changeset
2425 @emph{at compile time}.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 272
diff changeset
2426
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 272
diff changeset
2427 @item
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 272
diff changeset
2428 Header files should not include <config.h> and "lisp.h". It is the
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 272
diff changeset
2429 responsibility of the .c files that use it to do so.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 272
diff changeset
2430
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 272
diff changeset
2431 @item
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 272
diff changeset
2432 If the header uses INLINE, either directly or though DECLARE_LRECORD,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 272
diff changeset
2433 then it must be added to inline.c's includes.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 272
diff changeset
2434
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 272
diff changeset
2435 @item
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 272
diff changeset
2436 Try compiling at least once with
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 272
diff changeset
2437
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 272
diff changeset
2438 @example
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 272
diff changeset
2439 gcc --with-mule --with-union-type --error-checking=all
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 272
diff changeset
2440 @end example
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 272
diff changeset
2441 @end itemize
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2442
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2443 @node A Summary of the Various XEmacs Modules, Allocation of Objects in XEmacs Lisp, Rules When Writing New C Code, Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2444 @chapter A Summary of the Various XEmacs Modules
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2445
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2446 This is accurate as of XEmacs 20.0.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2447
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2448 @menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2449 * Low-Level Modules::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2450 * Basic Lisp Modules::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2451 * Modules for Standard Editing Operations::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2452 * Editor-Level Control Flow Modules::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2453 * Modules for the Basic Displayable Lisp Objects::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2454 * Modules for other Display-Related Lisp Objects::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2455 * Modules for the Redisplay Mechanism::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2456 * Modules for Interfacing with the File System::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2457 * Modules for Other Aspects of the Lisp Interpreter and Object System::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2458 * Modules for Interfacing with the Operating System::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2459 * Modules for Interfacing with X Windows::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2460 * Modules for Internationalization::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2461 @end menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2462
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2463 @node Low-Level Modules
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2464 @section Low-Level Modules
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2465
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2466 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2467 size name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2468 ------- ---------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2469 18150 config.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2470 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2471
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2472 This is automatically generated from @file{config.h.in} based on the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2473 results of configure tests and user-selected optional features and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2474 contains preprocessor definitions specifying the nature of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2475 environment in which XEmacs is being compiled.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2476
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2477
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2478
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2479 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2480 2347 paths.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2481 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2482
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2483 This is automatically generated from @file{paths.h.in} based on supplied
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2484 configure values, and allows for non-standard installed configurations
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2485 of the XEmacs directories. It's currently broken, though.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2486
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2487
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2488
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2489 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2490 47878 emacs.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2491 20239 signal.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2492 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2493
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2494 @file{emacs.c} contains @code{main()} and other code that performs the most
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2495 basic environment initializations and handles shutting down the XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2496 process (this includes @code{kill-emacs}, the normal way that XEmacs is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2497 exited; @code{dump-emacs}, which is used during the build process to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2498 write out the XEmacs executable; @code{run-emacs-from-temacs}, which can
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2499 be used to start XEmacs directly when temacs has finished loading all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2500 the Lisp code; and emergency code to handle crashes [XEmacs tries to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2501 auto-save all files before it crashes]).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2502
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2503 Low-level code that directly interacts with the Unix signal mechanism,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2504 however, is in @file{signal.c}. Note that this code does not handle system
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2505 dependencies in interfacing to signals; that is handled using the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2506 @file{syssignal.h} header file, described in section J below.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2507
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2508
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2509
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2510 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2511 23458 unexaix.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2512 9893 unexalpha.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2513 11302 unexapollo.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2514 16544 unexconvex.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2515 31967 unexec.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2516 30959 unexelf.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2517 35791 unexelfsgi.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2518 3207 unexencap.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2519 7276 unexenix.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2520 20539 unexfreebsd.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2521 1153 unexfx2800.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2522 13432 unexhp9k3.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2523 11049 unexhp9k800.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2524 9165 unexmips.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2525 8981 unexnext.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2526 1673 unexsol2.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2527 19261 unexsunos4.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2528 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2529
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2530 These modules contain code dumping out the XEmacs executable on various
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2531 different systems. (This process is highly machine-specific and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2532 requires intimate knowledge of the executable format and the memory map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2533 of the process.) Only one of these modules is actually used; this is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2534 chosen by @file{configure}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2535
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2536
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2537
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2538 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2539 15715 crt0.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2540 1484 lastfile.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2541 1115 pre-crt0.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2542 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2543
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2544 These modules are used in conjunction with the dump mechanism. On some
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2545 systems, an alternative version of the C startup code (the actual code
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2546 that receives control from the operating system when the process is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2547 started, and which calls @code{main()}) is required so that the dumping
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2548 process works properly; @file{crt0.c} provides this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2549
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2550 @file{pre-crt0.c} and @file{lastfile.c} should be the very first and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2551 very last file linked, respectively. (Actually, this is not really true.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2552 @file{lastfile.c} should be after all Emacs modules whose initialized
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2553 data should be made constant, and before all other Emacs files and all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2554 libraries. In particular, the allocation modules @file{gmalloc.c},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2555 @file{alloca.c}, etc. are normally placed past @file{lastfile.c}, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2556 all of the files that implement Xt widget classes @emph{must} be placed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2557 after @file{lastfile.c} because they contain various structures that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2558 must be statically initialized and into which Xt writes at various
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2559 times.) @file{pre-crt0.c} and @file{lastfile.c} contain exported symbols
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
2560 that are used to determine the start and end of XEmacs' initialized
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2561 data space when dumping.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2562
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2563
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2564
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2565 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2566 14786 alloca.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2567 16678 free-hook.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2568 1692 getpagesize.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2569 41936 gmalloc.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2570 25141 malloc.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2571 3802 mem-limits.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2572 39011 ralloc.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2573 3436 vm-limit.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2574 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2575
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2576 These handle basic C allocation of memory. @file{alloca.c} is an emulation of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2577 the stack allocation function @code{alloca()} on machines that lack
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2578 this. (XEmacs makes extensive use of @code{alloca()} in its code.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2579
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2580 @file{gmalloc.c} and @file{malloc.c} are two implementations of the standard C
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2581 functions @code{malloc()}, @code{realloc()} and @code{free()}. They are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2582 often used in place of the standard system-provided @code{malloc()}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2583 because they usually provide a much faster implementation, at the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2584 expense of additional memory use. @file{gmalloc.c} is a newer implementation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2585 that is much more memory-efficient for large allocations than @file{malloc.c},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2586 and should always be preferred if it works. (At one point, @file{gmalloc.c}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2587 didn't work on some systems where @file{malloc.c} worked; but this should be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2588 fixed now.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2589
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2590 @cindex relocating allocator
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2591 @file{ralloc.c} is the @dfn{relocating allocator}. It provides functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2592 similar to @code{malloc()}, @code{realloc()} and @code{free()} that allocate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2593 memory that can be dynamically relocated in memory. The advantage of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2594 this is that allocated memory can be shuffled around to place all the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2595 free memory at the end of the heap, and the heap can then be shrunk,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2596 releasing the memory back to the operating system. The use of this can
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2597 be controlled with the configure option @code{--rel-alloc}; if enabled, memory allocated for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2598 buffers will be relocatable, so that if a very large file is visited and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2599 the buffer is later killed, the memory can be released to the operating
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2600 system. (The disadvantage of this mechanism is that it can be very
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2601 slow. On systems with the @code{mmap()} system call, the XEmacs version
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2602 of @file{ralloc.c} uses this to move memory around without actually having to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2603 block-copy it, which can speed things up; but it can still cause
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2604 noticeable performance degradation.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2605
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2606 @file{free-hook.c} contains some debugging functions for checking for invalid
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2607 arguments to @code{free()}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2608
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2609 @file{vm-limit.c} contains some functions that warn the user when memory is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2610 getting low. These are callback functions that are called by @file{gmalloc.c}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2611 and @file{malloc.c} at appropriate times.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2612
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2613 @file{getpagesize.h} provides a uniform interface for retrieving the size of a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2614 page in virtual memory. @file{mem-limits.h} provides a uniform interface for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2615 retrieving the total amount of available virtual memory. Both are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2616 similar in spirit to the @file{sys*.h} files described in section J, below.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2617
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2618
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2619
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2620 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2621 2659 blocktype.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2622 1410 blocktype.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2623 7194 dynarr.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2624 2671 dynarr.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2625 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2626
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2627 These implement a couple of basic C data types to facilitate memory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2628 allocation. The @code{Blocktype} type efficiently manages the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2629 allocation of fixed-size blocks by minimizing the number of times that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2630 @code{malloc()} and @code{free()} are called. It allocates memory in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2631 large chunks, subdivides the chunks into blocks of the proper size, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2632 returns the blocks as requested. When blocks are freed, they are placed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2633 onto a linked list, so they can be efficiently reused. This data type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2634 is not much used in XEmacs currently, because it's a fairly new
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2635 addition.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2636
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2637 @cindex dynamic array
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2638 The @code{Dynarr} type implements a @dfn{dynamic array}, which is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2639 similar to a standard C array but has no fixed limit on the number of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2640 elements it can contain. Dynamic arrays can hold elements of any type,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2641 and when you add a new element, the array automatically resizes itself
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2642 if it isn't big enough. Dynarrs are extensively used in the redisplay
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2643 mechanism.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2644
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2645
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2646
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2647 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2648 2058 inline.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2649 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2650
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2651 This module is used in connection with inline functions (available in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2652 some compilers). Often, inline functions need to have a corresponding
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2653 non-inline function that does the same thing. This module is where they
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2654 reside. It contains no actual code, but defines some special flags that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2655 cause inline functions defined in header files to be rendered as actual
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2656 functions. It then includes all header files that contain any inline
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2657 function definitions, so that each one gets a real function equivalent.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2658
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2659
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2660
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2661 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2662 6489 debug.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2663 2267 debug.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2664 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2665
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2666 These functions provide a system for doing internal consistency checks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2667 during code development. This system is not currently used; instead the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2668 simpler @code{assert()} macro is used along with the various checks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2669 provided by the @samp{--error-check-*} configuration options.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2670
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2671
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2672
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2673 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2674 1643 prefix-args.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2675 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2676
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2677 This is actually the source for a small, self-contained program
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2678 used during building.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2679
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2680
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2681 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2682 904 universe.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2683 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2684
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2685 This is not currently used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2686
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2687
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2688
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2689 @node Basic Lisp Modules
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2690 @section Basic Lisp Modules
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2691
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2692 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2693 size name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2694 ------- ---------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2695 70167 emacsfns.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2696 6305 lisp-disunion.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2697 7086 lisp-union.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2698 54929 lisp.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2699 14235 lrecord.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2700 10728 symsinit.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2701 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2702
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2703 These are the basic header files for all XEmacs modules. Each module
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2704 includes @file{lisp.h}, which brings the other header files in.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2705 @file{lisp.h} contains the definitions of the structures and extractor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2706 and constructor macros for the basic Lisp objects and various other
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2707 basic definitions for the Lisp environment, as well as some
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2708 general-purpose definitions (e.g. @code{min()} and @code{max()}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2709 @file{lisp.h} includes either @file{lisp-disunion.h} or
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 265
diff changeset
2710 @file{lisp-union.h}, depending on whether @code{USE_UNION_TYPE} is
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2711 defined. These files define the typedef of the Lisp object itself (as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2712 described above) and the low-level macros that hide the actual
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2713 implementation of the Lisp object. All extractor and constructor macros
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2714 for particular types of Lisp objects are defined in terms of these
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2715 low-level macros.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2716
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2717 As a general rule, all typedefs should go into the typedefs section of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2718 @file{lisp.h} rather than into a module-specific header file even if the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2719 structure is defined elsewhere. This allows function prototypes that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2720 use the typedef to be placed into @file{emacsfns.h}. Forward structure
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2721 declarations (i.e. a simple declaration like @code{struct foo;} where
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2722 the structure itself is defined elsewhere) should be placed into the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2723 typedefs section as necessary.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2724
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2725 @file{lrecord.h} contains the basic structures and macros that implement
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2726 all record-type Lisp objects -- i.e. all objects whose type is a field
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2727 in their C structure, which includes all objects except the few most
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2728 basic ones.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2729
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2730 @file{emacsfns.h} contains prototypes for most of the exported functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2731 in the various modules. (In particular, prototypes for Lisp primitives
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2732 should always go into this header file. Prototypes for other functions
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2733 can either go here or in a module-specific header file, depending on how
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2734 general-purpose the function is and whether it has special-purpose
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2735 argument types requiring definitions not in @file{lisp.h}.) All
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2736 initialization functions are prototyped in @file{symsinit.h}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2737
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2738
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2739
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2740 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2741 120478 alloc.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2742 1029 pure.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2743 2506 puresize.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2744 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2745
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2746 The large module @file{alloc.c} implements all of the basic allocation and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2747 garbage collection for Lisp objects. The most commonly used Lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2748 objects are allocated in chunks, similar to the Blocktype data type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2749 described above; others are allocated in individually @code{malloc()}ed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2750 blocks. This module provides the foundation on which all other aspects
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2751 of the Lisp environment sit, and is the first module initialized at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2752 startup.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2753
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2754 Note that @file{alloc.c} provides a series of generic functions that are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2755 not dependent on any particular object type, and interfaces to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2756 particular types of objects using a standardized interface of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2757 type-specific methods. This scheme is a fundamental principle of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2758 object-oriented programming and is heavily used throughout XEmacs. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2759 great advantage of this is that it allows for a clean separation of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2760 functionality into different modules -- new classes of Lisp objects, new
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2761 event interfaces, new device types, new stream interfaces, etc. can be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2762 added transparently without affecting code anywhere else in XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2763 Because the different subsystems are divided into general and specific
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2764 code, adding a new subtype within a subsystem will in general not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2765 require changes to the generic subsystem code or affect any of the other
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2766 subtypes in the subsystem; this provides a great deal of robustness to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2767 the XEmacs code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2768
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2769 @cindex pure space
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2770 @file{pure.c} contains the declaration of the @dfn{purespace} array.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2771 Pure space is a hack used to place some constant Lisp data into the code
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2772 segment of the XEmacs executable, even though the data needs to be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2773 initialized through function calls. (See above in section VIII for more
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2774 info about this.) During startup, certain sorts of data is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2775 automatically copied into pure space, and other data is copied manually
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2776 in some of the basic Lisp files by calling the function @code{purecopy},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2777 which copies the object if possible (this only works in temacs, of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2778 course) and returns the new object. In particular, while temacs is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2779 executing, the Lisp reader automatically copies all compiled-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2780 objects that it reads into pure space. Since compiled-function objects
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2781 are large, are never modified, and typically comprise the majority of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2782 the contents of a compiled-Lisp file, this works well. While XEmacs is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2783 running, any attempt to modify an object that resides in pure space
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2784 causes an error. Objects in pure space are never garbage collected --
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2785 almost all of the time, they're intended to be permanent, and in any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2786 case you can't write into pure space to set the mark bits.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2787
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2788 @file{puresize.h} contains the declaration of the size of the pure space
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2789 array. This depends on the optional features that are compiled in, any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2790 extra purespace requested by the user at compile time, and certain other
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2791 factors (e.g. 64-bit machines need more pure space because their Lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2792 objects are larger). The smallest size that suffices should be used, so
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2793 that there's no wasted space. If there's not enough pure space, you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2794 will get an error during the build process, specifying how much more
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2795 pure space is needed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2796
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2797
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2798
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2799 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2800 122243 eval.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2801 2305 backtrace.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2802 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2803
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2804 This module contains all of the functions to handle the flow of control.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2805 This includes the mechanisms of defining functions, calling functions,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2806 traversing stack frames, and binding variables; the control primitives
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2807 and other special forms such as @code{while}, @code{if}, @code{eval},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2808 @code{let}, @code{and}, @code{or}, @code{progn}, etc.; handling of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2809 non-local exits, unwind-protects, and exception handlers; entering the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2810 debugger; methods for the subr Lisp object type; etc. It does
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2811 @emph{not} include the @code{read} function, the @code{print} function,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2812 or the handling of symbols and obarrays.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2813
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2814 @file{backtrace.h} contains some structures related to stack frames and the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2815 flow of control.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2816
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2817
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2818
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2819 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2820 64949 lread.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2821 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2822
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2823 This module implements the Lisp reader and the @code{read} function,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2824 which converts text into Lisp objects, according to the read syntax of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2825 the objects, as described above. This is similar to the parser that is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2826 a part of all compilers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2827
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2828
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2829
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2830 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2831 40900 print.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2832 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2833
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2834 This module implements the Lisp print mechanism and the @code{print}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2835 function and related functions. This is the inverse of the Lisp reader
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2836 -- it converts Lisp objects to a printed, textual representation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2837 (Hopefully something that can be read back in using @code{read} to get
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2838 an equivalent object.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2839
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2840
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2841
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2842 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2843 4518 general.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2844 60220 symbols.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2845 9966 symeval.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2846 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2847
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2848 @file{symbols.c} implements the handling of symbols, obarrays, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2849 retrieving the values of symbols. Much of the code is devoted to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2850 handling the special @dfn{symbol-value-magic} objects that define
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2851 special types of variables -- this includes buffer-local variables,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2852 variable aliases, variables that forward into C variables, etc. This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2853 module is initialized extremely early (right after @file{alloc.c}),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2854 because it is here that the basic symbols @code{t} and @code{nil} are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2855 created, and those symbols are used everywhere throughout XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2856
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2857 @file{symeval.h} contains the definitions of symbol structures and the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2858 @code{DEFVAR_LISP()} and related macros for declaring variables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2859
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2860
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2861
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2862 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2863 48973 data.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2864 25694 floatfns.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2865 71049 fns.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2866 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2867
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2868 These modules implement the methods and standard Lisp primitives for all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2869 the basic Lisp object types other than symbols (which are described
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2870 above). @file{data.c} contains all the predicates (primitives that return
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2871 whether an object is of a particular type); the integer arithmetic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2872 functions; and the basic accessor and mutator primitives for the various
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2873 object types. @file{fns.c} contains all the standard predicates for working
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2874 with sequences (where, abstractly speaking, a sequence is an ordered set
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2875 of objects, and can be represented by a list, string, vector, or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2876 bit-vector); it also contains @code{equal}, perhaps on the grounds that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2877 bulk of the operation of @code{equal} is comparing sequences.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2878 @file{floatfns.c} contains methods and primitives for floats and floating-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2879 arithmetic.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2880
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2881
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2882
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2883 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2884 23555 bytecode.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2885 3358 bytecode.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2886 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2887
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2888 @file{bytecode.c} implements the byte-code interpreter, and @file{bytecode.h} contains
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2889 associated structures. Note that the byte-code @emph{compiler} is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2890 written in Lisp.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2891
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2892
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2893
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2894
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2895 @node Modules for Standard Editing Operations
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2896 @section Modules for Standard Editing Operations
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2897
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2898 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2899 size name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2900 ------- ---------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2901 82900 buffer.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2902 60964 buffer.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2903 6059 bufslots.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2904 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2905
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2906 @file{buffer.c} implements the @dfn{buffer} Lisp object type. This
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2907 includes functions that create and destroy buffers; retrieve buffers by
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2908 name or by other properties; manipulate lists of buffers (remember that
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2909 buffers are permanent objects and stored in various ordered lists);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2910 retrieve or change buffer properties; etc. It also contains the
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2911 definitions of all the built-in buffer-local variables (which can be
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2912 viewed as buffer properties). It does @emph{not} contain code to
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2913 manipulate buffer-local variables (that's in @file{symbols.c}, described
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2914 above); or code to manipulate the text in a buffer.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2915
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2916 @file{buffer.h} defines the structures associated with a buffer and the various
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2917 macros for retrieving text from a buffer and special buffer positions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2918 (e.g. @code{point}, the default location for text insertion). It also
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2919 contains macros for working with buffer positions and converting between
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2920 their representations as character offsets and as byte offsets (under
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2921 MULE, they are different, because characters can be multi-byte). It is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2922 one of the largest header files.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2923
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2924 @file{bufslots.h} defines the fields in the buffer structure that correspond to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2925 the built-in buffer-local variables. It is its own header file because
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2926 it is included many times in @file{buffer.c}, as a way of iterating over all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2927 the built-in buffer-local variables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2928
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2929
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2930
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2931 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2932 79888 insdel.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2933 6103 insdel.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2934 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2935
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2936 @file{insdel.c} contains low-level functions for inserting and deleting text in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2937 a buffer, keeping track of changed regions for use by redisplay, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2938 calling any before-change and after-change functions that may have been
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2939 registered for the buffer. It also contains the actual functions that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2940 convert between byte offsets and character offsets.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2941
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2942 @file{insdel.h} contains associated headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2943
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2944
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2945
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2946 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2947 10975 marker.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2948 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2949
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2950 This module implements the @dfn{marker} Lisp object type, which
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2951 conceptually is a pointer to a text position in a buffer that moves
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2952 around as text is inserted and deleted, so as to remain in the same
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2953 relative position. This module doesn't actually move the markers around
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2954 -- that's handled in @file{insdel.c}. This module just creates them and
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2955 implements the primitives for working with them. As markers are simple
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2956 objects, this does not entail much.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2957
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2958 Note that the standard arithmetic primitives (e.g. @code{+}) accept
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2959 markers in place of integers and automatically substitute the value of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2960 @code{marker-position} for the marker, i.e. an integer describing the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2961 current buffer position of the marker.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2962
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2963
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2964
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2965 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2966 193714 extents.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2967 15686 extents.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2968 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2969
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2970 This module implements the @dfn{extent} Lisp object type, which is like
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2971 a marker that works over a range of text rather than a single position.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2972 Extents are also much more complex and powerful than markers and have a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2973 more efficient (and more algorithmically complex) implementation. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2974 implementation is described in detail in comments in @file{extents.c}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2975
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2976 The code in @file{extents.c} works closely with @file{insdel.c} so that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2977 extents are properly moved around as text is inserted and deleted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2978 There is also code in @file{extents.c} that provides information needed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2979 by the redisplay mechanism for efficient operation. (Remember that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2980 extents can have display properties that affect [sometimes drastically,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2981 as in the @code{invisible} property] the display of the text they
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2982 cover.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2983
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2984
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2985
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2986 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2987 60155 editfns.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2988 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2989
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2990 @file{editfns.c} contains the standard Lisp primitives for working with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2991 a buffer's text, and calls the low-level functions in @file{insdel.c}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2992 It also contains primitives for working with @code{point} (the default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2993 buffer insertion location).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2994
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2995 @file{editfns.c} also contains functions for retrieving various
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2996 characteristics from the external environment: the current time, the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2997 process ID of the running XEmacs process, the name of the user who ran
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2998 this XEmacs process, etc. It's not clear why this code is in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2999 @file{editfns.c}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3000
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3001
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3002
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3003 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3004 26081 callint.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3005 12577 cmds.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3006 2749 commands.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3007 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3008
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3009 @cindex interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3010 These modules implement the basic @dfn{interactive} commands,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3011 i.e. user-callable functions. Commands, as opposed to other functions,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3012 have special ways of getting their parameters interactively (by querying
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3013 the user), as opposed to having them passed in a normal function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3014 invocation. Many commands are not really meant to be called from other
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3015 Lisp functions, because they modify global state in a way that's often
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3016 undesired as part of other Lisp functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3017
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3018 @file{callint.c} implements the mechanism for querying the user for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3019 parameters and calling interactive commands. The bulk of this module is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3020 code that parses the interactive spec that is supplied with an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3021 interactive command.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3022
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3023 @file{cmds.c} implements the basic, most commonly used editing commands:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3024 commands to move around the current buffer and insert and delete
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3025 characters. These commands are implemented using the Lisp primitives
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3026 defined in @file{editfns.c}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3027
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3028 @file{commands.h} contains associated structure definitions and prototypes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3029
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3030
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3031
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3032 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3033 194863 regex.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3034 18968 regex.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3035 79800 search.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3036 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3037
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3038 @file{search.c} implements the Lisp primitives for searching for text in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3039 a buffer, and some of the low-level algorithms for doing this. In
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3040 particular, the fast fixed-string Boyer-Moore search algorithm is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3041 implemented in @file{search.c}. The low-level algorithms for doing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3042 regular-expression searching, however, are implemented in @file{regex.c}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3043 and @file{regex.h}. These two modules are largely independent of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3044 XEmacs, and are similar to (and based upon) the regular-expression
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3045 routines used in @file{grep} and other GNU utilities.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3046
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3047
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3048
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3049 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3050 20476 doprnt.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3051 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3052
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3053 @file{doprnt.c} implements formatted-string processing, similar to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3054 @code{printf()} command in C.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3055
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3056
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3057
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3058 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3059 15372 undo.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3060 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3061
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3062 This module implements the undo mechanism for tracking buffer changes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3063 Most of this could be implemented in Lisp.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3064
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3065
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3066
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3067 @node Editor-Level Control Flow Modules
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3068 @section Editor-Level Control Flow Modules
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3069
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3070 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3071 size name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3072 ------- ---------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3073 84546 event-Xt.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3074 121483 event-stream.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3075 6658 event-tty.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3076 49271 events.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3077 14459 events.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3078 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3079
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3080 These implement the handling of events (user input and other system
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3081 notifications).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3082
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3083 @file{events.c} and @file{events.h} define the @dfn{event} Lisp object
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3084 type and primitives for manipulating it.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3085
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3086 @file{event-stream.c} implements the basic functions for working with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3087 event queues, dispatching an event by looking it up in relevant keymaps
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3088 and such, and handling timeouts; this includes the primitives
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3089 @code{next-event} and @code{dispatch-event}, as well as related
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3090 primitives such as @code{sit-for}, @code{sleep-for}, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3091 @code{accept-process-output}. (@file{event-stream.c} is one of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3092 hairiest and trickiest modules in XEmacs. Beware! You can easily mess
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3093 things up here.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3094
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3095 @file{event-Xt.c} and @file{event-tty.c} implement the low-level
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3096 interfaces onto retrieving events from Xt (the X toolkit) and from TTY's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3097 (using @code{read()} and @code{select()}), respectively. The event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3098 interface enforces a clean separation between the specific code for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3099 interfacing with the operating system and the generic code for working
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3100 with events, by defining an API of basic, low-level event methods;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3101 @file{event-Xt.c} and @file{event-tty.c} are two different
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3102 implementations of this API. To add support for a new operating system
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3103 (e.g. NeXTstep), one merely needs to provide another implementation of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3104 those API functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3105
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3106 Note that the choice of whether to use @file{event-Xt.c} or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3107 @file{event-tty.c} is made at compile time! Or at the very latest, it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3108 is made at startup time. @file{event-Xt.c} handles events for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3109 @emph{both} X and TTY frames; @file{event-tty.c} is only used when X
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3110 support is not compiled into XEmacs. The reason for this is that there
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3111 is only one event loop in XEmacs: thus, it needs to be able to receive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3112 events from all different kinds of frames.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3113
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3114
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3115
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3116 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3117 129583 keymap.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3118 2621 keymap.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3119 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3120
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3121 @file{keymap.c} and @file{keymap.h} define the @dfn{keymap} Lisp object
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3122 type and associated methods and primitives. (Remember that keymaps are
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3123 objects that associate event descriptions with functions to be called to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3124 ``execute'' those events; @code{dispatch-event} looks up events in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3125 relevant keymaps.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3126
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3127
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3128
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3129 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3130 25212 keyboard.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3131 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3132
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3133 @file{keyboard.c} contains functions that implement the actual editor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3134 command loop -- i.e. the event loop that cyclically retrieves and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3135 dispatches events. This code is also rather tricky, just like
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3136 @file{event-stream.c}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3137
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3138
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3139
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3140 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3141 9973 macros.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3142 1397 macros.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3143 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3144
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3145 These two modules contain the basic code for defining keyboard macros.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3146 These functions don't actually do much; most of the code that handles keyboard
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3147 macros is mixed in with the event-handling code in @file{event-stream.c}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3148
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3149
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3150
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3151 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3152 23234 minibuf.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3153 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3154
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3155 This contains some miscellaneous code related to the minibuffer (most of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3156 the minibuffer code was moved into Lisp by Richard Mlynarik). This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3157 includes the primitives for completion (although filename completion is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3158 in @file{dired.c}), the lowest-level interface to the minibuffer (if the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3159 command loop were cleaned up, this too could be in Lisp), and code for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3160 dealing with the echo area (this, too, was mostly moved into Lisp, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3161 the only code remaining is code to call out to Lisp or provide simple
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3162 bootstrapping implementations early in temacs, before the echo-area Lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3163 code is loaded).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3164
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3165
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3166
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3167 @node Modules for the Basic Displayable Lisp Objects
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3168 @section Modules for the Basic Displayable Lisp Objects
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3169
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3170 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3171 size name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3172 ------- ---------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3173 985 device-ns.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3174 6454 device-stream.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3175 1196 device-stream.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3176 9526 device-tty.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3177 8660 device-tty.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3178 43798 device-x.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3179 11667 device-x.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3180 26056 device.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3181 22993 device.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3182 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3183
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3184 These modules implement the @dfn{device} Lisp object type. This
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3185 abstracts a particular screen or connection on which frames are
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3186 displayed. As with Lisp objects, event interfaces, and other
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3187 subsystems, the device code is separated into a generic component that
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3188 contains a standardized interface (in the form of a set of methods) onto
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3189 particular device types.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3190
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3191 The device subsystem defines all the methods and provides method
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3192 services for not only device operations but also for the frame, window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3193 menubar, scrollbar, toolbar, and other displayable-object subsystems.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3194 The reason for this is that all of these subsystems have the same
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3195 subtypes (X, TTY, NeXTstep, Microsoft Windows, etc.) as devices do.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3196
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3197
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3198
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3199 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3200 934 frame-ns.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3201 2303 frame-tty.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3202 69205 frame-x.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3203 5976 frame-x.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3204 68175 frame.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3205 15080 frame.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3206 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3207
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3208 Each device contains one or more frames in which objects (e.g. text) are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3209 displayed. A frame corresponds to a window in the window system;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3210 usually this is a top-level window but it could potentially be one of a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3211 number of overlapping child windows within a top-level window, using the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3212 MDI (Multiple Document Interface) protocol in Microsoft Windows or a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3213 similar scheme.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3214
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3215 The @file{frame-*} files implement the @dfn{frame} Lisp object type and
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3216 provide the generic and device-type-specific operations on frames
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3217 (e.g. raising, lowering, resizing, moving, etc.).
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3218
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3219
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3220
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3221 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3222 160783 window.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3223 15974 window.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3224 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3225
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3226 @cindex window (in Emacs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3227 @cindex pane
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3228 Each frame consists of one or more non-overlapping @dfn{windows} (better
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3229 known as @dfn{panes} in standard window-system terminology) in which a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3230 buffer's text can be displayed. Windows can also have scrollbars
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3231 displayed around their edges.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3232
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3233 @file{window.c} and @file{window.h} implement the @dfn{window} Lisp
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3234 object type and provide code to manage windows. Since windows have no
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3235 associated resources in the window system (the window system knows only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3236 about the frame; no child windows or anything are used for XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3237 windows), there is no device-type-specific code here; all of that code
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3238 is part of the redisplay mechanism or the code for particular object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3239 types such as scrollbars.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3240
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3241
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3242
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3243 @node Modules for other Display-Related Lisp Objects
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3244 @section Modules for other Display-Related Lisp Objects
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3245
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3246 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3247 size name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3248 ------- ---------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3249 54397 faces.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3250 15173 faces.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3251 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3252
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3253
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3254
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3255 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3256 4961 bitmaps.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3257 954 glyphs-ns.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3258 105345 glyphs-x.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3259 4288 glyphs-x.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3260 72102 glyphs.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3261 16356 glyphs.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3262 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3263
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3264
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3265
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3266 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3267 952 objects-ns.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3268 9971 objects-tty.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3269 1465 objects-tty.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3270 32326 objects-x.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3271 2806 objects-x.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3272 31944 objects.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3273 6809 objects.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3274 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3275
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3276
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3277
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3278 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3279 57511 menubar-x.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3280 11243 menubar.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3281 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3282
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3283
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3284
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3285 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3286 25012 scrollbar-x.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3287 2554 scrollbar-x.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3288 26954 scrollbar.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3289 2778 scrollbar.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3290 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3291
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3292
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3293
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3294 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3295 23117 toolbar-x.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3296 43456 toolbar.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3297 4280 toolbar.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3298 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3299
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3300
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3301
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3302 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3303 25070 font-lock.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3304 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3305
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3306 This file provides C support for syntax highlighting -- i.e.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3307 highlighting different syntactic constructs of a source file in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3308 different colors, for easy reading. The C support is provided so that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3309 this is fast.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3310
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3311
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3312
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3313 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3314 32180 dgif_lib.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3315 3999 gif_err.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3316 10697 gif_lib.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3317 9371 gifalloc.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3318 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3319
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3320 These modules decode GIF-format image files, for use with glyphs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3321
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3322
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3323
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3324 @node Modules for the Redisplay Mechanism
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3325 @section Modules for the Redisplay Mechanism
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3326
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3327 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3328 size name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3329 ------- ---------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3330 38692 redisplay-output.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3331 40835 redisplay-tty.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3332 65069 redisplay-x.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3333 234142 redisplay.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3334 17026 redisplay.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3335 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3336
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3337 These files provide the redisplay mechanism. As with many other
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3338 subsystems in XEmacs, there is a clean separation between the general
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3339 and device-specific support.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3340
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3341 @file{redisplay.c} contains the bulk of the redisplay engine. These
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3342 functions update the redisplay structures (which describe how the screen
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3343 is to appear) to reflect any changes made to the state of any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3344 displayable objects (buffer, frame, window, etc.) since the last time
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3345 that redisplay was called. These functions are highly optimized to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3346 avoid doing more work than necessary (since redisplay is called
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3347 extremely often and is potentially a huge time sink), and depend heavily
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3348 on notifications from the objects themselves that changes have occurred,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3349 so that redisplay doesn't explicitly have to check each possible object.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3350 The redisplay mechanism also contains a great deal of caching to further
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3351 speed things up; some of this caching is contained within the various
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3352 displayable objects.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3353
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3354 @file{redisplay-output.c} goes through the redisplay structures and converts
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3355 them into calls to device-specific methods to actually output the screen
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3356 changes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3357
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3358 @file{redisplay-x.c} and @file{redisplay-tty.c} are two implementations
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3359 of these redisplay output methods, for X frames and TTY frames,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3360 respectively.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3361
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3362
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3363
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3364 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3365 14129 indent.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3366 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3367
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3368 This module contains various functions and Lisp primitives for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3369 converting between buffer positions and screen positions. These
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3370 functions call the redisplay mechanism to do most of the work, and then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3371 examine the redisplay structures to get the necessary information. This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3372 module needs work.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3373
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3374
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3375
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3376 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3377 14754 termcap.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3378 2141 terminfo.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3379 7253 tparam.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3380 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3381
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3382 These files contain functions for working with the termcap (BSD-style)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3383 and terminfo (System V style) databases of terminal capabilities and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3384 escape sequences, used when XEmacs is displaying in a TTY.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3385
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3386
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3387
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3388 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3389 10869 cm.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3390 5876 cm.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3391 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3392
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3393 These files provide some miscellaneous TTY-output functions and should
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3394 probably be merged into @file{redisplay-tty.c}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3395
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3396
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3397
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3398 @node Modules for Interfacing with the File System
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3399 @section Modules for Interfacing with the File System
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3400
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3401 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3402 size name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3403 ------- ---------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3404 43362 lstream.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3405 14240 lstream.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3406 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3407
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3408 These modules implement the @dfn{stream} Lisp object type. This is an
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3409 internal-only Lisp object that implements a generic buffering stream.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3410 The idea is to provide a uniform interface onto all sources and sinks of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3411 data, including file descriptors, stdio streams, chunks of memory, Lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3412 buffers, Lisp strings, etc. That way, I/O functions can be written to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3413 the stream interface and can transparently handle all possible sources
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3414 and sinks. (For example, the @code{read} function can read data from a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3415 file, a string, a buffer, or even a function that is called repeatedly
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3416 to return data, without worrying about where the data is coming from or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3417 what-size chunks it is returned in.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3418
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3419 @cindex lstream
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3420 Note that in the C code, streams are called @dfn{lstreams} (for ``Lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3421 streams'') to distinguish them from other kinds of streams, e.g. stdio
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3422 streams and C++ I/O streams.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3423
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3424 Similar to other subsystems in XEmacs, lstreams are separated into
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3425 generic functions and a set of methods for the different types of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3426 lstreams. @file{lstream.c} provides implementations of many different
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3427 types of streams; others are provided, e.g., in @file{mule-coding.c}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3428
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3429
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3430
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3431 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3432 126926 fileio.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3433 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3434
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3435 This implements the basic primitives for interfacing with the file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3436 system. This includes primitives for reading files into buffers,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3437 writing buffers into files, checking for the presence or accessibility
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3438 of files, canonicalizing file names, etc. Note that these primitives
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3439 are usually not invoked directly by the user: There is a great deal of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3440 higher-level Lisp code that implements the user commands such as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3441 @code{find-file} and @code{save-buffer}. This is similar to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3442 distinction between the lower-level primitives in @file{editfns.c} and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3443 the higher-level user commands in @file{commands.c} and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3444 @file{simple.el}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3445
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3446
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3447
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3448 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3449 10960 filelock.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3450 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3451
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3452 This file provides functions for detecting clashes between different
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3453 processes (e.g. XEmacs and some external process, or two different
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3454 XEmacs processes) modifying the same file. (XEmacs can optionally use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3455 the @file{lock/} subdirectory to provide a form of ``locking'' between
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3456 different XEmacs processes.) This module is also used by the low-level
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3457 functions in @file{insdel.c} to ensure that, if the first modification
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3458 is being made to a buffer whose corresponding file has been externally
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3459 modified, the user is made aware of this so that the buffer can be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3460 synched up with the external changes if necessary.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3461
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3462
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3463 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3464 4527 filemode.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3465 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3466
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3467 This file provides some miscellaneous functions that construct a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3468 @samp{rwxr-xr-x}-type permissions string (as might appear in an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3469 @file{ls}-style directory listing) given the information returned by the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3470 @code{stat()} system call.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3471
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3472
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3473
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3474 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3475 22855 dired.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3476 2094 ndir.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3477 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3478
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3479 These files implement the XEmacs interface to directory searching. This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3480 includes a number of primitives for determining the files in a directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3481 and for doing filename completion. (Remember that generic completion is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3482 handled by a different mechanism, in @file{minibuf.c}.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3483
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3484 @file{ndir.h} is a header file used for the directory-searching
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3485 emulation functions provided in @file{sysdep.c} (see section J below),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3486 for systems that don't provide any directory-searching functions. (On
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3487 those systems, directories can be read directly as files, and parsed.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3488
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3489
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3490
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3491 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3492 4311 realpath.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3493 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3494
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3495 This file provides an implementation of the @code{realpath()} function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3496 for expanding symbolic links, on systems that don't implement it or have
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3497 a broken implementation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3498
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3499
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3500
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3501 @node Modules for Other Aspects of the Lisp Interpreter and Object System
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3502 @section Modules for Other Aspects of the Lisp Interpreter and Object System
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3503
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3504 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3505 size name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3506 ------- ---------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3507 22290 elhash.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3508 2454 elhash.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3509 12169 hash.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3510 3369 hash.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3511 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3512
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3513 These files implement the @dfn{hashtable} Lisp object type.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3514 @file{hash.c} and @file{hash.h} provide a generic C implementation of
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3515 hash tables (which can stand independently of XEmacs), and
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3516 @file{elhash.c} and @file{elhash.h} provide a Lisp interface onto the C
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3517 hash tables using the hashtable Lisp object type.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3518
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3519
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3520
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3521 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3522 95691 specifier.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3523 11167 specifier.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3524 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3525
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3526 This module implements the @dfn{specifier} Lisp object type. This is
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3527 primarily used for displayable properties, and allows for values that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3528 are specific to a particular buffer, window, frame, device, or device
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3529 class, as well as a default value existing. This is used, for example,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3530 to control the height of the horizontal scrollbar or the appearance of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3531 the @code{default}, @code{bold}, or other faces. The specifier object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3532 consists of a number of specifications, each of which maps from a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3533 buffer, window, etc. to a value. The function @code{specifier-instance}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3534 looks up a value given a window (from which a buffer, frame, and device
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3535 can be derived).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3536
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3537
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3538 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3539 43058 chartab.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3540 6503 chartab.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3541 9918 casetab.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3542 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3543
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
3544 @file{chartab.c} and @file{chartab.h} implement the @dfn{char table}
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
3545 Lisp object type, which maps from characters or certain sorts of
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
3546 character ranges to Lisp objects. The implementation of this object
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
3547 type is optimized for the internal representation of characters. Char
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
3548 tables come in different types, which affect the allowed object types to
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
3549 which a character can be mapped and also dictate certain other
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
3550 properties of the char table.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3551
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3552 @cindex case table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3553 @file{casetab.c} implements one sort of char table, the @dfn{case
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3554 table}, which maps characters to other characters of possibly different
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3555 case. These are used by XEmacs to implement case-changing primitives
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3556 and to do case-insensitive searching.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3557
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3558
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3559
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3560 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3561 49593 syntax.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3562 10200 syntax.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3563 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3564
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3565 @cindex scanner
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
3566 This module implements @dfn{syntax tables}, another sort of char table
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
3567 that maps characters into syntax classes that define the syntax of these
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
3568 characters (e.g. a parenthesis belongs to a class of @samp{open}
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
3569 characters that have corresponding @samp{close} characters and can be
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
3570 nested). This module also implements the Lisp @dfn{scanner}, a set of
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
3571 primitives for scanning over text based on syntax tables. This is used,
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
3572 for example, to find the matching parenthesis in a command such as
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3573 @code{forward-sexp}, and by @file{font-lock.c} to locate quoted strings,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3574 comments, etc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3575
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3576
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3577
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3578 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3579 10438 casefiddle.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3580 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3581
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3582 This module implements various Lisp primitives for upcasing, downcasing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3583 and capitalizing strings or regions of buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3584
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3585
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3586
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3587 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3588 20234 rangetab.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3589 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3590
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3591 This module implements the @dfn{range table} Lisp object type, which
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3592 provides for a mapping from ranges of integers to arbitrary Lisp
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3593 objects.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3594
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3595
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3596
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3597 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3598 3201 opaque.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3599 2206 opaque.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3600 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3601
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3602 This module implements the @dfn{opaque} Lisp object type, an
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3603 internal-only Lisp object that encapsulates an arbitrary block of memory
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3604 so that it can be managed by the Lisp allocation system. To create an
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3605 opaque object, you call @code{make_opaque()}, passing a pointer to a
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3606 block of memory. An object is created that is big enough to hold the
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3607 memory, which is copied into the object's storage. The object will then
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3608 stick around as long as you keep pointers to it, after which it will be
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3609 automatically reclaimed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3610
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3611 @cindex mark method
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3612 Opaque objects can also have an arbitrary @dfn{mark method} associated
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3613 with them, in case the block of memory contains other Lisp objects that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3614 need to be marked for garbage-collection purposes. (If you need other
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3615 object methods, such as a finalize method, you should just go ahead and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3616 create a new Lisp object type -- it's not hard.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3617
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3618
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3619
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3620 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3621 8783 abbrev.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3622 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3623
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3624 This function provides a few primitives for doing dynamic abbreviation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3625 expansion. In XEmacs, most of the code for this has been moved into
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3626 Lisp. Some C code remains for speed and because the primitive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3627 @code{self-insert-command} (which is executed for all self-inserting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3628 characters) hooks into the abbrev mechanism. (@code{self-insert-command}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3629 is itself in C only for speed.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3630
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3631
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3632
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3633 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3634 21934 doc.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3635 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3636
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3637 This function provides primitives for retrieving the documentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3638 strings of functions and variables. These documentation strings contain
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3639 certain special markers that get dynamically expanded (e.g. a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3640 reverse-lookup is performed on some named functions to retrieve their
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3641 current key bindings). Some documentation strings (in particular, for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3642 the built-in primitives and pre-loaded Lisp functions) are stored
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3643 externally in a file @file{DOC} in the @file{lib-src/} directory and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3644 need to be fetched from that file. (Part of the build stage involves
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3645 building this file, and another part involves constructing an index for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3646 this file and embedding it into the executable, so that the functions in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3647 @file{doc.c} do not have to search the entire @file{DOC} file to find
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3648 the appropriate documentation string.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3649
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3650
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3651
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3652 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3653 13197 md5.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3654 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3655
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3656 This function provides a Lisp primitive that implements the MD5 secure
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3657 hashing scheme, used to create a large hash value of a string of data such that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3658 the data cannot be derived from the hash value. This is used for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3659 various security applications on the Internet.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3660
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3661
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3662
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3663
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3664 @node Modules for Interfacing with the Operating System
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3665 @section Modules for Interfacing with the Operating System
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3666
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3667 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3668 size name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3669 ------- ---------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3670 33533 callproc.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3671 89697 process.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3672 4663 process.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3673 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3674
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3675 These modules allow XEmacs to spawn and communicate with subprocesses
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3676 and network connections.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3677
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3678 @cindex synchronous subprocesses
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3679 @cindex subprocesses, synchronous
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3680 @file{callproc.c} implements (through the @code{call-process}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3681 primitive) what are called @dfn{synchronous subprocesses}. This means
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3682 that XEmacs runs a program, waits till it's done, and retrieves its
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3683 output. A typical example might be calling the @file{ls} program to get
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3684 a directory listing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3685
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3686 @cindex asynchronous subprocesses
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3687 @cindex subprocesses, asynchronous
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3688 @file{process.c} and @file{process.h} implement @dfn{asynchronous
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3689 subprocesses}. This means that XEmacs starts a program and then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3690 continues normally, not waiting for the process to finish. Data can be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3691 sent to the process or retrieved from it as it's running. This is used
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3692 for the @code{shell} command (which provides a front end onto a shell
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3693 program such as @file{csh}), the mail and news readers implemented in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3694 XEmacs, etc. The result of calling @code{start-process} to start a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3695 subprocess is a process object, a particular kind of object used to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3696 communicate with the subprocess. You can send data to the process by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3697 passing the process object and the data to @code{send-process}, and you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3698 can specify what happens to data retrieved from the process by setting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3699 properties of the process object. (When the process sends data, XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3700 receives a process event, which says that there is data ready. When
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3701 @code{dispatch-event} is called on this event, it reads the data from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3702 the process and does something with it, as specified by the process
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3703 object's properties. Typically, this means inserting the data into a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3704 buffer or calling a function.) Another property of the process object is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3705 called the @dfn{sentinel}, which is a function that is called when the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3706 process terminates.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3707
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3708 @cindex network connections
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3709 Process objects are also used for network connections (connections to a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3710 process running on another machine). Network connections are started
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3711 with @code{open-network-stream} but otherwise work just like
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3712 subprocesses.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3713
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3714
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3715
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3716 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3717 136029 sysdep.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3718 5986 sysdep.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3719 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3720
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3721 These modules implement most of the low-level, messy operating-system
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3722 interface code. This includes various device control (ioctl) operations
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3723 for file descriptors, TTY's, pseudo-terminals, etc. (usually this stuff
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3724 is fairly system-dependent; thus the name of this module), and emulation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3725 of standard library functions and system calls on systems that don't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3726 provide them or have broken versions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3727
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3728
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3729
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3730 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3731 3605 sysdir.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3732 6708 sysfile.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3733 2027 sysfloat.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3734 2918 sysproc.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3735 745 syspwd.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3736 7643 syssignal.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3737 6892 systime.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3738 12477 systty.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3739 3487 syswait.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3740 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3741
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3742 These header files provide consistent interfaces onto system-dependent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3743 header files and system calls. The idea is that, instead of including a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3744 standard header file like @file{<sys/param.h>} (which may or may not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3745 exist on various systems) or having to worry about whether all system
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3746 provide a particular preprocessor constant, or having to deal with the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3747 four different paradigms for manipulating signals, you just include the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3748 appropriate @file{sys*.h} header file, which includes all the right
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3749 system header files, defines and missing preprocessor constants,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3750 provides a uniform interface onto system calls, etc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3751
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3752 @file{sysdir.h} provides a uniform interface onto directory-querying
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3753 functions. (In some cases, this is in conjunction with emulation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3754 functions in @file{sysdep.c}.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3755
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3756 @file{sysfile.h} includes all the necessary header files for standard
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3757 system calls (e.g. @code{read()}), ensures that all necessary
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3758 @code{open()} and @code{stat()} preprocessor constants are defined, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3759 possibly (usually) substitutes sugared versions of @code{read()},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3760 @code{write()}, etc. that automatically restart interrupted I/O
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3761 operations.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3762
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3763 @file{sysfloat.h} includes the necessary header files for floating-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3764 operations.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3765
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3766 @file{sysproc.h} includes the necessary header files for calling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3767 @code{select()}, @code{fork()}, @code{execve()}, socket operations, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3768 the like, and ensures that the @code{FD_*()} macros for descriptor-set
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3769 manipulations are available.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3770
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3771 @file{syspwd.h} includes the necessary header files for obtaining
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3772 information from @file{/etc/passwd} (the functions are emulated under
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3773 VMS).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3774
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3775 @file{syssignal.h} includes the necessary header files for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3776 signal-handling and provides a uniform interface onto the different
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3777 signal-handling and signal-blocking paradigms.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3778
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3779 @file{systime.h} includes the necessary header files and provides
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3780 uniform interfaces for retrieving the time of day, setting file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3781 access/modification times, getting the amount of time used by the XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3782 process, etc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3783
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3784 @file{systty.h} buffers against the infinitude of different ways of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3785 controlling TTY's.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3786
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3787 @file{syswait.h} provides a uniform way of retrieving the exit status
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3788 from a @code{wait()}ed-on process (some systems use a union, others use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3789 an int).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3790
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3791
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3792
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3793 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3794 7940 hpplay.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3795 10920 libsst.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3796 1480 libsst.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3797 3260 libst.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3798 15355 linuxplay.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3799 15849 nas.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3800 19133 sgiplay.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3801 15411 sound.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3802 7358 sunplay.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3803 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3804
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3805 These files implement the ability to play various sounds on some types
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3806 of computers. You have to configure your XEmacs with sound support in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3807 order to get this capability.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3808
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3809 @file{sound.c} provides the generic interface. It implements various
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3810 Lisp primitives and variables that let you specify which sounds should
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3811 be played in certain conditions. (The conditions are identified by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3812 symbols, which are passed to @code{ding} to make a sound. Various
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3813 standard functions call this function at certain times; if sound support
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3814 does not exist, a simple beep results.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3815
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3816 @cindex native sound
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3817 @cindex sound, native
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3818 @file{sgiplay.c}, @file{sunplay.c}, @file{hpplay.c}, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3819 @file{linuxplay.c} interface to the machine's speaker for various
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3820 different kind of machines. This is called @dfn{native} sound.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3821
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3822 @cindex sound, network
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3823 @cindex network sound
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3824 @cindex NAS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3825 @file{nas.c} interfaces to a computer somewhere else on the network
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3826 using the NAS (Network Audio Server) protocol, playing sounds on that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3827 machine. This allows you to run XEmacs on a remote machine, with its
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3828 display set to your local machine, and have the sounds be made on your
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3829 local machine, provided that you have a NAS server running on your local
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3830 machine.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3831
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3832 @file{libsst.c}, @file{libsst.h}, and @file{libst.h} provide some
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3833 additional functions for playing sound on a Sun SPARC but are not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3834 currently in use.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3835
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3836
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3837
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3838 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3839 44368 tooltalk.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3840 2137 tooltalk.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3841 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3842
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3843 These two modules implement an interface to the ToolTalk protocol, which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3844 is an interprocess communication protocol implemented on some versions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3845 of Unix. ToolTalk is a high-level protocol that allows processes to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3846 register themselves as providers of particular services; other processes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3847 can then request a service without knowing or caring exactly who is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3848 providing the service. It is similar in spirit to the DDE protocol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3849 provided under Microsoft Windows. ToolTalk is a part of the new CDE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3850 (Common Desktop Environment) specification and is used to connect the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3851 parts of the SPARCWorks development environment.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3852
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3853
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3854
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3855 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3856 22695 getloadavg.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3857 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3858
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3859 This module provides the ability to retrieve the system's current load
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3860 average. (The way to do this is highly system-specific, unfortunately,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3861 and requires a lot of special-case code.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3862
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3863
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3864
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3865 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3866 148520 energize.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3867 6896 energize.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3868 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3869
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3870 This module provides code to interface to an Energize server (when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3871 XEmacs is used as part of Lucid's Energize development environment) and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3872 provides some other Energize-specific functions. Much of the code in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3873 this module should be made more general-purpose and moved elsewhere, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3874 is no longer very relevant now that Lucid is defunct. It also hasn't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3875 worked since version 19.12, since nobody has been maintaining it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3876
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3877
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3878
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3879 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3880 2861 sunpro.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3881 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3882
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3883 This module provides a small amount of code used internally at Sun to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3884 keep statistics on the usage of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3885
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3886
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3887
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3888 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3889 5548 broken-sun.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3890 3468 strcmp.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3891 2179 strcpy.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3892 1650 sunOS-fix.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3893 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3894
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3895 These files provide replacement functions and prototypes to fix numerous
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3896 bugs in early releases of SunOS 4.1.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3897
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3898
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3899
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3900 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3901 11669 hftctl.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3902 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3903
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3904 This module provides some terminal-control code necessary on versions of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3905 AIX prior to 4.1.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3906
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3907
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3908
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3909 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3910 1776 acldef.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3911 1602 chpdef.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3912 9032 uaf.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3913 105 vlimit.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3914 7145 vms-pp.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3915 1158 vms-pwd.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3916 26532 vmsfns.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3917 6038 vmsmap.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3918 695 vmspaths.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3919 17482 vmsproc.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3920 469 vmsproc.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3921 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3922
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3923 All of these files are used for VMS support, which has never worked in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3924 XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3925
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3926
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3927
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3928 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3929 28316 msdos.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3930 1472 msdos.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3931 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3932
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3933 These modules are used for MS-DOS support, which does not work in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3934 XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3935
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3936
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3937
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3938 @node Modules for Interfacing with X Windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3939 @section Modules for Interfacing with X Windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3940
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3941 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3942 size name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3943 ------- ---------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3944 3196 Emacs.ad.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3945 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3946
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3947 A file generated from @file{Emacs.ad}, which contains XEmacs-supplied
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3948 fallback resources (so that XEmacs has pretty defaults).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3949
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3950
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3951
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3952 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3953 24242 EmacsFrame.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3954 6979 EmacsFrame.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3955 3351 EmacsFrameP.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3956 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3957
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3958 These modules implement an Xt widget class that encapsulates a frame.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3959 This is for ease in integrating with Xt. The EmacsFrame widget covers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3960 the entire X window except for the menubar; the scrollbars are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3961 positioned on top of the EmacsFrame widget.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3962
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3963 @strong{Warning:} Abandon hope, all ye who enter here. This code took
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3964 an ungodly amount of time to get right, and is likely to fall apart
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3965 mercilessly at the slightest change. Such is life under Xt.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3966
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3967
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3968
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3969 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3970 8178 EmacsManager.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3971 1967 EmacsManager.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3972 1895 EmacsManagerP.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3973 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3974
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3975 These modules implement a simple Xt manager (i.e. composite) widget
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3976 class that simply lets its children set whatever geometry they want.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3977 It's amazing that Xt doesn't provide this standardly, but on second
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3978 thought, it makes sense, considering how amazingly broken Xt is.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3979
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3980
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3981 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3982 13188 EmacsShell-sub.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3983 4588 EmacsShell.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3984 2180 EmacsShell.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3985 3133 EmacsShellP.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3986 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3987
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3988 These modules implement two Xt widget classes that are subclasses of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3989 the TopLevelShell and TransientShell classes. This is necessary to deal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3990 with more brokenness that Xt has sadistically thrust onto the backs of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3991 developers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3992
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3993
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3994
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3995 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3996 9673 xgccache.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3997 1111 xgccache.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3998 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3999
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4000 These modules provide functions for maintenance and caching of GC's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4001 (graphics contexts) under the X Window System. This code is junky and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4002 needs to be rewritten.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4003
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4004
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4005
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4006 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4007 69181 xselect.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4008 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4009
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4010 @cindex selections
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4011 This module provides an interface to the X Window System's concept of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4012 @dfn{selections}, the standard way for X applications to communicate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4013 with each other.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4014
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4015
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4016
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4017 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4018 929 xintrinsic.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4019 1038 xintrinsicp.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4020 1579 xmmanagerp.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4021 1585 xmprimitivep.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4022 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4023
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4024 These header files are similar in spirit to the @file{sys*.h} files and buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4025 against different implementations of Xt and Motif.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4026
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4027 @itemize @bullet
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4028 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4029 @file{xintrinsic.h} should be included in place of @file{<Intrinsic.h>}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4030 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4031 @file{xintrinsicp.h} should be included in place of @file{<IntrinsicP.h>}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4032 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4033 @file{xmmanagerp.h} should be included in place of @file{<XmManagerP.h>}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4034 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4035 @file{xmprimitivep.h} should be included in place of @file{<XmPrimitiveP.h>}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4036 @end itemize
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4037
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4038
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4039
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4040 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4041 16930 xmu.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4042 936 xmu.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4043 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4044
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4045 These files provide an emulation of the Xmu library for those systems
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4046 (i.e. HPUX) that don't provide it as a standard part of X.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4047
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4048
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4049
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4050 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4051 4201 ExternalClient-Xlib.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4052 18083 ExternalClient.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4053 2035 ExternalClient.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4054 2104 ExternalClientP.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4055 22684 ExternalShell.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4056 1709 ExternalShell.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4057 1971 ExternalShellP.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4058 2478 extw-Xlib.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4059 1481 extw-Xlib.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4060 6565 extw-Xt.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4061 1430 extw-Xt.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4062 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4063
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4064 @cindex external widget
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4065 These files provide the @dfn{external widget} interface, which allows an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4066 XEmacs frame to appear as a widget in another application. To do this,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4067 you have to configure with @samp{--external-widget}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4068
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4069 @file{ExternalShell*} provides the server (XEmacs) side of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4070 connection.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4071
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4072 @file{ExternalClient*} provides the client (other application) side of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4073 the connection. These files are not compiled into XEmacs but are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4074 compiled into libraries that are then linked into your application.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4075
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4076 @file{extw-*} is common code that is used for both the client and server.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4077
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4078 Don't touch this code; something is liable to break if you do.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4079
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4080
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4081
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4082 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4083 31014 epoch.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4084 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4085
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4086 This file provides some additional, Epoch-compatible, functionality for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4087 interfacing to the X Window System.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4088
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4089
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4090
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4091 @node Modules for Internationalization
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4092 @section Modules for Internationalization
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4093
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4094 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4095 size name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4096 ------- ---------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4097 42836 mule-canna.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4098 16737 mule-ccl.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4099 41080 mule-charset.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4100 30176 mule-charset.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4101 146844 mule-coding.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4102 16588 mule-coding.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4103 6996 mule-mcpath.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4104 2899 mule-mcpath.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4105 57158 mule-wnnfns.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4106 3351 mule.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4107 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4108
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4109 These files implement the MULE (Asian-language) support. Note that MULE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4110 actually provides a general interface for all sorts of languages, not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4111 just Asian languages (although they are generally the most complicated
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4112 to support). This code is still in beta.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4113
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4114 @file{mule-charset.*} and @file{mule-coding.*} provide the heart of the
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
4115 XEmacs MULE support. @file{mule-charset.*} implements the @dfn{charset}
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
4116 Lisp object type, which encapsulates a character set (an ordered one- or
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
4117 two-dimensional set of characters, such as US ASCII or JISX0208 Japanese
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
4118 Kanji).
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
4119
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
4120 @file{mule-coding.*} implements the @dfn{coding-system} Lisp object
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
4121 type, which encapsulates a method of converting between different
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
4122 encodings. An encoding is a representation of a stream of characters,
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
4123 possibly from multiple character sets, using a stream of bytes or words,
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
4124 and defines (e.g.) which escape sequences are used to specify particular
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
4125 character sets, how the indices for a character are converted into bytes
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
4126 (sometimes this involves setting the high bit; sometimes complicated
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
4127 rearranging of the values takes place, as in the Shift-JIS encoding),
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
4128 etc.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4129
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4130 @file{mule-ccl.c} provides the CCL (Code Conversion Language)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4131 interpreter. CCL is similar in spirit to Lisp byte code and is used to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4132 implement converters for custom encodings.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4133
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4134 @file{mule-canna.c} and @file{mule-wnnfns.c} implement interfaces to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4135 external programs used to implement the Canna and WNN input methods,
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
4136 respectively. This is currently in beta.
44
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
4137
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
4138 @file{mule-mcpath.c} provides some functions to allow for pathnames
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
4139 containing extended characters. This code is fragmentary, obsolete, and
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
4140 completely non-working. Instead, @var{pathname-coding-system} is used
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
4141 to specify conversions of names of files and directories. The standard
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
4142 C I/O functions like @samp{open()} are wrapped so that conversion occurs
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
4143 automatically.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4144
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4145 @file{mule.c} provides a few miscellaneous things that should probably
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4146 be elsewhere.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4147
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4148
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4149
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4150 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4151 9400 intl.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4152 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4153
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4154 This provides some miscellaneous internationalization code for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4155 implementing message translation and interfacing to the Ximp input
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4156 method. None of this code is currently working.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4157
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4158
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4159
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4160 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4161 1764 iso-wide.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4162 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4163
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4164 This contains leftover code from an earlier implementation of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4165 Asian-language support, and is not currently used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4166
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4167
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4168
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4169
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4170 @node Allocation of Objects in XEmacs Lisp, Events and the Event Loop, A Summary of the Various XEmacs Modules, Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4171 @chapter Allocation of Objects in XEmacs Lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4172
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4173 @menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4174 * Introduction to Allocation::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4175 * Garbage Collection::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4176 * GCPROing::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4177 * Integers and Characters::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4178 * Allocation from Frob Blocks::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4179 * lrecords::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4180 * Low-level allocation::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4181 * Pure Space::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4182 * Cons::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4183 * Vector::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4184 * Bit Vector::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4185 * Symbol::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4186 * Marker::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4187 * String::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4188 * Bytecode::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4189 @end menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4190
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4191 @node Introduction to Allocation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4192 @section Introduction to Allocation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4193
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4194 Emacs Lisp, like all Lisps, has garbage collection. This means that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4195 the programmer never has to explicitly free (destroy) an object; it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4196 happens automatically when the object becomes inaccessible. Most
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4197 experts agree that garbage collection is a necessity in a modern,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4198 high-level language. Its omission from C stems from the fact that C was
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4199 originally designed to be a nice abstract layer on top of assembly
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4200 language, for writing kernels and basic system utilities rather than
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4201 large applications.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4202
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4203 Lisp objects can be created by any of a number of Lisp primitives.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4204 Most object types have one or a small number of basic primitives
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4205 for creating objects. For conses, the basic primitive is @code{cons};
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4206 for vectors, the primitives are @code{make-vector} and @code{vector}; for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4207 symbols, the primitives are @code{make-symbol} and @code{intern}; etc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4208 Some Lisp objects, especially those that are primarily used internally,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4209 have no corresponding Lisp primitives. Every Lisp object, though,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4210 has at least one C primitive for creating it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4211
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4212 Recall from section (VII) that a Lisp object, as stored in a 32-bit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4213 or 64-bit word, has a mark bit, a few tag bits, and a ``value'' that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4214 occupies the remainder of the bits. We can separate the different
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4215 Lisp object types into four broad categories:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4216
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4217 @itemize @bullet
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4218 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4219 (a) Those for whom the value directly represents the contents of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4220 Lisp object. Only two types are in this category: integers and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4221 characters. No special allocation or garbage collection is necessary
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
4222 for such objects. Lisp objects of these types do not need to be
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
4223 @code{GCPRO}ed.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4224 @end itemize
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4225
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4226 In the remaining three categories, the value is a pointer to a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4227 structure.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4228
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4229 @itemize @bullet
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4230 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4231 @cindex frob block
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4232 (b) Those for whom the tag directly specifies the type. Recall that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4233 there are only three tag bits; this means that at most five types can be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4234 specified this way. The most commonly-used types are stored in this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4235 format; this includes conses, strings, vectors, and sometimes symbols.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4236 With the exception of vectors, objects in this category are allocated in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4237 @dfn{frob blocks}, i.e. large blocks of memory that are subdivided into
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4238 individual objects. This saves a lot on malloc overhead, since there
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4239 are typically quite a lot of these objects around, and the objects are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4240 small. (A cons, for example, occupies 8 bytes on 32-bit machines -- 4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4241 bytes for each of the two objects it contains.) Vectors are individually
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4242 @code{malloc()}ed since they are of variable size. (It would be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4243 possible, and desirable, to allocate vectors of certain small sizes out
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4244 of frob blocks, but it isn't currently done.) Strings are handled
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4245 specially: Each string is allocated in two parts, a fixed size structure
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4246 containing a length and a data pointer, and the actual data of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4247 string. The former structure is allocated in frob blocks as usual, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4248 the latter data is stored in @dfn{string chars blocks} and is relocated
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4249 during garbage collection to eliminate holes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4250 @end itemize
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4251
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4252 In the remaining two categories, the type is stored in the object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4253 itself. The tag for all such objects is the generic @dfn{lrecord}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4254 (Lisp_Record) tag. The first four bytes (or eight, for 64-bit machines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4255 of the object's structure are a pointer to a structure that describes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4256 the object's type, which includes method pointers and a pointer to a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4257 string naming the type. Note that it's possible to save some space by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4258 using a one- or two-byte tag, rather than a four- or eight-byte pointer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4259 to store the type, but it's not clear it's worth making the change.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4260
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4261 @itemize @bullet
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4262 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4263 (c) Those lrecords that are allocated in frob blocks (see above). This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4264 includes the objects that are most common and relatively small, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4265 includes floats, bytecodes, symbols (when not in category (b)), extents,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4266 events, and markers. With the cleanup of frob blocks done in 19.12,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4267 it's not terribly hard to add more objects to this category, but it's a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4268 bit trickier than adding an object type to type (d) (esp. if the object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4269 needs a finalization method), and is not likely to save much space
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4270 unless the object is small and there are many of them. (In fact, if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4271 there are very few of them, it might actually waste space.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4272 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4273 (d) Those lrecords that are individually @code{malloc()}ed. These are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4274 called @dfn{lcrecords}. All other types are in this category. Adding a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4275 new type to this category is comparatively easy, and all types added
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4276 since 19.8 (when the current allocation scheme was devised, by Richard
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4277 Mlynarik), with the exception of the character type, have been in this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4278 category.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4279 @end itemize
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4280
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4281 Note that bit vectors are a bit of a special case. They are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4282 simple lrecords as in category (c), but are individually @code{malloc()}ed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4283 like vectors. You can basically view them as exactly like vectors
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4284 except that their type is stored in lrecord fashion rather than
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4285 in directly-tagged fashion.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4286
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4287 Note that FSF Emacs redesigned their object system in 19.29 to follow
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4288 a similar scheme. However, given RMS's expressed dislike for data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4289 abstraction, the FSF scheme is not nearly as clean or as easy to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4290 extend. (FSF calls items of type (c) @code{Lisp_Misc} and items of type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4291 (d) @code{Lisp_Vectorlike}, with separate tags for each, although
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4292 @code{Lisp_Vectorlike} is also used for vectors.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4293
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4294 @node Garbage Collection
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4295 @section Garbage Collection
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4296 @cindex garbage collection
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4297
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4298 @cindex mark and sweep
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4299 Garbage collection is simple in theory but tricky to implement.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4300 Emacs Lisp uses the oldest garbage collection method, called
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4301 @dfn{mark and sweep}. Garbage collection begins by starting with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4302 all accessible locations (i.e. all variables and other slots where
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4303 Lisp objects might occur) and recursively traversing all objects
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4304 accessible from those slots, marking each one that is found.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4305 We then go through all of memory and free each object that is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4306 not marked, and unmarking each object that is marked. Note
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4307 that ``all of memory'' means all currently allocated objects.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4308 Traversing all these objects means traversing all frob blocks,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4309 all vectors (which are chained in one big list), and all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4310 lcrecords (which are likewise chained).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4311
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4312 Note that, when an object is marked, the mark has to occur
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4313 inside of the object's structure, rather than in the 32-bit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4314 @code{Lisp_Object} holding the object's pointer; i.e. you can't just
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4315 set the pointer's mark bit. This is because there may be many
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4316 pointers to the same object. This means that the method of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4317 marking an object can differ depending on the type. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4318 different marking methods are approximately as follows:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4319
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4320 @enumerate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4321 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4322 For conses, the mark bit of the car is set.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4323 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4324 For strings, the mark bit of the string's plist is set.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4325 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4326 For symbols when not lrecords, the mark bit of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4327 symbol's plist is set.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4328 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4329 For vectors, the length is negated after adding 1.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4330 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4331 For lrecords, the pointer to the structure describing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4332 the type is changed (see below).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4333 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4334 Integers and characters do not need to be marked, since
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4335 no allocation occurs for them.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4336 @end enumerate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4337
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4338 The details of this are in the @code{mark_object()} function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4339
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4340 Note that any code that operates during garbage collection has
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4341 to be especially careful because of the fact that some objects
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4342 may be marked and as such may not look like they normally do.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4343 In particular:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4344
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4345 @itemize @bullet
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4346 Some object pointers may have their mark bit set. This will make
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4347 @code{FOOBARP()} predicates fail. Use @code{GC_FOOBARP()} to deal with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4348 this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4349 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4350 Even if you clear the mark bit, @code{FOOBARP()} will still fail
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4351 for lrecords because the implementation pointer has been
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4352 changed (see below). @code{GC_FOOBARP()} will correctly deal with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4353 this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4354 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4355 Vectors have their size field munged, so anything that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4356 looks at this field will fail.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4357 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4358 Note that @code{XFOOBAR()} macros @emph{will} work correctly on object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4359 pointers with their mark bit set, because the logical shift operations
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4360 that remove the tag also remove the mark bit.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4361 @end itemize
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4362
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4363 Finally, note that garbage collection can be invoked explicitly
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4364 by calling @code{garbage-collect} but is also called automatically
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4365 by @code{eval}, once a certain amount of memory has been allocated
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4366 since the last garbage collection (according to @code{gc-cons-threshold}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4367
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4368 @node GCPROing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4369 @section @code{GCPRO}ing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4370
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4371 @code{GCPRO}ing is one of the ugliest and trickiest parts of Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4372 internals. The basic idea is that whenever garbage collection
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4373 occurs, all in-use objects must be reachable somehow or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4374 other from one of the roots of accessibility. The roots
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4375 of accessibility are:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4376
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4377 @enumerate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4378 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4379 All objects that have been @code{staticpro()}d. This is used for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4380 any global C variables that hold Lisp objects. A call to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4381 @code{staticpro()} happens implicitly as a result of any symbols
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4382 declared with @code{defsymbol()} and any variables declared with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4383 @code{DEFVAR_FOO()}. You need to explicitly call @code{staticpro()}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4384 (in the @code{vars_of_foo()} method of a module) for other global
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4385 C variables holding Lisp objects. (This typically includes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4386 internal lists and such things.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4387
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4388 Note that @code{obarray} is one of the @code{staticpro()}d things.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4389 Therefore, all functions and variables get marked through this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4390 @item
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 265
diff changeset
4391 Any shadowed bindings that are sitting on the @code{specpdl} stack.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4392 @item
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
4393 Any objects sitting in currently active (Lisp) stack frames,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4394 catches, and condition cases.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4395 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4396 A couple of special-case places where active objects are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4397 located.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4398 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4399 Anything currently marked with @code{GCPRO}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4400 @end enumerate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4401
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4402 Marking with @code{GCPRO} is necessary because some C functions (quite
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4403 a lot, in fact), allocate objects during their operation. Quite
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4404 frequently, there will be no other pointer to the object while the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4405 function is running, and if a garbage collection occurs and the object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4406 needs to be referenced again, bad things will happen. The solution is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4407 to mark those objects with @code{GCPRO}. Unfortunately this is easy to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4408 forget, and there is basically no way around this problem. Here are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4409 some rules, though:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4410
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4411 @enumerate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4412 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4413 For every @code{GCPRO@var{n}}, there have to be declarations of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4414 @code{struct gcpro gcpro1, gcpro2}, etc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4415
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4416 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4417 You @emph{must} @code{UNGCPRO} anything that's @code{GCPRO}ed, and you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4418 @emph{must not} @code{UNGCPRO} if you haven't @code{GCPRO}ed. Getting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4419 either of these wrong will lead to crashes, often in completely random
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4420 places unrelated to where the problem lies.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4421
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4422 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4423 The way this actually works is that all currently active @code{GCPRO}s
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4424 are chained through the @code{struct gcpro} local variables, with the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4425 variable @samp{gcprolist} pointing to the head of the list and the nth
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4426 local @code{gcpro} variable pointing to the first @code{gcpro} variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4427 in the next enclosing stack frame. Each @code{GCPRO}ed thing is an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4428 lvalue, and the @code{struct gcpro} local variable contains a pointer to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4429 this lvalue. This is why things will mess up badly if you don't pair up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4430 the @code{GCPRO}s and @code{UNGCPRO}s -- you will end up with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4431 @code{gcprolist}s containing pointers to @code{struct gcpro}s or local
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4432 @code{Lisp_Object} variables in no-longer-active stack frames.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4433
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4434 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4435 It is actually possible for a single @code{struct gcpro} to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4436 protect a contiguous array of any number of values, rather than
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4437 just a single lvalue. To effect this, call @code{GCPRO@var{n}} as usual on
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 265
diff changeset
4438 the first object in the array and then set @code{gcpro@var{n}.nvars}.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4439
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4440 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4441 @strong{Strings are relocated.} What this means in practice is that the
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
4442 pointer obtained using @code{XSTRING_DATA()} is liable to change at any
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4443 time, and you should never keep it around past any function call, or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4444 pass it as an argument to any function that might cause a garbage
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4445 collection. This is why a number of functions accept either a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4446 ``non-relocatable'' @code{char *} pointer or a relocatable Lisp string,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4447 and only access the Lisp string's data at the very last minute. In some
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4448 cases, you may end up having to @code{alloca()} some space and copy the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4449 string's data into it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4450
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4451 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4452 By convention, if you have to nest @code{GCPRO}'s, use @code{NGCPRO@var{n}}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4453 (along with @code{struct gcpro ngcpro1, ngcpro2}, etc.), @code{NNGCPRO@var{n}},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4454 etc. This avoids compiler warnings about shadowed locals.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4455
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4456 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4457 It is @emph{always} better to err on the side of extra @code{GCPRO}s
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4458 rather than too few. The extra cycles spent on this are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4459 almost never going to make a whit of difference in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4460 speed of anything.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4461
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4462 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4463 The general rule to follow is that caller, not callee, @code{GCPRO}s.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4464 That is, you should not have to explicitly @code{GCPRO} any Lisp objects
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents: 259
diff changeset
4465 that are passed in as parameters.
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents: 259
diff changeset
4466
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents: 259
diff changeset
4467 One exception from this rule is if you ever plan to change the parameter
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents: 259
diff changeset
4468 value, and store a new object in it. In that case, you @emph{must}
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents: 259
diff changeset
4469 @code{GCPRO} the parameter, because otherwise the new object will not be
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents: 259
diff changeset
4470 protected.
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents: 259
diff changeset
4471
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents: 259
diff changeset
4472 So, if you create any Lisp objects (remember, this happens in all sorts
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents: 259
diff changeset
4473 of circumstances, e.g. with @code{Fcons()}, etc.), you are responsible
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents: 259
diff changeset
4474 for @code{GCPRO}ing them, unless you are @emph{absolutely sure} that
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents: 259
diff changeset
4475 there's no possibility that a garbage-collection can occur while you
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents: 259
diff changeset
4476 need to use the object. Even then, consider @code{GCPRO}ing.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4477
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4478 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4479 A garbage collection can occur whenever anything calls @code{Feval}, or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4480 whenever a QUIT can occur where execution can continue past
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4481 this. (Remember, this is almost anywhere.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4482
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4483 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4484 If you have the @emph{least smidgeon of doubt} about whether
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4485 you need to @code{GCPRO}, you should @code{GCPRO}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4486
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4487 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4488 Beware of @code{GCPRO}ing something that is uninitialized. If you have
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
4489 any shade of doubt about this, initialize all your variables to @code{Qnil}.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4490
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4491 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4492 Be careful of traps, like calling @code{Fcons()} in the argument to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4493 another function. By the ``caller protects'' law, you should be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4494 @code{GCPRO}ing the newly-created cons, but you aren't. A certain
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4495 number of functions that are commonly called on freshly created stuff
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4496 (e.g. @code{nconc2()}, @code{Fsignal()}), break the ``caller protects''
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4497 law and go ahead and @code{GCPRO} their arguments so as to simplify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4498 things, but make sure and check if it's OK whenever doing something like
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4499 this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4500
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4501 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4502 Once again, remember to @code{GCPRO}! Bugs resulting from insufficient
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4503 @code{GCPRO}ing are intermittent and extremely difficult to track down,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4504 often showing up in crashes inside of @code{garbage-collect} or in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4505 weirdly corrupted objects or even in incorrect values in a totally
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4506 different section of code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4507 @end enumerate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4508
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4509 @cindex garbage collection, conservative
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4510 @cindex conservative garbage collection
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4511 Given the extremely error-prone nature of the @code{GCPRO} scheme, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4512 the difficulties in tracking down, it should be considered a deficiency
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4513 in the XEmacs code. A solution to this problem would involve
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4514 implementing so-called @dfn{conservative} garbage collection for the C
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4515 stack. That involves looking through all of stack memory and treating
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4516 anything that looks like a reference to an object as a reference. This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4517 will result in a few objects not getting collected when they should, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4518 it obviates the need for @code{GCPRO}ing, and allows garbage collection
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4519 to happen at any point at all, such as during object allocation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4520
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4521 @node Integers and Characters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4522 @section Integers and Characters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4523
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4524 Integer and character Lisp objects are created from integers using the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4525 macros @code{XSETINT()} and @code{XSETCHAR()} or the equivalent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4526 functions @code{make_int()} and @code{make_char()}. (These are actually
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4527 macros on most systems.) These functions basically just do some moving
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4528 of bits around, since the integral value of the object is stored
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4529 directly in the @code{Lisp_Object}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4530
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4531 @code{XSETINT()} and the like will truncate values given to them that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4532 are too big; i.e. you won't get the value you expected but the tag bits
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4533 will at least be correct.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4534
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4535 @node Allocation from Frob Blocks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4536 @section Allocation from Frob Blocks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4537
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4538 The uninitialized memory required by a @code{Lisp_Object} of a particular type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4539 is allocated using
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4540 @code{ALLOCATE_FIXED_TYPE()}. This only occurs inside of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4541 lowest-level object-creating functions in @file{alloc.c}:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4542 @code{Fcons()}, @code{make_float()}, @code{Fmake_byte_code()},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4543 @code{Fmake_symbol()}, @code{allocate_extent()},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4544 @code{allocate_event()}, @code{Fmake_marker()}, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4545 @code{make_uninit_string()}. The idea is that, for each type, there are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4546 a number of frob blocks (each 2K in size); each frob block is divided up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4547 into object-sized chunks. Each frob block will have some of these
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4548 chunks that are currently assigned to objects, and perhaps some that are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4549 free. (If a frob block has nothing but free chunks, it is freed at the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4550 end of the garbage collection cycle.) The free chunks are stored in a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4551 free list, which is chained by storing a pointer in the first four bytes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4552 of the chunk. (Except for the free chunks at the end of the last frob
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4553 block, which are handled using an index which points past the end of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4554 last-allocated chunk in the last frob block.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4555 @code{ALLOCATE_FIXED_TYPE()} first tries to retrieve a chunk from the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4556 free list; if that fails, it calls
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4557 @code{ALLOCATE_FIXED_TYPE_FROM_BLOCK()}, which looks at the end of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4558 last frob block for space, and creates a new frob block if there is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4559 none. (There are actually two versions of these macros, one of which is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4560 more defensive but less efficient and is used for error-checking.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4561
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4562 @node lrecords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4563 @section lrecords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4564
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4565 [see @file{lrecord.h}]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4566
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4567 All lrecords have at the beginning of their structure a @code{struct
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4568 lrecord_header}. This just contains a pointer to a @code{struct
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4569 lrecord_implementation}, which is a structure containing method pointers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4570 and such. There is one of these for each type, and it is a global,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4571 constant, statically-declared structure that is declared in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4572 @code{DEFINE_LRECORD_IMPLEMENTATION()} macro. (This macro actually
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4573 declares an array of two @code{struct lrecord_implementation}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4574 structures. The first one contains all the standard method pointers,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4575 and is used in all normal circumstances. During garbage collection,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4576 however, the lrecord is @dfn{marked} by bumping its implementation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4577 pointer by one, so that it points to the second structure in the array.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4578 This structure contains a special indication in it that it's a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4579 @dfn{marked-object} structure: the finalize method is the special
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4580 function @code{this_marks_a_marked_record()}, and all other methods are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4581 null pointers. At the end of garbage collection, all lrecords will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4582 either be reclaimed or unmarked by decrementing their implementation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4583 pointers, so this second structure pointer will never remain past
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4584 garbage collection.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4585
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4586 Simple lrecords (of type (c) above) just have a @code{struct
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4587 lrecord_header} at their beginning. lcrecords, however, actually have a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4588 @code{struct lcrecord_header}. This, in turn, has a @code{struct
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4589 lrecord_header} at its beginning, so sanity is preserved; but it also
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
4590 has a pointer used to chain all lcrecords together, and a special ID
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4591 field used to distinguish one lcrecord from another. (This field is used
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4592 only for debugging and could be removed, but the space gain is not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4593 significant.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4594
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4595 Simple lrecords are created using @code{ALLOCATE_FIXED_TYPE()}, just
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4596 like for other frob blocks. The only change is that the implementation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4597 pointer must be initialized correctly. (The implementation structure for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4598 an lrecord, or rather the pointer to it, is named @code{lrecord_float},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4599 @code{lrecord_extent}, @code{lrecord_buffer}, etc.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4600
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4601 lcrecords are created using @code{alloc_lcrecord()}. This takes a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4602 size to allocate and an implementation pointer. (The size needs to be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4603 passed because some lcrecords, such as window configurations, are of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4604 variable size.) This basically just @code{malloc()}s the storage,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4605 initializes the @code{struct lcrecord_header}, and chains the lcrecord
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4606 onto the head of the list of all lcrecords, which is stored in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4607 variable @code{all_lcrecords}. The calls to @code{alloc_lcrecord()}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4608 generally occur in the lowest-level allocation function for each lrecord
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4609 type.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4610
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4611 Whenever you create an lrecord, you need to call either
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4612 @code{DEFINE_LRECORD_IMPLEMENTATION()} or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4613 @code{DEFINE_LRECORD_SEQUENCE_IMPLEMENTATION()}. This needs to be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4614 specified in a C file, at the top level. What this actually does is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4615 define and initialize the implementation structure for the lrecord. (And
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4616 possibly declares a function @code{error_check_foo()} that implements
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4617 the @code{XFOO()} macro when error-checking is enabled.) The arguments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4618 to the macros are the actual type name (this is used to construct the C
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4619 variable name of the lrecord implementation structure and related
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4620 structures using the @samp{##} macro concatenation operator), a string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4621 that names the type on the Lisp level (this may not be the same as the C
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4622 type name; typically, the C type name has underscores, while the Lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4623 string has dashes), various method pointers, and the name of the C
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4624 structure that contains the object. The methods are used to encapsulate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4625 type-specific information about the object, such as how to print it or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4626 mark it for garbage collection, so that it's easy to add new object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4627 types without having to add a specific case for each new type in a bunch
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4628 of different places.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4629
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4630 The difference between @code{DEFINE_LRECORD_IMPLEMENTATION()} and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4631 @code{DEFINE_LRECORD_SEQUENCE_IMPLEMENTATION()} is that the former is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4632 used for fixed-size object types and the latter is for variable-size
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4633 object types. Most object types are fixed-size; some complex
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4634 types, however (e.g. window configurations), are variable-size.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4635 Variable-size object types have an extra method, which is called
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4636 to determine the actual size of a particular object of that type.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4637 (Currently this is only used for keeping allocation statistics.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4638
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4639 For the purpose of keeping allocation statistics, the allocation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4640 engine keeps a list of all the different types that exist. Note that,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4641 since @code{DEFINE_LRECORD_IMPLEMENTATION()} is a macro that is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4642 specified at top-level, there is no way for it to add to the list of all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4643 existing types. What happens instead is that each implementation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4644 structure contains in it a dynamically assigned number that is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4645 particular to that type. (Or rather, it contains a pointer to another
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4646 structure that contains this number. This evasiveness is done so that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4647 the implementation structure can be declared const.) In the sweep stage
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4648 of garbage collection, each lrecord is examined to see if its
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4649 implementation structure has its dynamically-assigned number set. If
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4650 not, it must be a new type, and it is added to the list of known types
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4651 and a new number assigned. The number is used to index into an array
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4652 holding the number of objects of each type and the total memory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4653 allocated for objects of that type. The statistics in this array are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4654 also computed during the sweep stage. These statistics are returned by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4655 the call to @code{garbage-collect} and are printed out at the end of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4656 loadup phase.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4657
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4658 Note that for every type defined with a @code{DEFINE_LRECORD_*()}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4659 macro, there needs to be a @code{DECLARE_LRECORD_IMPLEMENTATION()}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4660 somewhere in a @file{.h} file, and this @file{.h} file needs to be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4661 included by @file{inline.c}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4662
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4663 Furthermore, there should generally be a set of @code{XFOOBAR()},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4664 @code{FOOBARP()}, etc. macros in a @file{.h} (or occasionally @file{.c})
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4665 file. To create one of these, copy an existing model and modify as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4666 necessary.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4667
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4668 The various methods in the lrecord implementation structure are:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4669
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4670 @enumerate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4671 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4672 @cindex mark method
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4673 A @dfn{mark} method. This is called during the marking stage and passed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4674 a function pointer (usually the @code{mark_object()} function), which is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4675 used to mark an object. All Lisp objects that are contained within the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4676 object need to be marked by applying this function to them. The mark
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4677 method should also return a Lisp object, which should be either nil or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4678 an object to mark. (This can be used in lieu of calling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4679 @code{mark_object()} on the object, to reduce the recursion depth, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4680 consequently should be the most heavily nested sub-object, such as a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4681 long list.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4682
298
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 282
diff changeset
4683 @strong{Please note:} When the mark method is called, garbage collection
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 282
diff changeset
4684 is in progress, and special precautions need to be taken when accessing
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 282
diff changeset
4685 objects; see section (B) above.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4686
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4687 If your mark method does not need to do anything, it can be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4688 @code{NULL}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4689
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4690 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4691 A @dfn{print} method. This is called to create a printed representation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4692 of the object, whenever @code{princ}, @code{prin1}, or the like is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4693 called. It is passed the object, a stream to which the output is to be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4694 directed, and an @code{escapeflag} which indicates whether the object's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4695 printed representation should be @dfn{escaped} so that it is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4696 readable. (This corresponds to the difference between @code{princ} and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4697 @code{prin1}.) Basically, @dfn{escaped} means that strings will have
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4698 quotes around them and confusing characters in the strings such as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4699 quotes, backslashes, and newlines will be backslashed; and that special
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4700 care will be taken to make symbols print in a readable fashion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4701 (e.g. symbols that look like numbers will be backslashed). Other
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4702 readable objects should perhaps pass @code{escapeflag} on when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4703 sub-objects are printed, so that readability is preserved when necessary
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4704 (or if not, always pass in a 1 for @code{escapeflag}). Non-readable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4705 objects should in general ignore @code{escapeflag}, except that some use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4706 it as an indication that more verbose output should be given.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4707
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4708 Sub-objects are printed using @code{print_internal()}, which takes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4709 exactly the same arguments as are passed to the print method.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4710
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4711 Literal C strings should be printed using @code{write_c_string()},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4712 or @code{write_string_1()} for non-null-terminated strings.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4713
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4714 Functions that do not have a readable representation should check the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4715 @code{print_readably} flag and signal an error if it is set.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4716
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4717 If you specify NULL for the print method, the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4718 @code{default_object_printer()} will be used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4719
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4720 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4721 A @dfn{finalize} method. This is called at the beginning of the sweep
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4722 stage on lcrecords that are about to be freed, and should be used to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4723 perform any extra object cleanup. This typically involves freeing any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4724 extra @code{malloc()}ed memory associated with the object, releasing any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4725 operating-system and window-system resources associated with the object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4726 (e.g. pixmaps, fonts), etc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4727
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4728 The finalize method can be NULL if nothing needs to be done.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4729
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4730 WARNING #1: The finalize method is also called at the end of the dump
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4731 phase; this time with the for_disksave parameter set to non-zero. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4732 object is @emph{not} about to disappear, so you have to make sure to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4733 @emph{not} free any extra @code{malloc()}ed memory if you're going to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4734 need it later. (Also, signal an error if there are any operating-system
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4735 and window-system resources here, because they can't be dumped.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4736
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4737 Finalize methods should, as a rule, set to zero any pointers after
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4738 they've been freed, and check to make sure pointers are not zero before
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4739 freeing. Although I'm pretty sure that finalize methods are not called
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4740 twice on the same object (except for the @code{for_disksave} proviso),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4741 we've gotten nastily burned in some cases by not doing this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4742
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4743 WARNING #2: The finalize method is @emph{only} called for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4744 lcrecords, @emph{not} for simply lrecords. If you need a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4745 finalize method for simple lrecords, you have to stick
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4746 it in the @code{ADDITIONAL_FREE_foo()} macro in @file{alloc.c}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4747
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4748 WARNING #3: Things are in an @emph{extremely} bizarre state
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4749 when @code{ADDITIONAL_FREE_foo()} is called, so you have to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4750 be incredibly careful when writing one of these functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4751 See the comment in @code{gc_sweep()}. If you ever have to add
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4752 one of these, consider using an lcrecord or dealing with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4753 the problem in a different fashion.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4754
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4755 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4756 An @dfn{equal} method. This compares the two objects for similarity,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4757 when @code{equal} is called. It should compare the contents of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4758 objects in some reasonable fashion. It is passed the two objects and a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4759 @dfn{depth} value, which is used to catch circular objects. To compare
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4760 sub-Lisp-objects, call @code{internal_equal()} and bump the depth value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4761 by one. If this value gets too high, a @code{circular-object} error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4762 will be signaled.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4763
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4764 If this is NULL, objects are @code{equal} only when they are @code{eq},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4765 i.e. identical.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4766
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4767 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4768 A @dfn{hash} method. This is used to hash objects when they are to be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4769 compared with @code{equal}. The rule here is that if two objects are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4770 @code{equal}, they @emph{must} hash to the same value; i.e. your hash
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4771 function should use some subset of the sub-fields of the object that are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4772 compared in the ``equal'' method. If you specify this method as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4773 @code{NULL}, the object's pointer will be used as the hash, which will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4774 @emph{fail} if the object has an @code{equal} method, so don't do this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4775
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4776 To hash a sub-Lisp-object, call @code{internal_hash()}. Bump the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4777 depth by one, just like in the ``equal'' method.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4778
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4779 To convert a Lisp object directly into a hash value (using
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4780 its pointer), use @code{LISP_HASH()}. This is what happens when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4781 the hash method is NULL.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4782
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4783 To hash two or more values together into a single value, use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4784 @code{HASH2()}, @code{HASH3()}, @code{HASH4()}, etc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4785
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4786 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4787 @dfn{getprop}, @dfn{putprop}, @dfn{remprop}, and @dfn{plist} methods.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4788 These are used for object types that have properties. I don't feel like
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4789 documenting them here. If you create one of these objects, you have to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4790 use different macros to define them,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4791 i.e. @code{DEFINE_LRECORD_IMPLEMENTATION_WITH_PROPS()} or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4792 @code{DEFINE_LRECORD_SEQUENCE_IMPLEMENTATION_WITH_PROPS()}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4793
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4794 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4795 A @dfn{size_in_bytes} method, when the object is of variable-size.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4796 (i.e. declared with a @code{_SEQUENCE_IMPLEMENTATION} macro.) This should
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4797 simply return the object's size in bytes, exactly as you might expect.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4798 For an example, see the methods for window configurations and opaques.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4799 @end enumerate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4800
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4801 @node Low-level allocation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4802 @section Low-level allocation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4803
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4804 Memory that you want to allocate directly should be allocated using
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4805 @code{xmalloc()} rather than @code{malloc()}. This implements
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4806 error-checking on the return value, and once upon a time did some more
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4807 vital stuff (i.e. @code{BLOCK_INPUT}, which is no longer necessary).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4808 Free using @code{xfree()}, and realloc using @code{xrealloc()}. Note
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4809 that @code{xmalloc()} will do a non-local exit if the memory can't be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4810 allocated. (Many functions, however, do not expect this, and thus XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4811 will likely crash if this happens. @strong{This is a bug.} If you can,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4812 you should strive to make your function handle this OK. However, it's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4813 difficult in the general circumstance, perhaps requiring extra
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4814 unwind-protects and such.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4815
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4816 Note that XEmacs provides two separate replacements for the standard
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4817 @code{malloc()} library function. These are called @dfn{old GNU malloc}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4818 (@file{malloc.c}) and @dfn{new GNU malloc} (@file{gmalloc.c}),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4819 respectively. New GNU malloc is better in pretty much every way than
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4820 old GNU malloc, and should be used if possible. (It used to be that on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4821 some systems, the old one worked but the new one didn't. I think this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4822 was due specifically to a bug in SunOS, which the new one now works
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4823 around; so I don't think the old one ever has to be used any more.) The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4824 primary difference between both of these mallocs and the standard system
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4825 malloc is that they are much faster, at the expense of increased space.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4826 The basic idea is that memory is allocated in fixed chunks of powers of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4827 two. This allows for basically constant malloc time, since the various
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4828 chunks can just be kept on a number of free lists. (The standard system
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4829 malloc typically allocates arbitrary-sized chunks and has to spend some
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4830 time, sometimes a significant amount of time, walking the heap looking
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4831 for a free block to use and cleaning things up.) The new GNU malloc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4832 improves on things by allocating large objects in chunks of 4096 bytes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4833 rather than in ever larger powers of two, which results in ever larger
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4834 wastage. There is a slight speed loss here, but it's of doubtful
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4835 significance.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4836
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4837 NOTE: Apparently there is a third-generation GNU malloc that is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4838 significantly better than the new GNU malloc, and should probably
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4839 be included in XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4840
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4841 There is also the relocating allocator, @file{ralloc.c}. This actually
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4842 moves blocks of memory around so that the @code{sbrk()} pointer shrunk
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4843 and virtual memory released back to the system. On some systems,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4844 this is a big win. On all systems, it causes a noticeable (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4845 sometimes huge) speed penalty, so I turn it off by default.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4846 @file{ralloc.c} only works with the new GNU malloc in @file{gmalloc.c}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4847 There are also two versions of @file{ralloc.c}, one that uses @code{mmap()}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4848 rather than block copies to move data around. This purports to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4849 be faster, although that depends on the amount of data that would
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4850 have had to be block copied and the system-call overhead for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4851 @code{mmap()}. I don't know exactly how this works, except that the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4852 relocating-allocation routines are pretty much used only for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4853 the memory allocated for a buffer, which is the biggest consumer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4854 of space, esp. of space that may get freed later.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4855
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4856 Note that the GNU mallocs have some ``memory warning'' facilities.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4857 XEmacs taps into them and issues a warning through the standard
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4858 warning system, when memory gets to 75%, 85%, and 95% full.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4859 (On some systems, the memory warnings are not functional.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4860
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4861 Allocated memory that is going to be used to make a Lisp object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4862 is created using @code{allocate_lisp_storage()}. This calls @code{xmalloc()}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4863 but also verifies that the pointer to the memory can fit into
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4864 a Lisp word (remember that some bits are taken away for a type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4865 tag and a mark bit). If not, an error is issued through @code{memory_full()}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4866 @code{allocate_lisp_storage()} is called by @code{alloc_lcrecord()},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4867 @code{ALLOCATE_FIXED_TYPE()}, and the vector and bit-vector creation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4868 routines. These routines also call @code{INCREMENT_CONS_COUNTER()} at the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4869 appropriate times; this keeps statistics on how much memory is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4870 allocated, so that garbage-collection can be invoked when the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4871 threshold is reached.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4872
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4873 @node Pure Space
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4874 @section Pure Space
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4875
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4876 Not yet documented.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4877
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4878 @node Cons
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4879 @section Cons
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4880
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4881 Conses are allocated in standard frob blocks. The only thing to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4882 note is that conses can be explicitly freed using @code{free_cons()}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4883 and associated functions @code{free_list()} and @code{free_alist()}. This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4884 immediately puts the conses onto the cons free list, and decrements
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4885 the statistics on memory allocation appropriately. This is used
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4886 to good effect by some extremely commonly-used code, to avoid
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4887 generating extra objects and thereby triggering GC sooner.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4888 However, you have to be @emph{extremely} careful when doing this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4889 If you mess this up, you will get BADLY BURNED, and it has happened
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4890 before.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4891
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4892 @node Vector
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4893 @section Vector
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4894
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4895 As mentioned above, each vector is @code{malloc()}ed individually, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4896 all are threaded through the variable @code{all_vectors}. Vectors are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4897 marked strangely during garbage collection, by kludging the size field.
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
4898 Note that the @code{struct Lisp_Vector} is declared with its
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
4899 @code{contents} field being a @emph{stretchy} array of one element. It
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
4900 is actually @code{malloc()}ed with the right size, however, and access
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
4901 to any element through the @code{contents} array works fine.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4902
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4903 @node Bit Vector
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4904 @section Bit Vector
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4905
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4906 Bit vectors work exactly like vectors, except for more complicated
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4907 code to access an individual bit, and except for the fact that bit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4908 vectors are lrecords while vectors are not. (The only difference here is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4909 that there's an lrecord implementation pointer at the beginning and the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4910 tag field in bit vector Lisp words is ``lrecord'' rather than
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4911 ``vector''.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4912
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4913 @node Symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4914 @section Symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4915
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4916 Symbols are also allocated in frob blocks. Note that the code
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4917 exists for symbols to be either lrecords (category (c) above)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4918 or simple types (category (b) above), and are lrecords by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4919 default (I think), although there is no good reason for this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4920
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4921 Note that symbols in the awful horrible obarray structure are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4922 chained through their @code{next} field.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4923
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4924 Remember that @code{intern} looks up a symbol in an obarray, creating
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4925 one if necessary.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4926
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4927 @node Marker
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4928 @section Marker
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4929
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4930 Markers are allocated in frob blocks, as usual. They are kept
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4931 in a buffer unordered, but in a doubly-linked list so that they
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4932 can easily be removed. (Formerly this was a singly-linked list,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4933 but in some cases garbage collection took an extraordinarily
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4934 long time due to the O(N^2) time required to remove lots of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4935 markers from a buffer.) Markers are removed from a buffer in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4936 the finalize stage, in @code{ADDITIONAL_FREE_marker()}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4937
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4938 @node String
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4939 @section String
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4940
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4941 As mentioned above, strings are a special case. A string is logically
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4942 two parts, a fixed-size object (containing the length, property list,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4943 and a pointer to the actual data), and the actual data in the string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4944 The fixed-size object is a @code{struct Lisp_String} and is allocated in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4945 frob blocks, as usual. The actual data is stored in special
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4946 @dfn{string-chars blocks}, which are 8K blocks of memory.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4947 Currently-allocated strings are simply laid end to end in these
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4948 string-chars blocks, with a pointer back to the @code{struct Lisp_String}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4949 stored before each string in the string-chars block. When a new string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4950 needs to be allocated, the remaining space at the end of the last
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4951 string-chars block is used if there's enough, and a new string-chars
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4952 block is created otherwise.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4953
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4954 There are never any holes in the string-chars blocks due to the string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4955 compaction and relocation that happens at the end of garbage collection.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4956 During the sweep stage of garbage collection, when objects are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4957 reclaimed, the garbage collector goes through all string-chars blocks,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4958 looking for unused strings. Each chunk of string data is preceded by a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4959 pointer to the corresponding @code{struct Lisp_String}, which indicates
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4960 both whether the string is used and how big the string is, i.e. how to
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
4961 get to the next chunk of string data. Holes are compressed by
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4962 block-copying the next string into the empty space and relocating the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4963 pointer stored in the corresponding @code{struct Lisp_String}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4964 @strong{This means you have to be careful with strings in your code.}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4965 See the section above on @code{GCPRO}ing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4966
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4967 Note that there is one situation not handled: a string that is too big
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4968 to fit into a string-chars block. Such strings, called @dfn{big
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4969 strings}, are all @code{malloc()}ed as their own block. (#### Although it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4970 would make more sense for the threshold for big strings to be somewhat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4971 lower, e.g. 1/2 or 1/4 the size of a string-chars block. It seems that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4972 this was indeed the case formerly -- indeed, the threshold was set at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4973 1/8 -- but Mly forgot about this when rewriting things for 19.8.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4974
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4975 Note also that the string data in string-chars blocks is padded as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4976 necessary so that proper alignment constraints on the @code{struct
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4977 Lisp_String} back pointers are maintained.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4978
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4979 Finally, strings can be resized. This happens in Mule when a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4980 character is substituted with a different-length character, or during
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4981 modeline frobbing. (You could also export this to Lisp, but it's not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4982 done so currently.) Resizing a string is a potentially tricky process.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4983 If the change is small enough that the padding can absorb it, nothing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4984 other than a simple memory move needs to be done. Keep in mind,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4985 however, that the string can't shrink too much because the offset to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4986 next string in the string-chars block is computed by looking at the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4987 length and rounding to the nearest multiple of four or eight. If the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4988 string would shrink or expand beyond the correct padding, new string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4989 data needs to be allocated at the end of the last string-chars block and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4990 the data moved appropriately. This leaves some dead string data, which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4991 is marked by putting a special marker of 0xFFFFFFFF in the @code{struct
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4992 Lisp_String} pointer before the data (there's no real @code{struct
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4993 Lisp_String} to point to and relocate), and storing the size of the dead
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4994 string data (which would normally be obtained from the now-non-existent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4995 @code{struct Lisp_String}) at the beginning of the dead string data gap.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4996 The string compactor recognizes this special 0xFFFFFFFF marker and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4997 handles it correctly.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4998
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4999 @node Bytecode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5000 @section Bytecode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5001
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5002 Not yet documented.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5003
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5004 @node Events and the Event Loop, Evaluation; Stack Frames; Bindings, Allocation of Objects in XEmacs Lisp, Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5005 @chapter Events and the Event Loop
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5006
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5007 @menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5008 * Introduction to Events::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5009 * Main Loop::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5010 * Specifics of the Event Gathering Mechanism::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5011 * Specifics About the Emacs Event::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5012 * The Event Stream Callback Routines::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5013 * Other Event Loop Functions::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5014 * Converting Events::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5015 * Dispatching Events; The Command Builder::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5016 @end menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5017
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5018 @node Introduction to Events
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5019 @section Introduction to Events
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5020
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5021 An event is an object that encapsulates information about an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5022 interesting occurrence in the operating system. Events are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5023 generated either by user action, direct (e.g. typing on the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5024 keyboard or moving the mouse) or indirect (moving another
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5025 window, thereby generating an expose event on an Emacs frame),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5026 or as a result of some other typically asynchronous action happening,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5027 such as output from a subprocess being ready or a timer expiring.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5028 Events come into the system in an asynchronous fashion (typically
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5029 through a callback being called) and are converted into a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5030 synchronous event queue (first-in, first-out) in a process that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5031 we will call @dfn{collection}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5032
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
5033 Note that each application has its own event queue. (It is
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5034 immaterial whether the collection process directly puts the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5035 events in the proper application's queue, or puts them into
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5036 a single system queue, which is later split up.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5037
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5038 The most basic level of event collection is done by the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5039 operating system or window system. Typically, XEmacs does
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5040 its own event collection as well. Often there are multiple
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5041 layers of collection in XEmacs, with events from various
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5042 sources being collected into a queue, which is then combined
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5043 with other sources to go into another queue (i.e. a second
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5044 level of collection), with perhaps another level on top of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5045 this, etc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5046
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5047 XEmacs has its own types of events (called @dfn{Emacs events}),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5048 which provides an abstract layer on top of the system-dependent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5049 nature of the most basic events that are received. Part of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5050 complex nature of the XEmacs event collection process involves
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5051 converting from the operating-system events into the proper
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5052 Emacs events -- there may not be a one-to-one correspondence.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5053
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5054 Emacs events are documented in @file{events.h}; I'll discuss them
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5055 later.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5056
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5057 @node Main Loop
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5058 @section Main Loop
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5059
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5060 The @dfn{command loop} is the top-level loop that the editor is always
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5061 running. It loops endlessly, calling @code{next-event} to retrieve an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5062 event and @code{dispatch-event} to execute it. @code{dispatch-event} does
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5063 the appropriate thing with non-user events (process, timeout,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5064 magic, eval, mouse motion); this involves calling a Lisp handler
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5065 function, redrawing a newly-exposed part of a frame, reading
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5066 subprocess output, etc. For user events, @code{dispatch-event}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5067 looks up the event in relevant keymaps or menubars; when a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5068 full key sequence or menubar selection is reached, the appropriate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5069 function is executed. @code{dispatch-event} may have to keep state
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5070 across calls; this is done in the ``command-builder'' structure
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5071 associated with each console (remember, there's usually only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5072 one console), and the engine that looks up keystrokes and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5073 constructs full key sequences is called the @dfn{command builder}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5074 This is documented elsewhere.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5075
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5076 The guts of the command loop are in @code{command_loop_1()}. This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5077 function doesn't catch errors, though -- that's the job of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5078 @code{command_loop_2()}, which is a condition-case (i.e. error-trapping)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5079 wrapper around @code{command_loop_1()}. @code{command_loop_1()} never
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5080 returns, but may get thrown out of.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5081
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5082 When an error occurs, @code{cmd_error()} is called, which usually
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5083 invokes the Lisp error handler in @code{command-error}; however, a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5084 default error handler is provided if @code{command-error} is @code{nil}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5085 (e.g. during startup). The purpose of the error handler is simply to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5086 display the error message and do associated cleanup; it does not need to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5087 throw anywhere. When the error handler finishes, the condition-case in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5088 @code{command_loop_2()} will finish and @code{command_loop_2()} will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5089 reinvoke @code{command_loop_1()}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5090
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5091 @code{command_loop_2()} is invoked from three places: from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5092 @code{initial_command_loop()} (called from @code{main()} at the end of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5093 internal initialization), from the Lisp function @code{recursive-edit},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5094 and from @code{call_command_loop()}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5095
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5096 @code{call_command_loop()} is called when a macro is started and when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5097 the minibuffer is entered; normal termination of the macro or minibuffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5098 causes a throw out of the recursive command loop. (To
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5099 @code{execute-kbd-macro} for macros and @code{exit} for minibuffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5100 Note also that the low-level minibuffer-entering function,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5101 @code{read-minibuffer-internal}, provides its own error handling and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5102 does not need @code{command_loop_2()}'s error encapsulation; so it tells
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5103 @code{call_command_loop()} to invoke @code{command_loop_1()} directly.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5104
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5105 Note that both read-minibuffer-internal and recursive-edit set up a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5106 catch for @code{exit}; this is why @code{abort-recursive-edit}, which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5107 throws to this catch, exits out of either one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5108
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5109 @code{initial_command_loop()}, called from @code{main()}, sets up a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5110 catch for @code{top-level} when invoking @code{command_loop_2()},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5111 allowing functions to throw all the way to the top level if they really
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5112 need to. Before invoking @code{command_loop_2()},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5113 @code{initial_command_loop()} calls @code{top_level_1()}, which handles
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5114 all of the startup stuff (creating the initial frame, handling the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5115 command-line options, loading the user's @file{.emacs} file, etc.). The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5116 function that actually does this is in Lisp and is pointed to by the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5117 variable @code{top-level}; normally this function is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5118 @code{normal-top-level}. @code{top_level_1()} is just an error-handling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5119 wrapper similar to @code{command_loop_2()}. Note also that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5120 @code{initial_command_loop()} sets up a catch for @code{top-level} when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5121 invoking @code{top_level_1()}, just like when it invokes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5122 @code{command_loop_2()}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5123
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5124 @node Specifics of the Event Gathering Mechanism
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5125 @section Specifics of the Event Gathering Mechanism
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5126
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5127 Here is an approximate diagram of the collection processes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5128 at work in XEmacs, under TTY's (TTY's are simpler than X
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5129 so we'll look at this first):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5130
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5131 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5132 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5133 asynch. asynch. asynch. asynch. [Collectors in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5134 kbd events kbd events process process the OS]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5135 | | output output
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5136 | | | |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5137 | | | | SIGINT, [signal handlers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5138 | | | | SIGQUIT, in XEmacs]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5139 V V V V SIGWINCH,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5140 file file file file SIGALRM
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5141 desc. desc. desc. desc. |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5142 (TTY) (TTY) (pipe) (pipe) |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5143 | | | | fake timeouts
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5144 | | | | file |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5145 | | | | desc. |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5146 | | | | (pipe) |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5147 | | | | | |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5148 | | | | | |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5149 | | | | | |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5150 V V V V V V
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5151 ------>-----------<----------------<----------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5152 |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5153 |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5154 | [collected using select() in emacs_tty_next_event()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5155 | and converted to the appropriate Emacs event]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5156 |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5157 |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5158 V (above this line is TTY-specific)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5159 Emacs ------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5160 event (below this line is the generic event mechanism)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5161 |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5162 |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5163 was there if not, call
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5164 a SIGINT? emacs_tty_next_event()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5165 | |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5166 | |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5167 | |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5168 V V
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5169 --->-------<----
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5170 |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5171 | [collected in event_stream_next_event();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5172 | SIGINT is converted using maybe_read_quit_event()]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5173 V
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5174 Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5175 event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5176 |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5177 \---->------>----- maybe_kbd_translate() ---->---\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5178 |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5179 |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5180 |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5181 command event queue |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5182 if not from command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5183 (contains events that were event queue, call
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5184 read earlier but not processed, event_stream_next_event()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5185 typically when waiting in a |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5186 sit-for, sleep-for, etc. for |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5187 a particular event to be received) |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5188 | |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5189 | |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5190 V V
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5191 ---->------------------------------------<----
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5192 |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5193 | [collected in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5194 | next_event_internal()]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5195 |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5196 unread- unread- event from |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5197 command- command- keyboard else, call
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5198 events event macro next_event_internal()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5199 | | | |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5200 | | | |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5201 | | | |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5202 V V V V
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5203 --------->----------------------<------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5204 |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5205 | [collected in `next-event', which may loop
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5206 | more than once if the event it gets is on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5207 | a dead frame, device, etc.]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5208 |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5209 |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5210 V
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5211 feed into top-level event loop,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5212 which repeatedly calls `next-event'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5213 and then dispatches the event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5214 using `dispatch-event'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5215 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5216
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5217 Notice the separation between TTY-specific and generic event mechanism.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5218 When using the Xt-based event loop, the TTY-specific stuff is replaced
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5219 but the rest stays the same.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5220
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5221 It's also important to realize that only one different kind of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5222 system-specific event loop can be operating at a time, and must be able
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5223 to receive all kinds of events simultaneously. For the two existing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5224 event loops (implemented in @file{event-tty.c} and @file{event-Xt.c},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5225 respectively), the TTY event loop @emph{only} handles TTY consoles,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5226 while the Xt event loop handles @emph{both} TTY and X consoles. This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5227 situation is different from all of the output handlers, where you simply
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5228 have one per console type.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5229
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5230 Here's the Xt Event Loop Diagram (notice that below a certain point,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5231 it's the same as the above diagram):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5232
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5233 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5234 asynch. asynch. asynch. asynch. [Collectors in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5235 kbd kbd process process the OS]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5236 events events output output
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5237 | | | |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5238 | | | | asynch. asynch. [Collectors in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5239 | | | | X X OS and X Window System]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5240 | | | | events events
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5241 | | | | | |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5242 | | | | | |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5243 | | | | | | SIGINT, [signal handlers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5244 | | | | | | SIGQUIT, in XEmacs]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5245 | | | | | | SIGWINCH,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5246 | | | | | | SIGALRM
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5247 | | | | | | |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5248 | | | | | | |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5249 | | | | | | | timeouts
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5250 | | | | | | | |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5251 | | | | | | | |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5252 | | | | | | V |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5253 V V V V V V fake |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5254 file file file file file file file |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5255 desc. desc. desc. desc. desc. desc. desc. |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5256 (TTY) (TTY) (pipe) (pipe) (socket) (socket) (pipe) |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5257 | | | | | | | |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5258 | | | | | | | |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5259 | | | | | | | |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5260 V V V V V V V V
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5261 --->----------------------------------------<---------<------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5262 | | |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5263 | | | [collected using select() in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5264 | | | _XtWaitForSomething(), called
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5265 | | | from XtAppProcessEvent(), called
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5266 | | | in emacs_Xt_next_event();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5267 | | | dispatched to various callbacks]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5268 | | |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5269 | | |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5270 emacs_Xt_ p_s_callback(), | [popup_selection_callback]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5271 event_handler() x_u_v_s_callback(),| [x_update_vertical_scrollbar_
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5272 | x_u_h_s_callback(),| callback]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5273 | search_callback() | [x_update_horizontal_scrollbar_
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5274 | | | callback]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5275 | | |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5276 | | |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5277 enqueue_Xt_ signal_special_ |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5278 dispatch_event() Xt_user_event() |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5279 [maybe multiple | |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5280 times, maybe 0 | |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5281 times] | |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5282 | enqueue_Xt_ |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5283 | dispatch_event() |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5284 | | |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5285 | | |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5286 V V |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5287 -->----------<-- |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5288 | |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5289 | |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5290 dispatch Xt_what_callback()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5291 event sets flags
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5292 queue |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5293 | |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5294 | |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5295 | |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5296 | |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5297 ---->-----------<--------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5298 |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5299 |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5300 | [collected and converted as appropriate in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5301 | emacs_Xt_next_event()]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5302 |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5303 |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5304 V (above this line is Xt-specific)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5305 Emacs ------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5306 event (below this line is the generic event mechanism)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5307 |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5308 |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5309 was there if not, call
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5310 a SIGINT? emacs_Xt_next_event()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5311 | |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5312 | |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5313 | |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5314 V V
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5315 --->-------<----
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5316 |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5317 | [collected in event_stream_next_event();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5318 | SIGINT is converted using maybe_read_quit_event()]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5319 V
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5320 Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5321 event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5322 |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5323 \---->------>----- maybe_kbd_translate() -->-----\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5324 |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5325 |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5326 |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5327 command event queue |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5328 if not from command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5329 (contains events that were event queue, call
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5330 read earlier but not processed, event_stream_next_event()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5331 typically when waiting in a |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5332 sit-for, sleep-for, etc. for |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5333 a particular event to be received) |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5334 | |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5335 | |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5336 V V
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5337 ---->----------------------------------<------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5338 |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5339 | [collected in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5340 | next_event_internal()]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5341 |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5342 unread- unread- event from |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5343 command- command- keyboard else, call
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5344 events event macro next_event_internal()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5345 | | | |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5346 | | | |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5347 | | | |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5348 V V V V
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5349 --------->----------------------<------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5350 |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5351 | [collected in `next-event', which may loop
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5352 | more than once if the event it gets is on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5353 | a dead frame, device, etc.]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5354 |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5355 |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5356 V
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5357 feed into top-level event loop,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5358 which repeatedly calls `next-event'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5359 and then dispatches the event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5360 using `dispatch-event'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5361 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5362
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5363 @node Specifics About the Emacs Event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5364 @section Specifics About the Emacs Event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5365
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5366 @node The Event Stream Callback Routines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5367 @section The Event Stream Callback Routines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5368
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5369 @node Other Event Loop Functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5370 @section Other Event Loop Functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5371
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5372 @code{detect_input_pending()} and @code{input-pending-p} look for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5373 input by calling @code{event_stream->event_pending_p} and looking in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5374 @code{[V]unread-command-event} and the @code{command_event_queue} (they
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5375 do not check for an executing keyboard macro, though).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5376
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5377 @code{discard-input} cancels any command events pending (and any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5378 keyboard macros currently executing), and puts the others onto the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5379 @code{command_event_queue}. There is a comment about a ``race
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5380 condition'', which is not a good sign.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5381
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5382 @code{next-command-event} and @code{read-char} are higher-level
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5383 interfaces to @code{next-event}. @code{next-command-event} gets the
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
5384 next @dfn{command} event (i.e. keypress, mouse event, menu selection,
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
5385 or scrollbar action), calling @code{dispatch-event} on any others.
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
5386 @code{read-char} calls @code{next-command-event} and uses
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
5387 @code{event_to_character()} to return the character equivalent. With
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
5388 the right kind of input method support, it is possible for (read-char)
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
5389 to return a Kanji character.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5390
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5391 @node Converting Events
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5392 @section Converting Events
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5393
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5394 @code{character_to_event()}, @code{event_to_character()},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5395 @code{event-to-character}, and @code{character-to-event} convert between
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
5396 characters and keypress events corresponding to the characters. If the
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5397 event was not a keypress, @code{event_to_character()} returns -1 and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5398 @code{event-to-character} returns @code{nil}. These functions convert
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
5399 between character representation and the split-up event representation
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5400 (keysym plus mod keys).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5401
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5402 @node Dispatching Events; The Command Builder
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5403 @section Dispatching Events; The Command Builder
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5404
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5405 Not yet documented.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5406
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5407 @node Evaluation; Stack Frames; Bindings, Symbols and Variables, Events and the Event Loop, Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5408 @chapter Evaluation; Stack Frames; Bindings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5409
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5410 @menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5411 * Evaluation::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5412 * Dynamic Binding; The specbinding Stack; Unwind-Protects::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5413 * Simple Special Forms::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5414 * Catch and Throw::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5415 @end menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5416
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5417 @node Evaluation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5418 @section Evaluation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5419
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5420 @code{Feval()} evaluates the form (a Lisp object) that is passed to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5421 it. Note that evaluation is only non-trivial for two types of objects:
253
157b30c96d03 Import from CVS: tag r20-5b25
cvs
parents: 219
diff changeset
5422 symbols and conses. A symbol is evaluated simply by calling
157b30c96d03 Import from CVS: tag r20-5b25
cvs
parents: 219
diff changeset
5423 symbol-value on it and returning the value.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5424
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5425 Evaluating a cons means calling a function. First, @code{eval} checks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5426 to see if garbage-collection is necessary, and calls
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5427 @code{Fgarbage_collect()} if so. It then increases the evaluation depth
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5428 by 1 (@code{lisp_eval_depth}, which is always less than @code{max_lisp_eval_depth}) and adds an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5429 element to the linked list of @code{struct backtrace}'s
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5430 (@code{backtrace_list}). Each such structure contains a pointer to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5431 function being called plus a list of the function's arguments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5432 Originally these values are stored unevalled, and as they are evaluated,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5433 the backtrace structure is updated. Garbage collection pays attention
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5434 to the objects pointed to in the backtrace structures (garbage
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5435 collection might happen while a function is being called or while an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5436 argument is being evaluated, and there could easily be no other
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5437 references to the arguments in the argument list; once an argument is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5438 evaluated, however, the unevalled version is not needed by eval, and so
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5439 the backtrace structure is changed).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5440
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5441 At this point, the function to be called is determined by looking at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5442 the car of the cons (if this is a symbol, its function definition is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5443 retrieved and the process repeated). The function should then consist
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
5444 of either a @code{Lisp_Subr} (built-in function), a
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
5445 @code{Lisp_Compiled_Function} object, or a cons whose car is the symbol
253
157b30c96d03 Import from CVS: tag r20-5b25
cvs
parents: 219
diff changeset
5446 @code{autoload}, @code{macro} or @code{lambda}.
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
5447
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
5448 If the function is a @code{Lisp_Subr}, the lisp object points to a
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
5449 @code{struct Lisp_Subr} (created by @code{DEFUN()}), which contains a
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
5450 pointer to the C function, a minimum and maximum number of arguments
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
5451 (possibly the special constants @code{MANY} or @code{UNEVALLED}), a
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
5452 pointer to the symbol referring to that subr, and a couple of other
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
5453 things. If the subr wants its arguments @code{UNEVALLED}, they are
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
5454 passed raw as a list. Otherwise, an array of evaluated arguments is
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
5455 created and put into the backtrace structure, and either passed whole
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
5456 (@code{MANY}) or each argument is passed as a C argument.
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
5457
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
5458 If the function is a @code{Lisp_Compiled_Function} object or a lambda,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5459 @code{apply_lambda()} is called. If the function is a macro,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5460 [..... fill in] is done. If the function is an autoload,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5461 @code{do_autoload()} is called to load the definition and then eval
253
157b30c96d03 Import from CVS: tag r20-5b25
cvs
parents: 219
diff changeset
5462 starts over [explain this more].
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5463
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5464 When @code{Feval} exits, the evaluation depth is reduced by one, the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5465 debugger is called if appropriate, and the current backtrace structure
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5466 is removed from the list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5467
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5468 @code{apply_lambda()} is passed a function, a list of arguments, and a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5469 flag indicating whether to evaluate the arguments. It creates an array
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5470 of (possibly) evaluated arguments and fixes up the backtrace structure,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5471 just like eval does. Then it calls @code{funcall_lambda()}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5472
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5473 @code{funcall_lambda()} goes through the formal arguments to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5474 function and binds them to the actual arguments, checking for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5475 @code{&rest} and @code{&optional} symbols in the formal arguments and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5476 making sure the number of actual arguments is correct. Then either
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
5477 @code{progn} or @code{byte-code} is called to actually execute the body
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
5478 and return a value.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5479
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5480 @code{Ffuncall()} implements Lisp @code{funcall}. @code{(funcall fun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5481 x1 x2 x3 ...)} is equivalent to @code{(eval (list fun (quote x1) (quote
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5482 x2) (quote x3) ...))}. @code{Ffuncall()} contains its own code to do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5483 the evaluation, however, and is almost identical to eval.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5484
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5485 @code{Fapply()} implements Lisp @code{apply}, which is very similar to
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 265
diff changeset
5486 @code{funcall} except that if the last argument is a list, the result is the
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5487 same as if each of the arguments in the list had been passed separately.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5488 @code{Fapply()} does some business to expand the last argument if it's a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5489 list, then calls @code{Ffuncall()} to do the work.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5490
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5491 @code{apply1()}, @code{call0()}, @code{call1()}, @code{call2()}, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5492 @code{call3()} call a function, passing it the argument(s) given (the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5493 arguments are given as separate C arguments rather than being passed as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5494 an array). @code{apply1()} uses @code{apply} while the others use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5495 @code{funcall}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5496
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5497 @node Dynamic Binding; The specbinding Stack; Unwind-Protects
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5498 @section Dynamic Binding; The specbinding Stack; Unwind-Protects
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5499
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5500 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5501 struct specbinding
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5502 @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5503 Lisp_Object symbol, old_value;
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
5504 Lisp_Object (*func) (Lisp_Object); /* for unwind-protect */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5505 @};
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5506 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5507
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5508 @code{struct specbinding} is used for local-variable bindings and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5509 unwind-protects. @code{specpdl} holds an array of @code{struct specbinding}'s,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5510 @code{specpdl_ptr} points to the beginning of the free bindings in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5511 array, @code{specpdl_size} specifies the total number of binding slots
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5512 in the array, and @code{max_specpdl_size} specifies the maximum number
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5513 of bindings the array can be expanded to hold. @code{grow_specpdl()}
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 265
diff changeset
5514 increases the size of the @code{specpdl} array, multiplying its size by
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 265
diff changeset
5515 2 but never exceeding @code{max_specpdl_size} (except that if this
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 265
diff changeset
5516 number is less than 400, it is first set to 400).
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5517
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5518 @code{specbind()} binds a symbol to a value and is used for local
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5519 variables and @code{let} forms. The symbol and its old value (which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5520 might be @code{Qunbound}, indicating no prior value) are recorded in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5521 specpdl array, and @code{specpdl_size} is increased by 1.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5522
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5523 @code{record_unwind_protect()} implements an @dfn{unwind-protect},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5524 which, when placed around a section of code, ensures that some specified
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5525 cleanup routine will be executed even if the code exits abnormally
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
5526 (e.g. through a @code{throw} or quit). @code{record_unwind_protect()}
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 265
diff changeset
5527 simply adds a new specbinding to the @code{specpdl} array and stores the
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
5528 appropriate information in it. The cleanup routine can either be a C
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
5529 function, which is stored in the @code{func} field, or a @code{progn}
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
5530 form, which is stored in the @code{old_value} field.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5531
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 265
diff changeset
5532 @code{unbind_to()} removes specbindings from the @code{specpdl} array
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 265
diff changeset
5533 until the specified position is reached. Each specbinding can be one of
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 265
diff changeset
5534 three types:
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5535
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5536 @enumerate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5537 @item
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
5538 an unwind-protect with a C cleanup function (@code{func} is not 0, and
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5539 @code{old_value} holds an argument to be passed to the function);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5540 @item
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
5541 an unwind-protect with a Lisp form (@code{func} is 0, @code{symbol}
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
5542 is @code{nil}, and @code{old_value} holds the form to be executed with
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5543 @code{Fprogn()}); or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5544 @item
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
5545 a local-variable binding (@code{func} is 0, @code{symbol} is not
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
5546 @code{nil}, and @code{old_value} holds the old value, which is stored as
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5547 the symbol's value).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5548 @end enumerate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5549
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5550 @node Simple Special Forms
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5551 @section Simple Special Forms
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5552
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5553 @code{or}, @code{and}, @code{if}, @code{cond}, @code{progn},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5554 @code{prog1}, @code{prog2}, @code{setq}, @code{quote}, @code{function},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5555 @code{let*}, @code{let}, @code{while}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5556
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5557 All of these are very simple and work as expected, calling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5558 @code{Feval()} or @code{Fprogn()} as necessary and (in the case of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5559 @code{let} and @code{let*}) using @code{specbind()} to create bindings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5560 and @code{unbind_to()} to undo the bindings when finished. Note that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5561 these functions do a lot of @code{GCPRO}ing to protect their arguments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5562 from garbage collection because they call @code{Feval()} (@pxref{Garbage
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5563 Collection}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5564
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5565 @node Catch and Throw
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5566 @section Catch and Throw
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5567
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5568 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5569 struct catchtag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5570 @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5571 Lisp_Object tag;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5572 Lisp_Object val;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5573 struct catchtag *next;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5574 struct gcpro *gcpro;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5575 jmp_buf jmp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5576 struct backtrace *backlist;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5577 int lisp_eval_depth;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5578 int pdlcount;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5579 @};
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5580 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5581
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5582 @code{catch} is a Lisp function that places a catch around a body of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5583 code. A catch is a means of non-local exit from the code. When a catch
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5584 is created, a tag is specified, and executing a @code{throw} to this tag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5585 will exit from the body of code caught with this tag, and its value will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5586 be the value given in the call to @code{throw}. If there is no such
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5587 call, the code will be executed normally.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5588
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5589 Information pertaining to a catch is held in a @code{struct catchtag},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5590 which is placed at the head of a linked list pointed to by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5591 @code{catchlist}. @code{internal_catch()} is passed a C function to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5592 call (@code{Fprogn()} when Lisp @code{catch} is called) and arguments to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5593 give it, and places a catch around the function. Each @code{struct
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5594 catchtag} is held in the stack frame of the @code{internal_catch()}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5595 instance that created the catch.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5596
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5597 @code{internal_catch()} is fairly straightforward. It stores into the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5598 @code{struct catchtag} the tag name and the current values of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5599 @code{backtrace_list}, @code{lisp_eval_depth}, @code{gcprolist}, and the
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 265
diff changeset
5600 offset into the @code{specpdl} array, sets a jump point with @code{_setjmp()}
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5601 (storing the jump point into the @code{struct catchtag}), and calls the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5602 function. Control will return to @code{internal_catch()} either when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5603 the function exits normally or through a @code{_longjmp()} to this jump
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5604 point. In the latter case, @code{throw} will store the value to be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5605 returned into the @code{struct catchtag} before jumping. When it's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5606 done, @code{internal_catch()} removes the @code{struct catchtag} from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5607 the catchlist and returns the proper value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5608
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5609 @code{Fthrow()} goes up through the catchlist until it finds one with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5610 a matching tag. It then calls @code{unbind_catch()} to restore
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5611 everything to what it was when the appropriate catch was set, stores the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5612 return value in the @code{struct catchtag}, and jumps (with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5613 @code{_longjmp()}) to its jump point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5614
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5615 @code{unbind_catch()} removes all catches from the catchlist until it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5616 finds the correct one. Some of the catches might have been placed for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5617 error-trapping, and if so, the appropriate entries on the handlerlist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5618 must be removed (see ``errors''). @code{unbind_catch()} also restores
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5619 the values of @code{gcprolist}, @code{backtrace_list}, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5620 @code{lisp_eval}, and calls @code{unbind_to()} to undo any specbindings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5621 created since the catch.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5622
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5623
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5624 @node Symbols and Variables, Buffers and Textual Representation, Evaluation; Stack Frames; Bindings, Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5625 @chapter Symbols and Variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5626
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5627 @menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5628 * Introduction to Symbols::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5629 * Obarrays::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5630 * Symbol Values::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5631 @end menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5632
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5633 @node Introduction to Symbols
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5634 @section Introduction to Symbols
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5635
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5636 A symbol is basically just an object with four fields: a name (a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5637 string), a value (some Lisp object), a function (some Lisp object), and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5638 a property list (usually a list of alternating keyword/value pairs).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5639 What makes symbols special is that there is usually only one symbol with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5640 a given name, and the symbol is referred to by name. This makes a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5641 symbol a convenient way of calling up data by name, i.e. of implementing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5642 variables. (The variable's value is stored in the @dfn{value slot}.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5643 Similarly, functions are referenced by name, and the definition of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5644 function is stored in a symbol's @dfn{function slot}. This means that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5645 there can be a distinct function and variable with the same name. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5646 property list is used as a more general mechanism of associating
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5647 additional values with particular names, and once again the namespace is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5648 independent of the function and variable namespaces.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5649
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5650 @node Obarrays
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5651 @section Obarrays
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5652
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5653 The identity of symbols with their names is accomplished through a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5654 structure called an obarray, which is just a poorly-implemented hash
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5655 table mapping from strings to symbols whose name is that string. (I say
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5656 ``poorly implemented'' because an obarray appears in Lisp as a vector
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5657 with some hidden fields rather than as its own opaque type. This is an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5658 Emacs Lisp artifact that should be fixed.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5659
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5660 Obarrays are implemented as a vector of some fixed size (which should
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5661 be a prime for best results), where each ``bucket'' of the vector
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5662 contains one or more symbols, threaded through a hidden @code{next}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5663 field in the symbol. Lookup of a symbol in an obarray, and adding a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5664 symbol to an obarray, is accomplished through standard hash-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5665 techniques.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5666
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5667 The standard Lisp function for working with symbols and obarrays is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5668 @code{intern}. This looks up a symbol in an obarray given its name; if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5669 it's not found, a new symbol is automatically created with the specified
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5670 name, added to the obarray, and returned. This is what happens when the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5671 Lisp reader encounters a symbol (or more precisely, encounters the name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5672 of a symbol) in some text that it is reading. There is a standard
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5673 obarray called @code{obarray} that is used for this purpose, although
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5674 the Lisp programmer is free to create his own obarrays and @code{intern}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5675 symbols in them.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5676
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5677 Note that, once a symbol is in an obarray, it stays there until
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5678 something is done about it, and the standard obarray @code{obarray}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5679 always stays around, so once you use any particular variable name, a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5680 corresponding symbol will stay around in @code{obarray} until you exit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5681 XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5682
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5683 Note that @code{obarray} itself is a variable, and as such there is a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5684 symbol in @code{obarray} whose name is @code{"obarray"} and which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5685 contains @code{obarray} as its value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5686
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5687 Note also that this call to @code{intern} occurs only when in the Lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5688 reader, not when the code is executed (at which point the symbol is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5689 already around, stored as such in the definition of the function).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5690
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5691 You can create your own obarray using @code{make-vector} (this is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5692 horrible but is an artifact) and intern symbols into that obarray.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5693 Doing that will result in two or more symbols with the same name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5694 However, at most one of these symbols is in the standard @code{obarray}:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5695 You cannot have two symbols of the same name in any particular obarray.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5696 Note that you cannot add a symbol to an obarray in any fashion other
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5697 than using @code{intern}: i.e. you can't take an existing symbol and put
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5698 it in an existing obarray. Nor can you change the name of an existing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5699 symbol. (Since obarrays are vectors, you can violate the consistency of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5700 things by storing directly into the vector, but let's ignore that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5701 possibility.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5702
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5703 Usually symbols are created by @code{intern}, but if you really want,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5704 you can explicitly create a symbol using @code{make-symbol}, giving it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5705 some name. The resulting symbol is not in any obarray (i.e. it is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5706 @dfn{uninterned}), and you can't add it to any obarray. Therefore its
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
5707 primary purpose is as a symbol to use in macros to avoid namespace
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
5708 pollution. It can also be used as a carrier of information, but cons
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
5709 cells could probably be used just as well.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5710
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5711 You can also use @code{intern-soft} to look up a symbol but not create
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5712 a new one, and @code{unintern} to remove a symbol from an obarray. This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5713 returns the removed symbol. (Remember: You can't put the symbol back
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5714 into any obarray.) Finally, @code{mapatoms} maps over all of the symbols
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5715 in an obarray.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5716
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5717 @node Symbol Values
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5718 @section Symbol Values
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5719
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5720 The value field of a symbol normally contains a Lisp object. However,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5721 a symbol can be @dfn{unbound}, meaning that it logically has no value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5722 This is internally indicated by storing a special Lisp object, called
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5723 @dfn{the unbound marker} and stored in the global variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5724 @code{Qunbound}. The unbound marker is of a special Lisp object type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5725 called @dfn{symbol-value-magic}. It is impossible for the Lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5726 programmer to directly create or access any object of this type.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5727
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5728 @strong{You must not let any ``symbol-value-magic'' object escape to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5729 the Lisp level.} Printing any of these objects will cause the message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5730 @samp{INTERNAL EMACS BUG} to appear as part of the print representation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5731 (You may see this normally when you call @code{debug_print()} from the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5732 debugger on a Lisp object.) If you let one of these objects escape to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5733 the Lisp level, you will violate a number of assumptions contained in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5734 the C code and make the unbound marker not function right.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5735
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5736 When a symbol is created, its value field (and function field) are set
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5737 to @code{Qunbound}. The Lisp programmer can restore these conditions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5738 later using @code{makunbound} or @code{fmakunbound}, and can query to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5739 see whether the value of function fields are @dfn{bound} (i.e. have a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5740 value other than @code{Qunbound}) using @code{boundp} and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5741 @code{fboundp}. The fields are set to a normal Lisp object using
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5742 @code{set} (or @code{setq}) and @code{fset}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5743
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5744 Other symbol-value-magic objects are used as special markers to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5745 indicate variables that have non-normal properties. This includes any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5746 variables that are tied into C variables (setting the variable magically
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5747 sets some global variable in the C code, and likewise for retrieving the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5748 variable's value), variables that magically tie into slots in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5749 current buffer, variables that are buffer-local, etc. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5750 symbol-value-magic object is stored in the value cell in place of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5751 a normal object, and the code to retrieve a symbol's value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5752 (i.e. @code{symbol-value}) knows how to do special things with them.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5753 This means that you should not just fetch the value cell directly if you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5754 want a symbol's value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5755
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5756 The exact workings of this are rather complex and involved and are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5757 well-documented in comments in @file{buffer.c}, @file{symbols.c}, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5758 @file{lisp.h}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5759
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5760 @node Buffers and Textual Representation, MULE Character Sets and Encodings, Symbols and Variables, Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5761 @chapter Buffers and Textual Representation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5762
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5763 @menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5764 * Introduction to Buffers:: A buffer holds a block of text such as a file.
193
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 175
diff changeset
5765 * The Text in a Buffer:: Representation of the text in a buffer.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5766 * Buffer Lists:: Keeping track of all buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5767 * Markers and Extents:: Tagging locations within a buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5768 * Bufbytes and Emchars:: Representation of individual characters.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5769 * The Buffer Object:: The Lisp object corresponding to a buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5770 @end menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5771
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5772 @node Introduction to Buffers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5773 @section Introduction to Buffers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5774
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5775 A buffer is logically just a Lisp object that holds some text.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5776 In this, it is like a string, but a buffer is optimized for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5777 frequent insertion and deletion, while a string is not. Furthermore:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5778
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5779 @enumerate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5780 @item
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
5781 Buffers are @dfn{permanent} objects, i.e. once you create them, they
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5782 remain around, and need to be explicitly deleted before they go away.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5783 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5784 Each buffer has a unique name, which is a string. Buffers are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5785 normally referred to by name. In this respect, they are like
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5786 symbols.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5787 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5788 Buffers have a default insertion position, called @dfn{point}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5789 Inserting text (unless you explicitly give a position) goes at point,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5790 and moves point forward past the text. This is what is going on when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5791 you type text into Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5792 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5793 Buffers have lots of extra properties associated with them.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5794 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5795 Buffers can be @dfn{displayed}. What this means is that there
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5796 exist a number of @dfn{windows}, which are objects that correspond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5797 to some visible section of your display, and each window has
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5798 an associated buffer, and the current contents of the buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5799 are shown in that section of the display. The redisplay mechanism
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5800 (which takes care of doing this) knows how to look at the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5801 text of a buffer and come up with some reasonable way of displaying
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5802 this. Many of the properties of a buffer control how the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5803 buffer's text is displayed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5804 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5805 One buffer is distinguished and called the @dfn{current buffer}. It is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5806 stored in the variable @code{current_buffer}. Buffer operations operate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5807 on this buffer by default. When you are typing text into a buffer, the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5808 buffer you are typing into is always @code{current_buffer}. Switching
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5809 to a different window changes the current buffer. Note that Lisp code
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5810 can temporarily change the current buffer using @code{set-buffer} (often
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5811 enclosed in a @code{save-excursion} so that the former current buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5812 gets restored when the code is finished). However, calling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5813 @code{set-buffer} will NOT cause a permanent change in the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5814 buffer. The reason for this is that the top-level event loop sets
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
5815 @code{current_buffer} to the buffer of the selected window, each time
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
5816 it finishes executing a user command.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5817 @end enumerate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5818
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5819 Make sure you understand the distinction between @dfn{current buffer}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5820 and @dfn{buffer of the selected window}, and the distinction between
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5821 @dfn{point} of the current buffer and @dfn{window-point} of the selected
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5822 window. (This latter distinction is explained in detail in the section
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5823 on windows.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5824
193
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 175
diff changeset
5825 @node The Text in a Buffer
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 175
diff changeset
5826 @section The Text in a Buffer
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5827
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5828 The text in a buffer consists of a sequence of zero or more
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5829 characters. A @dfn{character} is an integer that logically represents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5830 a letter, number, space, or other unit of text. Most of the characters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5831 that you will typically encounter belong to the ASCII set of characters,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5832 but there are also characters for various sorts of accented letters,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5833 special symbols, Chinese and Japanese ideograms (i.e. Kanji, Katakana,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5834 etc.), Cyrillic and Greek letters, etc. The actual number of possible
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5835 characters is quite large.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5836
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5837 For now, we can view a character as some non-negative integer that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5838 has some shape that defines how it typically appears (e.g. as an
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
5839 uppercase A). (The exact way in which a character appears depends on the
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
5840 font used to display the character.) The internal type of characters in
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
5841 the C code is an @code{Emchar}; this is just an @code{int}, but using a
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
5842 symbolic type makes the code clearer.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5843
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5844 Between every character in a buffer is a @dfn{buffer position} or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5845 @dfn{character position}. We can speak of the character before or after
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5846 a particular buffer position, and when you insert a character at a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5847 particular position, all characters after that position end up at new
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5848 positions. When we speak of the character @dfn{at} a position, we
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5849 really mean the character after the position. (This schizophrenia
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5850 between a buffer position being ``between'' a character and ``on'' a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5851 character is rampant in Emacs.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5852
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5853 Buffer positions are numbered starting at 1. This means that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5854 position 1 is before the first character, and position 0 is not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5855 valid. If there are N characters in a buffer, then buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5856 position N+1 is after the last one, and position N+2 is not valid.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5857
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5858 The internal makeup of the Emchar integer varies depending on whether
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5859 we have compiled with MULE support. If not, the Emchar integer is an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5860 8-bit integer with possible values from 0 - 255. 0 - 127 are the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5861 standard ASCII characters, while 128 - 255 are the characters from the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5862 ISO-8859-1 character set. If we have compiled with MULE support, an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5863 Emchar is a 19-bit integer, with the various bits having meanings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5864 according to a complex scheme that will be detailed later. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5865 characters numbered 0 - 255 still have the same meanings as for the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5866 non-MULE case, though.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5867
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5868 Internally, the text in a buffer is represented in a fairly simple
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5869 fashion: as a contiguous array of bytes, with a @dfn{gap} of some size
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5870 in the middle. Although the gap is of some substantial size in bytes,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5871 there is no text contained within it: From the perspective of the text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5872 in the buffer, it does not exist. The gap logically sits at some buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5873 position, between two characters (or possibly at the beginning or end of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5874 the buffer). Insertion of text in a buffer at a particular position is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5875 always accomplished by first moving the gap to that position
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5876 (i.e. through some block moving of text), then writing the text into the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5877 beginning of the gap, thereby shrinking the gap. If the gap shrinks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5878 down to nothing, a new gap is created. (What actually happens is that a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5879 new gap is ``created'' at the end of the buffer's text, which requires
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5880 nothing more than changing a couple of indices; then the gap is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5881 ``moved'' to the position where the insertion needs to take place by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5882 moving up in memory all the text after that position.) Similarly,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5883 deletion occurs by moving the gap to the place where the text is to be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5884 deleted, and then simply expanding the gap to include the deleted text.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5885 (@dfn{Expanding} and @dfn{shrinking} the gap as just described means
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5886 just that the internal indices that keep track of where the gap is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5887 located are changed.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5888
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5889 Note that the total amount of memory allocated for a buffer text never
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5890 decreases while the buffer is live. Therefore, if you load up a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5891 20-megabyte file and then delete all but one character, there will be a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5892 20-megabyte gap, which won't get any smaller (except by inserting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5893 characters back again). Once the buffer is killed, the memory allocated
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5894 for the buffer text will be freed, but it will still be sitting on the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5895 heap, taking up virtual memory, and will not be released back to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5896 operating system. (However, if you have compiled XEmacs with rel-alloc,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5897 the situation is different. In this case, the space @emph{will} be
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
5898 released back to the operating system. However, this tends to result in a
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5899 noticeable speed penalty.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5900
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5901 Astute readers may notice that the text in a buffer is represented as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5902 an array of @emph{bytes}, while (at least in the MULE case) an Emchar is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5903 a 19-bit integer, which clearly cannot fit in a byte. This means (of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5904 course) that the text in a buffer uses a different representation from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5905 an Emchar: specifically, the 19-bit Emchar becomes a series of one to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5906 four bytes. The conversion between these two representations is complex
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5907 and will be described later.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5908
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5909 In the non-MULE case, everything is very simple: An Emchar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5910 is an 8-bit value, which fits neatly into one byte.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5911
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5912 If we are given a buffer position and want to retrieve the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5913 character at that position, we need to follow these steps:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5914
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5915 @enumerate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5916 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5917 Pretend there's no gap, and convert the buffer position into a @dfn{byte
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5918 index} that indexes to the appropriate byte in the buffer's stream of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5919 textual bytes. By convention, byte indices begin at 1, just like buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5920 positions. In the non-MULE case, byte indices and buffer positions are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5921 identical, since one character equals one byte.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5922 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5923 Convert the byte index into a @dfn{memory index}, which takes the gap
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5924 into account. The memory index is a direct index into the block of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5925 memory that stores the text of a buffer. This basically just involves
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5926 checking to see if the byte index is past the gap, and if so, adding the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5927 size of the gap to it. By convention, memory indices begin at 1, just
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5928 like buffer positions and byte indices, and when referring to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5929 position that is @dfn{at} the gap, we always use the memory position at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5930 the @emph{beginning}, not at the end, of the gap.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5931 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5932 Fetch the appropriate bytes at the determined memory position.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5933 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5934 Convert these bytes into an Emchar.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5935 @end enumerate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5936
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5937 In the non-Mule case, (3) and (4) boil down to a simple one-byte
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5938 memory access.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5939
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5940 Note that we have defined three types of positions in a buffer:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5941
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5942 @enumerate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5943 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5944 @dfn{buffer positions} or @dfn{character positions}, typedef @code{Bufpos}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5945 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5946 @dfn{byte indices}, typedef @code{Bytind}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5947 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5948 @dfn{memory indices}, typedef @code{Memind}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5949 @end enumerate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5950
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
5951 All three typedefs are just @code{int}s, but defining them this way makes
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5952 things a lot clearer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5953
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5954 Most code works with buffer positions. In particular, all Lisp code
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5955 that refers to text in a buffer uses buffer positions. Lisp code does
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5956 not know that byte indices or memory indices exist.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5957
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5958 Finally, we have a typedef for the bytes in a buffer. This is a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5959 @code{Bufbyte}, which is an unsigned char. Referring to them as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5960 Bufbytes underscores the fact that we are working with a string of bytes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5961 in the internal Emacs buffer representation rather than in one of a
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 112
diff changeset
5962 number of possible alternative representations (e.g. EUC-encoded text,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5963 etc.).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5964
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5965 @node Buffer Lists
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5966 @section Buffer Lists
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5967
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5968 Recall earlier that buffers are @dfn{permanent} objects, i.e. that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5969 they remain around until explicitly deleted. This entails that there is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5970 a list of all the buffers in existence. This list is actually an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5971 assoc-list (mapping from the buffer's name to the buffer) and is stored
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5972 in the global variable @code{Vbuffer_alist}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5973
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5974 The order of the buffers in the list is important: the buffers are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5975 ordered approximately from most-recently-used to least-recently-used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5976 Switching to a buffer using @code{switch-to-buffer},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5977 @code{pop-to-buffer}, etc. and switching windows using
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5978 @code{other-window}, etc. usually brings the new current buffer to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5979 front of the list. @code{switch-to-buffer}, @code{other-buffer},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5980 etc. look at the beginning of the list to find an alternative buffer to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5981 suggest. You can also explicitly move a buffer to the end of the list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5982 using @code{bury-buffer}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5983
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5984 In addition to the global ordering in @code{Vbuffer_alist}, each frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5985 has its own ordering of the list. These lists always contain the same
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5986 elements as in @code{Vbuffer_alist} although possibly in a different
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5987 order. @code{buffer-list} normally returns the list for the selected
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5988 frame. This allows you to work in separate frames without things
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5989 interfering with each other.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5990
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5991 The standard way to look up a buffer given a name is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5992 @code{get-buffer}, and the standard way to create a new buffer is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5993 @code{get-buffer-create}, which looks up a buffer with a given name,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5994 creating a new one if necessary. These operations correspond exactly
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5995 with the symbol operations @code{intern-soft} and @code{intern},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5996 respectively. You can also force a new buffer to be created using
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5997 @code{generate-new-buffer}, which takes a name and (if necessary) makes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5998 a unique name from this by appending a number, and then creates the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5999 buffer. This is basically like the symbol operation @code{gensym}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6000
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6001 @node Markers and Extents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6002 @section Markers and Extents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6003
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6004 Among the things associated with a buffer are things that are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6005 logically attached to certain buffer positions. This can be used to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6006 keep track of a buffer position when text is inserted and deleted, so
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6007 that it remains at the same spot relative to the text around it; to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6008 assign properties to particular sections of text; etc. There are two
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6009 such objects that are useful in this regard: they are @dfn{markers} and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6010 @dfn{extents}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6011
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6012 A @dfn{marker} is simply a flag placed at a particular buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6013 position, which is moved around as text is inserted and deleted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6014 Markers are used for all sorts of purposes, such as the @code{mark} that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6015 is the other end of textual regions to be cut, copied, etc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6016
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6017 An @dfn{extent} is similar to two markers plus some associated
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6018 properties, and is used to keep track of regions in a buffer as text is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6019 inserted and deleted, and to add properties (e.g. fonts) to particular
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6020 regions of text. The external interface of extents is explained
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6021 elsewhere.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6022
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6023 The important thing here is that markers and extents simply contain
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6024 buffer positions in them as integers, and every time text is inserted or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6025 deleted, these positions must be updated. In order to minimize the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6026 amount of shuffling that needs to be done, the positions in markers and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6027 extents (there's one per marker, two per extent) and stored in Meminds.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6028 This means that they only need to be moved when the text is physically
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6029 moved in memory; since the gap structure tries to minimize this, it also
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6030 minimizes the number of marker and extent indices that need to be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6031 adjusted. Look in @file{insdel.c} for the details of how this works.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6032
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6033 One other important distinction is that markers are @dfn{temporary}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6034 while extents are @dfn{permanent}. This means that markers disappear as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6035 soon as there are no more pointers to them, and correspondingly, there
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6036 is no way to determine what markers are in a buffer if you are just
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6037 given the buffer. Extents remain in a buffer until they are detached
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6038 (which could happen as a result of text being deleted) or the buffer is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6039 deleted, and primitives do exist to enumerate the extents in a buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6040
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6041 @node Bufbytes and Emchars
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6042 @section Bufbytes and Emchars
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6043
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6044 Not yet documented.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6045
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6046 @node The Buffer Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6047 @section The Buffer Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6048
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6049 Buffers contain fields not directly accessible by the Lisp programmer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6050 We describe them here, naming them by the names used in the C code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6051 Many are accessible indirectly in Lisp programs via Lisp primitives.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6052
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6053 @table @code
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6054 @item name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6055 The buffer name is a string that names the buffer. It is guaranteed to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6056 be unique. @xref{Buffer Names,,, lispref, XEmacs Lisp Programmer's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6057 Manual}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6058
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6059 @item save_modified
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6060 This field contains the time when the buffer was last saved, as an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6061 integer. @xref{Buffer Modification,,, lispref, XEmacs Lisp Programmer's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6062 Manual}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6063
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6064 @item modtime
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6065 This field contains the modification time of the visited file. It is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6066 set when the file is written or read. Every time the buffer is written
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6067 to the file, this field is compared to the modification time of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6068 file. @xref{Buffer Modification,,, lispref, XEmacs Lisp Programmer's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6069 Manual}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6070
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6071 @item auto_save_modified
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6072 This field contains the time when the buffer was last auto-saved.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6073
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6074 @item last_window_start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6075 This field contains the @code{window-start} position in the buffer as of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6076 the last time the buffer was displayed in a window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6077
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6078 @item undo_list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6079 This field points to the buffer's undo list. @xref{Undo,,, lispref,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6080 XEmacs Lisp Programmer's Manual}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6081
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6082 @item syntax_table_v
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6083 This field contains the syntax table for the buffer. @xref{Syntax
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6084 Tables,,, lispref, XEmacs Lisp Programmer's Manual}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6085
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6086 @item downcase_table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6087 This field contains the conversion table for converting text to lower
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6088 case. @xref{Case Tables,,, lispref, XEmacs Lisp Programmer's Manual}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6089
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6090 @item upcase_table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6091 This field contains the conversion table for converting text to upper
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6092 case. @xref{Case Tables,,, lispref, XEmacs Lisp Programmer's Manual}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6093
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6094 @item case_canon_table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6095 This field contains the conversion table for canonicalizing text for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6096 case-folding search. @xref{Case Tables,,, lispref, XEmacs Lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6097 Programmer's Manual}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6098
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6099 @item case_eqv_table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6100 This field contains the equivalence table for case-folding search.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6101 @xref{Case Tables,,, lispref, XEmacs Lisp Programmer's Manual}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6102
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6103 @item display_table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6104 This field contains the buffer's display table, or @code{nil} if it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6105 doesn't have one. @xref{Display Tables,,, lispref, XEmacs Lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6106 Programmer's Manual}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6107
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6108 @item markers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6109 This field contains the chain of all markers that currently point into
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6110 the buffer. Deletion of text in the buffer, and motion of the buffer's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6111 gap, must check each of these markers and perhaps update it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6112 @xref{Markers,,, lispref, XEmacs Lisp Programmer's Manual}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6113
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6114 @item backed_up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6115 This field is a flag that tells whether a backup file has been made for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6116 the visited file of this buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6117
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6118 @item mark
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6119 This field contains the mark for the buffer. The mark is a marker,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6120 hence it is also included on the list @code{markers}. @xref{The Mark,,,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6121 lispref, XEmacs Lisp Programmer's Manual}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6122
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6123 @item mark_active
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6124 This field is non-@code{nil} if the buffer's mark is active.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6125
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6126 @item local_var_alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6127 This field contains the association list describing the variables local
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6128 in this buffer, and their values, with the exception of local variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6129 that have special slots in the buffer object. (Those slots are omitted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6130 from this table.) @xref{Buffer-Local Variables,,, lispref, XEmacs Lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6131 Programmer's Manual}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6132
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6133 @item modeline_format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6134 This field contains a Lisp object which controls how to display the mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6135 line for this buffer. @xref{Modeline Format,,, lispref, XEmacs Lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6136 Programmer's Manual}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6137
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6138 @item base_buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6139 This field holds the buffer's base buffer (if it is an indirect buffer),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6140 or @code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6141 @end table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6142
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6143 @node MULE Character Sets and Encodings, The Lisp Reader and Compiler, Buffers and Textual Representation, Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6144 @chapter MULE Character Sets and Encodings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6145
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6146 Recall that there are two primary ways that text is represented in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6147 XEmacs. The @dfn{buffer} representation sees the text as a series of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6148 bytes (Bufbytes), with a variable number of bytes used per character.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6149 The @dfn{character} representation sees the text as a series of integers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6150 (Emchars), one per character. The character representation is a cleaner
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6151 representation from a theoretical standpoint, and is thus used in many
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6152 cases when lots of manipulations on a string need to be done. However,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6153 the buffer representation is the standard representation used in both
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6154 Lisp strings and buffers, and because of this, it is the ``default''
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6155 representation that text comes in. The reason for using this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6156 representation is that it's compact and is compatible with ASCII.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6157
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6158 @menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6159 * Character Sets::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6160 * Encodings::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6161 * Internal Mule Encodings::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6162 * CCL::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6163 @end menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6164
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6165 @node Character Sets
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6166 @section Character Sets
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6167
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6168 A character set (or @dfn{charset}) is an ordered set of characters. A
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6169 particular character in a charset is indexed using one or more
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6170 @dfn{position codes}, which are non-negative integers. The number of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6171 position codes needed to identify a particular character in a charset is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6172 called the @dfn{dimension} of the charset. In XEmacs/Mule, all charsets
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6173 have dimension 1 or 2, and the size of all charsets (except for a few
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6174 special cases) is either 94, 96, 94 by 94, or 96 by 96. The range of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6175 position codes used to index characters from any of these types of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6176 character sets is as follows:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6177
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6178 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6179 Charset type Position code 1 Position code 2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6180 ------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6181 94 33 - 126 N/A
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6182 96 32 - 127 N/A
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6183 94x94 33 - 126 33 - 126
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6184 96x96 32 - 127 32 - 127
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6185 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6186
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6187 Note that in the above cases position codes do not start at an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6188 expected value such as 0 or 1. The reason for this will become clear
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6189 later.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6190
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6191 For example, Latin-1 is a 96-character charset, and JISX0208 (the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6192 Japanese national character set) is a 94x94-character charset.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6193
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6194 [Note that, although the ranges above define the @emph{valid} position
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6195 codes for a charset, some of the slots in a particular charset may in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6196 fact be empty. This is the case for JISX0208, for example, where (e.g.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6197 all the slots whose first position code is in the range 118 - 127 are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6198 empty.]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6199
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6200 There are three charsets that do not follow the above rules. All of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6201 them have one dimension, and have ranges of position codes as follows:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6202
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6203 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6204 Charset name Position code 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6205 ------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6206 ASCII 0 - 127
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6207 Control-1 0 - 31
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6208 Composite 0 - some large number
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6209 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6210
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6211 (The upper bound of the position code for composite characters has not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6212 yet been determined, but it will probably be at least 16,383).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6213
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6214 ASCII is the union of two subsidiary character sets: Printing-ASCII
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6215 (the printing ASCII character set, consisting of position codes 33 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6216 126, like for a standard 94-character charset) and Control-ASCII (the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6217 non-printing characters that would appear in a binary file with codes 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6218 - 32 and 127).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6219
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6220 Control-1 contains the non-printing characters that would appear in a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6221 binary file with codes 128 - 159.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6222
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6223 Composite contains characters that are generated by overstriking one
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6224 or more characters from other charsets.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6225
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6226 Note that some characters in ASCII, and all characters in Control-1,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6227 are @dfn{control} (non-printing) characters. These have no printed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6228 representation but instead control some other function of the printing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6229 (e.g. TAB or 8 moves the current character position to the next tab
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6230 stop). All other characters in all charsets are @dfn{graphic}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6231 (printing) characters.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6232
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6233 When a binary file is read in, the bytes in the file are assigned to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6234 character sets as follows:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6235
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6236 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6237 Bytes Character set Range
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6238 --------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6239 0 - 127 ASCII 0 - 127
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6240 128 - 159 Control-1 0 - 31
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6241 160 - 255 Latin-1 32 - 127
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6242 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6243
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6244 This is a bit ad-hoc but gets the job done.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6245
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6246 @node Encodings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6247 @section Encodings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6248
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6249 An @dfn{encoding} is a way of numerically representing characters from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6250 one or more character sets. If an encoding only encompasses one
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6251 character set, then the position codes for the characters in that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6252 character set could be used directly. This is not possible, however, if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6253 more than one character set is to be used in the encoding.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6254
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6255 For example, the conversion detailed above between bytes in a binary
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6256 file and characters is effectively an encoding that encompasses the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6257 three character sets ASCII, Control-1, and Latin-1 in a stream of 8-bit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6258 bytes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6259
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6260 Thus, an encoding can be viewed as a way of encoding characters from a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6261 specified group of character sets using a stream of bytes, each of which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6262 contains a fixed number of bits (but not necessarily 8, as in the common
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6263 usage of ``byte'').
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6264
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6265 Here are descriptions of a couple of common
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6266 encodings:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6267
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6268 @menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6269 * Japanese EUC (Extended Unix Code)::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6270 * JIS7::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6271 @end menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6272
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6273 @node Japanese EUC (Extended Unix Code)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6274 @subsection Japanese EUC (Extended Unix Code)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6275
44
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
6276 This encompasses the character sets Printing-ASCII, Japanese-JISSX0201,
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
6277 and Japanese-JISX0208-Kana (half-width katakana, the right half of
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6278 JISX0201). It uses 8-bit bytes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6279
44
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
6280 Note that Printing-ASCII and Japanese-JISX0201-Kana are 94-character
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
6281 charsets, while Japanese-JISX0208 is a 94x94-character charset.
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
6282
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
6283 The encoding is as follows:
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6284
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6285 @example
44
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
6286 Character set Representation (PC=position-code)
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
6287 ------------- --------------
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
6288 Printing-ASCII PC1
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
6289 Japanese-JISX0201-Kana 0x8E | PC1 + 0x80
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
6290 Japanese-JISX0208 PC1 + 0x80 | PC2 + 0x80
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
6291 Japanese-JISX0212 PC1 + 0x80 | PC2 + 0x80
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6292 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6293
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6294
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6295 @node JIS7
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6296 @subsection JIS7
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6297
44
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
6298 This encompasses the character sets Printing-ASCII,
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
6299 Japanese-JISX0201-Roman (the left half of JISX0201; this character set
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
6300 is very similar to Printing-ASCII and is a 94-character charset),
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
6301 Japanese-JISX0208, and Japanese-JISX0201-Kana. It uses 7-bit bytes.
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
6302
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
6303 Unlike Japanese EUC, this is a @dfn{modal} encoding, which
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6304 means that there are multiple states that the encoding can
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6305 be in, which affect how the bytes are to be interpreted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6306 Special sequences of bytes (called @dfn{escape sequences})
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6307 are used to change states.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6308
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6309 The encoding is as follows:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6310
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6311 @example
44
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
6312 Character set Representation (PC=position-code)
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
6313 ------------- --------------
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
6314 Printing-ASCII PC1
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
6315 Japanese-JISX0201-Roman PC1
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
6316 Japanese-JISX0201-Kana PC1
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
6317 Japanese-JISX0208 PC1 PC2
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6318
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6319
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6320 Escape sequence ASCII equivalent Meaning
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6321 --------------- ---------------- -------
44
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
6322 0x1B 0x28 0x4A ESC ( J invoke Japanese-JISX0201-Roman
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
6323 0x1B 0x28 0x49 ESC ( I invoke Japanese-JISX0201-Kana
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
6324 0x1B 0x24 0x42 ESC $ B invoke Japanese-JISX0208
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6325 0x1B 0x28 0x42 ESC ( B invoke Printing-ASCII
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6326 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6327
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6328 Initially, Printing-ASCII is invoked.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6329
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6330 @node Internal Mule Encodings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6331 @section Internal Mule Encodings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6332
44
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
6333 In XEmacs/Mule, each character set is assigned a unique number, called a
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
6334 @dfn{leading byte}. This is used in the encodings of a character.
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
6335 Leading bytes are in the range 0x80 - 0xFF (except for ASCII, which has
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
6336 a leading byte of 0), although some leading bytes are reserved.
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
6337
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
6338 Charsets whose leading byte is in the range 0x80 - 0x9F are called
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
6339 @dfn{official} and are used for built-in charsets. Other charsets are
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
6340 called @dfn{private} and have leading bytes in the range 0xA0 - 0xFF;
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
6341 these are user-defined charsets.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6342
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6343 More specifically:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6344
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6345 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6346 Character set Leading byte
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6347 ------------- ------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6348 ASCII 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6349 Composite 0x80
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6350 Dimension-1 Official 0x81 - 0x8D
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6351 (0x8E is free)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6352 Control-1 0x8F
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6353 Dimension-2 Official 0x90 - 0x99
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6354 (0x9A - 0x9D are free;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6355 0x9E and 0x9F are reserved)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6356 Dimension-1 Private 0xA0 - 0xEF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6357 Dimension-2 Private 0xF0 - 0xFF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6358 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6359
44
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
6360 There are two internal encodings for characters in XEmacs/Mule. One is
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
6361 called @dfn{string encoding} and is an 8-bit encoding that is used for
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
6362 representing characters in a buffer or string. It uses 1 to 4 bytes per
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
6363 character. The other is called @dfn{character encoding} and is a 19-bit
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
6364 encoding that is used for representing characters individually in a
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
6365 variable.
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
6366
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
6367 (In the following descriptions, we'll ignore composite characters for
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
6368 the moment. We also give a general (structural) overview first,
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
6369 followed later by the exact details.)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6370
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6371 @menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6372 * Internal String Encoding::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6373 * Internal Character Encoding::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6374 @end menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6375
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6376 @node Internal String Encoding
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6377 @subsection Internal String Encoding
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6378
44
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
6379 ASCII characters are encoded using their position code directly. Other
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
6380 characters are encoded using their leading byte followed by their
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
6381 position code(s) with the high bit set. Characters in private character
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
6382 sets have their leading byte prefixed with a @dfn{leading byte prefix},
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
6383 which is either 0x9E or 0x9F. (No character sets are ever assigned these
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 34
diff changeset
6384 leading bytes.) Specifically:
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6385
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6386 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6387 Character set Encoding (PC=position-code, LB=leading-byte)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6388 ------------- --------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6389 ASCII PC-1 |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6390 Control-1 LB | PC1 + 0xA0 |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6391 Dimension-1 official LB | PC1 + 0x80 |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6392 Dimension-1 private 0x9E | LB | PC1 + 0x80 |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6393 Dimension-2 official LB | PC1 + 0x80 | PC2 + 0x80 |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6394 Dimension-2 private 0x9F | LB | PC1 + 0x80 | PC2 + 0x80
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6395 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6396
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6397 The basic characteristic of this encoding is that the first byte
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6398 of all characters is in the range 0x00 - 0x9F, and the second and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6399 following bytes of all characters is in the range 0xA0 - 0xFF.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6400 This means that it is impossible to get out of sync, or more
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6401 specifically:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6402
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6403 @enumerate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6404 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6405 Given any byte position, the beginning of the character it is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6406 within can be determined in constant time.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6407 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6408 Given any byte position at the beginning of a character, the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6409 beginning of the next character can be determined in constant
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6410 time.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6411 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6412 Given any byte position at the beginning of a character, the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6413 beginning of the previous character can be determined in constant
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6414 time.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6415 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6416 Textual searches can simply treat encoded strings as if they
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6417 were encoded in a one-byte-per-character fashion rather than
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6418 the actual multi-byte encoding.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6419 @end enumerate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6420
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6421 None of the standard non-modal encodings meet all of these
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6422 conditions. For example, EUC satisfies only (2) and (3), while
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6423 Shift-JIS and Big5 (not yet described) satisfy only (2). (All
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6424 non-modal encodings must satisfy (2), in order to be unambiguous.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6425
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6426 @node Internal Character Encoding
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6427 @subsection Internal Character Encoding
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6428
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6429 One 19-bit word represents a single character. The word is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6430 separated into three fields:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6431
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6432 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6433 Bit number: 18 17 16 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6434 <------------> <------------------> <------------------>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6435 Field: 1 2 3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6436 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6437
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6438 Note that fields 2 and 3 hold 7 bits each, while field 1 holds 5 bits.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6439
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6440 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6441 Character set Field 1 Field 2 Field 3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6442 ------------- ------- ------- -------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6443 ASCII 0 0 PC1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6444 range: (00 - 7F)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6445 Control-1 0 1 PC1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6446 range: (00 - 1F)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6447 Dimension-1 official 0 LB - 0x80 PC1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6448 range: (01 - 0D) (20 - 7F)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6449 Dimension-1 private 0 LB - 0x80 PC1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6450 range: (20 - 6F) (20 - 7F)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6451 Dimension-2 official LB - 0x8F PC1 PC2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6452 range: (01 - 0A) (20 - 7F) (20 - 7F)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6453 Dimension-2 private LB - 0xE1 PC1 PC2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6454 range: (0F - 1E) (20 - 7F) (20 - 7F)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6455 Composite 0x1F ? ?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6456 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6457
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6458 Note that character codes 0 - 255 are the same as the ``binary encoding''
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6459 described above.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6460
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6461 @node CCL
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6462 @section CCL
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6463
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6464 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6465 CCL PROGRAM SYNTAX:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6466 CCL_PROGRAM := (CCL_MAIN_BLOCK
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6467 [ CCL_EOF_BLOCK ])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6468
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6469 CCL_MAIN_BLOCK := CCL_BLOCK
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6470 CCL_EOF_BLOCK := CCL_BLOCK
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6471
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6472 CCL_BLOCK := STATEMENT | (STATEMENT [STATEMENT ...])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6473 STATEMENT :=
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6474 SET | IF | BRANCH | LOOP | REPEAT | BREAK
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6475 | READ | WRITE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6476
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6477 SET := (REG = EXPRESSION) | (REG SELF_OP EXPRESSION)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6478 | INT-OR-CHAR
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6479
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6480 EXPRESSION := ARG | (EXPRESSION OP ARG)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6481
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6482 IF := (if EXPRESSION CCL_BLOCK CCL_BLOCK)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6483 BRANCH := (branch EXPRESSION CCL_BLOCK [CCL_BLOCK ...])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6484 LOOP := (loop STATEMENT [STATEMENT ...])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6485 BREAK := (break)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6486 REPEAT := (repeat)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6487 | (write-repeat [REG | INT-OR-CHAR | string])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6488 | (write-read-repeat REG [INT-OR-CHAR | string | ARRAY]?)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6489 READ := (read REG) | (read REG REG)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6490 | (read-if REG ARITH_OP ARG CCL_BLOCK CCL_BLOCK)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6491 | (read-branch REG CCL_BLOCK [CCL_BLOCK ...])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6492 WRITE := (write REG) | (write REG REG)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6493 | (write INT-OR-CHAR) | (write STRING) | STRING
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6494 | (write REG ARRAY)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6495 END := (end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6496
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6497 REG := r0 | r1 | r2 | r3 | r4 | r5 | r6 | r7
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6498 ARG := REG | INT-OR-CHAR
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6499 OP := + | - | * | / | % | & | '|' | ^ | << | >> | <8 | >8 | //
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6500 | < | > | == | <= | >= | !=
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6501 SELF_OP :=
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6502 += | -= | *= | /= | %= | &= | '|=' | ^= | <<= | >>=
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6503 ARRAY := '[' INT-OR-CHAR ... ']'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6504 INT-OR-CHAR := INT | CHAR
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6505
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6506 MACHINE CODE:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6507
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6508 The machine code consists of a vector of 32-bit words.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6509 The first such word specifies the start of the EOF section of the code;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6510 this is the code executed to handle any stuff that needs to be done
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6511 (e.g. designating back to ASCII and left-to-right mode) after all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6512 other encoded/decoded data has been written out. This is not used for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6513 charset CCL programs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6514
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6515 REGISTER: 0..7 -- refered by RRR or rrr
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6516
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6517 OPERATOR BIT FIELD (27-bit): XXXXXXXXXXXXXXX RRR TTTTT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6518 TTTTT (5-bit): operator type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6519 RRR (3-bit): register number
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6520 XXXXXXXXXXXXXXXX (15-bit):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6521 CCCCCCCCCCCCCCC: constant or address
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6522 000000000000rrr: register number
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6523
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6524 AAAA: 00000 +
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6525 00001 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6526 00010 *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6527 00011 /
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6528 00100 %
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6529 00101 &
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6530 00110 |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6531 00111 ~
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6532
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6533 01000 <<
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6534 01001 >>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6535 01010 <8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6536 01011 >8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6537 01100 //
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6538 01101 not used
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6539 01110 not used
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6540 01111 not used
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6541
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6542 10000 <
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6543 10001 >
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6544 10010 ==
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6545 10011 <=
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6546 10100 >=
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6547 10101 !=
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6548
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6549 OPERATORS: TTTTT RRR XX..
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6550
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6551 SetCS: 00000 RRR C...C RRR = C...C
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6552 SetCL: 00001 RRR ..... RRR = c...c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6553 c.............c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6554 SetR: 00010 RRR ..rrr RRR = rrr
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6555 SetA: 00011 RRR ..rrr RRR = array[rrr]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6556 C.............C size of array = C...C
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6557 c.............c contents = c...c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6558
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6559 Jump: 00100 000 c...c jump to c...c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6560 JumpCond: 00101 RRR c...c if (!RRR) jump to c...c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6561 WriteJump: 00110 RRR c...c Write1 RRR, jump to c...c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6562 WriteReadJump: 00111 RRR c...c Write1, Read1 RRR, jump to c...c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6563 WriteCJump: 01000 000 c...c Write1 C...C, jump to c...c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6564 C...C
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6565 WriteCReadJump: 01001 RRR c...c Write1 C...C, Read1 RRR,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6566 C.............C and jump to c...c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6567 WriteSJump: 01010 000 c...c WriteS, jump to c...c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6568 C.............C
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6569 S.............S
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6570 ...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6571 WriteSReadJump: 01011 RRR c...c WriteS, Read1 RRR, jump to c...c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6572 C.............C
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6573 S.............S
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6574 ...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6575 WriteAReadJump: 01100 RRR c...c WriteA, Read1 RRR, jump to c...c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6576 C.............C size of array = C...C
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6577 c.............c contents = c...c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6578 ...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6579 Branch: 01101 RRR C...C if (RRR >= 0 && RRR < C..)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6580 c.............c branch to (RRR+1)th address
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6581 Read1: 01110 RRR ... read 1-byte to RRR
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6582 Read2: 01111 RRR ..rrr read 2-byte to RRR and rrr
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6583 ReadBranch: 10000 RRR C...C Read1 and Branch
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6584 c.............c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6585 ...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6586 Write1: 10001 RRR ..... write 1-byte RRR
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6587 Write2: 10010 RRR ..rrr write 2-byte RRR and rrr
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6588 WriteC: 10011 000 ..... write 1-char C...CC
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6589 C.............C
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6590 WriteS: 10100 000 ..... write C..-byte of string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6591 C.............C
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6592 S.............S
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6593 ...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6594 WriteA: 10101 RRR ..... write array[RRR]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6595 C.............C size of array = C...C
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6596 c.............c contents = c...c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6597 ...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6598 End: 10110 000 ..... terminate the execution
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6599
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6600 SetSelfCS: 10111 RRR C...C RRR AAAAA= C...C
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6601 ..........AAAAA
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6602 SetSelfCL: 11000 RRR ..... RRR AAAAA= c...c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6603 c.............c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6604 ..........AAAAA
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6605 SetSelfR: 11001 RRR ..Rrr RRR AAAAA= rrr
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6606 ..........AAAAA
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6607 SetExprCL: 11010 RRR ..Rrr RRR = rrr AAAAA c...c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6608 c.............c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6609 ..........AAAAA
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6610 SetExprR: 11011 RRR ..rrr RRR = rrr AAAAA Rrr
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6611 ............Rrr
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6612 ..........AAAAA
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6613 JumpCondC: 11100 RRR c...c if !(RRR AAAAA C..) jump to c...c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6614 C.............C
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6615 ..........AAAAA
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6616 JumpCondR: 11101 RRR c...c if !(RRR AAAAA rrr) jump to c...c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6617 ............rrr
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6618 ..........AAAAA
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6619 ReadJumpCondC: 11110 RRR c...c Read1 and JumpCondC
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6620 C.............C
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6621 ..........AAAAA
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6622 ReadJumpCondR: 11111 RRR c...c Read1 and JumpCondR
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6623 ............rrr
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6624 ..........AAAAA
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6625 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6626
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6627 @node The Lisp Reader and Compiler, Lstreams, MULE Character Sets and Encodings, Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6628 @chapter The Lisp Reader and Compiler
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6629
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6630 Not yet documented.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6631
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6632 @node Lstreams, Consoles; Devices; Frames; Windows, The Lisp Reader and Compiler, Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6633 @chapter Lstreams
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6634
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6635 An @dfn{lstream} is an internal Lisp object that provides a generic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6636 buffering stream implementation. Conceptually, you send data to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6637 stream or read data from the stream, not caring what's on the other end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6638 of the stream. The other end could be another stream, a file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6639 descriptor, a stdio stream, a fixed block of memory, a reallocating
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6640 block of memory, etc. The main purpose of the stream is to provide a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6641 standard interface and to do buffering. Macros are defined to read or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6642 write characters, so the calling functions do not have to worry about
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6643 blocking data together in order to achieve efficiency.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6644
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6645 @menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6646 * Creating an Lstream:: Creating an lstream object.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6647 * Lstream Types:: Different sorts of things that are streamed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6648 * Lstream Functions:: Functions for working with lstreams.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6649 * Lstream Methods:: Creating new lstream types.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6650 @end menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6651
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6652 @node Creating an Lstream
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6653 @section Creating an Lstream
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6654
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6655 Lstreams come in different types, depending on what is being interfaced
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6656 to. Although the primitive for creating new lstreams is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6657 @code{Lstream_new()}, generally you do not call this directly. Instead,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6658 you call some type-specific creation function, which creates the lstream
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6659 and initializes it as appropriate for the particular type.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6660
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6661 All lstream creation functions take a @var{mode} argument, specifying
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6662 what mode the lstream should be opened as. This controls whether the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6663 lstream is for input and output, and optionally whether data should be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6664 blocked up in units of MULE characters. Note that some types of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6665 lstreams can only be opened for input; others only for output; and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6666 others can be opened either way. #### Richard Mlynarik thinks that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6667 there should be a strict separation between input and output streams,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6668 and he's probably right.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6669
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6670 @var{mode} is a string, one of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6671
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6672 @table @code
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6673 @item "r"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6674 Open for reading.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6675 @item "w"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6676 Open for writing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6677 @item "rc"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6678 Open for reading, but ``read'' never returns partial MULE characters.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6679 @item "wc"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6680 Open for writing, but never writes partial MULE characters.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6681 @end table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6682
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6683 @node Lstream Types
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6684 @section Lstream Types
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6685
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6686 @table @asis
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6687 @item stdio
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6688
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6689 @item filedesc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6690
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6691 @item lisp-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6692
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6693 @item fixed-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6694
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6695 @item resizing-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6696
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6697 @item dynarr
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6698
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6699 @item lisp-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6700
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6701 @item print
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6702
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6703 @item decoding
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6704
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6705 @item encoding
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6706 @end table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6707
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6708 @node Lstream Functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6709 @section Lstream Functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6710
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6711 @deftypefun {Lstream *} Lstream_new (Lstream_implementation *@var{imp}, CONST char *@var{mode})
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6712 Allocate and return a new Lstream. This function is not really meant to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6713 be called directly; rather, each stream type should provide its own
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6714 stream creation function, which creates the stream and does any other
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6715 necessary creation stuff (e.g. opening a file).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6716 @end deftypefun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6717
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6718 @deftypefun void Lstream_set_buffering (Lstream *@var{lstr}, Lstream_buffering @var{buffering}, int @var{buffering_size})
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6719 Change the buffering of a stream. See @file{lstream.h}. By default the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6720 buffering is @code{STREAM_BLOCK_BUFFERED}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6721 @end deftypefun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6722
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6723 @deftypefun int Lstream_flush (Lstream *@var{lstr})
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6724 Flush out any pending unwritten data in the stream. Clear any buffered
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6725 input data. Returns 0 on success, -1 on error.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6726 @end deftypefun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6727
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6728 @deftypefn Macro int Lstream_putc (Lstream *@var{stream}, int @var{c})
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6729 Write out one byte to the stream. This is a macro and so it is very
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6730 efficient. The @var{c} argument is only evaluated once but the @var{stream}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6731 argument is evaluated more than once. Returns 0 on success, -1 on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6732 error.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6733 @end deftypefn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6734
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6735 @deftypefn Macro int Lstream_getc (Lstream *@var{stream})
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6736 Read one byte from the stream. This is a macro and so it is very
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6737 efficient. The @var{stream} argument is evaluated more than once. Return
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6738 value is -1 for EOF or error.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6739 @end deftypefn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6740
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6741 @deftypefn Macro void Lstream_ungetc (Lstream *@var{stream}, int @var{c})
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6742 Push one byte back onto the input queue. This will be the next byte
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6743 read from the stream. Any number of bytes can be pushed back and will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6744 be read in the reverse order they were pushed back -- most recent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6745 first. (This is necessary for consistency -- if there are a number of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6746 bytes that have been unread and I read and unread a byte, it needs to be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6747 the first to be read again.) This is a macro and so it is very
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6748 efficient. The @var{c} argument is only evaluated once but the @var{stream}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6749 argument is evaluated more than once.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6750 @end deftypefn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6751
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6752 @deftypefun int Lstream_fputc (Lstream *@var{stream}, int @var{c})
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6753 @deftypefunx int Lstream_fgetc (Lstream *@var{stream})
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6754 @deftypefunx void Lstream_fungetc (Lstream *@var{stream}, int @var{c})
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6755 Function equivalents of the above macros.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6756 @end deftypefun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6757
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6758 @deftypefun int Lstream_read (Lstream *@var{stream}, void *@var{data}, int @var{size})
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6759 Read @var{size} bytes of @var{data} from the stream. Return the number
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6760 of bytes read. 0 means EOF. -1 means an error occurred and no bytes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6761 were read.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6762 @end deftypefun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6763
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6764 @deftypefun int Lstream_write (Lstream *@var{stream}, void *@var{data}, int @var{size})
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6765 Write @var{size} bytes of @var{data} to the stream. Return the number
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6766 of bytes written. -1 means an error occurred and no bytes were written.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6767 @end deftypefun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6768
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6769 @deftypefun void Lstream_unread (Lstream *@var{stream}, void *@var{data}, int @var{size})
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6770 Push back @var{size} bytes of @var{data} onto the input queue. The next
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6771 call to @code{Lstream_read()} with the same size will read the same
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6772 bytes back. Note that this will be the case even if there is other
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6773 pending unread data.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6774 @end deftypefun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6775
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6776 @deftypefun int Lstream_close (Lstream *@var{stream})
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6777 Close the stream. All data will be flushed out.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6778 @end deftypefun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6779
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6780 @deftypefun void Lstream_reopen (Lstream *@var{stream})
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6781 Reopen a closed stream. This enables I/O on it again. This is not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6782 meant to be called except from a wrapper routine that reinitializes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6783 variables and such -- the close routine may well have freed some
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6784 necessary storage structures, for example.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6785 @end deftypefun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6786
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6787 @deftypefun void Lstream_rewind (Lstream *@var{stream})
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6788 Rewind the stream to the beginning.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6789 @end deftypefun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6790
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6791 @node Lstream Methods
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6792 @section Lstream Methods
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6793
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6794 @deftypefn {Lstream Method} int reader (Lstream *@var{stream}, unsigned char *@var{data}, int @var{size})
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6795 Read some data from the stream's end and store it into @var{data}, which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6796 can hold @var{size} bytes. Return the number of bytes read. A return
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6797 value of 0 means no bytes can be read at this time. This may be because
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6798 of an EOF, or because there is a granularity greater than one byte that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6799 the stream imposes on the returned data, and @var{size} is less than
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6800 this granularity. (This will happen frequently for streams that need to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6801 return whole characters, because @code{Lstream_read()} calls the reader
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6802 function repeatedly until it has the number of bytes it wants or until 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6803 is returned.) The lstream functions do not treat a 0 return as EOF or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6804 do anything special; however, the calling function will interpret any 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6805 it gets back as EOF. This will normally not happen unless the caller
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6806 calls @code{Lstream_read()} with a very small size.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6807
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6808 This function can be @code{NULL} if the stream is output-only.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6809 @end deftypefn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6810
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6811 @deftypefn {Lstream Method} int writer (Lstream *@var{stream}, CONST unsigned char *@var{data}, int @var{size})
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6812 Send some data to the stream's end. Data to be sent is in @var{data}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6813 and is @var{size} bytes. Return the number of bytes sent. This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6814 function can send and return fewer bytes than is passed in; in that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6815 case, the function will just be called again until there is no data left
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6816 or 0 is returned. A return value of 0 means that no more data can be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6817 currently stored, but there is no error; the data will be squirreled
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6818 away until the writer can accept data. (This is useful, e.g., if you're
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6819 dealing with a non-blocking file descriptor and are getting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6820 @code{EWOULDBLOCK} errors.) This function can be @code{NULL} if the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6821 stream is input-only.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6822 @end deftypefn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6823
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6824 @deftypefn {Lstream Method} int rewinder (Lstream *@var{stream})
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6825 Rewind the stream. If this is @code{NULL}, the stream is not seekable.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6826 @end deftypefn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6827
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6828 @deftypefn {Lstream Method} int seekable_p (Lstream *@var{stream})
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6829 Indicate whether this stream is seekable -- i.e. it can be rewound.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6830 This method is ignored if the stream does not have a rewind method. If
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6831 this method is not present, the result is determined by whether a rewind
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6832 method is present.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6833 @end deftypefn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6834
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6835 @deftypefn {Lstream Method} int flusher (Lstream *@var{stream})
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6836 Perform any additional operations necessary to flush the data in this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6837 stream.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6838 @end deftypefn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6839
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6840 @deftypefn {Lstream Method} int pseudo_closer (Lstream *@var{stream})
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6841 @end deftypefn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6842
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6843 @deftypefn {Lstream Method} int closer (Lstream *@var{stream})
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6844 Perform any additional operations necessary to close this stream down.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6845 May be @code{NULL}. This function is called when @code{Lstream_close()}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6846 is called or when the stream is garbage-collected. When this function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6847 is called, all pending data in the stream will already have been written
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6848 out.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6849 @end deftypefn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6850
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6851 @deftypefn {Lstream Method} Lisp_Object marker (Lisp_Object @var{lstream}, void (*@var{markfun}) (Lisp_Object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6852 Mark this object for garbage collection. Same semantics as a standard
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6853 @code{Lisp_Object} marker. This function can be @code{NULL}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6854 @end deftypefn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6855
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6856 @node Consoles; Devices; Frames; Windows, The Redisplay Mechanism, Lstreams, Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6857 @chapter Consoles; Devices; Frames; Windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6858
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6859 @menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6860 * Introduction to Consoles; Devices; Frames; Windows::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6861 * Point::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6862 * Window Hierarchy::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6863 * The Window Object::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6864 @end menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6865
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6866 @node Introduction to Consoles; Devices; Frames; Windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6867 @section Introduction to Consoles; Devices; Frames; Windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6868
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6869 A window-system window that you see on the screen is called a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6870 @dfn{frame} in Emacs terminology. Each frame is subdivided into one or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6871 more non-overlapping panes, called (confusingly) @dfn{windows}. Each
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6872 window displays the text of a buffer in it. (See above on Buffers.) Note
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6873 that buffers and windows are independent entities: Two or more windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6874 can be displaying the same buffer (potentially in different locations),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6875 and a buffer can be displayed in no windows.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6876
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6877 A single display screen that contains one or more frames is called
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6878 a @dfn{display}. Under most circumstances, there is only one display.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6879 However, more than one display can exist, for example if you have
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6880 a @dfn{multi-headed} console, i.e. one with a single keyboard but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6881 multiple displays. (Typically in such a situation, the various
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6882 displays act like one large display, in that the mouse is only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6883 in one of them at a time, and moving the mouse off of one moves
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6884 it into another.) In some cases, the different displays will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6885 have different characteristics, e.g. one color and one mono.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6886
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6887 XEmacs can display frames on multiple displays. It can even deal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6888 simultaneously with frames on multiple keyboards (called @dfn{consoles} in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6889 XEmacs terminology). Here is one case where this might be useful: You
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6890 are using XEmacs on your workstation at work, and leave it running.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6891 Then you go home and dial in on a TTY line, and you can use the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6892 already-running XEmacs process to display another frame on your local
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6893 TTY.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6894
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6895 Thus, there is a hierarchy console -> display -> frame -> window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6896 There is a separate Lisp object type for each of these four concepts.
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
6897 Furthermore, there is logically a @dfn{selected console},
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6898 @dfn{selected display}, @dfn{selected frame}, and @dfn{selected window}.
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
6899 Each of these objects is distinguished in various ways, such as being the
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
6900 default object for various functions that act on objects of that type.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
6901 Note that every containing object rememembers the ``selected'' object
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
6902 among the objects that it contains: e.g. not only is there a selected
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
6903 window, but every frame remembers the last window in it that was
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
6904 selected, and changing the selected frame causes the remembered window
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
6905 within it to become the selected window. Similar relationships apply
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
6906 for consoles to devices and devices to frames.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6907
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6908 @node Point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6909 @section Point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6910
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6911 Recall that every buffer has a current insertion position, called
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6912 @dfn{point}. Now, two or more windows may be displaying the same buffer,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6913 and the text cursor in the two windows (i.e. @code{point}) can be in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6914 two different places. You may ask, how can that be, since each
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6915 buffer has only one value of @code{point}? The answer is that each window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6916 also has a value of @code{point} that is squirreled away in it. There
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6917 is only one selected window, and the value of ``point'' in that buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6918 corresponds to that window. When the selected window is changed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6919 from one window to another displaying the same buffer, the old
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6920 value of @code{point} is stored into the old window's ``point'' and the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6921 value of @code{point} from the new window is retrieved and made the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6922 value of @code{point} in the buffer. This means that @code{window-point}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6923 for the selected window is potentially inaccurate, and if you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6924 want to retrieve the correct value of @code{point} for a window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6925 you must special-case on the selected window and retrieve the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6926 buffer's point instead. This is related to why @code{save-window-excursion}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6927 does not save the selected window's value of @code{point}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6928
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6929 @node Window Hierarchy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6930 @section Window Hierarchy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6931 @cindex window hierarchy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6932 @cindex hierarchy of windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6933
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6934 If a frame contains multiple windows (panes), they are always created
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6935 by splitting an existing window along the horizontal or vertical axis.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6936 Terminology is a bit confusing here: to @dfn{split a window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6937 horizontally} means to create two side-by-side windows, i.e. to make a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6938 @emph{vertical} cut in a window. Likewise, to @dfn{split a window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6939 vertically} means to create two windows, one above the other, by making
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6940 a @emph{horizontal} cut.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6941
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6942 If you split a window and then split again along the same axis, you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6943 will end up with a number of panes all arranged along the same axis.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6944 The precise way in which the splits were made should not be important,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6945 and this is reflected internally. Internally, all windows are arranged
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6946 in a tree, consisting of two types of windows, @dfn{combination} windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6947 (which have children, and are covered completely by those children) and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6948 @dfn{leaf} windows, which have no children and are visible. Every
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6949 combination window has two or more children, all arranged along the same
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6950 axis. There are (logically) two subtypes of windows, depending on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6951 whether their children are horizontally or vertically arrayed. There is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6952 always one root window, which is either a leaf window (if the frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6953 contains only one window) or a combination window (if the frame contains
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6954 more than one window). In the latter case, the root window will have
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6955 two or more children, either horizontally or vertically arrayed, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6956 each of those children will be either a leaf window or another
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6957 combination window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6958
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6959 Here are some rules:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6960
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6961 @enumerate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6962 @item
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
6963 Horizontal combination windows can never have children that are
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
6964 horizontal combination windows; same for vertical.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6965
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6966 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6967 Only leaf windows can be split (obviously) and this splitting does one
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6968 of two things: (a) turns the leaf window into a combination window and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6969 creates two new leaf children, or (b) turns the leaf window into one of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6970 the two new leaves and creates the other leaf. Rule (1) dictates which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6971 of these two outcomes happens.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6972
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6973 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6974 Every combination window must have at least two children.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6975
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6976 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6977 Leaf windows can never become combination windows. They can be deleted,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6978 however. If this results in a violation of (3), the parent combination
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6979 window also gets deleted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6980
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6981 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6982 All functions that accept windows must be prepared to accept combination
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6983 windows, and do something sane (e.g. signal an error if so).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6984 Combination windows @emph{do} escape to the Lisp level.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6985
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6986 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6987 All windows have three fields governing their contents:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6988 these are @dfn{hchild} (a list of horizontally-arrayed children),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6989 @dfn{vchild} (a list of vertically-arrayed children), and @dfn{buffer}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6990 (the buffer contained in a leaf window). Exactly one of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6991 these will be non-nil. Remember that @dfn{horizontally-arrayed}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6992 means ``side-by-side'' and @dfn{vertically-arrayed} means
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6993 @dfn{one above the other}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6994
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6995 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6996 Leaf windows also have markers in their @code{start} (the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6997 first buffer position displayed in the window) and @code{pointm}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6998 (the window's stashed value of @code{point} -- see above) fields,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6999 while combination windows have nil in these fields.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7000
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7001 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7002 The list of children for a window is threaded through the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7003 @code{next} and @code{prev} fields of each child window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7004
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7005 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7006 @strong{Deleted windows can be undeleted}. This happens as a result of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7007 restoring a window configuration, and is unlike frames, displays, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7008 consoles, which, once deleted, can never be restored. Deleting a window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7009 does nothing except set a special @code{dead} bit to 1 and clear out the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7010 @code{next}, @code{prev}, @code{hchild}, and @code{vchild} fields, for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7011 GC purposes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7012
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7013 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7014 Most frames actually have two top-level windows -- one for the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7015 minibuffer and one (the @dfn{root}) for everything else. The modeline
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7016 (if present) separates these two. The @code{next} field of the root
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7017 points to the minibuffer, and the @code{prev} field of the minibuffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7018 points to the root. The other @code{next} and @code{prev} fields are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7019 @code{nil}, and the frame points to both of these windows.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7020 Minibuffer-less frames have no minibuffer window, and the @code{next}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7021 and @code{prev} of the root window are @code{nil}. Minibuffer-only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7022 frames have no root window, and the @code{next} of the minibuffer window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7023 is @code{nil} but the @code{prev} points to itself. (#### This is an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7024 artifact that should be fixed.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7025 @end enumerate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7026
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7027 @node The Window Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7028 @section The Window Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7029
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7030 Windows have the following accessible fields:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7031
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7032 @table @code
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7033 @item frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7034 The frame that this window is on.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7035
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7036 @item mini_p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7037 Non-@code{nil} if this window is a minibuffer window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7038
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7039 @item buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7040 The buffer that the window is displaying. This may change often during
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7041 the life of the window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7042
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7043 @item dedicated
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7044 Non-@code{nil} if this window is dedicated to its buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7045
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7046 @item pointm
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7047 @cindex window point internals
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7048 This is the value of point in the current buffer when this window is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7049 selected; when it is not selected, it retains its previous value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7050
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7051 @item start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7052 The position in the buffer that is the first character to be displayed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7053 in the window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7054
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7055 @item force_start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7056 If this flag is non-@code{nil}, it says that the window has been
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7057 scrolled explicitly by the Lisp program. This affects what the next
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7058 redisplay does if point is off the screen: instead of scrolling the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7059 window to show the text around point, it moves point to a location that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7060 is on the screen.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7061
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7062 @item last_modified
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7063 The @code{modified} field of the window's buffer, as of the last time
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7064 a redisplay completed in this window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7065
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7066 @item last_point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7067 The buffer's value of point, as of the last time
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7068 a redisplay completed in this window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7069
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7070 @item left
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7071 This is the left-hand edge of the window, measured in columns. (The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7072 leftmost column on the screen is @w{column 0}.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7073
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7074 @item top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7075 This is the top edge of the window, measured in lines. (The top line on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7076 the screen is @w{line 0}.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7077
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7078 @item height
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7079 The height of the window, measured in lines.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7080
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7081 @item width
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7082 The width of the window, measured in columns.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7083
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7084 @item next
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7085 This is the window that is the next in the chain of siblings. It is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7086 @code{nil} in a window that is the rightmost or bottommost of a group of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7087 siblings.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7088
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7089 @item prev
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7090 This is the window that is the previous in the chain of siblings. It is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7091 @code{nil} in a window that is the leftmost or topmost of a group of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7092 siblings.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7093
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7094 @item parent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7095 Internally, XEmacs arranges windows in a tree; each group of siblings has
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7096 a parent window whose area includes all the siblings. This field points
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7097 to a window's parent.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7098
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7099 Parent windows do not display buffers, and play little role in display
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7100 except to shape their child windows. Emacs Lisp programs usually have
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7101 no access to the parent windows; they operate on the windows at the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7102 leaves of the tree, which actually display buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7103
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7104 @item hscroll
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7105 This is the number of columns that the display in the window is scrolled
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7106 horizontally to the left. Normally, this is 0.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7107
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7108 @item use_time
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7109 This is the last time that the window was selected. The function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7110 @code{get-lru-window} uses this field.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7111
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7112 @item display_table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7113 The window's display table, or @code{nil} if none is specified for it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7114
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7115 @item update_mode_line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7116 Non-@code{nil} means this window's mode line needs to be updated.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7117
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7118 @item base_line_number
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7119 The line number of a certain position in the buffer, or @code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7120 This is used for displaying the line number of point in the mode line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7121
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7122 @item base_line_pos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7123 The position in the buffer for which the line number is known, or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7124 @code{nil} meaning none is known.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7125
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7126 @item region_showing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7127 If the region (or part of it) is highlighted in this window, this field
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7128 holds the mark position that made one end of that region. Otherwise,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7129 this field is @code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7130 @end table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7131
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7132 @node The Redisplay Mechanism, Extents, Consoles; Devices; Frames; Windows, Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7133 @chapter The Redisplay Mechanism
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7134
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7135 The redisplay mechanism is one of the most complicated sections of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7136 XEmacs, especially from a conceptual standpoint. This is doubly so
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7137 because, unlike for the basic aspects of the Lisp interpreter, the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7138 computer science theories of how to efficiently handle redisplay are not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7139 well-developed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7140
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7141 When working with the redisplay mechanism, remember the Golden Rules
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7142 of Redisplay:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7143
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7144 @enumerate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7145 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7146 It Is Better To Be Correct Than Fast.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7147 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7148 Thou Shalt Not Run Elisp From Within Redisplay.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7149 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7150 It Is Better To Be Fast Than Not To Be.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7151 @end enumerate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7152
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7153 @menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7154 * Critical Redisplay Sections::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7155 * Line Start Cache::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7156 @end menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7157
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7158 @node Critical Redisplay Sections
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7159 @section Critical Redisplay Sections
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7160 @cindex critical redisplay sections
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7161
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7162 Within this section, we are defenseless and assume that the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7163 following cannot happen:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7164
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7165 @enumerate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7166 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7167 garbage collection
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7168 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7169 Lisp code evaluation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7170 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7171 frame size changes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7172 @end enumerate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7173
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7174 We ensure (3) by calling @code{hold_frame_size_changes()}, which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7175 will cause any pending frame size changes to get put on hold
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7176 till after the end of the critical section. (1) follows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7177 automatically if (2) is met. #### Unfortunately, there are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7178 some places where Lisp code can be called within this section.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7179 We need to remove them.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7180
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7181 If @code{Fsignal()} is called during this critical section, we
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7182 will @code{abort()}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7183
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7184 If garbage collection is called during this critical section,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7185 we simply return. #### We should abort instead.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7186
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7187 #### If a frame-size change does occur we should probably
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7188 actually be preempting redisplay.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7189
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7190 @node Line Start Cache
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7191 @section Line Start Cache
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7192 @cindex line start cache
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7193
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7194 The traditional scrolling code in Emacs breaks in a variable height
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7195 world. It depends on the key assumption that the number of lines that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7196 can be displayed at any given time is fixed. This led to a complete
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7197 separation of the scrolling code from the redisplay code. In order to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7198 fully support variable height lines, the scrolling code must actually be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7199 tightly integrated with redisplay. Only redisplay can determine how
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7200 many lines will be displayed on a screen for any given starting point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7201
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7202 What is ideally wanted is a complete list of the starting buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7203 position for every possible display line of a buffer along with the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7204 height of that display line. Maintaining such a full list would be very
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7205 expensive. We settle for having it include information for all areas
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7206 which we happen to generate anyhow (i.e. the region currently being
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7207 displayed) and for those areas we need to work with.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7208
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7209 In order to ensure that the cache accurately represents what redisplay
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7210 would actually show, it is necessary to invalidate it in many
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7211 situations. If the buffer changes, the starting positions may no longer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7212 be correct. If a face or an extent has changed then the line heights
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7213 may have altered. These events happen frequently enough that the cache
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7214 can end up being constantly disabled. With this potentially constant
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7215 invalidation when is the cache ever useful?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7216
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7217 Even if the cache is invalidated before every single usage, it is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7218 necessary. Scrolling often requires knowledge about display lines which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7219 are actually above or below the visible region. The cache provides a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7220 convenient light-weight method of storing this information for multiple
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7221 display regions. This knowledge is necessary for the scrolling code to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7222 always obey the First Golden Rule of Redisplay.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7223
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7224 If the cache already contains all of the information that the scrolling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7225 routines happen to need so that it doesn't have to go generate it, then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7226 we are able to obey the Third Golden Rule of Redisplay. The first thing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7227 we do to help out the cache is to always add the displayed region. This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7228 region had to be generated anyway, so the cache ends up getting the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7229 information basically for free. In those cases where a user is simply
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7230 scrolling around viewing a buffer there is a high probability that this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7231 is sufficient to always provide the needed information. The second
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7232 thing we can do is be smart about invalidating the cache.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7233
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7234 TODO -- Be smart about invalidating the cache. Potential places:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7235
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7236 @itemize @bullet
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7237 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7238 Insertions at end-of-line which don't cause line-wraps do not alter the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7239 starting positions of any display lines. These types of buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7240 modifications should not invalidate the cache. This is actually a large
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7241 optimization for redisplay speed as well.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7242 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7243 Buffer modifications frequently only affect the display of lines at and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7244 below where they occur. In these situations we should only invalidate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7245 the part of the cache starting at where the modification occurs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7246 @end itemize
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7247
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7248 In case you're wondering, the Second Golden Rule of Redisplay is not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7249 applicable.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7250
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7251 @node Extents, Faces and Glyphs, The Redisplay Mechanism, Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7252 @chapter Extents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7253
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7254 @menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7255 * Introduction to Extents:: Extents are ranges over text, with properties.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7256 * Extent Ordering:: How extents are ordered internally.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7257 * Format of the Extent Info:: The extent information in a buffer or string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7258 * Zero-Length Extents:: A weird special case.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7259 * Mathematics of Extent Ordering:: A rigorous foundation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7260 * Extent Fragments:: Cached information useful for redisplay.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7261 @end menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7262
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7263 @node Introduction to Extents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7264 @section Introduction to Extents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7265
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7266 Extents are regions over a buffer, with a start and an end position
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7267 denoting the region of the buffer included in the extent. In
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7268 addition, either end can be closed or open, meaning that the endpoint
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7269 is or is not logically included in the extent. Insertion of a character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7270 at a closed endpoint causes the character to go inside the extent;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7271 insertion at an open endpoint causes the character to go outside.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7272
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7273 Extent endpoints are stored using memory indices (see @file{insdel.c}),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7274 to minimize the amount of adjusting that needs to be done when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7275 characters are inserted or deleted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7276
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7277 (Formerly, extent endpoints at the gap could be either before or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7278 after the gap, depending on the open/closedness of the endpoint.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7279 The intent of this was to make it so that insertions would
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7280 automatically go inside or out of extents as necessary with no
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7281 further work needing to be done. It didn't work out that way,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7282 however, and just ended up complexifying and buggifying all the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7283 rest of the code.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7284
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7285 @node Extent Ordering
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7286 @section Extent Ordering
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7287
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7288 Extents are compared using memory indices. There are two orderings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7289 for extents and both orders are kept current at all times. The normal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7290 or @dfn{display} order is as follows:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7291
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7292 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7293 Extent A is ``less than'' extent B, that is, earlier in the display order,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7294 if: A-start < B-start,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7295 or if: A-start = B-start, and A-end > B-end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7296 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7297
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7298 So if two extents begin at the same position, the larger of them is the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7299 earlier one in the display order (@code{EXTENT_LESS} is true).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7300
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7301 For the e-order, the same thing holds:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7302
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7303 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7304 Extent A is ``less than'' extent B in e-order, that is, later in the buffer,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7305 if: A-end < B-end,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7306 or if: A-end = B-end, and A-start > B-start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7307 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7308
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7309 So if two extents end at the same position, the smaller of them is the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7310 earlier one in the e-order (@code{EXTENT_E_LESS} is true).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7311
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7312 The display order and the e-order are complementary orders: any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7313 theorem about the display order also applies to the e-order if you swap
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7314 all occurrences of ``display order'' and ``e-order'', ``less than'' and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7315 ``greater than'', and ``extent start'' and ``extent end''.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7316
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7317 @node Format of the Extent Info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7318 @section Format of the Extent Info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7319
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7320 An extent-info structure consists of a list of the buffer or string's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7321 extents and a @dfn{stack of extents} that lists all of the extents over
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7322 a particular position. The stack-of-extents info is used for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7323 optimization purposes -- it basically caches some info that might
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7324 be expensive to compute. Certain otherwise hard computations are easy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7325 given the stack of extents over a particular position, and if the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7326 stack of extents over a nearby position is known (because it was
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7327 calculated at some prior point in time), it's easy to move the stack
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7328 of extents to the proper position.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7329
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7330 Given that the stack of extents is an optimization, and given that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7331 it requires memory, a string's stack of extents is wiped out each
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7332 time a garbage collection occurs. Therefore, any time you retrieve
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7333 the stack of extents, it might not be there. If you need it to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7334 be there, use the @code{_force} version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7335
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7336 Similarly, a string may or may not have an extent_info structure.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7337 (Generally it won't if there haven't been any extents added to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7338 string.) So use the @code{_force} version if you need the extent_info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7339 structure to be there.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7340
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7341 A list of extents is maintained as a double gap array: one gap array
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7342 is ordered by start index (the @dfn{display order}) and the other is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7343 ordered by end index (the @dfn{e-order}). Note that positions in an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7344 extent list should logically be conceived of as referring @emph{to} a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7345 particular extent (as is the norm in programs) rather than sitting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7346 between two extents. Note also that callers of these functions should
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7347 not be aware of the fact that the extent list is implemented as an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7348 array, except for the fact that positions are integers (this should be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7349 generalized to handle integers and linked list equally well).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7350
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7351 @node Zero-Length Extents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7352 @section Zero-Length Extents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7353
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7354 Extents can be zero-length, and will end up that way if their endpoints
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7355 are explicitly set that way or if their detachable property is nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7356 and all the text in the extent is deleted. (The exception is open-open
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7357 zero-length extents, which are barred from existing because there is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7358 no sensible way to define their properties. Deletion of the text in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7359 an open-open extent causes it to be converted into a closed-open
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7360 extent.) Zero-length extents are primarily used to represent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7361 annotations, and behave as follows:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7362
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7363 @enumerate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7364 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7365 Insertion at the position of a zero-length extent expands the extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7366 if both endpoints are closed; goes after the extent if it is closed-open;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7367 and goes before the extent if it is open-closed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7368
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7369 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7370 Deletion of a character on a side of a zero-length extent whose
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7371 corresponding endpoint is closed causes the extent to be detached if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7372 it is detachable; if the extent is not detachable or the corresponding
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7373 endpoint is open, the extent remains in the buffer, moving as necessary.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7374 @end enumerate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7375
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7376 Note that closed-open, non-detachable zero-length extents behave
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7377 exactly like markers and that open-closed, non-detachable zero-length
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7378 extents behave like the ``point-type'' marker in Mule.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7379
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7380 @node Mathematics of Extent Ordering
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7381 @section Mathematics of Extent Ordering
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7382 @cindex extent mathematics
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7383 @cindex mathematics of extents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7384 @cindex extent ordering
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7385
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7386 @cindex display order of extents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7387 @cindex extents, display order
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7388 The extents in a buffer are ordered by ``display order'' because that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7389 is that order that the redisplay mechanism needs to process them in.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7390 The e-order is an auxiliary ordering used to facilitate operations
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7391 over extents. The operations that can be performed on the ordered
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7392 list of extents in a buffer are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7393
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7394 @enumerate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7395 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7396 Locate where an extent would go if inserted into the list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7397 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7398 Insert an extent into the list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7399 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7400 Remove an extent from the list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7401 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7402 Map over all the extents that overlap a range.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7403 @end enumerate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7404
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7405 (4) requires being able to determine the first and last extents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7406 that overlap a range.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7407
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7408 NOTE: @dfn{overlap} is used as follows:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7409
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7410 @itemize @bullet
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7411 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7412 two ranges overlap if they have at least one point in common.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7413 Whether the endpoints are open or closed makes a difference here.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7414 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7415 a point overlaps a range if the point is contained within the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7416 range; this is equivalent to treating a point @math{P} as the range
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7417 @math{[P, P]}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7418 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7419 In the case of an @emph{extent} overlapping a point or range, the extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7420 is normally treated as having closed endpoints. This applies
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7421 consistently in the discussion of stacks of extents and such below.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7422 Note that this definition of overlap is not necessarily consistent with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7423 the extents that @code{map-extents} maps over, since @code{map-extents}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7424 sometimes pays attention to whether the endpoints of an extents are open
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7425 or closed. But for our purposes, it greatly simplifies things to treat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7426 all extents as having closed endpoints.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7427 @end itemize
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7428
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7429 First, define @math{>}, @math{<}, @math{<=}, etc. as applied to extents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7430 to mean comparison according to the display order. Comparison between
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7431 an extent @math{E} and an index @math{I} means comparison between
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7432 @math{E} and the range @math{[I, I]}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7433
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7434 Also define @math{e>}, @math{e<}, @math{e<=}, etc. to mean comparison
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7435 according to the e-order.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7436
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7437 For any range @math{R}, define @math{R(0)} to be the starting index of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7438 the range and @math{R(1)} to be the ending index of the range.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7439
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7440 For any extent @math{E}, define @math{E(next)} to be the extent directly
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7441 following @math{E}, and @math{E(prev)} to be the extent directly
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7442 preceding @math{E}. Assume @math{E(next)} and @math{E(prev)} can be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7443 determined from @math{E} in constant time. (This is because we store
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7444 the extent list as a doubly linked list.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7445
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7446 Similarly, define @math{E(e-next)} and @math{E(e-prev)} to be the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7447 extents directly following and preceding @math{E} in the e-order.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7448
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7449 Now:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7450
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7451 Let @math{R} be a range.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7452 Let @math{F} be the first extent overlapping @math{R}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7453 Let @math{L} be the last extent overlapping @math{R}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7454
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7455 Theorem 1: @math{R(1)} lies between @math{L} and @math{L(next)},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7456 i.e. @math{L <= R(1) < L(next)}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7457
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7458 This follows easily from the definition of display order. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7459 basic reason that this theorem applies is that the display order
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7460 sorts by increasing starting index.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7461
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7462 Therefore, we can determine @math{L} just by looking at where we would
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7463 insert @math{R(1)} into the list, and if we know @math{F} and are moving
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7464 forward over extents, we can easily determine when we've hit @math{L} by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7465 comparing the extent we're at to @math{R(1)}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7466
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7467 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7468 Theorem 2: @math{F(e-prev) e< [1, R(0)] e<= F}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7469 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7470
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7471 This is the analog of Theorem 1, and applies because the e-order
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7472 sorts by increasing ending index.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7473
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7474 Therefore, @math{F} can be found in the same amount of time as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7475 operation (1), i.e. the time that it takes to locate where an extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7476 would go if inserted into the e-order list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7477
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7478 If the lists were stored as balanced binary trees, then operation (1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7479 would take logarithmic time, which is usually quite fast. However,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7480 currently they're stored as simple doubly-linked lists, and instead we
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7481 do some caching to try to speed things up.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7482
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7483 Define a @dfn{stack of extents} (or @dfn{SOE}) as the set of extents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7484 (ordered in the display order) that overlap an index @math{I}, together
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7485 with the SOE's @dfn{previous} extent, which is an extent that precedes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7486 @math{I} in the e-order. (Hopefully there will not be very many extents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7487 between @math{I} and the previous extent.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7488
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7489 Now:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7490
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7491 Let @math{I} be an index, let @math{S} be the stack of extents on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7492 @math{I}, let @math{F} be the first extent in @math{S}, and let @math{P}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7493 be @math{S}'s previous extent.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7494
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7495 Theorem 3: The first extent in @math{S} is the first extent that overlaps
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7496 any range @math{[I, J]}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7497
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7498 Proof: Any extent that overlaps @math{[I, J]} but does not include
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7499 @math{I} must have a start index @math{> I}, and thus be greater than
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7500 any extent in @math{S}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7501
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7502 Therefore, finding the first extent that overlaps a range @math{R} is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7503 the same as finding the first extent that overlaps @math{R(0)}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7504
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7505 Theorem 4: Let @math{I2} be an index such that @math{I2 > I}, and let
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7506 @math{F2} be the first extent that overlaps @math{I2}. Then, either
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7507 @math{F2} is in @math{S} or @math{F2} is greater than any extent in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7508 @math{S}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7509
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7510 Proof: If @math{F2} does not include @math{I} then its start index is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7511 greater than @math{I} and thus it is greater than any extent in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7512 @math{S}, including @math{F}. Otherwise, @math{F2} includes @math{I}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7513 and thus is in @math{S}, and thus @math{F2 >= F}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7514
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7515 @node Extent Fragments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7516 @section Extent Fragments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7517 @cindex extent fragment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7518
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7519 Imagine that the buffer is divided up into contiguous, non-overlapping
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7520 @dfn{runs} of text such that no extent starts or ends within a run
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7521 (extents that abut the run don't count).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7522
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7523 An extent fragment is a structure that holds data about the run that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7524 contains a particular buffer position (if the buffer position is at the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7525 junction of two runs, the run after the position is used) -- the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7526 beginning and end of the run, a list of all of the extents in that run,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7527 the @dfn{merged face} that results from merging all of the faces
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7528 corresponding to those extents, the begin and end glyphs at the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7529 beginning of the run, etc. This is the information that redisplay needs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7530 in order to display this run.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7531
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7532 Extent fragments have to be very quick to update to a new buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7533 position when moving linearly through the buffer. They rely on the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7534 stack-of-extents code, which does the heavy-duty algorithmic work of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7535 determining which extents overly a particular position.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7536
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7537 @node Faces and Glyphs, Specifiers, Extents, Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7538 @chapter Faces and Glyphs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7539
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7540 Not yet documented.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7541
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7542 @node Specifiers, Menus, Faces and Glyphs, Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7543 @chapter Specifiers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7544
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7545 Not yet documented.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7546
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7547 @node Menus, Subprocesses, Specifiers, Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7548 @chapter Menus
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7549
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7550 A menu is set by setting the value of the variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7551 @code{current-menubar} (which may be buffer-local) and then calling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7552 @code{set-menubar-dirty-flag} to signal a change. This will cause the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7553 menu to be redrawn at the next redisplay. The format of the data in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7554 @code{current-menubar} is described in @file{menubar.c}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7555
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7556 Internally the data in current-menubar is parsed into a tree of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7557 @code{widget_value's} (defined in @file{lwlib.h}); this is accomplished
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7558 by the recursive function @code{menu_item_descriptor_to_widget_value()},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7559 called by @code{compute_menubar_data()}. Such a tree is deallocated
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7560 using @code{free_widget_value()}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7561
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7562 @code{update_screen_menubars()} is one of the external entry points.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7563 This checks to see, for each screen, if that screen's menubar needs to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7564 be updated. This is the case if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7565
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7566 @enumerate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7567 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7568 @code{set-menubar-dirty-flag} was called since the last redisplay. (This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7569 function sets the C variable menubar_has_changed.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7570 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7571 The buffer displayed in the screen has changed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7572 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7573 The screen has no menubar currently displayed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7574 @end enumerate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7575
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7576 @code{set_screen_menubar()} is called for each such screen. This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7577 function calls @code{compute_menubar_data()} to create the tree of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7578 widget_value's, then calls @code{lw_create_widget()},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7579 @code{lw_modify_all_widgets()}, and/or @code{lw_destroy_all_widgets()}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7580 to create the X-Toolkit widget associated with the menu.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7581
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7582 @code{update_psheets()}, the other external entry point, actually
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7583 changes the menus being displayed. It uses the widgets fixed by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7584 @code{update_screen_menubars()} and calls various X functions to ensure
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7585 that the menus are displayed properly.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7586
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7587 The menubar widget is set up so that @code{pre_activate_callback()} is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7588 called when the menu is first selected (i.e. mouse button goes down),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7589 and @code{menubar_selection_callback()} is called when an item is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7590 selected. @code{pre_activate_callback()} calls the function in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7591 activate-menubar-hook, which can change the menubar (this is described
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7592 in @file{menubar.c}). If the menubar is changed,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7593 @code{set_screen_menubars()} is called.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7594 @code{menubar_selection_callback()} enqueues a menu event, putting in it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7595 a function to call (either @code{eval} or @code{call-interactively}) and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7596 its argument, which is the callback function or form given in the menu's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7597 description.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7598
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7599 @node Subprocesses, Interface to X Windows, Menus, Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7600 @chapter Subprocesses
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7601
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7602 The fields of a process are:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7603
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7604 @table @code
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7605 @item name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7606 A string, the name of the process.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7607
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7608 @item command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7609 A list containing the command arguments that were used to start this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7610 process.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7611
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7612 @item filter
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7613 A function used to accept output from the process instead of a buffer,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7614 or @code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7615
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7616 @item sentinel
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7617 A function called whenever the process receives a signal, or @code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7618
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7619 @item buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7620 The associated buffer of the process.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7621
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7622 @item pid
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7623 An integer, the Unix process @sc{id}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7624
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7625 @item childp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7626 A flag, non-@code{nil} if this is really a child process.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7627 It is @code{nil} for a network connection.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7628
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7629 @item mark
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7630 A marker indicating the position of the end of the last output from this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7631 process inserted into the buffer. This is often but not always the end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7632 of the buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7633
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7634 @item kill_without_query
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7635 If this is non-@code{nil}, killing XEmacs while this process is still
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7636 running does not ask for confirmation about killing the process.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7637
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7638 @item raw_status_low
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7639 @itemx raw_status_high
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7640 These two fields record 16 bits each of the process status returned by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7641 the @code{wait} system call.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7642
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7643 @item status
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7644 The process status, as @code{process-status} should return it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7645
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7646 @item tick
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7647 @itemx update_tick
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7648 If these two fields are not equal, a change in the status of the process
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7649 needs to be reported, either by running the sentinel or by inserting a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7650 message in the process buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7651
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7652 @item pty_flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7653 Non-@code{nil} if communication with the subprocess uses a @sc{pty};
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7654 @code{nil} if it uses a pipe.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7655
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7656 @item infd
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7657 The file descriptor for input from the process.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7658
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7659 @item outfd
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7660 The file descriptor for output to the process.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7661
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7662 @item subtty
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7663 The file descriptor for the terminal that the subprocess is using. (On
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7664 some systems, there is no need to record this, so the value is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7665 @code{-1}.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7666
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7667 @item tty_name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7668 The name of the terminal that the subprocess is using,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7669 or @code{nil} if it is using pipes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7670 @end table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7671
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7672 @node Interface to X Windows, Index, Subprocesses, Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7673 @chapter Interface to X Windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7674
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7675 Not yet documented.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7676
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7677 @include index.texi
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7678
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7679 @c Print the tables of contents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7680 @summarycontents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7681 @contents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7682 @c That's all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7683
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7684 @bye
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7685