Mercurial > hg > xemacs-beta
comparison man/internals/internals.texi @ 2393:2d4dd2ef74e7
[xemacs-hg @ 2004-11-16 07:37:29 by ben]
internals update
internals/internals.texi: Add sections on Basic Types and Low-Level Allocation. Move module
docs here. Incorporate dynamic array and blocktype docs from
source.
Add info on beta releases up to present.
Redo chapter on "Rules When Writing New C Code", grouping stuff
together properly. Put "Major Textual Changes" under this
chapter. Incorporate etc/CODING-STANDARDS.
Add discussion sections on "Instantiators and Generic Property
Accessors" and "Switching to C++". Fill out discussion on garbage
collection.
Incorporate backtraces showing crashes due to problems with
redisplay-critical-section protection.
author | ben |
---|---|
date | Tue, 16 Nov 2004 07:37:31 +0000 |
parents | ce4aa0ef8af1 |
children | a27c2650a716 |
comparison
equal
deleted
inserted
replaced
2392:9c4b194e4122 | 2393:2d4dd2ef74e7 |
---|---|
309 * XEmacs from the Outside:: A broad conceptual overview. | 309 * XEmacs from the Outside:: A broad conceptual overview. |
310 * The Lisp Language:: An overview. | 310 * The Lisp Language:: An overview. |
311 * XEmacs from the Perspective of Building:: | 311 * XEmacs from the Perspective of Building:: |
312 * Build-Time Dependencies:: | 312 * Build-Time Dependencies:: |
313 * The Modules of XEmacs:: | 313 * The Modules of XEmacs:: |
314 * Major Textual Changes:: | |
315 * Rules When Writing New C Code:: | 314 * Rules When Writing New C Code:: |
316 * Regression Testing XEmacs:: | 315 * Regression Testing XEmacs:: |
317 * CVS Techniques:: | 316 * CVS Techniques:: |
318 * XEmacs from the Inside:: | 317 * XEmacs from the Inside:: |
318 * Basic Types:: | |
319 * Low-Level Allocation:: | |
319 * The XEmacs Object System (Abstractly Speaking):: | 320 * The XEmacs Object System (Abstractly Speaking):: |
320 * How Lisp Objects Are Represented in C:: | 321 * How Lisp Objects Are Represented in C:: |
321 * Allocation of Objects in XEmacs Lisp:: | 322 * Allocation of Objects in XEmacs Lisp:: |
322 * The Lisp Reader and Compiler:: | 323 * The Lisp Reader and Compiler:: |
323 * Evaluation; Stack Frames; Bindings:: | 324 * Evaluation; Stack Frames; Bindings:: |
348 --- The Detailed Node Listing --- | 349 --- The Detailed Node Listing --- |
349 | 350 |
350 A History of Emacs | 351 A History of Emacs |
351 | 352 |
352 * Through Version 18:: Unification prevails. | 353 * Through Version 18:: Unification prevails. |
354 * Epoch:: An early graphical split of GNU Emacs. | |
353 * Lucid Emacs:: One version 19 Emacs. | 355 * Lucid Emacs:: One version 19 Emacs. |
354 * GNU Emacs 19:: The other version 19 Emacs. | 356 * GNU Emacs 19:: The other version 19 Emacs. |
355 * GNU Emacs 20:: The other version 20 Emacs. | 357 * GNU Emacs 20:: The other version 20 Emacs. |
356 * XEmacs:: The continuation of Lucid Emacs. | 358 * XEmacs:: The continuation of Lucid Emacs. |
357 | 359 |
363 * Modules for Standard Editing Operations:: | 365 * Modules for Standard Editing Operations:: |
364 * Modules for Interfacing with the File System:: | 366 * Modules for Interfacing with the File System:: |
365 * Modules for Other Aspects of the Lisp Interpreter and Object System:: | 367 * Modules for Other Aspects of the Lisp Interpreter and Object System:: |
366 * Modules for Interfacing with the Operating System:: | 368 * Modules for Interfacing with the Operating System:: |
367 | 369 |
368 Major Textual Changes | |
369 | |
370 * Great Integral Type Renaming:: | |
371 * Text/Char Type Renaming:: | |
372 | |
373 Rules When Writing New C Code | 370 Rules When Writing New C Code |
374 | 371 |
375 * A Reader's Guide to XEmacs Coding Conventions:: | 372 * Introduction to Writing C Code:: |
376 * General Coding Rules:: | 373 * Writing New Modules:: |
377 * Object-Oriented Techniques for C:: | 374 * Working with Lisp Objects:: |
378 * Writing Lisp Primitives:: | 375 * Writing Lisp Primitives:: |
379 * Writing Good Comments:: | 376 * Writing Good Comments:: |
380 * Adding Global Lisp Variables:: | 377 * Adding Global Lisp Variables:: |
381 * Writing Macros:: | 378 * Writing Macros:: |
382 * Proper Use of Unsigned Types:: | 379 * Proper Use of Unsigned Types:: |
383 * Techniques for XEmacs Developers:: | 380 * Major Textual Changes:: |
381 * Debugging and Testing:: | |
382 | |
383 Major Textual Changes | |
384 | |
385 * Great Integral Type Renaming:: | |
386 * Text/Char Type Renaming:: | |
384 | 387 |
385 Regression Testing XEmacs | 388 Regression Testing XEmacs |
386 | 389 |
387 * How to Regression-Test:: | 390 * How to Regression-Test:: |
388 * Modules for Regression Testing:: | 391 * Modules for Regression Testing:: |
389 | 392 |
390 CVS Techniques | 393 CVS Techniques |
391 | 394 |
392 * Merging a Branch into the Trunk:: | 395 * Merging a Branch into the Trunk:: |
396 | |
397 Low-Level Allocation | |
398 | |
399 * Basic Heap Allocation:: | |
400 * Stack Allocation:: | |
401 * Dynamic Arrays:: | |
402 * Allocation by Blocks:: | |
403 * Modules for Allocation:: | |
393 | 404 |
394 Allocation of Objects in XEmacs Lisp | 405 Allocation of Objects in XEmacs Lisp |
395 | 406 |
396 * Introduction to Allocation:: | 407 * Introduction to Allocation:: |
397 * Garbage Collection:: | 408 * Garbage Collection:: |
662 * Future Work -- Lisp Engine Replacement -- Implementation:: | 673 * Future Work -- Lisp Engine Replacement -- Implementation:: |
663 * Future Work -- Startup File Modification by Packages:: | 674 * Future Work -- Startup File Modification by Packages:: |
664 | 675 |
665 Future Work Discussion | 676 Future Work Discussion |
666 | 677 |
667 * Discussion -- garbage collection:: | 678 * Discussion -- Garbage Collection:: |
668 * Discussion -- glyphs:: | 679 * Discussion -- Glyphs:: |
669 * Discussion -- Dialog Boxes:: | 680 * Discussion -- Dialog Boxes:: |
670 * Discussion -- Multilingual Issues:: | 681 * Discussion -- Multilingual Issues:: |
682 * Discussion -- Instantiators and Generic Property Accessors:: | |
683 * Discussion -- Switching to C++:: | |
671 * Discussion -- Windows External Widget:: | 684 * Discussion -- Windows External Widget:: |
672 * Discussion -- Packages:: | 685 * Discussion -- Packages:: |
673 * Discussion -- Distribution Layout:: | 686 * Discussion -- Distribution Layout:: |
687 | |
688 Discussion -- Garbage Collection | |
689 | |
690 * Discussion -- Pure Space:: | |
691 * Discussion -- Hashtable-Based Marking and Cleanup:: | |
692 * Discussion -- The Anti-Cons:: | |
674 | 693 |
675 Old Future Work | 694 Old Future Work |
676 | 695 |
677 * Old Future Work -- A Portable Unexec Replacement:: | 696 * Old Future Work -- A Portable Unexec Replacement:: |
678 * Old Future Work -- Indirect Buffers:: | 697 * Old Future Work -- Indirect Buffers:: |
718 @enumerate | 737 @enumerate |
719 @item | 738 @item |
720 First is the introduction, including this chapter and chapters on the | 739 First is the introduction, including this chapter and chapters on the |
721 history and authorship of XEmacs. | 740 history and authorship of XEmacs. |
722 @item | 741 @item |
723 Next, starting with @ref{XEmacs from the Outside}, are some chapters | 742 Next, starting with @ref{XEmacs from the Outside}, are a couple of chapters |
724 giving a broad overview of the internal workings of XEmacs and | 743 giving a broad overview of the internal workings of XEmacs. |
725 documenting important information relevant to those working on the code. | 744 @item |
745 Afterwards, starting with @ref{XEmacs from the Perspective of | |
746 Building}, are some chapters documenting important information relevant to | |
747 those working on the code. | |
726 @item | 748 @item |
727 The remaining divisions document the nitty-gritty details of the | 749 The remaining divisions document the nitty-gritty details of the |
728 internal workings. First, starting with @ref{XEmacs from the Outside}, | 750 internal workings. First, starting with @ref{XEmacs from the Inside}, |
729 is a division on the workings of the Lisp interpreter that drives | 751 is a division on the low-level types and allocation routines and the |
730 XEmacs. | 752 workings of the Lisp interpreter that drives XEmacs. |
731 @item | 753 @item |
732 Next, starting with @ref{Buffers}, is a division on the parts of the | 754 Next, starting with @ref{Buffers}, is a division on the parts of the |
733 code specifically devoted to text processing, including multilingual | 755 code specifically devoted to text processing, including multilingual |
734 support (Mule). | 756 support (Mule). |
735 @item | 757 @item |
850 documentation including the internals manual and the Xemacs editions to | 872 documentation including the internals manual and the Xemacs editions to |
851 the Lisp reference manual, and responsible for much of the synching | 873 the Lisp reference manual, and responsible for much of the synching |
852 between Xemacs and GNU Emacs. | 874 between Xemacs and GNU Emacs. |
853 | 875 |
854 @item Kyle Jones | 876 @item Kyle Jones |
855 Author of the minimal tag bits support in—minimal lisp support for lisp | 877 Author of the minimal tag bits support, which allows for 32-bit |
856 objects which allows for 32-bit pointers and 31-bit integers. | 878 pointers and 31-bit integers. |
857 | 879 |
858 @item Olivier Galibert | 880 @item Olivier Galibert |
859 Author of the portable dumping mechanism. | 881 Author of the portable dumping mechanism. |
860 | 882 |
861 @item Andy Piper | 883 @item Andy Piper |
957 a lot of information about Stallman himself and the development of | 979 a lot of information about Stallman himself and the development of |
958 Lisp, a programming language developed at MIT that underlies Emacs.) | 980 Lisp, a programming language developed at MIT that underlies Emacs.) |
959 | 981 |
960 @menu | 982 @menu |
961 * Through Version 18:: Unification prevails. | 983 * Through Version 18:: Unification prevails. |
984 * Epoch:: An early graphical split of GNU Emacs. | |
962 * Lucid Emacs:: One version 19 Emacs. | 985 * Lucid Emacs:: One version 19 Emacs. |
963 * GNU Emacs 19:: The other version 19 Emacs. | 986 * GNU Emacs 19:: The other version 19 Emacs. |
964 * GNU Emacs 20:: The other version 20 Emacs. | 987 * GNU Emacs 20:: The other version 20 Emacs. |
965 * XEmacs:: The continuation of Lucid Emacs. | 988 * XEmacs:: The continuation of Lucid Emacs. |
966 @end menu | 989 @end menu |
967 | 990 |
968 @node Through Version 18, Lucid Emacs, A History of Emacs, A History of Emacs | 991 @node Through Version 18, Epoch, A History of Emacs, A History of Emacs |
969 @section Through Version 18 | 992 @section Through Version 18 |
970 @cindex version 18, through | 993 @cindex version 18, through |
971 @cindex Gosling, James | 994 @cindex Gosling, James |
972 @cindex Great Usenet Renaming | 995 @cindex Great Usenet Renaming |
973 | 996 |
1006 @item | 1029 @item |
1007 GNU Emacs version 16 (first released version was 16.56) was released on | 1030 GNU Emacs version 16 (first released version was 16.56) was released on |
1008 July 15, 1985. All Gosling code was removed due to potential copyright | 1031 July 15, 1985. All Gosling code was removed due to potential copyright |
1009 problems with the code. | 1032 problems with the code. |
1010 @item | 1033 @item |
1011 version 16.57: released on September 16, 1985. | 1034 Version 16.57: released on September 16, 1985. |
1012 @item | 1035 @item |
1013 versions 16.58, 16.59: released on September 17, 1985. | 1036 Versions 16.58, 16.59: released on September 17, 1985. |
1014 @item | 1037 @item |
1015 version 16.60: released on September 19, 1985. These later version 16's | 1038 Version 16.60: released on September 19, 1985. These later version 16's |
1016 incorporated patches from the net, esp. for getting Emacs to work under | 1039 incorporated patches from the net, esp. for getting Emacs to work under |
1017 System V. | 1040 System V. |
1018 @item | 1041 @item |
1019 version 17.36 (first official v17 release) released on December 20, | 1042 Version 17.36 (first official v17 release) released on December 20, |
1020 1985. Included a TeX-able user manual. First official unpatched | 1043 1985. Included a TeX-able user manual. First official unpatched |
1021 version that worked on vanilla System V machines. | 1044 version that worked on vanilla System V machines. |
1022 @item | 1045 @item |
1023 version 17.43 (second official v17 release) released on January 25, | 1046 Version 17.43 (second official v17 release) released on January 25, |
1024 1986. | 1047 1986. |
1025 @item | 1048 @item |
1026 version 17.45 released on January 30, 1986. | 1049 Version 17.45 released on January 30, 1986. |
1027 @item | 1050 @item |
1028 version 17.46 released on February 4, 1986. | 1051 Version 17.46 released on February 4, 1986. |
1029 @item | 1052 @item |
1030 version 17.48 released on February 10, 1986. | 1053 Version 17.48 released on February 10, 1986. |
1031 @item | 1054 @item |
1032 version 17.49 released on February 12, 1986. | 1055 Version 17.49 released on February 12, 1986. |
1033 @item | 1056 @item |
1034 version 17.55 released on March 18, 1986. | 1057 Version 17.55 released on March 18, 1986. |
1035 @item | 1058 @item |
1036 version 17.57 released on March 27, 1986. | 1059 Version 17.57 released on March 27, 1986. |
1037 @item | 1060 @item |
1038 version 17.58 released on April 4, 1986. | 1061 Version 17.58 released on April 4, 1986. |
1039 @item | 1062 @item |
1040 version 17.61 released on April 12, 1986. | 1063 Version 17.61 released on April 12, 1986. |
1041 @item | 1064 @item |
1042 version 17.63 released on May 7, 1986. | 1065 Version 17.63 released on May 7, 1986. |
1043 @item | 1066 @item |
1044 version 17.64 released on May 12, 1986. | 1067 Version 17.64 released on May 12, 1986. |
1045 @item | 1068 @item |
1046 version 18.24 (a beta version) released on October 2, 1986. | 1069 Version 18.24 (a beta version) released on October 2, 1986. |
1047 @item | 1070 @item |
1048 version 18.30 (a beta version) released on November 15, 1986. | 1071 Version 18.30 (a beta version) released on November 15, 1986. |
1049 @item | 1072 @item |
1050 version 18.31 (a beta version) released on November 23, 1986. | 1073 Version 18.31 (a beta version) released on November 23, 1986. |
1051 @item | 1074 @item |
1052 version 18.32 (a beta version) released on December 7, 1986. | 1075 Version 18.32 (a beta version) released on December 7, 1986. |
1053 @item | 1076 @item |
1054 version 18.33 (a beta version) released on December 12, 1986. | 1077 Version 18.33 (a beta version) released on December 12, 1986. |
1055 @item | 1078 @item |
1056 version 18.35 (a beta version) released on January 5, 1987. | 1079 Version 18.35 (a beta version) released on January 5, 1987. |
1057 @item | 1080 @item |
1058 version 18.36 (a beta version) released on January 21, 1987. | 1081 Version 18.36 (a beta version) released on January 21, 1987. |
1059 @item | 1082 @item |
1060 January 27, 1987: The Great Usenet Renaming. net.emacs is now | 1083 January 27, 1987: The Great Usenet Renaming. net.emacs is now |
1061 comp.emacs. | 1084 comp.emacs. |
1062 @item | 1085 @item |
1063 version 18.37 (a beta version) released on February 12, 1987. | 1086 Version 18.37 (a beta version) released on February 12, 1987. |
1064 @item | 1087 @item |
1065 version 18.38 (a beta version) released on March 3, 1987. | 1088 Version 18.38 (a beta version) released on March 3, 1987. |
1066 @item | 1089 @item |
1067 version 18.39 (a beta version) released on March 14, 1987. | 1090 Version 18.39 (a beta version) released on March 14, 1987. |
1068 @item | 1091 @item |
1069 version 18.40 (a beta version) released on March 18, 1987. | 1092 Version 18.40 (a beta version) released on March 18, 1987. |
1070 @item | 1093 @item |
1071 version 18.41 (the first ``official'' release) released on March 22, | 1094 Version 18.41 (the first ``official'' release) released on March 22, |
1072 1987. | 1095 1987. |
1073 @item | 1096 @item |
1074 version 18.45 released on June 2, 1987. | 1097 Version 18.45 released on June 2, 1987. |
1075 @item | 1098 @item |
1076 version 18.46 released on June 9, 1987. | 1099 Version 18.46 released on June 9, 1987. |
1077 @item | 1100 @item |
1078 version 18.47 released on June 18, 1987. | 1101 Version 18.47 released on June 18, 1987. |
1079 @item | 1102 @item |
1080 version 18.48 released on September 3, 1987. | 1103 Version 18.48 released on September 3, 1987. |
1081 @item | 1104 @item |
1082 version 18.49 released on September 18, 1987. | 1105 Version 18.49 released on September 18, 1987. |
1083 @item | 1106 @item |
1084 version 18.50 released on February 13, 1988. | 1107 Version 18.50 released on February 13, 1988. |
1085 @item | 1108 @item |
1086 version 18.51 released on May 7, 1988. | 1109 Version 18.51 released on May 7, 1988. |
1087 @item | 1110 @item |
1088 version 18.52 released on September 1, 1988. | 1111 Version 18.52 released on September 1, 1988. |
1089 @item | 1112 @item |
1090 version 18.53 released on February 24, 1989. | 1113 Version 18.53 released on February 24, 1989. |
1091 @item | 1114 @item |
1092 version 18.54 released on April 26, 1989. | 1115 Version 18.54 released on April 26, 1989. |
1093 @item | 1116 @item |
1094 version 18.55 released on August 23, 1989. This is the earliest version | 1117 Version 18.55 released on August 23, 1989. This is the earliest version |
1095 that is still available by FTP. | 1118 that is still available by FTP. (Verified in November 2004.) |
1096 @item | 1119 @item |
1097 version 18.56 released on January 17, 1991. | 1120 Version 18.56 released on January 17, 1991. |
1098 @item | 1121 @item |
1099 version 18.57 released late January, 1991. | 1122 Version 18.57 released late January, 1991. |
1100 @item | 1123 @item |
1101 version 18.58 released ?????. | 1124 Version 18.58 released sometime in 1991. |
1102 @item | 1125 @item |
1103 version 18.59 released October 31, 1992. | 1126 Version 18.59 released October 31, 1992. |
1104 @end itemize | 1127 @end itemize |
1105 | 1128 |
1106 @node Lucid Emacs, GNU Emacs 19, Through Version 18, A History of Emacs | 1129 |
1130 @node Epoch, Lucid Emacs, Through Version 18, A History of Emacs | |
1131 @section Epoch | |
1132 @cindex Epoch | |
1133 @cindex UIUC | |
1134 | |
1135 #### Document Epoch | |
1136 | |
1137 A time line for Epoch is | |
1138 | |
1139 @itemize @bullet | |
1140 @item | |
1141 Epoch 1.0 released December 14, 1989. (by Simon Kaplan, Chris Love, et al.) | |
1142 @item | |
1143 Epoch 2.0 released December 23, 1989. | |
1144 @item | |
1145 Epoch 3.1 released February 6, 1990. | |
1146 @item | |
1147 Epoch 3.2 released December[????] 11, 1990. | |
1148 @item | |
1149 Epoch 4.0 released August 27, 1990. | |
1150 @end itemize | |
1151 | |
1152 @node Lucid Emacs, GNU Emacs 19, Epoch, A History of Emacs | |
1107 @section Lucid Emacs | 1153 @section Lucid Emacs |
1108 @cindex Lucid Emacs | 1154 @cindex Lucid Emacs |
1109 @cindex Lucid Inc. | 1155 @cindex Lucid Inc. |
1110 @cindex Energize | 1156 @cindex Energize |
1111 @cindex Epoch | 1157 @cindex Epoch |
1142 | 1188 |
1143 A time line for Lucid Emacs is | 1189 A time line for Lucid Emacs is |
1144 | 1190 |
1145 @itemize @bullet | 1191 @itemize @bullet |
1146 @item | 1192 @item |
1147 version 19.0 shipped with Energize 1.0, April 1992. | 1193 Version 19.0 shipped with Energize 1.0, April 1992. |
1148 @item | 1194 @item |
1149 version 19.1 released June 4, 1992. | 1195 Version 19.1 released June 4, 1992. |
1150 @item | 1196 @item |
1151 version 19.2 released June 19, 1992. | 1197 Version 19.2 released June 19, 1992. |
1152 @item | 1198 @item |
1153 version 19.3 released September 9, 1992. | 1199 Version 19.3 released September 9, 1992. |
1154 @item | 1200 @item |
1155 version 19.4 released January 21, 1993. | 1201 Version 19.4 released January 21, 1993. |
1156 @item | 1202 @item |
1157 version 19.5 was a repackaging of 19.4 with a few bug fixes and | 1203 Version 19.5 released February 5, 1993. This was a repackaging of 19.4 with a |
1158 shipped with Energize 2.0. Never released to the net. | 1204 few bug fixes and shipped with Energize 2.0. It was a trade-show giveaway |
1159 @item | 1205 and never released to the net. |
1160 version 19.6 released April 9, 1993. | 1206 @item |
1161 @item | 1207 Version 19.6 released April 9, 1993. |
1162 version 19.7 was a repackaging of 19.6 with a few bug fixes and | 1208 @item |
1209 Version 19.7 was a repackaging of 19.6 with a few bug fixes and | |
1163 shipped with Energize 2.1. Never released to the net. | 1210 shipped with Energize 2.1. Never released to the net. |
1164 @item | 1211 @item |
1165 version 19.8 released September 6, 1993. | 1212 Version 19.8 released September 6, 1993. (Epoch 4.0 merger of |
1166 @item | 1213 redisplay code, preliminary I18N support, code merged from GNU Emacs |
1167 version 19.9 released January 12, 1994. | 1214 19.8 beta) |
1168 @item | 1215 @item |
1169 version 19.10 released May 27, 1994. | 1216 Version 19.9 released January 12, 1994. (Scrollbars, Athena.) |
1217 @item | |
1218 Version 19.10 released May 27, 1994. (Uses `configure'; code merged | |
1219 from GNU Emacs 19.23 beta and further merging with Epoch 4.0) Known as | |
1220 "Lucid Emacs" when shipped by Lucid, and as "XEmacs" when shipped by | |
1221 Sun; but Lucid went out of business a few days later and it's unclear | |
1222 very many copies of 19.10 were released by Lucid. (Last release by | |
1223 Jamie Zawinski.) | |
1170 @end itemize | 1224 @end itemize |
1171 | 1225 |
1172 @node GNU Emacs 19, GNU Emacs 20, Lucid Emacs, A History of Emacs | 1226 @node GNU Emacs 19, GNU Emacs 20, Lucid Emacs, A History of Emacs |
1173 @section GNU Emacs 19 | 1227 @section GNU Emacs 19 |
1174 @cindex GNU Emacs 19 | 1228 @cindex GNU Emacs 19 |
1182 19.6. (Strangely, the first released beta from the FSF was GNU Emacs | 1236 19.6. (Strangely, the first released beta from the FSF was GNU Emacs |
1183 19.7.) A time line for GNU Emacs version 19 is | 1237 19.7.) A time line for GNU Emacs version 19 is |
1184 | 1238 |
1185 @itemize @bullet | 1239 @itemize @bullet |
1186 @item | 1240 @item |
1187 version 19.8 (beta) released May 27, 1993. | 1241 Version 19.7 beta released May 22, 1993. First public beta v19 release. |
1188 @item | 1242 @item |
1189 version 19.9 (beta) released May 27, 1993. | 1243 Version 19.8 beta released May 27, 1993. |
1190 @item | 1244 @item |
1191 version 19.10 (beta) released May 30, 1993. | 1245 Version 19.9 beta released May 27, 1993. |
1192 @item | 1246 @item |
1193 version 19.11 (beta) released June 1, 1993. | 1247 Version 19.10 beta released May 30, 1993. |
1194 @item | 1248 @item |
1195 version 19.12 (beta) released June 2, 1993. | 1249 Version 19.11 beta released June 1, 1993. |
1196 @item | 1250 @item |
1197 version 19.13 (beta) released June 8, 1993. | 1251 Version 19.12 beta released June 2, 1993. |
1198 @item | 1252 @item |
1199 version 19.14 (beta) released June 17, 1993. | 1253 Version 19.13 beta released June 8, 1993. |
1200 @item | 1254 @item |
1201 version 19.15 (beta) released June 19, 1993. | 1255 Version 19.14 beta released June 17, 1993. |
1202 @item | 1256 @item |
1203 version 19.16 (beta) released July 6, 1993. | 1257 Version 19.15 beta released June 19, 1993. |
1204 @item | 1258 @item |
1205 version 19.17 (beta) released late July, 1993. | 1259 Version 19.16 beta released July 6, 1993. |
1206 @item | 1260 @item |
1207 version 19.18 (beta) released August 9, 1993. | 1261 Version 19.17 beta released late July, 1993. |
1208 @item | 1262 @item |
1209 version 19.19 (beta) released August 15, 1993. | 1263 Version 19.18 beta released August 9, 1993. |
1210 @item | 1264 @item |
1211 version 19.20 (beta) released November 17, 1993. | 1265 Version 19.19 beta released August 15, 1993. |
1212 @item | 1266 @item |
1213 version 19.21 (beta) released November 17, 1993. | 1267 Version 19.20 beta released November 17, 1993. |
1214 @item | 1268 @item |
1215 version 19.22 (beta) released November 28, 1993. | 1269 Version 19.21 beta released November 17, 1993. |
1216 @item | 1270 @item |
1217 version 19.23 (beta) released May 17, 1994. | 1271 Version 19.22 beta released November 28, 1993. |
1218 @item | 1272 @item |
1219 version 19.24 (beta) released May 16, 1994. | 1273 Version 19.23 beta released May 17, 1994. |
1220 @item | 1274 @item |
1221 version 19.25 (beta) released June 3, 1994. | 1275 Version 19.24 beta released May 16, 1994. |
1222 @item | 1276 @item |
1223 version 19.26 (beta) released September 11, 1994. | 1277 Version 19.25 beta released June 3, 1994. |
1224 @item | 1278 @item |
1225 version 19.27 (beta) released September 14, 1994. | 1279 Version 19.26 beta released September 11, 1994. |
1226 @item | 1280 @item |
1227 version 19.28 (first ``official'' release) released November 1, 1994. | 1281 Version 19.27 beta released September 14, 1994. |
1228 @item | 1282 @item |
1229 version 19.29 released June 21, 1995. | 1283 Version 19.28 (first ``official'' release) released November 1, 1994. |
1230 @item | 1284 @item |
1231 version 19.30 released November 24, 1995. | 1285 Version 19.29 released June 21, 1995. |
1232 @item | 1286 @item |
1233 version 19.31 released May 25, 1996. | 1287 Version 19.30 released November 24, 1995. |
1234 @item | 1288 @item |
1235 version 19.32 released July 31, 1996. | 1289 Version 19.31 released May 25, 1996. |
1236 @item | 1290 @item |
1237 version 19.33 released August 11, 1996. | 1291 Version 19.32 released July 31, 1996. |
1238 @item | 1292 @item |
1239 version 19.34 released August 21, 1996. | 1293 Version 19.33 released August 11, 1996. |
1240 @item | 1294 @item |
1241 version 19.34b released September 6, 1996. | 1295 Version 19.34 released August 21, 1996. |
1296 @item | |
1297 Version 19.34b released September 6, 1996. | |
1242 @end itemize | 1298 @end itemize |
1243 | 1299 |
1244 @cindex Mlynarik, Richard | 1300 @cindex Mlynarik, Richard |
1301 @cindex Baur, Steve | |
1245 In some ways, GNU Emacs 19 was better than Lucid Emacs; in some ways, | 1302 In some ways, GNU Emacs 19 was better than Lucid Emacs; in some ways, |
1246 worse. Lucid soon began incorporating features from GNU Emacs 19 into | 1303 worse. Lucid soon began incorporating features from GNU Emacs 19 into |
1247 Lucid Emacs; the work was mostly done by Richard Mlynarik, who had been | 1304 Lucid Emacs; for the first year, the work was mostly done by Richard |
1248 working on and using GNU Emacs for a long time (back as far as version | 1305 Mlynarik, who had been working on and using GNU Emacs for a long time |
1249 16 or 17). | 1306 (back as far as version 16 or 17). After that, Lucid folded and Sun |
1307 continued with XEmacs; further merging work has continued up through | |
1308 the present, done mostly by Ben Wing but a good deal of synching was | |
1309 done by Steve Baur in 1996 with GNU Emacs 19.34. | |
1250 | 1310 |
1251 @node GNU Emacs 20, XEmacs, GNU Emacs 19, A History of Emacs | 1311 @node GNU Emacs 20, XEmacs, GNU Emacs 19, A History of Emacs |
1252 @section GNU Emacs 20 | 1312 @section GNU Emacs 20 |
1253 @cindex GNU Emacs 20 | 1313 @cindex GNU Emacs 20 |
1254 @cindex Emacs 20, GNU | 1314 @cindex Emacs 20, GNU |
1256 @cindex FSF Emacs | 1316 @cindex FSF Emacs |
1257 | 1317 |
1258 On February 2, 1997 work began on GNU Emacs to integrate Mule. The first | 1318 On February 2, 1997 work began on GNU Emacs to integrate Mule. The first |
1259 release was made in September of that year. | 1319 release was made in September of that year. |
1260 | 1320 |
1261 A timeline for Emacs 20 is | 1321 A timeline for GNU Emacs 20 is |
1262 | 1322 |
1263 @itemize @bullet | 1323 @itemize @bullet |
1264 @item | 1324 @item |
1265 version 20.1 released September 17, 1997. | 1325 Version 20.1 released September 17, 1997. |
1266 @item | 1326 @item |
1267 version 20.2 released September 20, 1997. | 1327 Version 20.2 released September 20, 1997. |
1268 @item | 1328 @item |
1269 version 20.3 released August 19, 1998. | 1329 Version 20.3 released August 19, 1998. |
1330 @item | |
1331 version 20.4 released July 12, 1999; on comp.emacs, July 27. | |
1332 @item | |
1333 version 20.5 released ???. | |
1334 @item | |
1335 version 20.6 released ???. | |
1336 @item | |
1337 version 20.7 released ???. | |
1338 @end itemize | |
1339 | |
1340 A timeline for GNU Emacs 21 is | |
1341 | |
1342 @itemize @bullet | |
1343 @item | |
1344 version 21.1 released October 20, 2001. | |
1345 @item | |
1346 Version 21.2 released March 16, 2002. | |
1347 @item | |
1348 Version 21.3 released March 19, 2003. | |
1270 @end itemize | 1349 @end itemize |
1271 | 1350 |
1272 @node XEmacs, , GNU Emacs 20, A History of Emacs | 1351 @node XEmacs, , GNU Emacs 20, A History of Emacs |
1273 @section XEmacs | 1352 @section XEmacs |
1274 @cindex XEmacs | 1353 @cindex XEmacs |
1300 to Microsoft Windows 3.1) in 1993, for what was initially a one-month | 1379 to Microsoft Windows 3.1) in 1993, for what was initially a one-month |
1301 contract to fix some event problems but later became a many-year | 1380 contract to fix some event problems but later became a many-year |
1302 involvement, punctuated by a six-month contract with Amdahl Corporation. | 1381 involvement, punctuated by a six-month contract with Amdahl Corporation. |
1303 | 1382 |
1304 @cindex rename to XEmacs | 1383 @cindex rename to XEmacs |
1384 @cindex Thompson, Chuck | |
1385 @cindex Wing, Ben | |
1305 In 1994, Sun and Lucid agreed to rename Lucid Emacs to XEmacs (a name | 1386 In 1994, Sun and Lucid agreed to rename Lucid Emacs to XEmacs (a name |
1306 not favorable to either company); the first release called XEmacs was | 1387 not favorable to either company); the first release called XEmacs was |
1307 version 19.11. In June 1994, Lucid folded and Jamie quit to work for | 1388 version 19.11. In June 1994, Lucid folded and Jamie quit to work for |
1308 the newly formed Mosaic Communications Corp., later Netscape | 1389 the newly formed Mosaic Communications Corp., later Netscape |
1309 Communications Corp. (co-founded by the same Marc Andreessen, who had | 1390 Communications Corp. (co-founded by the same Marc Andreessen, who had |
1310 quit his Epoch job to work on a graphical browser for the World Wide | 1391 quit his Epoch job to work on a graphical browser for the World Wide |
1311 Web). Chuck then become the primary maintainer of XEmacs, and put out | 1392 Web). Chuck and Ben then become the primary authors and maintainers |
1312 versions 19.11 through 19.14 in conjunction with Ben. For 19.12 and | 1393 of XEmacs, with Chuck putting out versions 19.11 through 19.14 in |
1313 19.13, Chuck added the new redisplay and many other display improvements | 1394 conjunction with Ben. For 19.12 through 19.14, Chuck added the new |
1314 and Ben added MULE support (support for Asian and other languages) and | 1395 redisplay and various other display improvements and Ben added MULE |
1315 redesigned most of the internal Lisp subsystems to better support the | 1396 support (support for Asian and other languages), multi-device support, |
1316 MULE work and the various other features being added to XEmacs. After | 1397 glyphs, specifiers, and GIF/JPG/PNG support, and redesigned most of |
1317 19.14 Chuck retired as primary maintainer and Steve Baur stepped in. | 1398 the internal Lisp subsystems to better support the MULE work, display |
1399 work and the various other features being added to XEmacs. After | |
1400 19.14 Chuck retired from XEmacs and Steve Baur stepped in as release | |
1401 engineer. Ben Wing continued on as the primary author and architect | |
1402 of XEmacs and has remained, sometimes on-and-off, with XEmacs until | |
1403 the present day (late 2004), being responsible for perhaps 75% of all | |
1404 the non-FSF code in the core (i.e. not the packages) of XEmacs. | |
1318 | 1405 |
1319 @cindex MULE merged XEmacs appears | 1406 @cindex MULE merged XEmacs appears |
1320 Soon after 19.13 was released, work began in earnest on the MULE | 1407 Soon after 19.13 was released, work began in earnest on the MULE |
1321 internationalization code and the source tree was divided into two | 1408 internationalization code and the source tree was divided into two |
1322 development paths. The MULE version was initially called 19.20, but was | 1409 development paths. The MULE version was initially called 19.20, but was |
1327 1997. The source tree remained divided until 20.2 when the version 19 | 1414 1997. The source tree remained divided until 20.2 when the version 19 |
1328 source was finally retired at version 19.16. | 1415 source was finally retired at version 19.16. |
1329 | 1416 |
1330 @cindex Baur, Steve | 1417 @cindex Baur, Steve |
1331 @cindex Buchholz, Martin | 1418 @cindex Buchholz, Martin |
1332 @cindex Jones, Kyle | |
1333 @cindex Niksic, Hrvoje | |
1334 @cindex XEmacs goes it alone | 1419 @cindex XEmacs goes it alone |
1335 In 1997, Sun finally dropped all pretense of support for XEmacs and | 1420 In 1997, Sun finally dropped all pretense of support for XEmacs and |
1336 Martin Buchholz left the company in November. Since then, and mostly | 1421 Martin Buchholz left the company in November. Since then, and mostly |
1337 for the previous year, because Steve Baur was never paid to work on | 1422 for the previous year, because Steve Baur was never paid to work on |
1338 XEmacs, XEmacs has existed solely on the contributions of volunteers | 1423 XEmacs, XEmacs has existed solely on the contributions of volunteers |
1339 from the Free Software Community. Starting from 1997, Hrvoje Niksic and | 1424 from the Free Software Community. |
1340 Kyle Jones have figured prominently in XEmacs development. | 1425 |
1426 @cindex Jones, Kyle | |
1427 @cindex Niksic, Hrvoje | |
1428 @cindex Galibert, Olivier | |
1429 @cindex Piper, Andy | |
1430 @cindex Harris, Jonathan | |
1431 @cindex Katsnelson, Kirill | |
1432 @cindex Turnbull, Stephen | |
1433 @cindex Shelton, Vin | |
1434 @cindex Wing, Ben | |
1435 Between 1997 and 2000, MS-Windows support was added and stabilized by | |
1436 Jonathan Harris, Andy Piper, Ben Wing and Kirill Katsnelson. Hrvoje | |
1437 Niksic and Kyle Jones figured prominently in XEmacs development during | |
1438 these same years. Steve Baur added the package system in 1997 (?), | |
1439 and Olivier Galibert also added the portable dumper support around | |
1440 2000. Martin Buchholz took over from Steve Baur as release manager in | |
1441 late 1998 (?), and continued in this position through to eary 2000 | |
1442 (?), when Stephen Turnbull took it over. XEmacs has also been split | |
1443 into stable and experimental branches since early 1999, and Vin | |
1444 Shelton has been the release manager of the stable branches since the | |
1445 beginning. Ben Wing suffered severe pain problems throughout much of | |
1446 this time, making him unable to use his hands, but he contributed when | |
1447 he could, especially in the form of dictated design documents. | |
1448 | |
1449 @cindex Sperber, Michael | |
1450 @cindex Turnbull, Stephen | |
1451 @cindex James, Jerry | |
1452 @cindex Youngs, Steve | |
1453 @cindex Aichner, Adrian | |
1454 @cindex Wing, Ben | |
1455 @cindex Crestani, Marcus | |
1456 @cindex Perry, Bill | |
1457 @cindex Purvis, Malcolm | |
1458 @cindex Shelton, Vin | |
1459 Starting around 2000, Kyle, Hrvoje, Martin and Kirill became less active. | |
1460 Jonathan Harris had dropped out of the project around 1998, and Andy | |
1461 Piper became mostly inactive by the year 2001 or 2002. New faces | |
1462 appeared, however, and others continued strong: | |
1463 | |
1464 @itemize @bullet | |
1465 @item | |
1466 Michael Sperber, who had been in the background as a beta tester for a | |
1467 fair amount of time, began to assume a more active role. He revamped | |
1468 the path-searching code at initialization time, did some major work on | |
1469 the CVS repositories, and is in the process of a major project to | |
1470 replace the garbage collector, which he is overseeing with some of his | |
1471 students (e.g. Marcus Crestani). | |
1472 @item | |
1473 Steve Youngs stepped in as package maintainer in late 1998 (?). | |
1474 @item | |
1475 Stephen Turnbull has contained to produce the experimental beta | |
1476 releases, write code when he can, produce many design documents, and | |
1477 generally oversee the managerial aspects of the project. | |
1478 @item | |
1479 Jerry James appeared on the scene in early 2002 and has contributed a | |
1480 large amount of code, including the module subsystem, bignums, and | |
1481 lots of other code cleanup. | |
1482 @item | |
1483 Bill Perry, who had been active on and off in XEmacs since the early | |
1484 1990's (e.g. he did a fair amount of work on the JPG and PNG interface | |
1485 and added the TIFF interface, in addition to writing the Emacs/W3 | |
1486 browser), added GTK support for XEmacs, a major project for which he | |
1487 received a multi-month contract through BeOpen (?). He has since | |
1488 disappeared but Malcolm Purvis has taken up the GTK project again and | |
1489 is keeping it going when he has time. | |
1490 @item | |
1491 Adrian Aichner is continuing to create and update the web site on | |
1492 @uref{www.xemacs.org,XEmacs Web Site}, and is a particularly active | |
1493 beta tester. | |
1494 @item | |
1495 Ben Wing has recovered somewhat from the bad years of 1997 - 1999 and | |
1496 has resumed his position as Architect of XEmacs and chief code | |
1497 contributor to the project. He added Mule on Windows support, Unicode | |
1498 support, the Internals manual (originally written by him during his | |
1499 last days at Sun) and many other projects, and is now working on a new | |
1500 behaviors system and cleanups of various other subsystems. | |
1501 @item | |
1502 Vin Shelton continues to put out stable releases of XEmacs. | |
1503 @end itemize | |
1341 | 1504 |
1342 @cindex merging attempts | 1505 @cindex merging attempts |
1343 Many attempts have been made to merge XEmacs and GNU Emacs, but they | 1506 Many attempts have been made to merge XEmacs and GNU Emacs, but they |
1344 have consistently failed. | 1507 have consistently failed. |
1345 | 1508 |
1346 A more detailed history is contained in the XEmacs About page. | 1509 A more detailed history is contained in the XEmacs About page. |
1347 | 1510 |
1511 For more detailed information about the features added to each version, | |
1512 see the files @file{NEWS}, @file{ONEWS}, and @file{OONEWS} in the | |
1513 @file{etc/} directory. | |
1514 | |
1348 A time line for XEmacs is | 1515 A time line for XEmacs is |
1349 | 1516 |
1350 @itemize @bullet | 1517 @itemize @bullet |
1351 @item | 1518 @item |
1352 version 19.11 (first XEmacs) released September 13, 1994. | 1519 version 19.11 (first XEmacs) released September 13, 1994. |
1353 @item | 1520 @item |
1354 version 19.12 released June 23, 1995. | 1521 Initial work on Mule support begins September 1994 by both Ben Wing and |
1355 @item | 1522 Stig. Both projects got bogged down in other issues. |
1356 version 19.13 released September 1, 1995. | 1523 @item |
1357 @item | 1524 version 19.12 released June 23, 1995. (The Release Times 10. Included |
1358 version 19.14 released June 23, 1996. | 1525 rewritten redisplay, TTY support, multi-device support, device and |
1526 console objects, specifiers, glyphs, toolbars, horizontal scrollbars, | |
1527 Lucid scrollbar widget, 3-d modeline, stay-up Lucid menus, resizable | |
1528 minibuffer, echo area is a true buffer, MD5 hashing support, expanded | |
1529 menubar, redone menu specification format (including menu filters), | |
1530 rewritten extents, renamed "screen" to "frame", misc-user events, | |
1531 rewritten face code, rewritten mouse code, warnings system, CL | |
1532 backquote syntax, critical C-g, code merging with GNU Emacs 19.28. | |
1533 New packages Hyperbole, OOBR, hm--html-menus, viper, lazy-lock, | |
1534 ksh-mode, rsz-minibuf.) | |
1535 @item | |
1536 Mule work done in earnest from May through November, 1995 by Ben Wing. | |
1537 Early on, much of the work involved Mule-izing and was incorporated | |
1538 into 19.12 and 19.13. After the release of 19.13, further work was | |
1539 forked onto a new development branch, which eventually became 20.0. | |
1540 @item | |
1541 version 19.13 released September 1, 1995. (Bug-fix release. Message | |
1542 logging, background pixmaps, sticky modifiers, Linux audio support, | |
1543 new Elisp manual, keyboard-translate-table. New packages ada-mode, | |
1544 arc-mode, auto-show-mode, completion, dabbrev, easymenu, live-icon, | |
1545 mailcrypt 3.2, two-column.) | |
1546 @item | |
1547 xemacs.org created, date ??? -- early 1996?. | |
1548 @item | |
1549 version 19.14 released June 23, 1996. (TTY colors, mousable/color | |
1550 modeline, GIF/JPEG/PNG support, file dialog box, blinking cursor, | |
1551 gnuattach, auto scrolling horizontally to keep point in view, major | |
1552 code merging with GNU Emacs 19.30, key bindings from GNU Emacs 19.30, | |
1553 surrogate minibuffers, function-key-map, key-translation-map. New | |
1554 packages PSGML, Java/VRML modes, GNUS 5.2.) | |
1359 @item | 1555 @item |
1360 version 20.0 released February 9, 1997. | 1556 version 20.0 released February 9, 1997. |
1361 @item | 1557 @item |
1362 version 19.15 released March 28, 1997. | 1558 version 19.15 released March 28, 1997. (Custom, widget, new logo and |
1559 background color, introduction of `compatible' variables, major code | |
1560 merging with GNU Emacs 19.30. New packages EFS, TM, AUC Tex, redo, | |
1561 igrep, uniquify, many others.) | |
1363 @item | 1562 @item |
1364 version 20.1 (not released to the net) April 15, 1997. | 1563 version 20.1 (not released to the net) April 15, 1997. |
1365 @item | 1564 @item |
1366 version 20.2 released May 16, 1997. | 1565 version 20.2 released May 16, 1997. |
1367 @item | 1566 @item |
1368 version 19.16 released October 31, 1997. | 1567 version 19.16 released October 31, 1997. (Bug-fix release. Faster |
1568 font-locking. Not much else.) | |
1369 @item | 1569 @item |
1370 version 20.3 (the first stable version of XEmacs 20.x) released November 30, | 1570 version 20.3 (the first stable version of XEmacs 20.x) released November 30, |
1371 1997. | 1571 1997. |
1372 @item | 1572 @item |
1373 version 20.4 released February 28, 1998. | 1573 version 20.4 released February 28, 1998. |
1481 @item | 1681 @item |
1482 version 21.2.39 released December 31, 2000. | 1682 version 21.2.39 released December 31, 2000. |
1483 @item | 1683 @item |
1484 version 21.2.40 released January 8, 2001. | 1684 version 21.2.40 released January 8, 2001. |
1485 @item | 1685 @item |
1486 version 21.2.41 released January 17, 2001. | 1686 version 21.2.41 "Polyhymnia" released January 17, 2001. |
1487 @item | 1687 @item |
1488 version 21.2.42 released January 20, 2001. | 1688 version 21.2.42 "Poseidon" released January 20, 2001. |
1489 @item | 1689 @item |
1490 version 21.2.43 released January 26, 2001. | 1690 version 21.2.43 "Terspichore" released January 26, 2001. |
1491 @item | 1691 @item |
1492 version 21.2.44 released February 8, 2001. | 1692 version 21.2.44 "Thalia" released February 8, 2001. |
1493 @item | 1693 @item |
1494 version 21.2.45 released February 23, 2001. | 1694 version 21.2.45 "Thelxepeia" released February 23, 2001. |
1495 @item | 1695 @item |
1496 version 21.2.46 released March 21, 2001. | 1696 version 21.2.46 "Urania" released March 21, 2001. |
1697 @item | |
1698 version 21.2.47 "Zephir" released April 14, 2001. | |
1699 @item | |
1700 XEmacs 21.4.0 "Solid Vapor" released April 16, 2001. | |
1701 @item | |
1702 XEmacs 21.4.1 "Copyleft" released April 19, 2001. | |
1703 @item | |
1704 XEmacs 21.4.2 "Developer-Friendly Unix APIs" released May 10, 2001. | |
1705 @item | |
1706 XEmacs 21.4.3 "Academic Rigor" released May 17, 2001. | |
1707 @item | |
1708 XEmacs 21.4.4 "Artificial Intelligence" released July 28, 2001. | |
1709 @item | |
1710 XEmacs 21.4.5 "Civil Service" released October 23, 2001. | |
1711 @item | |
1712 XEmacs 21.4.6 "Common Lisp" released December 17, 2001. | |
1713 @item | |
1714 XEmacs 21.4.7 "Economic Science" released May 4, 2002. | |
1715 @item | |
1716 XEmacs 21.4.8 "Honest Recruiter" released May 9, 2002. | |
1717 @item | |
1718 XEmacs 21.4.9 "Informed Management" released August 23, 2002. | |
1719 @item | |
1720 XEmacs 21.4.10 "Military Intelligence" released November 2, 2002. | |
1721 @item | |
1722 XEmacs 21.4.11 "Native Windows TTY Support" released January 3, 2003. | |
1723 @item | |
1724 XEmacs 21.4.12 "Portable Code" released January 15, 2003. | |
1725 @item | |
1726 XEmacs 21.4.13 "Rational FORTRAN" released May 25, 2003. | |
1727 @item | |
1728 XEmacs 21.4.14 "Reasonable Discussion" released September 3, 2003. | |
1729 @item | |
1730 XEmacs 21.4.15 "Security Through Obscurity" released February 2, 2004. | |
1731 @item | |
1732 version 21.5.0 "alfalfa" released April 18, 2001. | |
1733 @item | |
1734 version 21.5.1 "anise" released May 9, 2001. | |
1735 @item | |
1736 version 21.5.2 "artichoke" released July 28, 2001. | |
1737 @item | |
1738 version 21.5.3 "asparagus" released September 7, 2001. | |
1739 @item | |
1740 version 21.5.4 "bamboo" released January 8, 2002. | |
1741 @item | |
1742 version 21.5.5 "beets" released March 5, 2002. | |
1743 @item | |
1744 version 21.5.6 "bok choi" released April 5, 2002. | |
1745 @item | |
1746 version 21.5.7 "broccoflower" released July 2, 2002. | |
1747 @item | |
1748 version 21.5.8 "broccoli" released July 27, 2002. | |
1749 @item | |
1750 version 21.5.9 "brussels sprouts" released August 30, 2002. | |
1751 @item | |
1752 version 21.5.10 "burdock" released January 4, 2003. | |
1753 @item | |
1754 version 21.5.11 "cabbage" released February 16, 2003. | |
1755 @item | |
1756 version 21.5.12 "carrot" released April 24, 2003. | |
1757 @item | |
1758 version 21.5.13 "cauliflower" released May 10, 2003. | |
1759 @item | |
1760 version 21.5.14 "cassava" released June 1, 2003. | |
1761 @item | |
1762 version 21.5.15 "celery" released September 3, 2003. | |
1763 @item | |
1764 version 21.5.16 "celeriac" released September 26, 2003. | |
1765 @item | |
1766 version 21.5.17 "chayote" released March 22, 2004. | |
1767 @item | |
1768 version 21.5.18 "chestnut" released October 22, 2004. | |
1497 @end itemize | 1769 @end itemize |
1498 | 1770 |
1499 @node The XEmacs Split, XEmacs from the Outside, A History of Emacs, Top | 1771 @node The XEmacs Split, XEmacs from the Outside, A History of Emacs, Top |
1500 @chapter The XEmacs Split | 1772 @chapter The XEmacs Split |
1501 @cindex XEmacs split | 1773 @cindex XEmacs split |
1502 | 1774 |
1503 Author: @uref{mailto:ben@@xemacs.org,Ben Wing} | 1775 Author: @uref{mailto:ben@@xemacs.org,Ben Wing} |
1776 | |
1777 @subheading Ben Wing's attempts | |
1504 | 1778 |
1505 @strong{NOTE NOTE NOTE}: The following is a @strong{highly} opinionated | 1779 @strong{NOTE NOTE NOTE}: The following is a @strong{highly} opinionated |
1506 piece written by one of the main authors of XEmacs. This reflects his | 1780 piece written by one of the main authors of XEmacs. This reflects his |
1507 opinions, and his only! It is included here because it may help to | 1781 opinions, and his only! It is included here because it may help to |
1508 clarify some of the issues that are keeping the two versions of Emacs | 1782 clarify some of the issues that are keeping the two versions of Emacs |
1612 that RMS has no real interest in unity except if it happens to be on his | 1886 that RMS has no real interest in unity except if it happens to be on his |
1613 own terms and allows him ultimate control over the result. He would rather | 1887 own terms and allows him ultimate control over the result. He would rather |
1614 see nothing happen at all than something that is not exactly according to | 1888 see nothing happen at all than something that is not exactly according to |
1615 his principles. The fact that few if any people share his principles is | 1889 his principles. The fact that few if any people share his principles is |
1616 meaningless to him. | 1890 meaningless to him. |
1891 | |
1892 @subheading Jamie Zawinski's attempts | |
1893 | |
1894 In 1991, I was working at Lucid Inc., and our newest product, | |
1895 Energize, was an integrated development environment for C and C++ on | |
1896 Unix. The design of this development environment involved very tight | |
1897 integration between the various tools: compilers, linkers, debuggers, | |
1898 graphers, and editors. So of course we needed a powerful editor to tie | |
1899 the whole thing together, and it was obvious to all of us that there | |
1900 was only one editor that would do: Emacs. | |
1901 | |
1902 At the time, the current version of GNU Emacs from the FSF was Emacs | |
1903 18. There was another version of GNU Emacs called Epoch, that had been | |
1904 developed at NCSA, which was a set of patches to Emacs 18 that gave it | |
1905 much better GUI support (Emacs 18 was very much a tty program, with | |
1906 GUI support crudely grafted on as an afterthought.) | |
1907 | |
1908 For the last few years, Emacs 19 had been due to be released ``real | |
1909 soon now,'' and was expected to integrate the various features of | |
1910 Epoch in a cleaner way. The Epoch maintainers themselves saw Epoch as | |
1911 an interim measure, awaiting the release of Emacs 19. | |
1912 | |
1913 So, at Lucid we didn't want to tie ourselves to Emacs 18 or on Epoch, | |
1914 because those code bases were considered obsolete by their | |
1915 maintainers. We wanted to use Emacs 19 with our product: the idea was | |
1916 that our product would operate with the off-the-shelf version of Emacs | |
1917 19, which most people would already have pre-installed on their system | |
1918 anyway. That way, Energize would make use, to some extent, of tools | |
1919 you already had and were already using. | |
1920 | |
1921 The only problem was, Emacs 19 wasn't done yet. So, we decided we | |
1922 could help solve that problem, by providing money and resources to get | |
1923 Emacs 19 finished. | |
1924 | |
1925 Even though Energize was a proprietary, commercial product, all of our | |
1926 work on Emacs (and on GCC and GDB) was released under the GPL. We even | |
1927 assigned the copyright on all of our work back to the FSF, because we | |
1928 had no proprietary interest in Emacs per se: it was just a tool that | |
1929 we wanted to use, and we wanted it to work well, and that was best | |
1930 achieved by making our modifications to it be as freely available as | |
1931 possible. (This was one of the earliest, if not the earliest, example | |
1932 of a commercial product being built to a significant extent out of | |
1933 open source software.) | |
1934 | |
1935 Well, our attempts to help the FSF complete their Emacs 19 project | |
1936 were pretty much a disaster, and we reached the point where we just | |
1937 couldn't wait any longer: we needed to ship our product to customers, | |
1938 and our product needed to have an editor in it. So we bundled up our | |
1939 work on GNU Emacs 19, called it Lucid Emacs, and released it to the | |
1940 world. | |
1941 | |
1942 This incident has become famous as one of the most significant | |
1943 ``forks'' in a free software code base. | |
1944 | |
1945 When Lucid went out of business in 1994, and I came to Netscape, I | |
1946 passed the torch for the maintenance of Lucid Emacs to Chuck Thompson | |
1947 (at NCSA) and Ben Wing (at Sun), who renamed it from ``Lucid Emacs'' | |
1948 to ``XEmacs.'' | |
1949 | |
1950 To this day, XEmacs is as popular as FSFmacs, because it still | |
1951 provides features and a design that many people find superior to the | |
1952 FSF's version. | |
1953 | |
1954 I attribute Lucid Emacs's success to two things, primarily: | |
1955 | |
1956 | |
1957 First, that my focus was on user interface, and an attempt to both | |
1958 make Emacs be a good citizen of modern GUI desktops, and to make it as | |
1959 easy for new users to pick up Emacs as any other GUI editor; | |
1960 | |
1961 Second, that I ran the Lucid Emacs project in a much more open, | |
1962 inclusive way than RMS ran his project. I was not just willing, but | |
1963 eager, to delegate significant and critical pieces of the project to | |
1964 other hackers once they had shown that they knew what they were | |
1965 doing. RMS was basically never willing to do this with anybody. Other | |
1966 things that helped Lucid Emacs's success, but were probably less | |
1967 important than the above: | |
1968 | |
1969 | |
1970 We gave the users what they wanted first. People had been anticipating | |
1971 Emacs 19 for years, and we stopped dragging our feet and finished | |
1972 it. So this got us a lot of users up front. However, XEmacs's current | |
1973 popularity can't be attributed to this, not since 1993, anyway. | |
1974 | |
1975 Lucid Emacs was technically superior in many ways. This won us the | |
1976 mindshare of many good developers, who preferred working with Lucid | |
1977 Emacs to FSF Emacs. It would be nice if technical superiority was all | |
1978 that mattered, but realistically, the other factors were probably more | |
1979 important than this one, as far as number of users is concerned. The | |
1980 following messages, from the Lucid Emacs mailing lists in 1992 and | |
1981 1993, comprise the bulk (if not the entirety) of the public | |
1982 discussions between the Lucid and FSF camps on why the split happened | |
1983 and why a merger never did. | |
1984 | |
1985 The current XEmacs maintainers have a much more pusillanimous summary | |
1986 of this history on their XEmacs versus GNU Emacs page. | |
1987 | |
1988 -- jwz, 11-Feb-2000. | |
1617 | 1989 |
1618 @node XEmacs from the Outside, The Lisp Language, The XEmacs Split, Top | 1990 @node XEmacs from the Outside, The Lisp Language, The XEmacs Split, Top |
1619 @chapter XEmacs from the Outside | 1991 @chapter XEmacs from the Outside |
1620 @cindex XEmacs from the outside | 1992 @cindex XEmacs from the outside |
1621 @cindex outside, XEmacs from the | 1993 @cindex outside, XEmacs from the |
2054 use any higher-level functionality that might load @file{custom.el}, but | 2426 use any higher-level functionality that might load @file{custom.el}, but |
2055 you do not need @file{subr.el}, you should @samp{defvar} | 2427 you do not need @file{subr.el}, you should @samp{defvar} |
2056 @code{custom-declare-variable-list} to prevent the @samp{void-variable} | 2428 @code{custom-declare-variable-list} to prevent the @samp{void-variable} |
2057 error. (Currently this is only needed for @file{make-docfile.el}.) | 2429 error. (Currently this is only needed for @file{make-docfile.el}.) |
2058 | 2430 |
2059 @node The Modules of XEmacs, Major Textual Changes, Build-Time Dependencies, Top | 2431 @node The Modules of XEmacs, Rules When Writing New C Code, Build-Time Dependencies, Top |
2060 @chapter The Modules of XEmacs | 2432 @chapter The Modules of XEmacs |
2061 @cindex modules of XEmacs | 2433 @cindex modules of XEmacs |
2062 | 2434 |
2063 @menu | 2435 @menu |
2064 * A Summary of the Various XEmacs Modules:: | 2436 * A Summary of the Various XEmacs Modules:: |
2657 times.) @file{pre-crt0.c} and @file{lastfile.c} contain exported symbols | 3029 times.) @file{pre-crt0.c} and @file{lastfile.c} contain exported symbols |
2658 that are used to determine the start and end of XEmacs' initialized | 3030 that are used to determine the start and end of XEmacs' initialized |
2659 data space when dumping. | 3031 data space when dumping. |
2660 | 3032 |
2661 | 3033 |
2662 | |
2663 @example | |
2664 @file{alloca.c} | |
2665 @file{free-hook.c} | |
2666 @file{getpagesize.h} | |
2667 @file{gmalloc.c} | |
2668 @file{malloc.c} | |
2669 @file{mem-limits.h} | |
2670 @file{ralloc.c} | |
2671 @file{vm-limit.c} | |
2672 @end example | |
2673 | |
2674 These handle basic C allocation of memory. @file{alloca.c} is an emulation of | |
2675 the stack allocation function @code{alloca()} on machines that lack | |
2676 this. (XEmacs makes extensive use of @code{alloca()} in its code.) | |
2677 | |
2678 @file{gmalloc.c} and @file{malloc.c} are two implementations of the standard C | |
2679 functions @code{malloc()}, @code{realloc()} and @code{free()}. They are | |
2680 often used in place of the standard system-provided @code{malloc()} | |
2681 because they usually provide a much faster implementation, at the | |
2682 expense of additional memory use. @file{gmalloc.c} is a newer implementation | |
2683 that is much more memory-efficient for large allocations than @file{malloc.c}, | |
2684 and should always be preferred if it works. (At one point, @file{gmalloc.c} | |
2685 didn't work on some systems where @file{malloc.c} worked; but this should be | |
2686 fixed now.) | |
2687 | |
2688 @cindex relocating allocator | |
2689 @file{ralloc.c} is the @dfn{relocating allocator}. It provides | |
2690 functions similar to @code{malloc()}, @code{realloc()} and @code{free()} | |
2691 that allocate memory that can be dynamically relocated in memory. The | |
2692 advantage of this is that allocated memory can be shuffled around to | |
2693 place all the free memory at the end of the heap, and the heap can then | |
2694 be shrunk, releasing the memory back to the operating system. The use | |
2695 of this can be controlled with the configure option @code{--rel-alloc}; | |
2696 if enabled, memory allocated for buffers will be relocatable, so that if | |
2697 a very large file is visited and the buffer is later killed, the memory | |
2698 can be released to the operating system. (The disadvantage of this | |
2699 mechanism is that it can be very slow. On systems with the | |
2700 @code{mmap()} system call, the XEmacs version of @file{ralloc.c} uses | |
2701 this to move memory around without actually having to block-copy it, | |
2702 which can speed things up; but it can still cause noticeable performance | |
2703 degradation.) | |
2704 | |
2705 On Linux systems using @samp{glibc 2}, these strategies are built in to | |
2706 the so-called ``Doug Lea malloc.'' See, for example, Doug Lea's home | |
2707 page, especially @uref{http://gee.cs.oswego.edu/dl/html/malloc.html,``A | |
2708 Memory Allocator''}. The source file, @file{malloc.c} (available at the | |
2709 same place) is copiously (and usefully!) commented. | |
2710 @uref{http://www.malloc.de/,Wolfram Gloger's home page} may also be | |
2711 useful. | |
2712 | |
2713 @file{free-hook.c} contains some debugging functions for checking for invalid | |
2714 arguments to @code{free()}. | |
2715 | |
2716 @file{vm-limit.c} contains some functions that warn the user when memory is | |
2717 getting low. These are callback functions that are called by @file{gmalloc.c} | |
2718 and @file{malloc.c} at appropriate times. | |
2719 | |
2720 @file{getpagesize.h} provides a uniform interface for retrieving the size of a | |
2721 page in virtual memory. @file{mem-limits.h} provides a uniform interface for | |
2722 retrieving the total amount of available virtual memory. Both are | |
2723 similar in spirit to the @file{sys*.h} files described in section J, below. | |
2724 | |
2725 | |
2726 @example | |
2727 @file{blocktype.c} | |
2728 @file{blocktype.h} | |
2729 @file{dynarr.c} | |
2730 @end example | |
2731 | |
2732 These implement a couple of basic C data types to facilitate memory | |
2733 allocation. The @code{Blocktype} type efficiently manages the | |
2734 allocation of fixed-size blocks by minimizing the number of times that | |
2735 @code{malloc()} and @code{free()} are called. It allocates memory in | |
2736 large chunks, subdivides the chunks into blocks of the proper size, and | |
2737 returns the blocks as requested. When blocks are freed, they are placed | |
2738 onto a linked list, so they can be efficiently reused. This data type | |
2739 is not much used in XEmacs currently, because it's a fairly new | |
2740 addition. | |
2741 | |
2742 @cindex dynamic array | |
2743 The @code{Dynarr} type implements a @dfn{dynamic array}, which is | |
2744 similar to a standard C array but has no fixed limit on the number of | |
2745 elements it can contain. Dynamic arrays can hold elements of any type, | |
2746 and when you add a new element, the array automatically resizes itself | |
2747 if it isn't big enough. Dynarrs are extensively used in the redisplay | |
2748 mechanism. | |
2749 | |
2750 | |
2751 | |
2752 @example | 3034 @example |
2753 @file{inline.c} | 3035 @file{inline.c} |
2754 @end example | 3036 @end example |
2755 | 3037 |
2756 This module is used in connection with inline functions (available in | 3038 This module is used in connection with inline functions (available in |
3680 @end example | 3962 @end example |
3681 | 3963 |
3682 This module provides some terminal-control code necessary on versions of | 3964 This module provides some terminal-control code necessary on versions of |
3683 AIX prior to 4.1. | 3965 AIX prior to 4.1. |
3684 | 3966 |
3685 @node Major Textual Changes, Rules When Writing New C Code, The Modules of XEmacs, Top | 3967 @node Rules When Writing New C Code, Regression Testing XEmacs, The Modules of XEmacs, Top |
3686 @chapter Major Textual Changes | 3968 @chapter Rules When Writing New C Code |
3969 @cindex writing new C code, rules when | |
3970 @cindex C code, rules when writing new | |
3971 @cindex code, rules when writing new C | |
3972 | |
3973 The XEmacs C Code is extremely complex and intricate, and there are many | |
3974 rules that are more or less consistently followed throughout the code. | |
3975 Many of these rules are not obvious, so they are explained here. It is | |
3976 of the utmost importance that you follow them. If you don't, you may | |
3977 get something that appears to work, but which will crash in odd | |
3978 situations, often in code far away from where the actual breakage is. | |
3979 | |
3980 @menu | |
3981 * Introduction to Writing C Code:: | |
3982 * Writing New Modules:: | |
3983 * Working with Lisp Objects:: | |
3984 * Writing Lisp Primitives:: | |
3985 * Writing Good Comments:: | |
3986 * Adding Global Lisp Variables:: | |
3987 * Writing Macros:: | |
3988 * Proper Use of Unsigned Types:: | |
3989 * Major Textual Changes:: | |
3990 * Debugging and Testing:: | |
3991 @end menu | |
3992 | |
3993 See also @ref{Coding for Mule}. | |
3994 | |
3995 @node Introduction to Writing C Code, Writing New Modules, Rules When Writing New C Code, Rules When Writing New C Code | |
3996 @section Introduction to Writing C Code | |
3997 @cindex introduction to writing c code | |
3998 @cindex coding conventions | |
3999 | |
4000 The C code is actually written in a dialect of C called @dfn{Clean C}, | |
4001 meaning that it can be compiled, mostly warning-free, with either a C | |
4002 or C++ compiler. Coding in Clean C has several advantages over plain | |
4003 C. C++ compilers are more nit-picking, and a number of coding errors | |
4004 have been found by compiling with C++. The ability to use both C and | |
4005 C++ tools means that a greater variety of development tools are | |
4006 available to the developer. In addition, the ability to overload | |
4007 operators in C++ means it is possible, for error-checking purposes, to | |
4008 redefine certain simple types (normally defined as aliases for simple | |
4009 built-in types such as @code{unsigned char} or @code{long}) as | |
4010 classes, strictly limiting the permissible operations and catching | |
4011 illegal implicit casts and such. | |
4012 | |
4013 XEmacs follows the GNU coding standards, which are documented | |
4014 separately in @xref{top,,, standards, GNU Coding Standards}. This | |
4015 section mainly documents standards that are not included in that | |
4016 document; typically this consists of standards that are specifically | |
4017 relevant to the XEmacs code itself. | |
4018 | |
4019 First, a recap of the GNU standards: | |
4020 | |
4021 @itemize @bullet | |
4022 @item | |
4023 Put a space after every comma. | |
4024 @item | |
4025 Put a space before the parenthesis that begins a function call, | |
4026 macro call, function declaration or definition, or control | |
4027 statement (if, while, switch, for). (DO NOT do this for macro | |
4028 definitions; this is invalid preprocessor syntax.) | |
4029 @item | |
4030 The brace that begins a control statement (if, while, for, switch, | |
4031 do) or a function definition should go on a line by itself. | |
4032 @item | |
4033 In function definitions, put the return type and all other | |
4034 qualifiers on a line before the function name. Thus, the function | |
4035 name is always at the beginning of a line. | |
4036 @item | |
4037 Indentation level is two spaces. (However, the first and following | |
4038 statements of a while/for/if/etc. block are indented four spaces | |
4039 from the while/for/if keyword. The opening and closing braces are | |
4040 indented two spaces.) | |
4041 @item | |
4042 Variable and function names should be all lowercase, with underscores | |
4043 separating words, except for a prefixing tag, which may be in | |
4044 uppercase. Do not use the mixed-case convention (e.g. | |
4045 SetVariableToValue ()) and *especially* do not use Microsoft | |
4046 Hungarian notation (char **rgszRedundantTag). | |
4047 @item | |
4048 preprocessor and enum constants should be all uppercase, and should | |
4049 be prefixed with a tag that groups related constants together. | |
4050 @end itemize | |
4051 | |
4052 Now, the XEmacs coding standards: | |
4053 | |
4054 @subheading Specially-prefixed functions/variables: | |
4055 | |
4056 @itemize @bullet | |
4057 @item | |
4058 All global C variables whose value is constant and is a symbol begin | |
4059 with a capital Q, e.g. Qkey_press_event. (The type will always be | |
4060 Lisp_Object.) | |
4061 @item | |
4062 All other global C variables whose value is a Lisp_Object (this | |
4063 includes variables that forward into Lisp variables plus others like | |
4064 Vselected_console) begin with a capital V. | |
4065 @item | |
4066 No C variables whose value is other than a Lisp_Object should begin | |
4067 with a capital V. (This includes C variables that forward into | |
4068 integer or boolean Lisp variables.) | |
4069 @item | |
4070 All global C variables whose value is a struct Lisp_Subr begin with a | |
4071 capital S. (This only occurs in connection with DEFUN ()). | |
4072 @item | |
4073 All C functions that are Lisp primitives begin with a capital F, | |
4074 and no others should begin this way. | |
4075 @end itemize | |
4076 | |
4077 @subheading Functions for manipulating Lisp types: | |
4078 | |
4079 @itemize @bullet | |
4080 @item | |
4081 Any function that creates an empty or mostly empty Lisp object | |
4082 should begin allocate_(). (*Not* make_().) (Except, of course, | |
4083 for Lisp primitives, which usually begin Fmake_()). | |
4084 @item | |
4085 Any function that converts a pointer into an equivalent Lisp_Object | |
4086 should begin make_(). | |
4087 @item | |
4088 Any function that converts a Lisp_Object into its equivalent pointer | |
4089 and checks the type and validity of the object (e.g. making sure | |
4090 it's not dead) should begin decode_(). | |
4091 @item | |
4092 Any function that looks up a Lisp object (e.g. buffer, face) given | |
4093 a symbol or string should begin get_(). (Except, of course, for | |
4094 Lisp primitives, which usually begin Fget_()). | |
4095 @end itemize | |
4096 | |
4097 @subheading Other: | |
4098 | |
4099 @itemize @bullet | |
4100 @item | |
4101 Any header-file declarations of the sort | |
4102 | |
4103 struct foobar; | |
4104 | |
4105 go into the "types" section of lisp.h. | |
4106 @end itemize | |
4107 | |
4108 @node Writing New Modules, Working with Lisp Objects, Introduction to Writing C Code, Rules When Writing New C Code | |
4109 @section Writing New Modules | |
4110 @cindex writing new modules | |
4111 | |
4112 Every module includes @file{<config.h>} (angle brackets so that | |
4113 @samp{--srcdir} works correctly; @file{config.h} may or may not be in | |
4114 the same directory as the C sources) and @file{lisp.h}. @file{config.h} | |
4115 must always be included before any other header files (including | |
4116 system header files) to ensure that certain tricks played by various | |
4117 @file{s/} and @file{m/} files work out correctly. | |
4118 | |
4119 When including header files, always use angle brackets, not double | |
4120 quotes, except when the file to be included is always in the same | |
4121 directory as the including file. If either file is a generated file, | |
4122 then that is not likely to be the case. In order to understand why we | |
4123 have this rule, imagine what happens when you do a build in the source | |
4124 directory using @samp{./configure} and another build in another | |
4125 directory using @samp{../work/configure}. There will be two different | |
4126 @file{config.h} files. Which one will be used if you @samp{#include | |
4127 "config.h"}? | |
4128 | |
4129 Almost every module contains a @code{syms_of_*()} function and a | |
4130 @code{vars_of_*()} function. The former declares any Lisp primitives | |
4131 you have defined and defines any symbols you will be using. The latter | |
4132 declares any global Lisp variables you have added and initializes global | |
4133 C variables in the module. @strong{Important}: There are stringent | |
4134 requirements on exactly what can go into these functions. See the | |
4135 comment in @file{emacs.c}. The reason for this is to avoid obscure | |
4136 unwanted interactions during initialization. If you don't follow these | |
4137 rules, you'll be sorry! If you want to do anything that isn't allowed, | |
4138 create a @code{complex_vars_of_*()} function for it. Doing this is | |
4139 tricky, though: you have to make sure your function is called at the | |
4140 right time so that all the initialization dependencies work out. | |
4141 | |
4142 Declare each function of these kinds in @file{symsinit.h}. Make sure | |
4143 it's called in the appropriate place in @file{emacs.c}. You never need | |
4144 to include @file{symsinit.h} directly, because it is included by | |
4145 @file{lisp.h}. | |
4146 | |
4147 @strong{All global and static variables that are to be modifiable must | |
4148 be declared uninitialized.} This means that you may not use the | |
4149 ``declare with initializer'' form for these variables, such as @code{int | |
4150 some_variable = 0;}. The reason for this has to do with some kludges | |
4151 done during the dumping process: If possible, the initialized data | |
4152 segment is re-mapped so that it becomes part of the (unmodifiable) code | |
4153 segment in the dumped executable. This allows this memory to be shared | |
4154 among multiple running XEmacs processes. XEmacs is careful to place as | |
4155 much constant data as possible into initialized variables during the | |
4156 @file{temacs} phase. | |
4157 | |
4158 @cindex copy-on-write | |
4159 @strong{Please note:} This kludge only works on a few systems nowadays, | |
4160 and is rapidly becoming irrelevant because most modern operating systems | |
4161 provide @dfn{copy-on-write} semantics. All data is initially shared | |
4162 between processes, and a private copy is automatically made (on a | |
4163 page-by-page basis) when a process first attempts to write to a page of | |
4164 memory. | |
4165 | |
4166 Formerly, there was a requirement that static variables not be declared | |
4167 inside of functions. This had to do with another hack along the same | |
4168 vein as what was just described: old USG systems put statically-declared | |
4169 variables in the initialized data space, so those header files had a | |
4170 @code{#define static} declaration. (That way, the data-segment remapping | |
4171 described above could still work.) This fails badly on static variables | |
4172 inside of functions, which suddenly become automatic variables; | |
4173 therefore, you weren't supposed to have any of them. This awful kludge | |
4174 has been removed in XEmacs because | |
4175 | |
4176 @enumerate | |
4177 @item | |
4178 almost all of the systems that used this kludge ended up having | |
4179 to disable the data-segment remapping anyway; | |
4180 @item | |
4181 the only systems that didn't were extremely outdated ones; | |
4182 @item | |
4183 this hack completely messed up inline functions. | |
4184 @end enumerate | |
4185 | |
4186 Here are things to know when you create a new source file: | |
4187 | |
4188 @itemize @bullet | |
4189 @item | |
4190 All @file{.c} files should @code{#include <config.h>} first. Almost all | |
4191 @file{.c} files should @code{#include "lisp.h"} second. | |
4192 | |
4193 @item | |
4194 Generated header files should be included using the @samp{#include <...>} | |
4195 syntax, not the @samp{#include "..."} syntax. The generated headers are: | |
4196 | |
4197 @file{config.h sheap-adjust.h paths.h Emacs.ad.h} | |
4198 | |
4199 The basic rule is that you should assume builds using @samp{--srcdir} | |
4200 and the @samp{#include <...>} syntax needs to be used when the | |
4201 to-be-included generated file is in a potentially different directory | |
4202 @emph{at compile time}. The non-obvious C rule is that | |
4203 @samp{#include "..."} means to search for the included file in the same | |
4204 directory as the including file, @emph{not} in the current directory. | |
4205 Normally this is not a problem but when building with @samp{--srcdir}, | |
4206 @file{make} will search the @samp{VPATH} for you, while the C compiler | |
4207 knows nothing about it. | |
4208 | |
4209 @item | |
4210 Header files should @emph{not} include @samp{<config.h>} and | |
4211 @samp{"lisp.h"}. It is the responsibility of the @file{.c} files that | |
4212 use it to do so. | |
4213 | |
4214 @end itemize | |
4215 | |
4216 @node Working with Lisp Objects, Writing Lisp Primitives, Writing New Modules, Rules When Writing New C Code | |
4217 @section Working with Lisp Objects | |
4218 @cindex working with lisp objects | |
4219 | |
4220 @subheading Conventions involving Lisp objects | |
4221 | |
4222 Of course the low-level implementation language of XEmacs is C, but much | |
4223 of that uses the Lisp engine to do its work. However, because the code | |
4224 is ``inside'' of the protective containment shell around the ``reactor | |
4225 core,'' you'll see lots of complex ``plumbing'' needed to do the work | |
4226 and ``safety mechanisms,'' whose failure results in a meltdown. This | |
4227 section provides a quick overview (or review) of the various components | |
4228 of the implementation of Lisp objects. | |
4229 | |
4230 Two typographic conventions help to identify C objects that implement | |
4231 Lisp objects. The first is that capitalized identifiers, especially | |
4232 beginning with the letters @samp{Q}, @samp{V}, @samp{F}, and @samp{S}, | |
4233 for C variables and functions, and C macros with beginning with the | |
4234 letter @samp{X}, are used to implement Lisp. The second is that where | |
4235 Lisp uses the hyphen @samp{-} in symbol names, the corresponding C | |
4236 identifiers use the underscore @samp{_}. Of course, since XEmacs Lisp | |
4237 contains interfaces to many external libraries, those external names | |
4238 will follow the coding conventions their authors chose, and may overlap | |
4239 the ``XEmacs name space.'' However these cases are usually pretty | |
4240 obvious. | |
4241 | |
4242 All Lisp objects are handled indirectly. The @code{Lisp_Object} | |
4243 type is usually a pointer to a structure, except for a very small number | |
4244 of types with immediate representations (currently characters and | |
4245 integers). However, these types cannot be directly operated on in C | |
4246 code, either, so they can also be considered indirect. Types that do | |
4247 not have an immediate representation always have a C typedef | |
4248 @code{Lisp_@var{type}} for a corresponding structure. | |
4249 @c #### mention l(c)records here? | |
4250 | |
4251 In older code, it was common practice to pass around pointers to | |
4252 @code{Lisp_@var{type}}, but this is now deprecated in favor of using | |
4253 @code{Lisp_Object} for all function arguments and return values that are | |
4254 Lisp objects. The @code{X@var{type}} macro is used to extract the | |
4255 pointer and cast it to @code{(Lisp_@var{type} *)} for the desired type. | |
4256 | |
4257 @strong{Convention}: macros whose names begin with @samp{X} operate on | |
4258 @code{Lisp_Object}s and do no type-checking. Many such macros are type | |
4259 extractors, but others implement Lisp operations in C (@emph{e.g.}, | |
4260 @code{XCAR} implements the Lisp @code{car} function). These are unsafe, | |
4261 and must only be used where types of all data have already been checked. | |
4262 Such macros are only applied to @code{Lisp_Object}s. In internal | |
4263 implementations where the pointer has already been converted, the | |
4264 structure is operated on directly using the C @code{->} member access | |
4265 operator. | |
4266 | |
4267 The @code{@var{type}P}, @code{CHECK_@var{type}}, and | |
4268 @code{CONCHECK_@var{type}} macros are used to test types. The first | |
4269 returns a Boolean value, and the latter signal errors. (The | |
4270 @samp{CONCHECK} variety allows execution to be CONtinued under some | |
4271 circumstances, thus the name.) Functions which expect to be passed user | |
4272 data invariably call @samp{CHECK} macros on arguments. | |
4273 | |
4274 There are many types of specialized Lisp objects implemented in C, but | |
4275 the most pervasive type is the @dfn{symbol}. Symbols are used as | |
4276 identifiers, variables, and functions. | |
4277 | |
4278 @strong{Convention}: Global variables whose names begin with @samp{Q} | |
4279 are constants whose value is a symbol. The name of the variable should | |
4280 be derived from the name of the symbol using the same rules as for Lisp | |
4281 primitives. Such variables allow the C code to check whether a | |
4282 particular @code{Lisp_Object} is equal to a given symbol. Symbols are | |
4283 Lisp objects, so these variables may be passed to Lisp primitives. (An | |
4284 alternative to the use of @samp{Q...} variables is to call the | |
4285 @code{intern} function at initialization in the | |
4286 @code{vars_of_@var{module}} function, which is hardly less efficient.) | |
4287 | |
4288 @strong{Convention}: Global variables whose names begin with @samp{V} | |
4289 are variables that contain Lisp objects. The convention here is that | |
4290 all global variables of type @code{Lisp_Object} begin with @samp{V}, and | |
4291 no others do (not even integer and boolean variables that have Lisp | |
4292 equivalents). Most of the time, these variables have equivalents in | |
4293 Lisp, which are defined via the @samp{DEFVAR} family of macros, but some | |
4294 don't. Since the variable's value is a @code{Lisp_Object}, it can be | |
4295 passed to Lisp primitives. | |
4296 | |
4297 The implementation of Lisp primitives is more complex. | |
4298 @strong{Convention}: Global variables with names beginning with @samp{S} | |
4299 contain a structure that allows the Lisp engine to identify and call a C | |
4300 function. In modern versions of XEmacs, these identifiers are almost | |
4301 always completely hidden in the @code{DEFUN} and @code{SUBR} macros, but | |
4302 you will encounter them if you look at very old versions of XEmacs or at | |
4303 GNU Emacs. @strong{Convention}: Functions with names beginning with | |
4304 @samp{F} implement Lisp primitives. Of course all their arguments and | |
4305 their return values must be Lisp_Objects. (This is hidden in the | |
4306 @code{DEFUN} macro.) | |
4307 | |
4308 @subheading Working with Lisp lists | |
4309 | |
4310 Lisp lists are popular data structures in the C code as well as in | |
4311 Elisp. There are two sets of macros that iterate over lists. | |
4312 @code{EXTERNAL_LIST_LOOP_@var{n}} should be used when the list has been | |
4313 supplied by the user, and cannot be trusted to be acyclic and | |
4314 @code{nil}-terminated. A @code{malformed-list} or @code{circular-list} error | |
4315 will be generated if the list being iterated over is not entirely | |
4316 kosher. @code{LIST_LOOP_@var{n}}, on the other hand, is faster and less | |
4317 safe, and can be used only on trusted lists. | |
4318 | |
4319 Related macros are @code{GET_EXTERNAL_LIST_LENGTH} and | |
4320 @code{GET_LIST_LENGTH}, which calculate the length of a list, and in the | |
4321 case of @code{GET_EXTERNAL_LIST_LENGTH}, validating the properness of | |
4322 the list. The macros @code{EXTERNAL_LIST_LOOP_DELETE_IF} and | |
4323 @code{LIST_LOOP_DELETE_IF} delete elements from a lisp list satisfying some | |
4324 predicate. | |
4325 | |
4326 @subheading Implementation of Lisp objects | |
4327 | |
4328 At the lowest levels, XEmacs makes heavy use of object-oriented | |
4329 techniques to promote code-sharing and uniform interfaces for different | |
4330 devices and platforms. Commonly, but not always, such objects are | |
4331 ``wrapped'' and exported to Lisp as Lisp objects. Usually they use | |
4332 the internal structures developed for Lisp objects (the @samp{lrecord} | |
4333 structure) in order to take advantage of Lisp memory management. | |
4334 Unfortunately, XEmacs was originally written in C, so these techniques | |
4335 are based on heavy use of C macros. | |
4336 | |
4337 @c You can't use @var{} for type below, because case is important. | |
4338 A module defining a class is likely to use most of the following | |
4339 declarations and macros. In the following, the notation @samp{<type>} | |
4340 will stand for the full name of the class, and will be capitalized in | |
4341 the way normal for its context. The notation @samp{<typ>} will stand | |
4342 for the abbreviated form commonly used in macro names, while @samp{ty} | |
4343 will be used as the typical name for instances of the class. (See the | |
4344 entry for @samp{MAYBE_<TY>METH} below for an example using all three | |
4345 notations.) | |
4346 | |
4347 In the interface (@file{.h} file), the following declarations are used | |
4348 often. Others may be used in for particular modules. Since they're | |
4349 quite short in most cases, the definitions are given as well. The | |
4350 generic macros used are defined in @file{lisp.h} or @file{lrecord.h}. | |
4351 | |
4352 @c #### reorganize this table into stuff used in general code, and stuff | |
4353 @c used only in declarations or initializations | |
4354 @table @samp | |
4355 @c #### declaration | |
4356 @item typedef struct Lisp_<Type> Lisp_<Type> | |
4357 This refers to the internal structure used by C code. The XEmacs coding | |
4358 style now forbids passing pointers to @samp{Lisp_<Type>} structures into | |
4359 or out of a function; instead, a @samp{Lisp_Object} should be passed or | |
4360 returned (created using @samp{wrap_<type>}, if necessary). | |
4361 | |
4362 @c #### declaration | |
4363 @item DECLARE_LRECORD (<type>, Lisp_<Type>) | |
4364 Declares an @samp{lrecord} for @samp{<Type>}, which is the unit of | |
4365 allocation. | |
4366 | |
4367 @item #define X<TYPE>(x) XRECORD (x, <type>, Lisp_<Type>) | |
4368 Turns a @code{Lisp_Object} into a pointer to @samp{struct Lisp_<Type>}. | |
4369 | |
4370 @item #define wrap_<type>(p) wrap_record (p, <type>) | |
4371 Turns a pointer to @samp{struct Lisp_<Type>} into a @code{Lisp_Object}. | |
4372 | |
4373 @item #define <TYPE>P(x) RECORDP (x, <type>) | |
4374 Tests whether a given @code{Lisp_Object} is of type @samp{Lisp_<Type>}. | |
4375 Returns a C int, not a Lisp Boolean value. | |
4376 | |
4377 @item #define CHECK_<TYPE>(x) CHECK_RECORD (x, <type>) | |
4378 @itemx #define CONCHECK_<TYPE>(x) CONCHECK_RECORD (x, <type>) | |
4379 Tests whether a given @code{Lisp_Object} is of type @samp{Lisp_<Type>}, | |
4380 and signals a Lisp error if not. The @samp{CHECK} version of the macro | |
4381 never returns if the type is wrong, while the @samp{CONCHECK} version | |
4382 can return if the user catches it in the debugger and explicitly | |
4383 requests a return. | |
4384 | |
4385 @item #define RAW_<TYP>METH(ty, m) ((ty)->methods->m##_method) | |
4386 Return a function pointer for the method for an object @var{TY} of class | |
4387 @samp{Lisp_<Type>}, or @samp{NULL} if there is none for this type. | |
4388 | |
4389 @item #define HAS_<TYP>METH_P(ty, m) (!!RAW_<TYP>METH (ty, m)) | |
4390 Test whether the class that @var{TY} is an instance of has the method. | |
4391 | |
4392 @item #define <TYP>METH(ty, m, args) ((RAW_<TYP>METH (ty, m)) args) | |
4393 Call the method on @samp{args}. @samp{args} must be enclosed in | |
4394 parentheses in the call. It is the programmer's responsibility to | |
4395 ensure that the method is available. The standard convenience macro | |
4396 @samp{MAYBE_<TYP>METH} is often provided for the common case where a | |
4397 void-returning method of @samp{Type} is called. | |
4398 | |
4399 @item #define MAYBE_<TYP>METH(ty, m, args) do @{ ... @} while (0) | |
4400 Call a void-returning @samp{<Type>} method, if it exists. Note the use | |
4401 of the @samp{do ... while (0)} idiom to give the macro call C statement | |
4402 semantics. The full definition is equally idiomatic: | |
4403 | |
4404 @example | |
4405 #define MAYBE_<TYP>METH(ty, m, args) do @{ \ | |
4406 Lisp_<Type> *maybe_<typ>meth_ty = (ty); \ | |
4407 if (HAS_<TYP>METH_P (maybe_<typ>meth_ty, m)) \ | |
4408 <TYP>METH (maybe_<typ>meth_ty, m, args); \ | |
4409 @} while (0) | |
4410 @end example | |
4411 @end table | |
4412 | |
4413 The use of macros for invoking an object's methods makes life a bit | |
4414 difficult for the student or maintainer when browsing the code. In | |
4415 particular, calls are of the form @samp{<TYP>METH (ty, some_method, (x, | |
4416 y))}, but definitions typically are for @samp{<subtype>_some_method}. | |
4417 Thus, when you are trying to find calls, you need to grep for | |
4418 @samp{some_method}, but this will also catch calls and definitions of | |
4419 that method for instances of other subtypes of @samp{<Type>}, and there | |
4420 may be a rather large number of them. | |
4421 | |
4422 @cindex Lisp object types, creating | |
4423 @cindex creating Lisp object types | |
4424 @cindex object types, creating Lisp | |
4425 Here is a checklist of things to do when creating a new lisp object type | |
4426 named @var{foo}: | |
4427 | |
4428 @enumerate | |
4429 @item | |
4430 create @var{foo}.h | |
4431 @item | |
4432 create @var{foo}.c | |
4433 @item | |
4434 add definitions of @code{syms_of_@var{foo}}, etc. to @file{@var{foo}.c} | |
4435 @item | |
4436 add declarations of @code{syms_of_@var{foo}}, etc. to @file{symsinit.h} | |
4437 @item | |
4438 add calls to @code{syms_of_@var{foo}}, etc. to @file{emacs.c} | |
4439 @item | |
4440 add definitions of macros like @code{CHECK_@var{FOO}} and | |
4441 @code{@var{FOO}P} to @file{@var{foo}.h} | |
4442 @item | |
4443 add the new type index to @code{enum lrecord_type} | |
4444 @item | |
4445 add a DEFINE_LRECORD_IMPLEMENTATION call to @file{@var{foo}.c} | |
4446 @item | |
4447 add an INIT_LRECORD_IMPLEMENTATION call to @code{syms_of_@var{foo}.c} | |
4448 @end enumerate | |
4449 | |
4450 | |
4451 @node Writing Lisp Primitives, Writing Good Comments, Working with Lisp Objects, Rules When Writing New C Code | |
4452 @section Writing Lisp Primitives | |
4453 @cindex writing Lisp primitives | |
4454 @cindex Lisp primitives, writing | |
4455 @cindex primitives, writing Lisp | |
4456 | |
4457 Lisp primitives are Lisp functions implemented in C. The details of | |
4458 interfacing the C function so that Lisp can call it are handled by a few | |
4459 C macros. The only way to really understand how to write new C code is | |
4460 to read the source, but we can explain some things here. | |
4461 | |
4462 An example of a special form is the definition of @code{prog1}, from | |
4463 @file{eval.c}. (An ordinary function would have the same general | |
4464 appearance.) | |
4465 | |
4466 @cindex garbage collection protection | |
4467 @smallexample | |
4468 @group | |
4469 DEFUN ("prog1", Fprog1, 1, UNEVALLED, 0, /* | |
4470 Similar to `progn', but the value of the first form is returned. | |
4471 \(prog1 FIRST BODY...): All the arguments are evaluated sequentially. | |
4472 The value of FIRST is saved during evaluation of the remaining args, | |
4473 whose values are discarded. | |
4474 */ | |
4475 (args)) | |
4476 @{ | |
4477 /* This function can GC */ | |
4478 REGISTER Lisp_Object val, form, tail; | |
4479 struct gcpro gcpro1; | |
4480 | |
4481 val = Feval (XCAR (args)); | |
4482 | |
4483 GCPRO1 (val); | |
4484 | |
4485 LIST_LOOP_3 (form, XCDR (args), tail) | |
4486 Feval (form); | |
4487 | |
4488 UNGCPRO; | |
4489 return val; | |
4490 @} | |
4491 @end group | |
4492 @end smallexample | |
4493 | |
4494 Let's start with a precise explanation of the arguments to the | |
4495 @code{DEFUN} macro. Here is a template for them: | |
4496 | |
4497 @example | |
4498 @group | |
4499 DEFUN (@var{lname}, @var{fname}, @var{min_args}, @var{max_args}, @var{interactive}, /* | |
4500 @var{docstring} | |
4501 */ | |
4502 (@var{arglist})) | |
4503 @end group | |
4504 @end example | |
4505 | |
4506 @table @var | |
4507 @item lname | |
4508 This string is the name of the Lisp symbol to define as the function | |
4509 name; in the example above, it is @code{"prog1"}. | |
4510 | |
4511 @item fname | |
4512 This is the C function name for this function. This is the name that is | |
4513 used in C code for calling the function. The name is, by convention, | |
4514 @samp{F} prepended to the Lisp name, with all dashes (@samp{-}) in the | |
4515 Lisp name changed to underscores. Thus, to call this function from C | |
4516 code, call @code{Fprog1}. Remember that the arguments are of type | |
4517 @code{Lisp_Object}; various macros and functions for creating values of | |
4518 type @code{Lisp_Object} are declared in the file @file{lisp.h}. | |
4519 | |
4520 Primitives whose names are special characters (e.g. @code{+} or | |
4521 @code{<}) are named by spelling out, in some fashion, the special | |
4522 character: e.g. @code{Fplus()} or @code{Flss()}. Primitives whose names | |
4523 begin with normal alphanumeric characters but also contain special | |
4524 characters are spelled out in some creative way, e.g. @code{let*} | |
4525 becomes @code{FletX()}. | |
4526 | |
4527 Each function also has an associated structure that holds the data for | |
4528 the subr object that represents the function in Lisp. This structure | |
4529 conveys the Lisp symbol name to the initialization routine that will | |
4530 create the symbol and store the subr object as its definition. The C | |
4531 variable name of this structure is always @samp{S} prepended to the | |
4532 @var{fname}. You hardly ever need to be aware of the existence of this | |
4533 structure, since @code{DEFUN} plus @code{DEFSUBR} takes care of all the | |
4534 details. | |
4535 | |
4536 @item min_args | |
4537 This is the minimum number of arguments that the function requires. The | |
4538 function @code{prog1} allows a minimum of one argument. | |
4539 | |
4540 @item max_args | |
4541 This is the maximum number of arguments that the function accepts, if | |
4542 there is a fixed maximum. Alternatively, it can be @code{UNEVALLED}, | |
4543 indicating a special form that receives unevaluated arguments, or | |
4544 @code{MANY}, indicating an unlimited number of evaluated arguments (the | |
4545 C equivalent of @code{&rest}). Both @code{UNEVALLED} and @code{MANY} | |
4546 are macros. If @var{max_args} is a number, it may not be less than | |
4547 @var{min_args} and it may not be greater than 8. (If you need to add a | |
4548 function with more than 8 arguments, use the @code{MANY} form. Resist | |
4549 the urge to edit the definition of @code{DEFUN} in @file{lisp.h}. If | |
4550 you do it anyways, make sure to also add another clause to the switch | |
4551 statement in @code{primitive_funcall().}) | |
4552 | |
4553 @item interactive | |
4554 This is an interactive specification, a string such as might be used as | |
4555 the argument of @code{interactive} in a Lisp function. In the case of | |
4556 @code{prog1}, it is 0 (a null pointer), indicating that @code{prog1} | |
4557 cannot be called interactively. A value of @code{""} indicates a | |
4558 function that should receive no arguments when called interactively. | |
4559 | |
4560 @item docstring | |
4561 This is the documentation string. It is written just like a | |
4562 documentation string for a function defined in Lisp; in particular, the | |
4563 first line should be a single sentence. Note how the documentation | |
4564 string is enclosed in a comment, none of the documentation is placed on | |
4565 the same lines as the comment-start and comment-end characters, and the | |
4566 comment-start characters are on the same line as the interactive | |
4567 specification. @file{make-docfile}, which scans the C files for | |
4568 documentation strings, is very particular about what it looks for, and | |
4569 will not properly extract the doc string if it's not in this exact format. | |
4570 | |
4571 In order to make both @file{etags} and @file{make-docfile} happy, make | |
4572 sure that the @code{DEFUN} line contains the @var{lname} and | |
4573 @var{fname}, and that the comment-start characters for the doc string | |
4574 are on the same line as the interactive specification, and put a newline | |
4575 directly after them (and before the comment-end characters). | |
4576 | |
4577 @item arglist | |
4578 This is the comma-separated list of arguments to the C function. For a | |
4579 function with a fixed maximum number of arguments, provide a C argument | |
4580 for each Lisp argument. In this case, unlike regular C functions, the | |
4581 types of the arguments are not declared; they are simply always of type | |
4582 @code{Lisp_Object}. | |
4583 | |
4584 The names of the C arguments will be used as the names of the arguments | |
4585 to the Lisp primitive as displayed in its documentation, modulo the same | |
4586 concerns described above for @code{F...} names (in particular, | |
4587 underscores in the C arguments become dashes in the Lisp arguments). | |
4588 | |
4589 There is one additional kludge: A trailing @samp{_} on the C argument is | |
4590 discarded when forming the Lisp argument. This allows C language | |
4591 reserved words (like @code{default}) or global symbols (like | |
4592 @code{dirname}) to be used as argument names without compiler warnings | |
4593 or errors. | |
4594 | |
4595 A Lisp function with @w{@var{max_args} = @code{UNEVALLED}} is a | |
4596 @w{@dfn{special form}}; its arguments are not evaluated. Instead it | |
4597 receives one argument of type @code{Lisp_Object}, a (Lisp) list of the | |
4598 unevaluated arguments, conventionally named @code{(args)}. | |
4599 | |
4600 When a Lisp function has no upper limit on the number of arguments, | |
4601 specify @w{@var{max_args} = @code{MANY}}. In this case its implementation in | |
4602 C actually receives exactly two arguments: the number of Lisp arguments | |
4603 (an @code{int}) and the address of a block containing their values (a | |
4604 @w{@code{Lisp_Object *}}). In this case only are the C types specified | |
4605 in the @var{arglist}: @w{@code{(int nargs, Lisp_Object *args)}}. | |
4606 | |
4607 @end table | |
4608 | |
4609 Within the function @code{Fprog1} itself, note the use of the macros | |
4610 @code{GCPRO1} and @code{UNGCPRO}. @code{GCPRO1} is used to ``protect'' | |
4611 a variable from garbage collection---to inform the garbage collector | |
4612 that it must look in that variable and regard the object pointed at by | |
4613 its contents as an accessible object. This is necessary whenever you | |
4614 call @code{Feval} or anything that can directly or indirectly call | |
4615 @code{Feval} (this includes the @code{QUIT} macro!). At such a time, | |
4616 any Lisp object that you intend to refer to again must be protected | |
4617 somehow. @code{UNGCPRO} cancels the protection of the variables that | |
4618 are protected in the current function. It is necessary to do this | |
4619 explicitly. | |
4620 | |
4621 The macro @code{GCPRO1} protects just one local variable. If you want | |
4622 to protect two, use @code{GCPRO2} instead; repeating @code{GCPRO1} will | |
4623 not work. Macros @code{GCPRO3} and @code{GCPRO4} also exist. | |
4624 | |
4625 These macros implicitly use local variables such as @code{gcpro1}; you | |
4626 must declare these explicitly, with type @code{struct gcpro}. Thus, if | |
4627 you use @code{GCPRO2}, you must declare @code{gcpro1} and @code{gcpro2}. | |
4628 | |
4629 @cindex caller-protects (@code{GCPRO} rule) | |
4630 Note also that the general rule is @dfn{caller-protects}; i.e. you are | |
4631 only responsible for protecting those Lisp objects that you create. Any | |
4632 objects passed to you as arguments should have been protected by whoever | |
4633 created them, so you don't in general have to protect them. | |
4634 | |
4635 In particular, the arguments to any Lisp primitive are always | |
4636 automatically @code{GCPRO}ed, when called ``normally'' from Lisp code or | |
4637 bytecode. So only a few Lisp primitives that are called frequently from | |
4638 C code, such as @code{Fprogn} protect their arguments as a service to | |
4639 their caller. You don't need to protect your arguments when writing a | |
4640 new @code{DEFUN}. | |
4641 | |
4642 @code{GCPRO}ing is perhaps the trickiest and most error-prone part of | |
4643 XEmacs coding. It is @strong{extremely} important that you get this | |
4644 right and use a great deal of discipline when writing this code. | |
4645 @xref{GCPROing, ,@code{GCPRO}ing}, for full details on how to do this. | |
4646 | |
4647 What @code{DEFUN} actually does is declare a global structure of type | |
4648 @code{Lisp_Subr} whose name begins with capital @samp{SF} and which | |
4649 contains information about the primitive (e.g. a pointer to the | |
4650 function, its minimum and maximum allowed arguments, a string describing | |
4651 its Lisp name); @code{DEFUN} then begins a normal C function declaration | |
4652 using the @code{F...} name. The Lisp subr object that is the function | |
4653 definition of a primitive (i.e. the object in the function slot of the | |
4654 symbol that names the primitive) actually points to this @samp{SF} | |
4655 structure; when @code{Feval} encounters a subr, it looks in the | |
4656 structure to find out how to call the C function. | |
4657 | |
4658 Defining the C function is not enough to make a Lisp primitive | |
4659 available; you must also create the Lisp symbol for the primitive (the | |
4660 symbol is @dfn{interned}; @pxref{Obarrays}) and store a suitable subr | |
4661 object in its function cell. (If you don't do this, the primitive won't | |
4662 be seen by Lisp code.) The code looks like this: | |
4663 | |
4664 @example | |
4665 DEFSUBR (@var{fname}); | |
4666 @end example | |
4667 | |
4668 @noindent | |
4669 Here @var{fname} is the same name you used as the second argument to | |
4670 @code{DEFUN}. | |
4671 | |
4672 This call to @code{DEFSUBR} should go in the @code{syms_of_*()} function | |
4673 at the end of the module. If no such function exists, create it and | |
4674 make sure to also declare it in @file{symsinit.h} and call it from the | |
4675 appropriate spot in @code{main()}. @xref{Writing New Modules}. | |
4676 | |
4677 Note that C code cannot call functions by name unless they are defined | |
4678 in C. The way to call a function written in Lisp from C is to use | |
4679 @code{Ffuncall}, which embodies the Lisp function @code{funcall}. Since | |
4680 the Lisp function @code{funcall} accepts an unlimited number of | |
4681 arguments, in C it takes two: the number of Lisp-level arguments, and a | |
4682 one-dimensional array containing their values. The first Lisp-level | |
4683 argument is the Lisp function to call, and the rest are the arguments to | |
4684 pass to it. Since @code{Ffuncall} can call the evaluator, you must | |
4685 protect pointers from garbage collection around the call to | |
4686 @code{Ffuncall}. (However, @code{Ffuncall} explicitly protects all of | |
4687 its parameters, so you don't have to protect any pointers passed as | |
4688 parameters to it.) | |
4689 | |
4690 The C functions @code{call0}, @code{call1}, @code{call2}, and so on, | |
4691 provide handy ways to call a Lisp function conveniently with a fixed | |
4692 number of arguments. They work by calling @code{Ffuncall}. | |
4693 | |
4694 @file{eval.c} is a very good file to look through for examples; | |
4695 @file{lisp.h} contains the definitions for important macros and | |
4696 functions. | |
4697 | |
4698 @node Writing Good Comments, Adding Global Lisp Variables, Writing Lisp Primitives, Rules When Writing New C Code | |
4699 @section Writing Good Comments | |
4700 @cindex writing good comments | |
4701 @cindex comments, writing good | |
4702 | |
4703 Comments are a lifeline for programmers trying to understand tricky | |
4704 code. In general, the less obvious it is what you are doing, the more | |
4705 you need a comment, and the more detailed it needs to be. You should | |
4706 always be on guard when you're writing code for stuff that's tricky, and | |
4707 should constantly be putting yourself in someone else's shoes and asking | |
4708 if that person could figure out without much difficulty what's going | |
4709 on. (Assume they are a competent programmer who understands the | |
4710 essentials of how the XEmacs code is structured but doesn't know much | |
4711 about the module you're working on or any algorithms you're using.) If | |
4712 you're not sure whether they would be able to, add a comment. Always | |
4713 err on the side of more comments, rather than less. | |
4714 | |
4715 Generally, when making comments, there is no need to attribute them with | |
4716 your name or initials. This especially goes for small, | |
4717 easy-to-understand, non-opinionated ones. Also, comments indicating | |
4718 where, when, and by whom a file was changed are @emph{strongly} | |
4719 discouraged, and in general will be removed as they are discovered. | |
4720 This is exactly what @file{ChangeLogs} are there for. However, it can | |
4721 occasionally be useful to mark exactly where (but not when or by whom) | |
4722 changes are made, particularly when making small changes to a file | |
4723 imported from elsewhere. These marks help when later on a newer version | |
4724 of the file is imported and the changes need to be merged. (If | |
4725 everything were always kept in CVS, there would be no need for this. | |
4726 But in practice, this often doesn't happen, or the CVS repository is | |
4727 later on lost or unavailable to the person doing the update.) | |
4728 | |
4729 When putting in an explicit opinion in a comment, you should | |
4730 @emph{always} attribute it with your name and the date. This also goes | |
4731 for long, complex comments explaining in detail the workings of | |
4732 something -- by putting your name there, you make it possible for | |
4733 someone who has questions about how that thing works to determine who | |
4734 wrote the comment so they can write to them. Use your actual name or | |
4735 your alias at xemacs.org, and not your initials or nickname, unless that | |
4736 is generally recognized (e.g. @samp{jwz}). Even then, please consider | |
4737 requesting a virtual user at xemacs.org (forwarding address; we can't | |
4738 provide an actual mailbox). Otherwise, give first and last name. If | |
4739 you're not a regular contributor, you might consider putting your email | |
4740 address in -- it may be in the ChangeLog, but after awhile ChangeLogs | |
4741 have a tendency of disappearing or getting muddled. (E.g. your comment | |
4742 may get copied somewhere else or even into another program, and tracking | |
4743 down the proper ChangeLog may be very difficult.) | |
4744 | |
4745 If you come across an opinion that is not or is no longer valid, or you | |
4746 come across any comment that no longer applies but you want to keep it | |
4747 around, enclose it in @samp{[[ } and @samp{ ]]} marks and add a comment | |
4748 afterwards explaining why the preceding comment is no longer valid. Put | |
4749 your name on this comment, as explained above. | |
4750 | |
4751 Just as comments are a lifeline to programmers, incorrect comments are | |
4752 death. If you come across an incorrect comment, @strong{immediately} | |
4753 correct it or flag it as incorrect, as described in the previous | |
4754 paragraph. Whenever you work on a section of code, @emph{always} make | |
4755 sure to update any comments to be correct -- or, at the very least, flag | |
4756 them as incorrect. | |
4757 | |
4758 To indicate a "todo" or other problem, use four pound signs -- | |
4759 i.e. @samp{####}. | |
4760 | |
4761 @node Adding Global Lisp Variables, Writing Macros, Writing Good Comments, Rules When Writing New C Code | |
4762 @section Adding Global Lisp Variables | |
4763 @cindex global Lisp variables, adding | |
4764 @cindex variables, adding global Lisp | |
4765 | |
4766 Global variables whose names begin with @samp{Q} are constants whose | |
4767 value is a symbol of a particular name. The name of the variable should | |
4768 be derived from the name of the symbol using the same rules as for Lisp | |
4769 primitives. These variables are initialized using a call to | |
4770 @code{defsymbol()} in the @code{syms_of_*()} function. (This call | |
4771 interns a symbol, sets the C variable to the resulting Lisp object, and | |
4772 calls @code{staticpro()} on the C variable to tell the | |
4773 garbage-collection mechanism about this variable. What | |
4774 @code{staticpro()} does is add a pointer to the variable to a large | |
4775 global array; when garbage-collection happens, all pointers listed in | |
4776 the array are used as starting points for marking Lisp objects. This is | |
4777 important because it's quite possible that the only current reference to | |
4778 the object is the C variable. In the case of symbols, the | |
4779 @code{staticpro()} doesn't matter all that much because the symbol is | |
4780 contained in @code{obarray}, which is itself @code{staticpro()}ed. | |
4781 However, it's possible that a naughty user could do something like | |
4782 uninterning the symbol out of @code{obarray} or even setting | |
4783 @code{obarray} to a different value [although this is likely to make | |
4784 XEmacs crash!].) | |
4785 | |
4786 @strong{Please note:} It is potentially deadly if you declare a | |
4787 @samp{Q...} variable in two different modules. The two calls to | |
4788 @code{defsymbol()} are no problem, but some linkers will complain about | |
4789 multiply-defined symbols. The most insidious aspect of this is that | |
4790 often the link will succeed anyway, but then the resulting executable | |
4791 will sometimes crash in obscure ways during certain operations! | |
4792 | |
4793 To avoid this problem, declare any symbols with common names (such as | |
4794 @code{text}) that are not obviously associated with this particular | |
4795 module in the file @file{general-slots.h}. The ``-slots'' suffix | |
4796 indicates that this is a file that is included multiple times in | |
4797 @file{general.c}. Redefinition of preprocessor macros allows the | |
4798 effects to be different in each context, so this is actually more | |
4799 convenient and less error-prone than doing it in your module. | |
4800 | |
4801 Global variables whose names begin with @samp{V} are variables that | |
4802 contain Lisp objects. The convention here is that all global variables | |
4803 of type @code{Lisp_Object} begin with @samp{V}, and all others don't | |
4804 (including integer and boolean variables that have Lisp | |
4805 equivalents). Most of the time, these variables have equivalents in | |
4806 Lisp, but some don't. Those that do are declared this way by a call to | |
4807 @code{DEFVAR_LISP()} in the @code{vars_of_*()} initializer for the | |
4808 module. What this does is create a special @dfn{symbol-value-forward} | |
4809 Lisp object that contains a pointer to the C variable, intern a symbol | |
4810 whose name is as specified in the call to @code{DEFVAR_LISP()}, and set | |
4811 its value to the symbol-value-forward Lisp object; it also calls | |
4812 @code{staticpro()} on the C variable to tell the garbage-collection | |
4813 mechanism about the variable. When @code{eval} (or actually | |
4814 @code{symbol-value}) encounters this special object in the process of | |
4815 retrieving a variable's value, it follows the indirection to the C | |
4816 variable and gets its value. @code{setq} does similar things so that | |
4817 the C variable gets changed. | |
4818 | |
4819 Whether or not you @code{DEFVAR_LISP()} a variable, you need to | |
4820 initialize it in the @code{vars_of_*()} function; otherwise it will end | |
4821 up as all zeroes, which is the integer 0 (@emph{not} @code{nil}), and | |
4822 this is probably not what you want. Also, if the variable is not | |
4823 @code{DEFVAR_LISP()}ed, @strong{you must call} @code{staticpro()} on the | |
4824 C variable in the @code{vars_of_*()} function. Otherwise, the | |
4825 garbage-collection mechanism won't know that the object in this variable | |
4826 is in use, and will happily collect it and reuse its storage for another | |
4827 Lisp object, and you will be the one who's unhappy when you can't figure | |
4828 out how your variable got overwritten. | |
4829 | |
4830 @node Writing Macros, Proper Use of Unsigned Types, Adding Global Lisp Variables, Rules When Writing New C Code | |
4831 @section Writing Macros | |
4832 @cindex writing macros | |
4833 @cindex macros, writing | |
4834 | |
4835 Heavily used small code fragments need to be fast. The traditional way | |
4836 to implement such code fragments in C is with macros. But macros in C | |
4837 are known to be broken. | |
4838 | |
4839 @cindex macro hygiene | |
4840 Macro arguments that are repeatedly evaluated may suffer from repeated | |
4841 side effects or suboptimal performance. | |
4842 | |
4843 Variable names used in macros may collide with caller's variables, | |
4844 causing (at least) unwanted compiler warnings. | |
4845 | |
4846 In order to solve these problems, and maintain statement semantics, | |
4847 one should use the @code{do @{ ... @} while (0)} trick (which safely | |
4848 works inside of if statements) while trying to reference macro | |
4849 arguments exactly once using local variables. | |
4850 | |
4851 Let's take a look at this poor macro definition: | |
4852 | |
4853 @example | |
4854 #define MARK_OBJECT(obj) \ | |
4855 if (!marked_p (obj)) mark_object (obj), did_mark = 1 | |
4856 @end example | |
4857 | |
4858 This macro evaluates its argument twice, and also fails if used like this: | |
4859 @example | |
4860 if (flag) MARK_OBJECT (obj); else @code{do_something()}; | |
4861 @end example | |
4862 | |
4863 A much better definition is | |
4864 | |
4865 @example | |
4866 #define MARK_OBJECT(obj) do @{ \ | |
4867 Lisp_Object mo_obj = (obj); \ | |
4868 if (!marked_p (mo_obj)) \ | |
4869 @{ \ | |
4870 mark_object (mo_obj); \ | |
4871 did_mark = 1; \ | |
4872 @} \ | |
4873 @} while (0) | |
4874 @end example | |
4875 | |
4876 Notice the elimination of double evaluation by using the local variable | |
4877 with the obscure name. Writing safe and efficient macros requires great | |
4878 care. The one problem with macros that cannot be portably worked around | |
4879 is, since a C block has no value, a macro used as an expression rather | |
4880 than a statement cannot use the techniques just described to avoid | |
4881 multiple evaluation. | |
4882 | |
4883 @cindex inline functions | |
4884 In most cases where a macro has function semantics, an inline function | |
4885 is a better implementation technique. Modern compiler optimizers tend | |
4886 to inline functions even if they have no @code{inline} keyword, and | |
4887 configure magic ensures that the @code{inline} keyword can be safely | |
4888 used as an additional compiler hint. Inline functions used in a single | |
4889 .c files are easy. The function must already be defined to be | |
4890 @code{static}. Just add another @code{inline} keyword to the | |
4891 definition. | |
4892 | |
4893 @example | |
4894 inline static int | |
4895 heavily_used_small_function (int arg) | |
4896 @{ | |
4897 ... | |
4898 @} | |
4899 @end example | |
4900 | |
4901 Inline functions in header files are trickier, because we would like to | |
4902 make the following optimization if the function is @emph{not} inlined | |
4903 (for example, because we're compiling for debugging). We would like the | |
4904 function to be defined externally exactly once, and each calling | |
4905 translation unit would create an external reference to the function, | |
4906 instead of including a definition of the inline function in the object | |
4907 code of every translation unit that uses it. This optimization is | |
4908 currently only available for gcc. But you don't have to worry about the | |
4909 trickiness; just define your inline functions in header files using this | |
4910 pattern: | |
4911 | |
4912 @example | |
4913 DECLARE_INLINE_HEADER ( | |
4914 int | |
4915 i_used_to_be_a_crufty_macro_but_look_at_me_now (int arg) | |
4916 ) | |
4917 @{ | |
4918 ... | |
4919 @} | |
4920 @end example | |
4921 | |
4922 We use @code{DECLARE_INLINE_HEADER} rather than just the modifier | |
4923 @code{INLINE_HEADER} to prevent warnings when compiling with @code{gcc | |
4924 -Wmissing-declarations}. I consider issuing this warning for inline | |
4925 functions a gcc bug, but the gcc maintainers disagree. | |
4926 | |
4927 @cindex inline functions, headers | |
4928 @cindex header files, inline functions | |
4929 Every header which contains inline functions, either directly by using | |
4930 @code{DECLARE_INLINE_HEADER} or indirectly by using @code{DECLARE_LRECORD} must | |
4931 be added to @file{inline.c}'s includes to make the optimization | |
4932 described above work. (Optimization note: if all INLINE_HEADER | |
4933 functions are in fact inlined in all translation units, then the linker | |
4934 can just discard @code{inline.o}, since it contains only unreferenced code). | |
4935 | |
4936 The three golden rules of macros: | |
4937 | |
4938 @enumerate | |
4939 @item | |
4940 Anything that's an lvalue can be evaluated more than once. | |
4941 @item | |
4942 Macros where anything else can be evaluated more than once should | |
4943 have the word "unsafe" in their name (exceptions may be made for | |
4944 large sets of macros that evaluate arguments of certain types more | |
4945 than once, e.g. struct buffer * arguments, when clearly indicated in | |
4946 the macro documentation). These macros are generally meant to be | |
4947 called only by other macros that have already stored the calling | |
4948 values in temporary variables. | |
4949 @item | |
4950 Nothing else can be evaluated more than once. Use inline | |
4951 functions, if necessary, to prevent multiple evaluation. | |
4952 @end enumerate | |
4953 | |
4954 NOTE: The functions and macros below are given full prototypes in their | |
4955 docs, even when the implementation is a macro. In such cases, passing | |
4956 an argument of a type other than expected will produce undefined | |
4957 results. Also, given that macros can do things functions can't (in | |
4958 particular, directly modify arguments as if they were passed by | |
4959 reference), the declaration syntax has been extended to include the | |
4960 call-by-reference syntax from C++, where an & after a type indicates | |
4961 that the argument is an lvalue and is passed by reference, i.e. the | |
4962 function can modify its value. (This is equivalent in C to passing a | |
4963 pointer to the argument, but without the need to explicitly worry about | |
4964 pointers.) | |
4965 | |
4966 When to capitalize macros: | |
4967 | |
4968 @itemize @bullet | |
4969 @item | |
4970 Capitalize macros doing stuff obviously impossible with (C) | |
4971 functions, e.g. directly modifying arguments as if they were passed by | |
4972 reference. | |
4973 @item | |
4974 Capitalize macros that evaluate @strong{any} argument more than once regardless | |
4975 of whether that's "allowed" (e.g. buffer arguments). | |
4976 @item | |
4977 Capitalize macros that directly access a field in a Lisp_Object or | |
4978 its equivalent underlying structure. In such cases, access through the | |
4979 Lisp_Object precedes the macro with an X, and access through the underlying | |
4980 structure doesn't. | |
4981 @item | |
4982 Capitalize certain other basic macros relating to Lisp_Objects; e.g. | |
4983 FRAMEP, CHECK_FRAME, etc. | |
4984 @item | |
4985 Try to avoid capitalizing any other macros. | |
4986 @end itemize | |
4987 | |
4988 @node Proper Use of Unsigned Types, Major Textual Changes, Writing Macros, Rules When Writing New C Code | |
4989 @section Proper Use of Unsigned Types | |
4990 @cindex unsigned types, proper use of | |
4991 @cindex types, proper use of unsigned | |
4992 | |
4993 Avoid using @code{unsigned int} and @code{unsigned long} whenever | |
4994 possible. Unsigned types are viral -- any arithmetic or comparisons | |
4995 involving mixed signed and unsigned types are automatically converted to | |
4996 unsigned, which is almost certainly not what you want. Many subtle and | |
4997 hard-to-find bugs are created by careless use of unsigned types. In | |
4998 general, you should almost @emph{never} use an unsigned type to hold a | |
4999 regular quantity of any sort. The only exceptions are | |
5000 | |
5001 @enumerate | |
5002 @item | |
5003 When there's a reasonable possibility you will actually need all 32 or | |
5004 64 bits to store the quantity. | |
5005 @item | |
5006 When calling existing API's that require unsigned types. In this case, | |
5007 you should still do all manipulation using signed types, and do the | |
5008 conversion at the very threshold of the API call. | |
5009 @item | |
5010 In existing code that you don't want to modify because you don't | |
5011 maintain it. | |
5012 @item | |
5013 In bit-field structures. | |
5014 @end enumerate | |
5015 | |
5016 Other reasonable uses of @code{unsigned int} and @code{unsigned long} | |
5017 are representing non-quantities -- e.g. bit-oriented flags and such. | |
5018 | |
5019 @node Major Textual Changes, Debugging and Testing, Proper Use of Unsigned Types, Rules When Writing New C Code | |
5020 @section Major Textual Changes | |
3687 @cindex textual changes, major | 5021 @cindex textual changes, major |
3688 @cindex major textual changes | 5022 @cindex major textual changes |
3689 | 5023 |
3690 Sometimes major textual changes are made to the source. This means that | 5024 Sometimes major textual changes are made to the source. This means that |
3691 a search-and-replace is done to change type names and such. Some people | 5025 a search-and-replace is done to change type names and such. Some people |
3700 * Great Integral Type Renaming:: | 5034 * Great Integral Type Renaming:: |
3701 * Text/Char Type Renaming:: | 5035 * Text/Char Type Renaming:: |
3702 @end menu | 5036 @end menu |
3703 | 5037 |
3704 @node Great Integral Type Renaming, Text/Char Type Renaming, Major Textual Changes, Major Textual Changes | 5038 @node Great Integral Type Renaming, Text/Char Type Renaming, Major Textual Changes, Major Textual Changes |
3705 @section Great Integral Type Renaming | 5039 @subsection Great Integral Type Renaming |
3706 @cindex Great Integral Type Renaming | 5040 @cindex Great Integral Type Renaming |
3707 @cindex integral type renaming, great | 5041 @cindex integral type renaming, great |
3708 @cindex type renaming, integral | 5042 @cindex type renaming, integral |
3709 @cindex renaming, integral types | 5043 @cindex renaming, integral types |
3710 | 5044 |
3892 case blocks contain identical code, and you should *REMOVE THE SECOND* | 5226 case blocks contain identical code, and you should *REMOVE THE SECOND* |
3893 and leave the first. | 5227 and leave the first. |
3894 @end enumerate | 5228 @end enumerate |
3895 | 5229 |
3896 @node Text/Char Type Renaming, , Great Integral Type Renaming, Major Textual Changes | 5230 @node Text/Char Type Renaming, , Great Integral Type Renaming, Major Textual Changes |
3897 @section Text/Char Type Renaming | 5231 @subsection Text/Char Type Renaming |
3898 @cindex Text/Char Type Renaming | 5232 @cindex Text/Char Type Renaming |
3899 @cindex type renaming, text/char | 5233 @cindex type renaming, text/char |
3900 @cindex renaming, text/char types | 5234 @cindex renaming, text/char types |
3901 | 5235 |
3902 The purpose of this was | 5236 The purpose of this was |
4008 gr '_ITEXT' _CHARPTR $files | 5342 gr '_ITEXT' _CHARPTR $files |
4009 gr '_itext' _charptr $files | 5343 gr '_itext' _charptr $files |
4010 gr '_Itext' _CHARPTR $files | 5344 gr '_Itext' _CHARPTR $files |
4011 @end example | 5345 @end example |
4012 | 5346 |
4013 @node Rules When Writing New C Code, Regression Testing XEmacs, Major Textual Changes, Top | 5347 @node Debugging and Testing, , Major Textual Changes, Rules When Writing New C Code |
4014 @chapter Rules When Writing New C Code | 5348 @section Debugging and Testing |
4015 @cindex writing new C code, rules when | 5349 @cindex debugging and testing |
4016 @cindex C code, rules when writing new | |
4017 @cindex code, rules when writing new C | |
4018 | |
4019 The XEmacs C Code is extremely complex and intricate, and there are many | |
4020 rules that are more or less consistently followed throughout the code. | |
4021 Many of these rules are not obvious, so they are explained here. It is | |
4022 of the utmost importance that you follow them. If you don't, you may | |
4023 get something that appears to work, but which will crash in odd | |
4024 situations, often in code far away from where the actual breakage is. | |
4025 | |
4026 @menu | |
4027 * A Reader's Guide to XEmacs Coding Conventions:: | |
4028 * General Coding Rules:: | |
4029 * Object-Oriented Techniques for C:: | |
4030 * Writing Lisp Primitives:: | |
4031 * Writing Good Comments:: | |
4032 * Adding Global Lisp Variables:: | |
4033 * Writing Macros:: | |
4034 * Proper Use of Unsigned Types:: | |
4035 * Techniques for XEmacs Developers:: | |
4036 @end menu | |
4037 | |
4038 See also @ref{Coding for Mule}. | |
4039 | |
4040 @node A Reader's Guide to XEmacs Coding Conventions, General Coding Rules, Rules When Writing New C Code, Rules When Writing New C Code | |
4041 @section A Reader's Guide to XEmacs Coding Conventions | |
4042 @cindex coding conventions | |
4043 @cindex reader's guide | |
4044 @cindex coding rules, naming | |
4045 | |
4046 Of course the low-level implementation language of XEmacs is C, but much | |
4047 of that uses the Lisp engine to do its work. However, because the code | |
4048 is ``inside'' of the protective containment shell around the ``reactor | |
4049 core,'' you'll see lots of complex ``plumbing'' needed to do the work | |
4050 and ``safety mechanisms,'' whose failure results in a meltdown. This | |
4051 section provides a quick overview (or review) of the various components | |
4052 of the implementation of Lisp objects. | |
4053 | |
4054 Two typographic conventions help to identify C objects that implement | |
4055 Lisp objects. The first is that capitalized identifiers, especially | |
4056 beginning with the letters @samp{Q}, @samp{V}, @samp{F}, and @samp{S}, | |
4057 for C variables and functions, and C macros with beginning with the | |
4058 letter @samp{X}, are used to implement Lisp. The second is that where | |
4059 Lisp uses the hyphen @samp{-} in symbol names, the corresponding C | |
4060 identifiers use the underscore @samp{_}. Of course, since XEmacs Lisp | |
4061 contains interfaces to many external libraries, those external names | |
4062 will follow the coding conventions their authors chose, and may overlap | |
4063 the ``XEmacs name space.'' However these cases are usually pretty | |
4064 obvious. | |
4065 | |
4066 All Lisp objects are handled indirectly. The @code{Lisp_Object} | |
4067 type is usually a pointer to a structure, except for a very small number | |
4068 of types with immediate representations (currently characters and | |
4069 integers). However, these types cannot be directly operated on in C | |
4070 code, either, so they can also be considered indirect. Types that do | |
4071 not have an immediate representation always have a C typedef | |
4072 @code{Lisp_@var{type}} for a corresponding structure. | |
4073 @c #### mention l(c)records here? | |
4074 | |
4075 In older code, it was common practice to pass around pointers to | |
4076 @code{Lisp_@var{type}}, but this is now deprecated in favor of using | |
4077 @code{Lisp_Object} for all function arguments and return values that are | |
4078 Lisp objects. The @code{X@var{type}} macro is used to extract the | |
4079 pointer and cast it to @code{(Lisp_@var{type} *)} for the desired type. | |
4080 | |
4081 @strong{Convention}: macros whose names begin with @samp{X} operate on | |
4082 @code{Lisp_Object}s and do no type-checking. Many such macros are type | |
4083 extractors, but others implement Lisp operations in C (@emph{e.g.}, | |
4084 @code{XCAR} implements the Lisp @code{car} function). These are unsafe, | |
4085 and must only be used where types of all data have already been checked. | |
4086 Such macros are only applied to @code{Lisp_Object}s. In internal | |
4087 implementations where the pointer has already been converted, the | |
4088 structure is operated on directly using the C @code{->} member access | |
4089 operator. | |
4090 | |
4091 The @code{@var{type}P}, @code{CHECK_@var{type}}, and | |
4092 @code{CONCHECK_@var{type}} macros are used to test types. The first | |
4093 returns a Boolean value, and the latter signal errors. (The | |
4094 @samp{CONCHECK} variety allows execution to be CONtinued under some | |
4095 circumstances, thus the name.) Functions which expect to be passed user | |
4096 data invariably call @samp{CHECK} macros on arguments. | |
4097 | |
4098 There are many types of specialized Lisp objects implemented in C, but | |
4099 the most pervasive type is the @dfn{symbol}. Symbols are used as | |
4100 identifiers, variables, and functions. | |
4101 | |
4102 @strong{Convention}: Global variables whose names begin with @samp{Q} | |
4103 are constants whose value is a symbol. The name of the variable should | |
4104 be derived from the name of the symbol using the same rules as for Lisp | |
4105 primitives. Such variables allow the C code to check whether a | |
4106 particular @code{Lisp_Object} is equal to a given symbol. Symbols are | |
4107 Lisp objects, so these variables may be passed to Lisp primitives. (An | |
4108 alternative to the use of @samp{Q...} variables is to call the | |
4109 @code{intern} function at initialization in the | |
4110 @code{vars_of_@var{module}} function, which is hardly less efficient.) | |
4111 | |
4112 @strong{Convention}: Global variables whose names begin with @samp{V} | |
4113 are variables that contain Lisp objects. The convention here is that | |
4114 all global variables of type @code{Lisp_Object} begin with @samp{V}, and | |
4115 no others do (not even integer and boolean variables that have Lisp | |
4116 equivalents). Most of the time, these variables have equivalents in | |
4117 Lisp, which are defined via the @samp{DEFVAR} family of macros, but some | |
4118 don't. Since the variable's value is a @code{Lisp_Object}, it can be | |
4119 passed to Lisp primitives. | |
4120 | |
4121 The implementation of Lisp primitives is more complex. | |
4122 @strong{Convention}: Global variables with names beginning with @samp{S} | |
4123 contain a structure that allows the Lisp engine to identify and call a C | |
4124 function. In modern versions of XEmacs, these identifiers are almost | |
4125 always completely hidden in the @code{DEFUN} and @code{SUBR} macros, but | |
4126 you will encounter them if you look at very old versions of XEmacs or at | |
4127 GNU Emacs. @strong{Convention}: Functions with names beginning with | |
4128 @samp{F} implement Lisp primitives. Of course all their arguments and | |
4129 their return values must be Lisp_Objects. (This is hidden in the | |
4130 @code{DEFUN} macro.) | |
4131 | |
4132 | |
4133 @node General Coding Rules, Object-Oriented Techniques for C, A Reader's Guide to XEmacs Coding Conventions, Rules When Writing New C Code | |
4134 @section General Coding Rules | |
4135 @cindex coding rules, general | |
4136 | |
4137 The C code is actually written in a dialect of C called @dfn{Clean C}, | |
4138 meaning that it can be compiled, mostly warning-free, with either a C or | |
4139 C++ compiler. Coding in Clean C has several advantages over plain C. | |
4140 C++ compilers are more nit-picking, and a number of coding errors have | |
4141 been found by compiling with C++. The ability to use both C and C++ | |
4142 tools means that a greater variety of development tools are available to | |
4143 the developer. In addition, the ability to overload operators in C++ | |
4144 means it is possible, for error-checking purposes, to redefine certain | |
4145 simple types (normally defined as aliases for simple built-in types such | |
4146 as @code{unsigned char} or @code{long}) as classes, strictly limiting the permissible | |
4147 operations and catching illegal implicit casts and such. | |
4148 | |
4149 Every module includes @file{<config.h>} (angle brackets so that | |
4150 @samp{--srcdir} works correctly; @file{config.h} may or may not be in | |
4151 the same directory as the C sources) and @file{lisp.h}. @file{config.h} | |
4152 must always be included before any other header files (including | |
4153 system header files) to ensure that certain tricks played by various | |
4154 @file{s/} and @file{m/} files work out correctly. | |
4155 | |
4156 When including header files, always use angle brackets, not double | |
4157 quotes, except when the file to be included is always in the same | |
4158 directory as the including file. If either file is a generated file, | |
4159 then that is not likely to be the case. In order to understand why we | |
4160 have this rule, imagine what happens when you do a build in the source | |
4161 directory using @samp{./configure} and another build in another | |
4162 directory using @samp{../work/configure}. There will be two different | |
4163 @file{config.h} files. Which one will be used if you @samp{#include | |
4164 "config.h"}? | |
4165 | |
4166 Almost every module contains a @code{syms_of_*()} function and a | |
4167 @code{vars_of_*()} function. The former declares any Lisp primitives | |
4168 you have defined and defines any symbols you will be using. The latter | |
4169 declares any global Lisp variables you have added and initializes global | |
4170 C variables in the module. @strong{Important}: There are stringent | |
4171 requirements on exactly what can go into these functions. See the | |
4172 comment in @file{emacs.c}. The reason for this is to avoid obscure | |
4173 unwanted interactions during initialization. If you don't follow these | |
4174 rules, you'll be sorry! If you want to do anything that isn't allowed, | |
4175 create a @code{complex_vars_of_*()} function for it. Doing this is | |
4176 tricky, though: you have to make sure your function is called at the | |
4177 right time so that all the initialization dependencies work out. | |
4178 | |
4179 Declare each function of these kinds in @file{symsinit.h}. Make sure | |
4180 it's called in the appropriate place in @file{emacs.c}. You never need | |
4181 to include @file{symsinit.h} directly, because it is included by | |
4182 @file{lisp.h}. | |
4183 | |
4184 @strong{All global and static variables that are to be modifiable must | |
4185 be declared uninitialized.} This means that you may not use the | |
4186 ``declare with initializer'' form for these variables, such as @code{int | |
4187 some_variable = 0;}. The reason for this has to do with some kludges | |
4188 done during the dumping process: If possible, the initialized data | |
4189 segment is re-mapped so that it becomes part of the (unmodifiable) code | |
4190 segment in the dumped executable. This allows this memory to be shared | |
4191 among multiple running XEmacs processes. XEmacs is careful to place as | |
4192 much constant data as possible into initialized variables during the | |
4193 @file{temacs} phase. | |
4194 | |
4195 @cindex copy-on-write | |
4196 @strong{Please note:} This kludge only works on a few systems nowadays, | |
4197 and is rapidly becoming irrelevant because most modern operating systems | |
4198 provide @dfn{copy-on-write} semantics. All data is initially shared | |
4199 between processes, and a private copy is automatically made (on a | |
4200 page-by-page basis) when a process first attempts to write to a page of | |
4201 memory. | |
4202 | |
4203 Formerly, there was a requirement that static variables not be declared | |
4204 inside of functions. This had to do with another hack along the same | |
4205 vein as what was just described: old USG systems put statically-declared | |
4206 variables in the initialized data space, so those header files had a | |
4207 @code{#define static} declaration. (That way, the data-segment remapping | |
4208 described above could still work.) This fails badly on static variables | |
4209 inside of functions, which suddenly become automatic variables; | |
4210 therefore, you weren't supposed to have any of them. This awful kludge | |
4211 has been removed in XEmacs because | |
4212 | |
4213 @enumerate | |
4214 @item | |
4215 almost all of the systems that used this kludge ended up having | |
4216 to disable the data-segment remapping anyway; | |
4217 @item | |
4218 the only systems that didn't were extremely outdated ones; | |
4219 @item | |
4220 this hack completely messed up inline functions. | |
4221 @end enumerate | |
4222 | |
4223 The C source code makes heavy use of C preprocessor macros. One popular | |
4224 macro style is: | |
4225 | |
4226 @example | |
4227 #define FOO(var, value) do @{ \ | |
4228 Lisp_Object FOO_value = (value); \ | |
4229 ... /* compute using FOO_value */ \ | |
4230 (var) = bar; \ | |
4231 @} while (0) | |
4232 @end example | |
4233 | |
4234 The @code{do @{...@} while (0)} is a standard trick to allow FOO to have | |
4235 statement semantics, so that it can safely be used within an @code{if} | |
4236 statement in C, for example. Multiple evaluation is prevented by | |
4237 copying a supplied argument into a local variable, so that | |
4238 @code{FOO(var,fun(1))} only calls @code{fun} once. | |
4239 | |
4240 Lisp lists are popular data structures in the C code as well as in | |
4241 Elisp. There are two sets of macros that iterate over lists. | |
4242 @code{EXTERNAL_LIST_LOOP_@var{n}} should be used when the list has been | |
4243 supplied by the user, and cannot be trusted to be acyclic and | |
4244 @code{nil}-terminated. A @code{malformed-list} or @code{circular-list} error | |
4245 will be generated if the list being iterated over is not entirely | |
4246 kosher. @code{LIST_LOOP_@var{n}}, on the other hand, is faster and less | |
4247 safe, and can be used only on trusted lists. | |
4248 | |
4249 Related macros are @code{GET_EXTERNAL_LIST_LENGTH} and | |
4250 @code{GET_LIST_LENGTH}, which calculate the length of a list, and in the | |
4251 case of @code{GET_EXTERNAL_LIST_LENGTH}, validating the properness of | |
4252 the list. The macros @code{EXTERNAL_LIST_LOOP_DELETE_IF} and | |
4253 @code{LIST_LOOP_DELETE_IF} delete elements from a lisp list satisfying some | |
4254 predicate. | |
4255 | |
4256 @node Object-Oriented Techniques for C, Writing Lisp Primitives, General Coding Rules, Rules When Writing New C Code | |
4257 @section Object-Oriented Techniques for C | |
4258 @cindex coding rules, object-oriented | |
4259 @cindex object-oriented techniques | |
4260 | |
4261 At the lowest levels, XEmacs makes heavy use of object-oriented | |
4262 techniques to promote code-sharing and uniform interfaces for different | |
4263 devices and platforms. Commonly, but not always, such objects are | |
4264 ``wrapped'' and exported to Lisp as Lisp objects. Usually they use | |
4265 the internal structures developed for Lisp objects (the @samp{lrecord} | |
4266 structure) in order to take advantage of Lisp memory management. | |
4267 Unfortunately, XEmacs was originally written in C, so these techniques | |
4268 are based on heavy use of C macros. | |
4269 | |
4270 @c You can't use @var{} for type below, because case is important. | |
4271 A module defining a class is likely to use most of the following | |
4272 declarations and macros. In the following, the notation @samp{<type>} | |
4273 will stand for the full name of the class, and will be capitalized in | |
4274 the way normal for its context. The notation @samp{<typ>} will stand | |
4275 for the abbreviated form commonly used in macro names, while @samp{ty} | |
4276 will be used as the typical name for instances of the class. (See the | |
4277 entry for @samp{MAYBE_<TY>METH} below for an example using all three | |
4278 notations.) | |
4279 | |
4280 In the interface (@file{.h} file), the following declarations are used | |
4281 often. Others may be used in for particular modules. Since they're | |
4282 quite short in most cases, the definitions are given as well. The | |
4283 generic macros used are defined in @file{lisp.h} or @file{lrecord.h}. | |
4284 | |
4285 @c #### reorganize this table into stuff used in general code, and stuff | |
4286 @c used only in declarations or initializations | |
4287 @table @samp | |
4288 @c #### declaration | |
4289 @item typedef struct Lisp_<Type> Lisp_<Type> | |
4290 This refers to the internal structure used by C code. The XEmacs coding | |
4291 style now forbids passing pointers to @samp{Lisp_<Type>} structures into | |
4292 or out of a function; instead, a @samp{Lisp_Object} should be passed or | |
4293 returned (created using @samp{wrap_<type>}, if necessary). | |
4294 | |
4295 @c #### declaration | |
4296 @item DECLARE_LRECORD (<type>, Lisp_<Type>) | |
4297 Declares an @samp{lrecord} for @samp{<Type>}, which is the unit of | |
4298 allocation. | |
4299 | |
4300 @item #define X<TYPE>(x) XRECORD (x, <type>, Lisp_<Type>) | |
4301 Turns a @code{Lisp_Object} into a pointer to @samp{struct Lisp_<Type>}. | |
4302 | |
4303 @item #define wrap_<type>(p) wrap_record (p, <type>) | |
4304 Turns a pointer to @samp{struct Lisp_<Type>} into a @code{Lisp_Object}. | |
4305 | |
4306 @item #define <TYPE>P(x) RECORDP (x, <type>) | |
4307 Tests whether a given @code{Lisp_Object} is of type @samp{Lisp_<Type>}. | |
4308 Returns a C int, not a Lisp Boolean value. | |
4309 | |
4310 @item #define CHECK_<TYPE>(x) CHECK_RECORD (x, <type>) | |
4311 @itemx #define CONCHECK_<TYPE>(x) CONCHECK_RECORD (x, <type>) | |
4312 Tests whether a given @code{Lisp_Object} is of type @samp{Lisp_<Type>}, | |
4313 and signals a Lisp error if not. The @samp{CHECK} version of the macro | |
4314 never returns if the type is wrong, while the @samp{CONCHECK} version | |
4315 can return if the user catches it in the debugger and explicitly | |
4316 requests a return. | |
4317 | |
4318 @item #define RAW_<TYP>METH(ty, m) ((ty)->methods->m##_method) | |
4319 Return a function pointer for the method for an object @var{TY} of class | |
4320 @samp{Lisp_<Type>}, or @samp{NULL} if there is none for this type. | |
4321 | |
4322 @item #define HAS_<TYP>METH_P(ty, m) (!!RAW_<TYP>METH (ty, m)) | |
4323 Test whether the class that @var{TY} is an instance of has the method. | |
4324 | |
4325 @item #define <TYP>METH(ty, m, args) ((RAW_<TYP>METH (ty, m)) args) | |
4326 Call the method on @samp{args}. @samp{args} must be enclosed in | |
4327 parentheses in the call. It is the programmer's responsibility to | |
4328 ensure that the method is available. The standard convenience macro | |
4329 @samp{MAYBE_<TYP>METH} is often provided for the common case where a | |
4330 void-returning method of @samp{Type} is called. | |
4331 | |
4332 @item #define MAYBE_<TYP>METH(ty, m, args) do @{ ... @} while (0) | |
4333 Call a void-returning @samp{<Type>} method, if it exists. Note the use | |
4334 of the @samp{do ... while (0)} idiom to give the macro call C statement | |
4335 semantics. The full definition is equally idiomatic: | |
4336 | |
4337 @example | |
4338 #define MAYBE_<TYP>METH(ty, m, args) do @{ \ | |
4339 Lisp_<Type> *maybe_<typ>meth_ty = (ty); \ | |
4340 if (HAS_<TYP>METH_P (maybe_<typ>meth_ty, m)) \ | |
4341 <TYP>METH (maybe_<typ>meth_ty, m, args); \ | |
4342 @} while (0) | |
4343 @end example | |
4344 @end table | |
4345 | |
4346 The use of macros for invoking an object's methods makes life a bit | |
4347 difficult for the student or maintainer when browsing the code. In | |
4348 particular, calls are of the form @samp{<TYP>METH (ty, some_method, (x, | |
4349 y))}, but definitions typically are for @samp{<subtype>_some_method}. | |
4350 Thus, when you are trying to find calls, you need to grep for | |
4351 @samp{some_method}, but this will also catch calls and definitions of | |
4352 that method for instances of other subtypes of @samp{<Type>}, and there | |
4353 may be a rather large number of them. | |
4354 | |
4355 | |
4356 @node Writing Lisp Primitives, Writing Good Comments, Object-Oriented Techniques for C, Rules When Writing New C Code | |
4357 @section Writing Lisp Primitives | |
4358 @cindex writing Lisp primitives | |
4359 @cindex Lisp primitives, writing | |
4360 @cindex primitives, writing Lisp | |
4361 | |
4362 Lisp primitives are Lisp functions implemented in C. The details of | |
4363 interfacing the C function so that Lisp can call it are handled by a few | |
4364 C macros. The only way to really understand how to write new C code is | |
4365 to read the source, but we can explain some things here. | |
4366 | |
4367 An example of a special form is the definition of @code{prog1}, from | |
4368 @file{eval.c}. (An ordinary function would have the same general | |
4369 appearance.) | |
4370 | |
4371 @cindex garbage collection protection | |
4372 @smallexample | |
4373 @group | |
4374 DEFUN ("prog1", Fprog1, 1, UNEVALLED, 0, /* | |
4375 Similar to `progn', but the value of the first form is returned. | |
4376 \(prog1 FIRST BODY...): All the arguments are evaluated sequentially. | |
4377 The value of FIRST is saved during evaluation of the remaining args, | |
4378 whose values are discarded. | |
4379 */ | |
4380 (args)) | |
4381 @{ | |
4382 /* This function can GC */ | |
4383 REGISTER Lisp_Object val, form, tail; | |
4384 struct gcpro gcpro1; | |
4385 | |
4386 val = Feval (XCAR (args)); | |
4387 | |
4388 GCPRO1 (val); | |
4389 | |
4390 LIST_LOOP_3 (form, XCDR (args), tail) | |
4391 Feval (form); | |
4392 | |
4393 UNGCPRO; | |
4394 return val; | |
4395 @} | |
4396 @end group | |
4397 @end smallexample | |
4398 | |
4399 Let's start with a precise explanation of the arguments to the | |
4400 @code{DEFUN} macro. Here is a template for them: | |
4401 | |
4402 @example | |
4403 @group | |
4404 DEFUN (@var{lname}, @var{fname}, @var{min_args}, @var{max_args}, @var{interactive}, /* | |
4405 @var{docstring} | |
4406 */ | |
4407 (@var{arglist})) | |
4408 @end group | |
4409 @end example | |
4410 | |
4411 @table @var | |
4412 @item lname | |
4413 This string is the name of the Lisp symbol to define as the function | |
4414 name; in the example above, it is @code{"prog1"}. | |
4415 | |
4416 @item fname | |
4417 This is the C function name for this function. This is the name that is | |
4418 used in C code for calling the function. The name is, by convention, | |
4419 @samp{F} prepended to the Lisp name, with all dashes (@samp{-}) in the | |
4420 Lisp name changed to underscores. Thus, to call this function from C | |
4421 code, call @code{Fprog1}. Remember that the arguments are of type | |
4422 @code{Lisp_Object}; various macros and functions for creating values of | |
4423 type @code{Lisp_Object} are declared in the file @file{lisp.h}. | |
4424 | |
4425 Primitives whose names are special characters (e.g. @code{+} or | |
4426 @code{<}) are named by spelling out, in some fashion, the special | |
4427 character: e.g. @code{Fplus()} or @code{Flss()}. Primitives whose names | |
4428 begin with normal alphanumeric characters but also contain special | |
4429 characters are spelled out in some creative way, e.g. @code{let*} | |
4430 becomes @code{FletX()}. | |
4431 | |
4432 Each function also has an associated structure that holds the data for | |
4433 the subr object that represents the function in Lisp. This structure | |
4434 conveys the Lisp symbol name to the initialization routine that will | |
4435 create the symbol and store the subr object as its definition. The C | |
4436 variable name of this structure is always @samp{S} prepended to the | |
4437 @var{fname}. You hardly ever need to be aware of the existence of this | |
4438 structure, since @code{DEFUN} plus @code{DEFSUBR} takes care of all the | |
4439 details. | |
4440 | |
4441 @item min_args | |
4442 This is the minimum number of arguments that the function requires. The | |
4443 function @code{prog1} allows a minimum of one argument. | |
4444 | |
4445 @item max_args | |
4446 This is the maximum number of arguments that the function accepts, if | |
4447 there is a fixed maximum. Alternatively, it can be @code{UNEVALLED}, | |
4448 indicating a special form that receives unevaluated arguments, or | |
4449 @code{MANY}, indicating an unlimited number of evaluated arguments (the | |
4450 C equivalent of @code{&rest}). Both @code{UNEVALLED} and @code{MANY} | |
4451 are macros. If @var{max_args} is a number, it may not be less than | |
4452 @var{min_args} and it may not be greater than 8. (If you need to add a | |
4453 function with more than 8 arguments, use the @code{MANY} form. Resist | |
4454 the urge to edit the definition of @code{DEFUN} in @file{lisp.h}. If | |
4455 you do it anyways, make sure to also add another clause to the switch | |
4456 statement in @code{primitive_funcall().}) | |
4457 | |
4458 @item interactive | |
4459 This is an interactive specification, a string such as might be used as | |
4460 the argument of @code{interactive} in a Lisp function. In the case of | |
4461 @code{prog1}, it is 0 (a null pointer), indicating that @code{prog1} | |
4462 cannot be called interactively. A value of @code{""} indicates a | |
4463 function that should receive no arguments when called interactively. | |
4464 | |
4465 @item docstring | |
4466 This is the documentation string. It is written just like a | |
4467 documentation string for a function defined in Lisp; in particular, the | |
4468 first line should be a single sentence. Note how the documentation | |
4469 string is enclosed in a comment, none of the documentation is placed on | |
4470 the same lines as the comment-start and comment-end characters, and the | |
4471 comment-start characters are on the same line as the interactive | |
4472 specification. @file{make-docfile}, which scans the C files for | |
4473 documentation strings, is very particular about what it looks for, and | |
4474 will not properly extract the doc string if it's not in this exact format. | |
4475 | |
4476 In order to make both @file{etags} and @file{make-docfile} happy, make | |
4477 sure that the @code{DEFUN} line contains the @var{lname} and | |
4478 @var{fname}, and that the comment-start characters for the doc string | |
4479 are on the same line as the interactive specification, and put a newline | |
4480 directly after them (and before the comment-end characters). | |
4481 | |
4482 @item arglist | |
4483 This is the comma-separated list of arguments to the C function. For a | |
4484 function with a fixed maximum number of arguments, provide a C argument | |
4485 for each Lisp argument. In this case, unlike regular C functions, the | |
4486 types of the arguments are not declared; they are simply always of type | |
4487 @code{Lisp_Object}. | |
4488 | |
4489 The names of the C arguments will be used as the names of the arguments | |
4490 to the Lisp primitive as displayed in its documentation, modulo the same | |
4491 concerns described above for @code{F...} names (in particular, | |
4492 underscores in the C arguments become dashes in the Lisp arguments). | |
4493 | |
4494 There is one additional kludge: A trailing @samp{_} on the C argument is | |
4495 discarded when forming the Lisp argument. This allows C language | |
4496 reserved words (like @code{default}) or global symbols (like | |
4497 @code{dirname}) to be used as argument names without compiler warnings | |
4498 or errors. | |
4499 | |
4500 A Lisp function with @w{@var{max_args} = @code{UNEVALLED}} is a | |
4501 @w{@dfn{special form}}; its arguments are not evaluated. Instead it | |
4502 receives one argument of type @code{Lisp_Object}, a (Lisp) list of the | |
4503 unevaluated arguments, conventionally named @code{(args)}. | |
4504 | |
4505 When a Lisp function has no upper limit on the number of arguments, | |
4506 specify @w{@var{max_args} = @code{MANY}}. In this case its implementation in | |
4507 C actually receives exactly two arguments: the number of Lisp arguments | |
4508 (an @code{int}) and the address of a block containing their values (a | |
4509 @w{@code{Lisp_Object *}}). In this case only are the C types specified | |
4510 in the @var{arglist}: @w{@code{(int nargs, Lisp_Object *args)}}. | |
4511 | |
4512 @end table | |
4513 | |
4514 Within the function @code{Fprog1} itself, note the use of the macros | |
4515 @code{GCPRO1} and @code{UNGCPRO}. @code{GCPRO1} is used to ``protect'' | |
4516 a variable from garbage collection---to inform the garbage collector | |
4517 that it must look in that variable and regard the object pointed at by | |
4518 its contents as an accessible object. This is necessary whenever you | |
4519 call @code{Feval} or anything that can directly or indirectly call | |
4520 @code{Feval} (this includes the @code{QUIT} macro!). At such a time, | |
4521 any Lisp object that you intend to refer to again must be protected | |
4522 somehow. @code{UNGCPRO} cancels the protection of the variables that | |
4523 are protected in the current function. It is necessary to do this | |
4524 explicitly. | |
4525 | |
4526 The macro @code{GCPRO1} protects just one local variable. If you want | |
4527 to protect two, use @code{GCPRO2} instead; repeating @code{GCPRO1} will | |
4528 not work. Macros @code{GCPRO3} and @code{GCPRO4} also exist. | |
4529 | |
4530 These macros implicitly use local variables such as @code{gcpro1}; you | |
4531 must declare these explicitly, with type @code{struct gcpro}. Thus, if | |
4532 you use @code{GCPRO2}, you must declare @code{gcpro1} and @code{gcpro2}. | |
4533 | |
4534 @cindex caller-protects (@code{GCPRO} rule) | |
4535 Note also that the general rule is @dfn{caller-protects}; i.e. you are | |
4536 only responsible for protecting those Lisp objects that you create. Any | |
4537 objects passed to you as arguments should have been protected by whoever | |
4538 created them, so you don't in general have to protect them. | |
4539 | |
4540 In particular, the arguments to any Lisp primitive are always | |
4541 automatically @code{GCPRO}ed, when called ``normally'' from Lisp code or | |
4542 bytecode. So only a few Lisp primitives that are called frequently from | |
4543 C code, such as @code{Fprogn} protect their arguments as a service to | |
4544 their caller. You don't need to protect your arguments when writing a | |
4545 new @code{DEFUN}. | |
4546 | |
4547 @code{GCPRO}ing is perhaps the trickiest and most error-prone part of | |
4548 XEmacs coding. It is @strong{extremely} important that you get this | |
4549 right and use a great deal of discipline when writing this code. | |
4550 @xref{GCPROing, ,@code{GCPRO}ing}, for full details on how to do this. | |
4551 | |
4552 What @code{DEFUN} actually does is declare a global structure of type | |
4553 @code{Lisp_Subr} whose name begins with capital @samp{SF} and which | |
4554 contains information about the primitive (e.g. a pointer to the | |
4555 function, its minimum and maximum allowed arguments, a string describing | |
4556 its Lisp name); @code{DEFUN} then begins a normal C function declaration | |
4557 using the @code{F...} name. The Lisp subr object that is the function | |
4558 definition of a primitive (i.e. the object in the function slot of the | |
4559 symbol that names the primitive) actually points to this @samp{SF} | |
4560 structure; when @code{Feval} encounters a subr, it looks in the | |
4561 structure to find out how to call the C function. | |
4562 | |
4563 Defining the C function is not enough to make a Lisp primitive | |
4564 available; you must also create the Lisp symbol for the primitive (the | |
4565 symbol is @dfn{interned}; @pxref{Obarrays}) and store a suitable subr | |
4566 object in its function cell. (If you don't do this, the primitive won't | |
4567 be seen by Lisp code.) The code looks like this: | |
4568 | |
4569 @example | |
4570 DEFSUBR (@var{fname}); | |
4571 @end example | |
4572 | |
4573 @noindent | |
4574 Here @var{fname} is the same name you used as the second argument to | |
4575 @code{DEFUN}. | |
4576 | |
4577 This call to @code{DEFSUBR} should go in the @code{syms_of_*()} function | |
4578 at the end of the module. If no such function exists, create it and | |
4579 make sure to also declare it in @file{symsinit.h} and call it from the | |
4580 appropriate spot in @code{main()}. @xref{General Coding Rules}. | |
4581 | |
4582 Note that C code cannot call functions by name unless they are defined | |
4583 in C. The way to call a function written in Lisp from C is to use | |
4584 @code{Ffuncall}, which embodies the Lisp function @code{funcall}. Since | |
4585 the Lisp function @code{funcall} accepts an unlimited number of | |
4586 arguments, in C it takes two: the number of Lisp-level arguments, and a | |
4587 one-dimensional array containing their values. The first Lisp-level | |
4588 argument is the Lisp function to call, and the rest are the arguments to | |
4589 pass to it. Since @code{Ffuncall} can call the evaluator, you must | |
4590 protect pointers from garbage collection around the call to | |
4591 @code{Ffuncall}. (However, @code{Ffuncall} explicitly protects all of | |
4592 its parameters, so you don't have to protect any pointers passed as | |
4593 parameters to it.) | |
4594 | |
4595 The C functions @code{call0}, @code{call1}, @code{call2}, and so on, | |
4596 provide handy ways to call a Lisp function conveniently with a fixed | |
4597 number of arguments. They work by calling @code{Ffuncall}. | |
4598 | |
4599 @file{eval.c} is a very good file to look through for examples; | |
4600 @file{lisp.h} contains the definitions for important macros and | |
4601 functions. | |
4602 | |
4603 @node Writing Good Comments, Adding Global Lisp Variables, Writing Lisp Primitives, Rules When Writing New C Code | |
4604 @section Writing Good Comments | |
4605 @cindex writing good comments | |
4606 @cindex comments, writing good | |
4607 | |
4608 Comments are a lifeline for programmers trying to understand tricky | |
4609 code. In general, the less obvious it is what you are doing, the more | |
4610 you need a comment, and the more detailed it needs to be. You should | |
4611 always be on guard when you're writing code for stuff that's tricky, and | |
4612 should constantly be putting yourself in someone else's shoes and asking | |
4613 if that person could figure out without much difficulty what's going | |
4614 on. (Assume they are a competent programmer who understands the | |
4615 essentials of how the XEmacs code is structured but doesn't know much | |
4616 about the module you're working on or any algorithms you're using.) If | |
4617 you're not sure whether they would be able to, add a comment. Always | |
4618 err on the side of more comments, rather than less. | |
4619 | |
4620 Generally, when making comments, there is no need to attribute them with | |
4621 your name or initials. This especially goes for small, | |
4622 easy-to-understand, non-opinionated ones. Also, comments indicating | |
4623 where, when, and by whom a file was changed are @emph{strongly} | |
4624 discouraged, and in general will be removed as they are discovered. | |
4625 This is exactly what @file{ChangeLogs} are there for. However, it can | |
4626 occasionally be useful to mark exactly where (but not when or by whom) | |
4627 changes are made, particularly when making small changes to a file | |
4628 imported from elsewhere. These marks help when later on a newer version | |
4629 of the file is imported and the changes need to be merged. (If | |
4630 everything were always kept in CVS, there would be no need for this. | |
4631 But in practice, this often doesn't happen, or the CVS repository is | |
4632 later on lost or unavailable to the person doing the update.) | |
4633 | |
4634 When putting in an explicit opinion in a comment, you should | |
4635 @emph{always} attribute it with your name and the date. This also goes | |
4636 for long, complex comments explaining in detail the workings of | |
4637 something -- by putting your name there, you make it possible for | |
4638 someone who has questions about how that thing works to determine who | |
4639 wrote the comment so they can write to them. Use your actual name or | |
4640 your alias at xemacs.org, and not your initials or nickname, unless that | |
4641 is generally recognized (e.g. @samp{jwz}). Even then, please consider | |
4642 requesting a virtual user at xemacs.org (forwarding address; we can't | |
4643 provide an actual mailbox). Otherwise, give first and last name. If | |
4644 you're not a regular contributor, you might consider putting your email | |
4645 address in -- it may be in the ChangeLog, but after awhile ChangeLogs | |
4646 have a tendency of disappearing or getting muddled. (E.g. your comment | |
4647 may get copied somewhere else or even into another program, and tracking | |
4648 down the proper ChangeLog may be very difficult.) | |
4649 | |
4650 If you come across an opinion that is not or is no longer valid, or you | |
4651 come across any comment that no longer applies but you want to keep it | |
4652 around, enclose it in @samp{[[ } and @samp{ ]]} marks and add a comment | |
4653 afterwards explaining why the preceding comment is no longer valid. Put | |
4654 your name on this comment, as explained above. | |
4655 | |
4656 Just as comments are a lifeline to programmers, incorrect comments are | |
4657 death. If you come across an incorrect comment, @strong{immediately} | |
4658 correct it or flag it as incorrect, as described in the previous | |
4659 paragraph. Whenever you work on a section of code, @emph{always} make | |
4660 sure to update any comments to be correct -- or, at the very least, flag | |
4661 them as incorrect. | |
4662 | |
4663 To indicate a "todo" or other problem, use four pound signs -- | |
4664 i.e. @samp{####}. | |
4665 | |
4666 @node Adding Global Lisp Variables, Writing Macros, Writing Good Comments, Rules When Writing New C Code | |
4667 @section Adding Global Lisp Variables | |
4668 @cindex global Lisp variables, adding | |
4669 @cindex variables, adding global Lisp | |
4670 | |
4671 Global variables whose names begin with @samp{Q} are constants whose | |
4672 value is a symbol of a particular name. The name of the variable should | |
4673 be derived from the name of the symbol using the same rules as for Lisp | |
4674 primitives. These variables are initialized using a call to | |
4675 @code{defsymbol()} in the @code{syms_of_*()} function. (This call | |
4676 interns a symbol, sets the C variable to the resulting Lisp object, and | |
4677 calls @code{staticpro()} on the C variable to tell the | |
4678 garbage-collection mechanism about this variable. What | |
4679 @code{staticpro()} does is add a pointer to the variable to a large | |
4680 global array; when garbage-collection happens, all pointers listed in | |
4681 the array are used as starting points for marking Lisp objects. This is | |
4682 important because it's quite possible that the only current reference to | |
4683 the object is the C variable. In the case of symbols, the | |
4684 @code{staticpro()} doesn't matter all that much because the symbol is | |
4685 contained in @code{obarray}, which is itself @code{staticpro()}ed. | |
4686 However, it's possible that a naughty user could do something like | |
4687 uninterning the symbol out of @code{obarray} or even setting | |
4688 @code{obarray} to a different value [although this is likely to make | |
4689 XEmacs crash!].) | |
4690 | |
4691 @strong{Please note:} It is potentially deadly if you declare a | |
4692 @samp{Q...} variable in two different modules. The two calls to | |
4693 @code{defsymbol()} are no problem, but some linkers will complain about | |
4694 multiply-defined symbols. The most insidious aspect of this is that | |
4695 often the link will succeed anyway, but then the resulting executable | |
4696 will sometimes crash in obscure ways during certain operations! | |
4697 | |
4698 To avoid this problem, declare any symbols with common names (such as | |
4699 @code{text}) that are not obviously associated with this particular | |
4700 module in the file @file{general-slots.h}. The ``-slots'' suffix | |
4701 indicates that this is a file that is included multiple times in | |
4702 @file{general.c}. Redefinition of preprocessor macros allows the | |
4703 effects to be different in each context, so this is actually more | |
4704 convenient and less error-prone than doing it in your module. | |
4705 | |
4706 Global variables whose names begin with @samp{V} are variables that | |
4707 contain Lisp objects. The convention here is that all global variables | |
4708 of type @code{Lisp_Object} begin with @samp{V}, and all others don't | |
4709 (including integer and boolean variables that have Lisp | |
4710 equivalents). Most of the time, these variables have equivalents in | |
4711 Lisp, but some don't. Those that do are declared this way by a call to | |
4712 @code{DEFVAR_LISP()} in the @code{vars_of_*()} initializer for the | |
4713 module. What this does is create a special @dfn{symbol-value-forward} | |
4714 Lisp object that contains a pointer to the C variable, intern a symbol | |
4715 whose name is as specified in the call to @code{DEFVAR_LISP()}, and set | |
4716 its value to the symbol-value-forward Lisp object; it also calls | |
4717 @code{staticpro()} on the C variable to tell the garbage-collection | |
4718 mechanism about the variable. When @code{eval} (or actually | |
4719 @code{symbol-value}) encounters this special object in the process of | |
4720 retrieving a variable's value, it follows the indirection to the C | |
4721 variable and gets its value. @code{setq} does similar things so that | |
4722 the C variable gets changed. | |
4723 | |
4724 Whether or not you @code{DEFVAR_LISP()} a variable, you need to | |
4725 initialize it in the @code{vars_of_*()} function; otherwise it will end | |
4726 up as all zeroes, which is the integer 0 (@emph{not} @code{nil}), and | |
4727 this is probably not what you want. Also, if the variable is not | |
4728 @code{DEFVAR_LISP()}ed, @strong{you must call} @code{staticpro()} on the | |
4729 C variable in the @code{vars_of_*()} function. Otherwise, the | |
4730 garbage-collection mechanism won't know that the object in this variable | |
4731 is in use, and will happily collect it and reuse its storage for another | |
4732 Lisp object, and you will be the one who's unhappy when you can't figure | |
4733 out how your variable got overwritten. | |
4734 | |
4735 @node Writing Macros, Proper Use of Unsigned Types, Adding Global Lisp Variables, Rules When Writing New C Code | |
4736 @section Writing Macros | |
4737 @cindex writing macros | |
4738 @cindex macros, writing | |
4739 | |
4740 The three golden rules of macros: | |
4741 | |
4742 @enumerate | |
4743 @item | |
4744 Anything that's an lvalue can be evaluated more than once. | |
4745 @item | |
4746 Macros where anything else can be evaluated more than once should | |
4747 have the word "unsafe" in their name (exceptions may be made for | |
4748 large sets of macros that evaluate arguments of certain types more | |
4749 than once, e.g. struct buffer * arguments, when clearly indicated in | |
4750 the macro documentation). These macros are generally meant to be | |
4751 called only by other macros that have already stored the calling | |
4752 values in temporary variables. | |
4753 @item | |
4754 Nothing else can be evaluated more than once. Use inline | |
4755 functions, if necessary, to prevent multiple evaluation. | |
4756 @end enumerate | |
4757 | |
4758 NOTE: The functions and macros below are given full prototypes in their | |
4759 docs, even when the implementation is a macro. In such cases, passing | |
4760 an argument of a type other than expected will produce undefined | |
4761 results. Also, given that macros can do things functions can't (in | |
4762 particular, directly modify arguments as if they were passed by | |
4763 reference), the declaration syntax has been extended to include the | |
4764 call-by-reference syntax from C++, where an & after a type indicates | |
4765 that the argument is an lvalue and is passed by reference, i.e. the | |
4766 function can modify its value. (This is equivalent in C to passing a | |
4767 pointer to the argument, but without the need to explicitly worry about | |
4768 pointers.) | |
4769 | |
4770 When to capitalize macros: | |
4771 | |
4772 @itemize @bullet | |
4773 @item | |
4774 Capitalize macros doing stuff obviously impossible with (C) | |
4775 functions, e.g. directly modifying arguments as if they were passed by | |
4776 reference. | |
4777 @item | |
4778 Capitalize macros that evaluate @strong{any} argument more than once regardless | |
4779 of whether that's "allowed" (e.g. buffer arguments). | |
4780 @item | |
4781 Capitalize macros that directly access a field in a Lisp_Object or | |
4782 its equivalent underlying structure. In such cases, access through the | |
4783 Lisp_Object precedes the macro with an X, and access through the underlying | |
4784 structure doesn't. | |
4785 @item | |
4786 Capitalize certain other basic macros relating to Lisp_Objects; e.g. | |
4787 FRAMEP, CHECK_FRAME, etc. | |
4788 @item | |
4789 Try to avoid capitalizing any other macros. | |
4790 @end itemize | |
4791 | |
4792 @node Proper Use of Unsigned Types, Techniques for XEmacs Developers, Writing Macros, Rules When Writing New C Code | |
4793 @section Proper Use of Unsigned Types | |
4794 @cindex unsigned types, proper use of | |
4795 @cindex types, proper use of unsigned | |
4796 | |
4797 Avoid using @code{unsigned int} and @code{unsigned long} whenever | |
4798 possible. Unsigned types are viral -- any arithmetic or comparisons | |
4799 involving mixed signed and unsigned types are automatically converted to | |
4800 unsigned, which is almost certainly not what you want. Many subtle and | |
4801 hard-to-find bugs are created by careless use of unsigned types. In | |
4802 general, you should almost @emph{never} use an unsigned type to hold a | |
4803 regular quantity of any sort. The only exceptions are | |
4804 | |
4805 @enumerate | |
4806 @item | |
4807 When there's a reasonable possibility you will actually need all 32 or | |
4808 64 bits to store the quantity. | |
4809 @item | |
4810 When calling existing API's that require unsigned types. In this case, | |
4811 you should still do all manipulation using signed types, and do the | |
4812 conversion at the very threshold of the API call. | |
4813 @item | |
4814 In existing code that you don't want to modify because you don't | |
4815 maintain it. | |
4816 @item | |
4817 In bit-field structures. | |
4818 @end enumerate | |
4819 | |
4820 Other reasonable uses of @code{unsigned int} and @code{unsigned long} | |
4821 are representing non-quantities -- e.g. bit-oriented flags and such. | |
4822 | |
4823 @node Techniques for XEmacs Developers, , Proper Use of Unsigned Types, Rules When Writing New C Code | |
4824 @section Techniques for XEmacs Developers | |
4825 @cindex techniques for XEmacs developers | |
4826 @cindex developers, techniques for XEmacs | |
4827 | 5350 |
4828 @cindex Purify | 5351 @cindex Purify |
4829 @cindex Quantify | 5352 @cindex Quantify |
4830 To make a purified XEmacs, do: @code{make puremacs}. | 5353 To make a purified XEmacs, do: @code{make puremacs}. |
4831 To make a quantified XEmacs, do: @code{make quantmacs}. | 5354 To make a quantified XEmacs, do: @code{make quantmacs}. |
4892 | 5415 |
4893 Unfortunately, Emacs Lisp is slow, and is going to stay slow. Function | 5416 Unfortunately, Emacs Lisp is slow, and is going to stay slow. Function |
4894 calls in elisp are especially expensive. Iterating over a long list is | 5417 calls in elisp are especially expensive. Iterating over a long list is |
4895 going to be 30 times faster implemented in C than in Elisp. | 5418 going to be 30 times faster implemented in C than in Elisp. |
4896 | 5419 |
4897 Heavily used small code fragments need to be fast. The traditional way | |
4898 to implement such code fragments in C is with macros. But macros in C | |
4899 are known to be broken. | |
4900 | |
4901 @cindex macro hygiene | |
4902 Macro arguments that are repeatedly evaluated may suffer from repeated | |
4903 side effects or suboptimal performance. | |
4904 | |
4905 Variable names used in macros may collide with caller's variables, | |
4906 causing (at least) unwanted compiler warnings. | |
4907 | |
4908 In order to solve these problems, and maintain statement semantics, one | |
4909 should use the @code{do @{ ... @} while (0)} trick while trying to | |
4910 reference macro arguments exactly once using local variables. | |
4911 | |
4912 Let's take a look at this poor macro definition: | |
4913 | |
4914 @example | |
4915 #define MARK_OBJECT(obj) \ | |
4916 if (!marked_p (obj)) mark_object (obj), did_mark = 1 | |
4917 @end example | |
4918 | |
4919 This macro evaluates its argument twice, and also fails if used like this: | |
4920 @example | |
4921 if (flag) MARK_OBJECT (obj); else @code{do_something()}; | |
4922 @end example | |
4923 | |
4924 A much better definition is | |
4925 | |
4926 @example | |
4927 #define MARK_OBJECT(obj) do @{ \ | |
4928 Lisp_Object mo_obj = (obj); \ | |
4929 if (!marked_p (mo_obj)) \ | |
4930 @{ \ | |
4931 mark_object (mo_obj); \ | |
4932 did_mark = 1; \ | |
4933 @} \ | |
4934 @} while (0) | |
4935 @end example | |
4936 | |
4937 Notice the elimination of double evaluation by using the local variable | |
4938 with the obscure name. Writing safe and efficient macros requires great | |
4939 care. The one problem with macros that cannot be portably worked around | |
4940 is, since a C block has no value, a macro used as an expression rather | |
4941 than a statement cannot use the techniques just described to avoid | |
4942 multiple evaluation. | |
4943 | |
4944 @cindex inline functions | |
4945 In most cases where a macro has function semantics, an inline function | |
4946 is a better implementation technique. Modern compiler optimizers tend | |
4947 to inline functions even if they have no @code{inline} keyword, and | |
4948 configure magic ensures that the @code{inline} keyword can be safely | |
4949 used as an additional compiler hint. Inline functions used in a single | |
4950 .c files are easy. The function must already be defined to be | |
4951 @code{static}. Just add another @code{inline} keyword to the | |
4952 definition. | |
4953 | |
4954 @example | |
4955 inline static int | |
4956 heavily_used_small_function (int arg) | |
4957 @{ | |
4958 ... | |
4959 @} | |
4960 @end example | |
4961 | |
4962 Inline functions in header files are trickier, because we would like to | |
4963 make the following optimization if the function is @emph{not} inlined | |
4964 (for example, because we're compiling for debugging). We would like the | |
4965 function to be defined externally exactly once, and each calling | |
4966 translation unit would create an external reference to the function, | |
4967 instead of including a definition of the inline function in the object | |
4968 code of every translation unit that uses it. This optimization is | |
4969 currently only available for gcc. But you don't have to worry about the | |
4970 trickiness; just define your inline functions in header files using this | |
4971 pattern: | |
4972 | |
4973 @example | |
4974 DECLARE_INLINE_HEADER ( | |
4975 int | |
4976 i_used_to_be_a_crufty_macro_but_look_at_me_now (int arg) | |
4977 ) | |
4978 @{ | |
4979 ... | |
4980 @} | |
4981 @end example | |
4982 | |
4983 We use @code{DECLARE_INLINE_HEADER} rather than just the modifier | |
4984 @code{INLINE_HEADER} to prevent warnings when compiling with @code{gcc | |
4985 -Wmissing-declarations}. I consider issuing this warning for inline | |
4986 functions a gcc bug, but the gcc maintainers disagree. | |
4987 | |
4988 @cindex inline functions, headers | |
4989 @cindex header files, inline functions | |
4990 Every header which contains inline functions, either directly by using | |
4991 @code{DECLARE_INLINE_HEADER} or indirectly by using @code{DECLARE_LRECORD} must | |
4992 be added to @file{inline.c}'s includes to make the optimization | |
4993 described above work. (Optimization note: if all INLINE_HEADER | |
4994 functions are in fact inlined in all translation units, then the linker | |
4995 can just discard @code{inline.o}, since it contains only unreferenced code). | |
4996 | |
4997 To get started debugging XEmacs, take a look at the @file{.gdbinit} and | 5420 To get started debugging XEmacs, take a look at the @file{.gdbinit} and |
4998 @file{.dbxrc} files in the @file{src} directory. See the section in the | 5421 @file{.dbxrc} files in the @file{src} directory. See the section in the |
4999 XEmacs FAQ on How to Debug an XEmacs problem with a debugger. | 5422 XEmacs FAQ on How to Debug an XEmacs problem with a debugger. |
5000 | 5423 |
5001 After making source code changes, run @code{make check} to ensure that | 5424 After making source code changes, run @code{make check} to ensure that |
5007 Before submitting a patch, please try compiling at least once with | 5430 Before submitting a patch, please try compiling at least once with |
5008 | 5431 |
5009 @example | 5432 @example |
5010 configure --with-mule --use-union-type --error-checking=all | 5433 configure --with-mule --use-union-type --error-checking=all |
5011 @end example | 5434 @end example |
5012 | |
5013 Here are things to know when you create a new source file: | |
5014 | |
5015 @itemize @bullet | |
5016 @item | |
5017 All @file{.c} files should @code{#include <config.h>} first. Almost all | |
5018 @file{.c} files should @code{#include "lisp.h"} second. | |
5019 | |
5020 @item | |
5021 Generated header files should be included using the @samp{#include <...>} | |
5022 syntax, not the @samp{#include "..."} syntax. The generated headers are: | |
5023 | |
5024 @file{config.h sheap-adjust.h paths.h Emacs.ad.h} | |
5025 | |
5026 The basic rule is that you should assume builds using @samp{--srcdir} | |
5027 and the @samp{#include <...>} syntax needs to be used when the | |
5028 to-be-included generated file is in a potentially different directory | |
5029 @emph{at compile time}. The non-obvious C rule is that | |
5030 @samp{#include "..."} means to search for the included file in the same | |
5031 directory as the including file, @emph{not} in the current directory. | |
5032 Normally this is not a problem but when building with @samp{--srcdir}, | |
5033 @file{make} will search the @samp{VPATH} for you, while the C compiler | |
5034 knows nothing about it. | |
5035 | |
5036 @item | |
5037 Header files should @emph{not} include @samp{<config.h>} and | |
5038 @samp{"lisp.h"}. It is the responsibility of the @file{.c} files that | |
5039 use it to do so. | |
5040 | |
5041 @end itemize | |
5042 | |
5043 @cindex Lisp object types, creating | |
5044 @cindex creating Lisp object types | |
5045 @cindex object types, creating Lisp | |
5046 Here is a checklist of things to do when creating a new lisp object type | |
5047 named @var{foo}: | |
5048 | |
5049 @enumerate | |
5050 @item | |
5051 create @var{foo}.h | |
5052 @item | |
5053 create @var{foo}.c | |
5054 @item | |
5055 add definitions of @code{syms_of_@var{foo}}, etc. to @file{@var{foo}.c} | |
5056 @item | |
5057 add declarations of @code{syms_of_@var{foo}}, etc. to @file{symsinit.h} | |
5058 @item | |
5059 add calls to @code{syms_of_@var{foo}}, etc. to @file{emacs.c} | |
5060 @item | |
5061 add definitions of macros like @code{CHECK_@var{FOO}} and | |
5062 @code{@var{FOO}P} to @file{@var{foo}.h} | |
5063 @item | |
5064 add the new type index to @code{enum lrecord_type} | |
5065 @item | |
5066 add a DEFINE_LRECORD_IMPLEMENTATION call to @file{@var{foo}.c} | |
5067 @item | |
5068 add an INIT_LRECORD_IMPLEMENTATION call to @code{syms_of_@var{foo}.c} | |
5069 @end enumerate | |
5070 | 5435 |
5071 @node Regression Testing XEmacs, CVS Techniques, Rules When Writing New C Code, Top | 5436 @node Regression Testing XEmacs, CVS Techniques, Rules When Writing New C Code, Top |
5072 @chapter Regression Testing XEmacs | 5437 @chapter Regression Testing XEmacs |
5073 @cindex testing, regression | 5438 @cindex testing, regression |
5074 | 5439 |
5331 @file{test-harness.el} defines the macros @code{Assert}, | 5696 @file{test-harness.el} defines the macros @code{Assert}, |
5332 @code{Check-Error}, @code{Check-Error-Message}, and | 5697 @code{Check-Error}, @code{Check-Error-Message}, and |
5333 @code{Check-Message}. The other files are test files, testing various | 5698 @code{Check-Message}. The other files are test files, testing various |
5334 XEmacs facilities. @xref{Regression Testing XEmacs}. | 5699 XEmacs facilities. @xref{Regression Testing XEmacs}. |
5335 | 5700 |
5336 | |
5337 @node CVS Techniques, XEmacs from the Inside, Regression Testing XEmacs, Top | 5701 @node CVS Techniques, XEmacs from the Inside, Regression Testing XEmacs, Top |
5338 @chapter CVS Techniques | 5702 @chapter CVS Techniques |
5339 @cindex CVS techniques | 5703 @cindex CVS techniques |
5340 | 5704 |
5341 @menu | 5705 @menu |
5422 crw rtag -F -r next-sync-ben-mule-21-5 last-sync-ben-mule-21-5 xemacs | 5786 crw rtag -F -r next-sync-ben-mule-21-5 last-sync-ben-mule-21-5 xemacs |
5423 @end example | 5787 @end example |
5424 @end enumerate | 5788 @end enumerate |
5425 | 5789 |
5426 | 5790 |
5427 @node XEmacs from the Inside, The XEmacs Object System (Abstractly Speaking), CVS Techniques, Top | 5791 @node XEmacs from the Inside, Basic Types, CVS Techniques, Top |
5428 @chapter XEmacs from the Inside | 5792 @chapter XEmacs from the Inside |
5429 @cindex XEmacs from the inside | 5793 @cindex XEmacs from the inside |
5430 @cindex inside, XEmacs from the | 5794 @cindex inside, XEmacs from the |
5431 | 5795 |
5432 Internally, XEmacs is quite complex, and can be very confusing. To | 5796 Internally, XEmacs is quite complex, and can be very confusing. To |
5558 @code{Fcommand_loop_1()}. Note that this event loop could very well be | 5922 @code{Fcommand_loop_1()}. Note that this event loop could very well be |
5559 written in Lisp, and in fact a Lisp version exists; but apparently, | 5923 written in Lisp, and in fact a Lisp version exists; but apparently, |
5560 doing this makes XEmacs run noticeably slower. | 5924 doing this makes XEmacs run noticeably slower. |
5561 | 5925 |
5562 Notice how much of the initialization is done in Lisp, not in C. | 5926 Notice how much of the initialization is done in Lisp, not in C. |
5563 In general, XEmacs tries to move as much code as is possible | 5927 In general, XEmacs tries to move as much code as is possible into |
5564 into Lisp. Code that remains in C is code that implements the | 5928 Lisp. Code that remains in C is code that implements the Lisp |
5565 Lisp interpreter itself, or code that needs to be very fast, or | 5929 interpreter itself, or code that needs to be very fast, or code that |
5566 code that needs to do system calls or other such stuff that | 5930 needs to do system calls or other such stuff that needs to be done in |
5567 needs to be done in C, or code that needs to have access to | 5931 C, or code that needs to have access to ``forbidden'' structures. (One |
5568 ``forbidden'' structures. (One conscious aspect of the design of | 5932 conscious aspect of the design of Lisp under XEmacs is a clean |
5569 Lisp under XEmacs is a clean separation between the external | 5933 separation between the external interface to a Lisp object's |
5570 interface to a Lisp object's functionality and its internal | 5934 functionality and its internal implementation. Part of this design is |
5571 implementation. Part of this design is that Lisp programs | 5935 that Lisp programs are forbidden from accessing the contents of the |
5572 are forbidden from accessing the contents of the object other | 5936 object other than through using a standard API. In this respect, |
5573 than through using a standard API. In this respect, XEmacs Lisp | 5937 XEmacs Lisp is similar to modern Lisp dialects but differs from GNU |
5574 is similar to modern Lisp dialects but differs from GNU Emacs, | 5938 Emacs, which tends to expose the implementation and allow Lisp |
5575 which tends to expose the implementation and allow Lisp | 5939 programs to look at it directly. The major advantage of hiding the |
5576 programs to look at it directly. The major advantage of | 5940 implementation is that it allows the implementation to be redesigned |
5577 hiding the implementation is that it allows the implementation | 5941 without affecting any Lisp programs, including those that might want |
5578 to be redesigned without affecting any Lisp programs, including | 5942 to be ``clever'' by looking directly at the object's contents and |
5579 those that might want to be ``clever'' by looking directly at | 5943 possibly manipulating them.) |
5580 the object's contents and possibly manipulating them.) | |
5581 | 5944 |
5582 Moving code into Lisp makes the code easier to debug and maintain and | 5945 Moving code into Lisp makes the code easier to debug and maintain and |
5583 makes it much easier for people who are not XEmacs developers to | 5946 makes it much easier for people who are not XEmacs developers to |
5584 customize XEmacs, because they can make a change with much less chance | 5947 customize XEmacs, because they can make a change with much less chance |
5585 of obscure and unwanted interactions occurring than if they were to | 5948 of obscure and unwanted interactions occurring than if they were to |
5586 change the C code. | 5949 change the C code. |
5587 | 5950 |
5588 @node The XEmacs Object System (Abstractly Speaking), How Lisp Objects Are Represented in C, XEmacs from the Inside, Top | 5951 @node Basic Types, Low-Level Allocation, XEmacs from the Inside, Top |
5952 @chapter Basic Types | |
5953 @cindex basic types | |
5954 @cindex types, basic | |
5955 | |
5956 Not yet documented. | |
5957 | |
5958 @node Low-Level Allocation, The XEmacs Object System (Abstractly Speaking), Basic Types, Top | |
5959 @chapter Low-Level Allocation | |
5960 @cindex low-level allocation | |
5961 @cindex allocation, low-level | |
5962 | |
5963 @menu | |
5964 * Basic Heap Allocation:: | |
5965 * Stack Allocation:: | |
5966 * Dynamic Arrays:: | |
5967 * Allocation by Blocks:: | |
5968 * Modules for Allocation:: | |
5969 @end menu | |
5970 | |
5971 @node Basic Heap Allocation, Stack Allocation, Low-Level Allocation, Low-Level Allocation | |
5972 @section Basic Heap Allocation | |
5973 @cindex basic heap allocation | |
5974 | |
5975 @node Stack Allocation, Dynamic Arrays, Basic Heap Allocation, Low-Level Allocation | |
5976 @section Stack Allocation | |
5977 @cindex stack allocation | |
5978 | |
5979 @node Dynamic Arrays, Allocation by Blocks, Stack Allocation, Low-Level Allocation | |
5980 @section Dynamic Arrays | |
5981 @cindex dynamic arrays | |
5982 | |
5983 @cindex dynamic array | |
5984 The @code{Dynarr} type implements a @dfn{dynamic array}, which is | |
5985 similar to a standard C array but has no fixed limit on the number of | |
5986 elements it can contain. Dynamic arrays can hold elements of any type, | |
5987 and when you add a new element, the array automatically resizes itself | |
5988 if it isn't big enough. Dynarrs are extensively used in the redisplay | |
5989 mechanism. | |
5990 | |
5991 | |
5992 A "dynamic array" is a contiguous array of fixed-size elements where there | |
5993 is no upper limit (except available memory) on the number of elements in the | |
5994 array. Because the elements are maintained contiguously, space is used | |
5995 efficiently (no per-element pointers necessary) and random access to a | |
5996 particular element is in constant time. At any one point, the block of memory | |
5997 that holds the array has an upper limit; if this limit is exceeded, the | |
5998 memory is realloc()ed into a new array that is twice as big. Assuming that | |
5999 the time to grow the array is on the order of the new size of the array | |
6000 block, this scheme has a provably constant amortized time (i.e. average | |
6001 time over all additions). | |
6002 | |
6003 When you add elements or retrieve elements, pointers are used. Note that | |
6004 the element itself (of whatever size it is), and not the pointer to it, | |
6005 is stored in the array; thus you do not have to allocate any heap memory | |
6006 on your own. Also, returned pointers are only guaranteed to be valid | |
6007 until the next operation that changes the length of the array. | |
6008 | |
6009 This is a container object. Declare a dynamic array of a specific type | |
6010 as follows: | |
6011 | |
6012 typedef struct | |
6013 @{ | |
6014 Dynarr_declare (mytype); | |
6015 @} mytype_dynarr; | |
6016 | |
6017 Use the following functions/macros: | |
6018 | |
6019 @example | |
6020 void *Dynarr_new(type) | |
6021 [MACRO] Create a new dynamic-array object, with each element of the | |
6022 specified type. The return value is cast to (type##_dynarr). | |
6023 This requires following the convention that types are declared in | |
6024 such a way that this type concatenation works. In particular, TYPE | |
6025 must be a symbol, not an arbitrary C type. | |
6026 | |
6027 Dynarr_add(d, el) | |
6028 [MACRO] Add an element to the end of a dynamic array. EL is a pointer | |
6029 to the element; the element itself is stored in the array, however. | |
6030 No function call is performed unless the array needs to be resized. | |
6031 | |
6032 Dynarr_add_many(d, base, len) | |
6033 [MACRO] Add LEN elements to the end of the dynamic array. The elements | |
6034 should be contiguous in memory, starting at BASE. If BASE if NULL, | |
6035 just make space for the elements; don't actually add them. | |
6036 | |
6037 Dynarr_insert_many_at_start(d, base, len) | |
6038 [MACRO] Append LEN elements to the beginning of the dynamic array. | |
6039 The elements should be contiguous in memory, starting at BASE. | |
6040 If BASE if NULL, just make space for the elements; don't actually | |
6041 add them. | |
6042 | |
6043 Dynarr_insert_many(d, base, len, start) | |
6044 Insert LEN elements to the dynamic array starting at position | |
6045 START. The elements should be contiguous in memory, starting at BASE. | |
6046 If BASE if NULL, just make space for the elements; don't actually | |
6047 add them. | |
6048 | |
6049 Dynarr_delete(d, i) | |
6050 [MACRO] Delete an element from the dynamic array at position I. | |
6051 | |
6052 Dynarr_delete_many(d, start, len) | |
6053 Delete LEN elements from the dynamic array starting at position | |
6054 START. | |
6055 | |
6056 Dynarr_delete_by_pointer(d, p) | |
6057 [MACRO] Delete an element from the dynamic array at pointer P, | |
6058 which must point within the block of memory that stores the data. | |
6059 P should be obtained using Dynarr_atp(). | |
6060 | |
6061 int Dynarr_length(d) | |
6062 [MACRO] Return the number of elements currently in a dynamic array. | |
6063 | |
6064 int Dynarr_largest(d) | |
6065 [MACRO] Return the maximum value that Dynarr_length(d) would | |
6066 ever have returned. | |
6067 | |
6068 type Dynarr_at(d, i) | |
6069 [MACRO] Return the element at the specified index (no bounds checking | |
6070 done on the index). The element itself is returned, not a pointer | |
6071 to it. | |
6072 | |
6073 type *Dynarr_atp(d, i) | |
6074 [MACRO] Return a pointer to the element at the specified index (no | |
6075 bounds checking done on the index). The pointer may not be valid | |
6076 after an element is added to or removed from the array. | |
6077 | |
6078 Dynarr_reset(d) | |
6079 [MACRO] Reset the length of a dynamic array to 0. | |
6080 | |
6081 Dynarr_free(d) | |
6082 Destroy a dynamic array and the memory allocated to it. | |
6083 @end example | |
6084 | |
6085 Use the following global variable: | |
6086 | |
6087 @example | |
6088 Dynarr_min_size | |
6089 Minimum allowable size for a dynamic array when it is resized. | |
6090 @end example | |
6091 | |
6092 @node Allocation by Blocks, Modules for Allocation, Dynamic Arrays, Low-Level Allocation | |
6093 @section Allocation by Blocks | |
6094 @cindex allocation by blocks | |
6095 | |
6096 The @code{Blocktype} type efficiently manages the | |
6097 allocation of fixed-size blocks by minimizing the number of times that | |
6098 @code{malloc()} and @code{free()} are called. It allocates memory in | |
6099 large chunks, subdivides the chunks into blocks of the proper size, and | |
6100 returns the blocks as requested. When blocks are freed, they are placed | |
6101 onto a linked list, so they can be efficiently reused. This data type | |
6102 is not much used in XEmacs currently, because it's a fairly new | |
6103 addition. | |
6104 | |
6105 | |
6106 A "block-type object" is used to efficiently allocate and free blocks | |
6107 of a particular size. Freed blocks are remembered in a free list and | |
6108 are reused as necessary to allocate new blocks, so as to avoid as | |
6109 much as possible making calls to malloc() and free(). | |
6110 | |
6111 This is a container object. Declare a block-type object of a specific type | |
6112 as follows: | |
6113 | |
6114 struct mytype_blocktype @{ | |
6115 Blocktype_declare (mytype); | |
6116 @}; | |
6117 | |
6118 Use the following functions/macros: | |
6119 | |
6120 @example | |
6121 structype *Blocktype_new(structype) | |
6122 [MACRO] Create a new block-type object of the specified type. | |
6123 The argument to this call should be the type of object to be | |
6124 created, e.g. foobar_blocktype. | |
6125 type *Blocktype_alloc(b) | |
6126 [MACRO] Allocate a block of the proper type for the specified | |
6127 block-type object and return a pointer to it. | |
6128 Blocktype_free(b, block) | |
6129 Free a block of the type corresponding to the specified block-type | |
6130 object. | |
6131 Blocktype_delete(b) | |
6132 Destroy a block-type object and the memory allocated to it. | |
6133 @end example | |
6134 | |
6135 | |
6136 @node Modules for Allocation, , Allocation by Blocks, Low-Level Allocation | |
6137 @section Modules for Allocation | |
6138 @cindex modules for allocation | |
6139 | |
6140 @example | |
6141 @file{alloca.c} | |
6142 @file{free-hook.c} | |
6143 @file{getpagesize.h} | |
6144 @file{gmalloc.c} | |
6145 @file{malloc.c} | |
6146 @file{mem-limits.h} | |
6147 @file{ralloc.c} | |
6148 @file{vm-limit.c} | |
6149 @end example | |
6150 | |
6151 These handle basic C allocation of memory. @file{alloca.c} is an emulation of | |
6152 the stack allocation function @code{alloca()} on machines that lack | |
6153 this. (XEmacs makes extensive use of @code{alloca()} in its code.) | |
6154 | |
6155 @file{gmalloc.c} and @file{malloc.c} are two implementations of the standard C | |
6156 functions @code{malloc()}, @code{realloc()} and @code{free()}. They are | |
6157 often used in place of the standard system-provided @code{malloc()} | |
6158 because they usually provide a much faster implementation, at the | |
6159 expense of additional memory use. @file{gmalloc.c} is a newer implementation | |
6160 that is much more memory-efficient for large allocations than @file{malloc.c}, | |
6161 and should always be preferred if it works. (At one point, @file{gmalloc.c} | |
6162 didn't work on some systems where @file{malloc.c} worked; but this should be | |
6163 fixed now.) | |
6164 | |
6165 @cindex relocating allocator | |
6166 @file{ralloc.c} is the @dfn{relocating allocator}. It provides | |
6167 functions similar to @code{malloc()}, @code{realloc()} and @code{free()} | |
6168 that allocate memory that can be dynamically relocated in memory. The | |
6169 advantage of this is that allocated memory can be shuffled around to | |
6170 place all the free memory at the end of the heap, and the heap can then | |
6171 be shrunk, releasing the memory back to the operating system. The use | |
6172 of this can be controlled with the configure option @code{--rel-alloc}; | |
6173 if enabled, memory allocated for buffers will be relocatable, so that if | |
6174 a very large file is visited and the buffer is later killed, the memory | |
6175 can be released to the operating system. (The disadvantage of this | |
6176 mechanism is that it can be very slow. On systems with the | |
6177 @code{mmap()} system call, the XEmacs version of @file{ralloc.c} uses | |
6178 this to move memory around without actually having to block-copy it, | |
6179 which can speed things up; but it can still cause noticeable performance | |
6180 degradation.) | |
6181 | |
6182 On Linux systems using @samp{glibc 2}, these strategies are built in to | |
6183 the so-called ``Doug Lea malloc.'' See, for example, Doug Lea's home | |
6184 page, especially @uref{http://gee.cs.oswego.edu/dl/html/malloc.html,``A | |
6185 Memory Allocator''}. The source file, @file{malloc.c} (available at the | |
6186 same place) is copiously (and usefully!) commented. | |
6187 @uref{http://www.malloc.de/,Wolfram Gloger's home page} may also be | |
6188 useful. | |
6189 | |
6190 @file{free-hook.c} contains some debugging functions for checking for invalid | |
6191 arguments to @code{free()}. | |
6192 | |
6193 @file{vm-limit.c} contains some functions that warn the user when memory is | |
6194 getting low. These are callback functions that are called by @file{gmalloc.c} | |
6195 and @file{malloc.c} at appropriate times. | |
6196 | |
6197 @file{getpagesize.h} provides a uniform interface for retrieving the size of a | |
6198 page in virtual memory. @file{mem-limits.h} provides a uniform interface for | |
6199 retrieving the total amount of available virtual memory. Both are | |
6200 similar in spirit to the @file{sys*.h} files described in section J, below. | |
6201 | |
6202 | |
6203 @example | |
6204 @file{blocktype.c} | |
6205 @file{blocktype.h} | |
6206 @file{dynarr.c} | |
6207 @end example | |
6208 | |
6209 These implement a couple of basic C data types to facilitate memory | |
6210 allocation. | |
6211 | |
6212 @node The XEmacs Object System (Abstractly Speaking), How Lisp Objects Are Represented in C, Low-Level Allocation, Top | |
5589 @chapter The XEmacs Object System (Abstractly Speaking) | 6213 @chapter The XEmacs Object System (Abstractly Speaking) |
5590 @cindex XEmacs object system (abstractly speaking), the | 6214 @cindex XEmacs object system (abstractly speaking), the |
5591 @cindex object system (abstractly speaking), the XEmacs | 6215 @cindex object system (abstractly speaking), the XEmacs |
5592 | 6216 |
5593 At the heart of the Lisp interpreter is its management of objects. | 6217 At the heart of the Lisp interpreter is its management of objects. |
12859 @node Critical Redisplay Sections, Line Start Cache, The Redisplay Mechanism, The Redisplay Mechanism | 13483 @node Critical Redisplay Sections, Line Start Cache, The Redisplay Mechanism, The Redisplay Mechanism |
12860 @section Critical Redisplay Sections | 13484 @section Critical Redisplay Sections |
12861 @cindex redisplay sections, critical | 13485 @cindex redisplay sections, critical |
12862 @cindex critical redisplay sections | 13486 @cindex critical redisplay sections |
12863 | 13487 |
13488 | |
13489 @strong{The following paragraphs are way out-of-date and inaccurate.} | |
13490 | |
12864 Within this section, we are defenseless and assume that the | 13491 Within this section, we are defenseless and assume that the |
12865 following cannot happen: | 13492 following cannot happen: |
12866 | 13493 |
12867 @enumerate | 13494 @enumerate |
12868 @item | 13495 @item |
12886 If garbage collection is called during this critical section, | 13513 If garbage collection is called during this critical section, |
12887 we simply return. #### We should abort instead. | 13514 we simply return. #### We should abort instead. |
12888 | 13515 |
12889 #### If a frame-size change does occur we should probably | 13516 #### If a frame-size change does occur we should probably |
12890 actually be preempting redisplay. | 13517 actually be preempting redisplay. |
13518 | |
13519 @strong{Begin up-to-date stuff} | |
13520 | |
13521 @subsection Nasty Bugs due to Reentrancy in Redisplay Structures handling QUIT | |
13522 | |
13523 These are now fixed as of November 10, 2004. | |
13524 | |
13525 @subheading Crash -- reentrant @code{regenerate_window()} | |
13526 | |
13527 Here is a crash I (ben) just got -- November 9, 2004: | |
13528 It can sort of be reproduced by creating a bunch of frames, opening a bunch of | |
13529 large files (which may be fontlocking for awhile). and immediately start | |
13530 Alt-TAB-ing back and forth quickly and constantly scrolling up and down using | |
13531 the scrolling dial on your mouse. | |
13532 | |
13533 @example | |
13534 | |
13535 Fatal error: assertion failed, file c:\xemacs\build\src\redisplay.c, line 5532, | |
13536 !dy->locked | |
13537 | |
13538 C backtrace: | |
13539 | |
13540 assert_failed(const char * 0x012a4ff0 `string', int 5532, const char * 0x0127bea4 `string') line 3839 | |
13541 Dynarr_verify_mod_1(void * 0x023ad2b0, const char * 0x012a4ff0 `string', int 5532) line 1306 + 36 bytes | |
13542 regenerate_window(window * 0x02f2ca88, long 40372, long 40372, int 2) line 5532 + 25 bytes | |
13543 update_line_start_cache(window * 0x02f2ca88, long 40372, long 40401, long 40372, int 0) line 8543 + 19 bytes | |
13544 point_in_line_start_cache(window * 0x02f2ca88, long 40372, int 0) line 7850 + 23 bytes | |
13545 start_end_of_last_line(window * 0x02f2ca88, long 40372, int 1, int 1) line 8121 + 15 bytes | |
13546 end_of_last_line_may_error(window * 0x02f2ca88, long 40372) line 8203 + 17 bytes | |
13547 pixel_to_glyph_translation(frame * 0x02f2c900, int 291, int 317, int * 0x0082bb04, int * 0x0082bb00, int * 0x0082bafc, int * 0x0082baf8, window * * 0x0082bae8, long * 0x0082baf4, long * 0x0082baf0, long * 0x0082baec, long * 0x0082bb10, long * 0x0082bb0c) line 9336 + 32 bytes | |
13548 mswindows_handle_mousewheel_event(long 49465600, int 0, int -240, tagPOINTS @{...@}) line 360 + 82 bytes | |
13549 mswindows_wnd_proc(HWND__ * 0x00260a42, unsigned int 522, unsigned int 4279238656, long 29885130) line 3561 + 36 bytes | |
13550 intercepted_wnd_proc(HWND__ * 0x00260a42, unsigned int 522, unsigned int 4279238656, long 29885130) line 2376 | |
13551 USER32! 77e11ef0() | |
13552 USER32! 77e1204c() | |
13553 USER32! 77e121af() | |
13554 mswindows_drain_windows_queue(int 0) line 1330 + 9 bytes | |
13555 emacs_mswindows_drain_queue() line 1339 + 7 bytes | |
13556 event_stream_drain_queue() line 1785 | |
13557 event_stream_quit_p() line 1893 | |
13558 check_quit() line 938 | |
13559 check_what_happened() line 459 | |
13560 internal_equal(long 22180468, long 22180468, int 0) line 2823 + 14 bytes | |
13561 update_image_instance(long 83498640, long 22180468) line 2121 + 18 bytes | |
13562 image_instantiate(long 21418616, long 20663624, long 54932896, long 22180468, long 3) line 3403 + 13 bytes | |
13563 va_call_trapping_problems_1(void * 0x0082cf94) line 5220 + 221 bytes | |
13564 call_trapping_problems_2(long 83160440) line 4867 + 13 bytes | |
13565 call_with_condition_handler(long (long, long, long)* 0x010cc4c0 flagged_a_squirmer(long, long, long), long 83160440, long (long)* 0x010cc440 call_trapping_problems_2(long), long 83160440) line 2129 + 7 bytes | |
13566 call_trapping_problems_1(long 83160440) line 4874 + 23 bytes | |
13567 internal_catch(long 21399864, long (long)* 0x010cc490 call_trapping_problems_1(long), long 83160440, int * volatile 0x0082ce4c, long * volatile 0x0082ce54) line 1527 + 7 bytes | |
13568 call_trapping_problems(long 20908160, const char * 0x00000000, int 98315, call_trapping_problems_result * 0x00000000, long (void *)* 0x010cca30 va_call_trapping_problems_1(void *), void * 0x0082cf94) line 5147 + 32 bytes | |
13569 call_with_suspended_errors(long (void)* 0x011448c0 image_instantiate(long, long, long, long, long), long 20663624, long 20908160, _error_behavior_struct_ @{...@}, int 5) line 5314 + 26 bytes | |
13570 specifier_instance_from_inst_list(long 21418616, long 20663624, long 54932896, long 21673760, _error_behavior_struct_ @{...@}, int 1, long 3) line 2501 + 54 bytes | |
13571 specifier_instance(long 21418616, long 20663624, long 54932896, _error_behavior_struct_ @{...@}, int 1, int 0, long 3) line 2614 + 64 bytes | |
13572 glyph_image_instance(long 22692176, long 54932896, _error_behavior_struct_ @{...@}, int 1) line 3955 + 31 bytes | |
13573 add_glyph_rune(position_redisplay_data_type * 0x0082d52c, glyph_block * 0x0082d454, int 0, int 0, glyph_cachel * 0x04f4e518) line 1972 + 26 bytes | |
13574 create_text_block(window * 0x034635a0, display_line * 0x033bfb28, long 29860, prop_block_dynarr * * 0x0082d7b8, int 2) line 2827 + 30 bytes | |
13575 generate_display_line(window * 0x034635a0, display_line * 0x033bfb28, int 1, long 29860, prop_block_dynarr * * 0x0082d7b8, int 2) line 979 + 38 bytes | |
13576 regenerate_window(window * 0x034635a0, long 29860, long 25012, int 2) line 5607 + 30 bytes | |
13577 update_line_start_cache(window * 0x034635a0, long 25012, long 28767, long 25012, int 0) line 8614 + 19 bytes | |
13578 point_in_line_start_cache(window * 0x034635a0, long 25012, int 0) line 7850 + 23 bytes | |
13579 start_end_of_last_line(window * 0x034635a0, long 25012, int 1, int 0) line 8121 + 15 bytes | |
13580 end_of_last_line(window * 0x034635a0, long 25012) line 8197 + 17 bytes | |
13581 Fwindow_end(long 54932896, long 20926544) line 1848 + 13 bytes | |
13582 Ffuncall(int 3, long * 0x0082dbb8) line 3841 + 93 bytes | |
13583 execute_optimized_program(const unsigned char * 0x032ceee8, int 7, long * 0x03289f40) line 823 + 16 bytes | |
13584 funcall_compiled_function(long 52991916, int 1, long * 0x0082dfb0) line 3454 + 85 bytes | |
13585 Ffuncall(int 2, long * 0x0082dfac) line 3880 + 17 bytes | |
13586 execute_optimized_program(const unsigned char * 0x02f667d8, int 6, long * 0x01558748) line 823 + 16 bytes | |
13587 funcall_compiled_function(long 22579576, int 3, long * 0x0082e3ac) line 3454 + 85 bytes | |
13588 Ffuncall(int 4, long * 0x0082e3a8) line 3880 + 17 bytes | |
13589 execute_optimized_program(const unsigned char * 0x03209c98, int 5, long * 0x03288c68) line 823 + 16 bytes | |
13590 funcall_compiled_function(long 51656320, int 1, long * 0x0082e7a4) line 3454 + 85 bytes | |
13591 Ffuncall(int 2, long * 0x0082e7a0) line 3880 + 17 bytes | |
13592 execute_optimized_program(const unsigned char * 0x0082e9ec, int 4, long * 0x03224990) line 823 + 16 bytes | |
13593 Fbyte_code(long 37927380, long 52578688, long 9) line 2564 + 70 bytes | |
13594 Feval(long 51505420) line 3601 + 187 bytes | |
13595 internal_catch(long 51959412, long (long)* 0x010c6f40 Feval(long), long 51505420, int * volatile 0x00000000, long * volatile 0x00000000) line 1527 + 7 bytes | |
13596 execute_rare_opcode(long * 0x0082eee8, const unsigned char * 0x03248365, Opcode Bcatch) line 1380 + 24 bytes | |
13597 execute_optimized_program(const unsigned char * 0x03248340, int 2, long * 0x02f3c0a0) line 715 + 17 bytes | |
13598 funcall_compiled_function(long 51656276, int 0, long * 0x0082f444) line 3454 + 85 bytes | |
13599 Ffuncall(int 1, long * 0x0082f440) line 3880 + 17 bytes | |
13600 run_hook_with_args_in_buffer(buffer * 0x04ee9060, int 1, long * 0x0082f440, run_hooks_condition RUN_HOOKS_TO_COMPLETION) line 4361 + 13 bytes | |
13601 run_hook_with_args(int 1, long * 0x0082f440, run_hooks_condition RUN_HOOKS_TO_COMPLETION) line 4374 + 23 bytes | |
13602 run_hook(long 51959028) line 4443 + 13 bytes | |
13603 safe_run_hook_trapping_problems_1(void * 0x013c73c0) line 5517 + 9 bytes | |
13604 call_trapping_problems_2(long 83157920) line 4867 + 13 bytes | |
13605 call_with_condition_handler(long (long, long, long)* 0x010cc4c0 flagged_a_squirmer(long, long, long), long 83157920, long (long)* 0x010cc440 call_trapping_problems_2(long), long 83157920) line 2129 + 7 bytes | |
13606 call_trapping_problems_1(long 83157920) line 4874 + 23 bytes | |
13607 internal_catch(long 21399864, long (long)* 0x010cc490 call_trapping_problems_1(long), long 83157920, int * volatile 0x0082f700, long * volatile 0x0082f708) line 1527 + 7 bytes | |
13608 call_trapping_problems(long 20925944, const char * 0x00000000, int 131235, call_trapping_problems_result * 0x0082f830, long (void *)* 0x010cd990 safe_run_hook_trapping_problems_1(void *), void * 0x013c73c0) line 5147 + 32 bytes | |
13609 safe_run_hook_trapping_problems(long 20741312, long 20739008, int 160) line 5543 + 36 bytes | |
13610 run_pre_idle_hook() line 2084 + 24 bytes | |
13611 redisplay() line 7224 | |
13612 Fnext_event(long 37363732, long 20928056) line 2263 | |
13613 Fcommand_loop_1() line 600 + 15 bytes | |
13614 command_loop_1(long 20928056) line 512 | |
13615 condition_case_1(long 20925944, long (long)* 0x01096a80 command_loop_1(long), long 20928056, long (long, long)* 0x01096630 cmd_error(long, long), long 20928056) line 1918 + 7 bytes | |
13616 command_loop_3() line 262 + 35 bytes | |
13617 command_loop_2(long 20928056) line 277 | |
13618 internal_catch(long 20683712, long (long)* 0x010967a0 command_loop_2(long), long 20928056, int * volatile 0x00000000, long * volatile 0x00000000) line 1527 + 7 bytes | |
13619 initial_command_loop(long 20928056) line 313 + 28 bytes | |
13620 xemacs_21_5_b18_i586_pc_win32(int 1, unsigned short * * 0x0082fed0, unsigned short * * 0x00000000, int 0) line 2551 | |
13621 main(int 1, char * * 0x00e52610, char * * 0x00e52bb0) line 2992 | |
13622 mainCRTStartup() line 338 + 17 bytes | |
13623 KERNEL32! 7c59893d() | |
13624 | |
13625 Lisp backtrace: | |
13626 | |
13627 # (unwind-protect ...) | |
13628 # (unwind-protect ...) | |
13629 # (unwind-protect ...) | |
13630 # (unwind-protect ...) | |
13631 # (unwind-protect ...) | |
13632 # (unwind-protect ...) | |
13633 # (unwind-protect ...) | |
13634 # (unwind-protect ...) | |
13635 # (unwind-protect ...) | |
13636 # (catch #<INTERNAL OBJECT (XEmacs bug?) (opaque, size=0) 0x1468938> ...) | |
13637 # (unwind-protect ...) | |
13638 # bind (inhibit-quit) | |
13639 window-end(#<window on "signal.c<2>" 0x5e4a> t) | |
13640 # (unwind-protect ...) | |
13641 # bind (buffer we-are-screwed check-text-props window) | |
13642 lazy-lock-fontify-window(#<window on "signal.c<2>" 0x5e4a>) | |
13643 # bind (walk-windows-current walk-windows-start arg which-devices which-frames | |
13644 minibuf function) | |
13645 walk-windows(lazy-lock-fontify-window no-minibuf #<mswindows-frame "emacs" 0x5 | |
13646 e49>) | |
13647 # (unwind-protect ...) | |
13648 # bind (ssf65112 tick frame) | |
13649 lazy-lock-maybe-fontify-frame(#<mswindows-frame "emacs" 0x5e49>) | |
13650 # bind (frame starting-frame) | |
13651 byte-code("..." [starting-frame frame selected-frame frame-visible-p frame-min | |
13652 ibuffer-only-p next-frame visible-nomini throw lazy-lock-frame-loop-done t lazy- | |
13653 lock-maybe-fontify-frame] 4) | |
13654 # (catch lazy-lock-frame-loop-done ...) | |
13655 lazy-lock-pre-idle-fontify-windows() | |
13656 # (unwind-protect ...) | |
13657 # (catch #<INTERNAL OBJECT (XEmacs bug?) (opaque, size=0) 0x1468938> ...) | |
13658 # (unwind-protect ...) | |
13659 # (unwind-protect ...) | |
13660 # bind (inhibit-quit) | |
13661 # (unwind-protect ...) | |
13662 # (unwind-protect ...) | |
13663 # bind (inhibit-quit) | |
13664 (next-event "[internal]") | |
13665 # (condition-case ... . error) | |
13666 # (catch top-level ...) | |
13667 @end example | |
13668 | |
13669 @subsubheading Another Lisp trace of a similar situation (C stack trace not available): | |
13670 | |
13671 @example | |
13672 Fatal error: assertion failed, file c:\xemacs\build\src\redisplay.c, line 5532, | |
13673 !dy->locked | |
13674 | |
13675 Lisp backtrace follows: | |
13676 | |
13677 # (unwind-protect ...) | |
13678 # (unwind-protect ...) | |
13679 # (unwind-protect ...) | |
13680 # (unwind-protect ...) | |
13681 # (unwind-protect ...) | |
13682 # (unwind-protect ...) | |
13683 # (unwind-protect ...) | |
13684 scrollbar-page-down((#<window on "*grep*" 0x1a5f9>)) | |
13685 (dispatch-event "[internal]") | |
13686 # (unwind-protect ...) | |
13687 # (catch #<INTERNAL OBJECT (XEmacs bug?) (opaque, size=0) 0x1468270> ...) | |
13688 # (unwind-protect ...) | |
13689 # (unwind-protect ...) | |
13690 # (catch #<INTERNAL OBJECT (XEmacs bug?) (opaque, size=0) 0x1468270> ...) | |
13691 # (unwind-protect ...) | |
13692 # bind (inhibit-quit) | |
13693 window-end(#<window on "*grep*" 0x1a5f9> t) | |
13694 # (unwind-protect ...) | |
13695 # bind (buffer we-are-screwed check-text-props window) | |
13696 lazy-lock-fontify-window(#<window on "*grep*" 0x1a5f9>) | |
13697 # bind (walk-windows-current walk-windows-start arg which-devices which-frames | |
13698 minibuf function) | |
13699 walk-windows(lazy-lock-fontify-window no-minibuf #<mswindows-frame "emacs" 0x1 | |
13700 9f64>) | |
13701 # (unwind-protect ...) | |
13702 # bind (ssf65112 tick frame) | |
13703 lazy-lock-maybe-fontify-frame(#<mswindows-frame "emacs" 0x19f64>) | |
13704 # bind (frame starting-frame) | |
13705 byte-code("..." [starting-frame frame selected-frame frame-visible-p frame-min | |
13706 ibuffer-only-p next-frame visible-nomini throw lazy-lock-frame-loop-done t lazy- | |
13707 lock-maybe-fontify-frame] 4) | |
13708 # (catch lazy-lock-frame-loop-done ...) | |
13709 lazy-lock-pre-idle-fontify-windows() | |
13710 # (unwind-protect ...) | |
13711 # (catch #<INTERNAL OBJECT (XEmacs bug?) (opaque, size=0) 0x1468270> ...) | |
13712 # (unwind-protect ...) | |
13713 # (unwind-protect ...) | |
13714 # bind (inhibit-quit) | |
13715 # (unwind-protect ...) | |
13716 # (unwind-protect ...) | |
13717 # bind (inhibit-quit) | |
13718 (next-event "[internal]") | |
13719 # (condition-case ... . error) | |
13720 # (catch top-level ...) | |
13721 @end example | |
13722 | |
13723 @subheading Crash -- reentrant @code{generate_displayable_area()} | |
13724 | |
13725 Original code said [Tricky tricky tricky. | |
13726 @code{generate_displayable_area()} can (could) be called reentrantly, | |
13727 and redisplay is not prepared to handle this:]. | |
13728 | |
13729 assert_failed(const char * 0x0129c8c8 `string', int 5328, const char * 0x01274068 `string') line 3620 | |
13730 Dynarr_verify_mod_1(void * 0x0250f228, const char * 0x0129c8c8 `string', int 5328) line 1256 + 36 bytes | |
13731 generate_displayable_area(window * 0x02480028, long 38776292, int 0, int 0, int 265, int 169, display_line_dynarr * 0x0250f228, long 0, int 2) line 5328 + 25 bytes | |
13732 output_gutter(frame * 0x0228ad90, gutter_pos TOP_GUTTER, int 1) line 409 + 69 bytes | |
13733 redraw_exposed_gutter(frame * 0x0228ad90, gutter_pos TOP_GUTTER, int 8, int 23, int 249, int 127) line 687 + 15 bytes | |
13734 redraw_exposed_gutters(frame * 0x0228ad90, int 8, int 23, int 249, int 127) line 703 + 29 bytes | |
13735 mswindows_redraw_exposed_area(frame * 0x0228ad90, int 8, int 23, int 249, int 127) line 862 + 25 bytes | |
13736 mswindows_handle_paint(frame * 0x0228ad90) line 2176 + 25 bytes | |
13737 mswindows_wnd_proc(HWND__ * 0x001003e2, unsigned int 15, unsigned int 0, long 0) line 3233 + 45 bytes | |
13738 intercepted_wnd_proc(HWND__ * 0x001003e2, unsigned int 15, unsigned int 0, long 0) line 2488 | |
13739 USER32! 77e3a244() | |
13740 USER32! 77e14730() | |
13741 USER32! 77e1558a() | |
13742 NTDLL! KiUserCallbackDispatcher@@12 + 19 bytes | |
13743 USER32! 77e14680() | |
13744 USER32! 77e1a792() | |
13745 qxeIsDialogMessage(HWND__ * 0x001003e2, tagMSG * 0x0082a93c @{msg=0x0000000f wp=0x00000000 lp=0x00000000@}) line 2298 + 14 bytes | |
13746 mswindows_is_dialog_msg(tagMSG * 0x0082a93c @{msg=0x0000000f wp=0x00000000 lp=0x00000000@}) line 165 + 13 bytes | |
13747 mswindows_drain_windows_queue(int 0) line 1282 + 9 bytes | |
13748 emacs_mswindows_drain_queue() line 1326 + 7 bytes | |
13749 event_stream_drain_queue() line 1887 | |
13750 event_stream_quit_p() line 1992 | |
13751 check_quit() line 993 | |
13752 unbind_to_hairy(int 35) line 5963 | |
13753 unbind_to_1(int 35, long 20888208) line 5945 + 200 bytes | |
13754 specifier_instance_from_inst_list(long 21379344, long 38135616, long 36220304, long 20888208, _error_behavior_struct_ @{...@}, int 1, long 3) line 2522 + 16 bytes | |
13755 specifier_instance(long 21379344, long 38135616, long 36220304, _error_behavior_struct_ @{...@}, int 1, int 0, long 3) line 2625 + 65 bytes | |
13756 specifier_instance_no_quit(long 21379344, long 38135616, long 36220304, _error_behavior_struct_ @{...@}, int 0, long 1) line 2658 + 31 bytes | |
13757 face_property_matching_instance(long 22612340, long 20860632, long 22530956, long 36220304, _error_behavior_struct_ @{...@}, int 0, long 1) line 565 + 48 bytes | |
13758 ensure_face_cachel_contains_charset(face_cachel * 0x0082b014, long 36220304, long 22530956) line 1104 + 35 bytes | |
13759 update_face_cachel_data(face_cachel * 0x0082b014, long 36220304, long 22612340) line 1304 + 19 bytes | |
13760 query_string_geometry(long 21110576, long 22612340, int * 0x00000000, int * 0x0082b5b4, int * 0x00000000, long 38852960) line 2370 + 23 bytes | |
13761 mswindows_widget_query_string_geometry(long 21110576, long 22612340, int * 0x0082b5b8, int * 0x0082b5b4, long 38852960) line 2914 + 25 bytes | |
13762 widget_query_string_geometry(long 21110576, long 22612340, int * 0x0082b5b8, int * 0x0082b5b4, long 38852960) line 514 + 32 bytes | |
13763 edit_field_query_geometry(long 38857648, int * 0x0082b7b4, int * 0x0082b7b8, image_instance_geometry IMAGE_DESIRED_GEOMETRY, long 38852960) line 920 + 390 bytes | |
13764 widget_query_geometry(long 38857648, int * 0x0082b7b4, int * 0x0082b7b8, image_instance_geometry IMAGE_DESIRED_GEOMETRY, long 38852960) line 567 + 26 bytes | |
13765 image_instance_query_geometry(long 38857648, int * 0x0082b7b4, int * 0x0082b7b8, image_instance_geometry IMAGE_DESIRED_GEOMETRY, long 38852960) line 2015 + 26 bytes | |
13766 glyph_query_geometry(long 38853384, int * 0x0082b7b4, int * 0x0082b7b8, image_instance_geometry IMAGE_DESIRED_GEOMETRY, long 38852960) line 4197 + 25 bytes | |
13767 layout_query_geometry(long 38852960, int * 0x0082b9cc, int * 0x0082b9d0, image_instance_geometry IMAGE_DESIRED_GEOMETRY, long 38404624) line 1351 + 25 bytes | |
13768 widget_query_geometry(long 38852960, int * 0x0082b9cc, int * 0x0082b9d0, image_instance_geometry IMAGE_DESIRED_GEOMETRY, long 38404624) line 567 + 26 bytes | |
13769 image_instance_query_geometry(long 38852960, int * 0x0082b9cc, int * 0x0082b9d0, image_instance_geometry IMAGE_DESIRED_GEOMETRY, long 38404624) line 2015 + 26 bytes | |
13770 glyph_query_geometry(long 38537976, int * 0x0082b9cc, int * 0x0082b9d0, image_instance_geometry IMAGE_DESIRED_GEOMETRY, long 38404624) line 4197 + 25 bytes | |
13771 layout_layout(long 38404624, int 265, int 156, int -2, int -2, long 38273064) line 1468 + 23 bytes | |
13772 widget_layout(long 38404624, int 265, int 156, int -2, int -2, long 38273064) line 626 + 30 bytes | |
13773 image_instance_layout(long 38404624, int 265, int 156, int -2, int -2, long 38273064) line 2102 + 51 bytes | |
13774 glyph_ascent(long 38404624, long 38273064) line 4009 + 21 bytes | |
13775 update_glyph_cachel_data(window * 0x02480028, long 36201168, glyph_cachel * 0x0248c3d8) line 4272 + 13 bytes | |
13776 get_glyph_cachel_index(window * 0x02480028, long 36201168) line 4306 + 17 bytes | |
13777 add_glyph_rune(position_redisplay_data_type * 0x0082bf2c, glyph_block * 0x024bd028, int 0, int 0, glyph_cachel * 0x00000000) line 1800 + 15 bytes | |
13778 add_glyph_runes(position_redisplay_data_type * 0x0082bf2c, int 0) line 2085 + 31 bytes | |
13779 create_string_text_block(window * 0x02480028, long 38776292, display_line * 0x02514500, long 0, prop_block_dynarr * * 0x0082c13c, int 2) line 4907 + 14 bytes | |
13780 generate_string_display_line(window * 0x02480028, long 38776292, display_line * 0x02514500, long 0, prop_block_dynarr * * 0x0082c13c, int 2) line 5293 + 29 bytes | |
13781 generate_displayable_area(window * 0x02480028, long 38776292, int 0, int 0, int 265, int 169, display_line_dynarr * 0x0250f228, long 0, int 2) line 5372 + 29 bytes | |
13782 output_gutter(frame * 0x0228ad90, gutter_pos TOP_GUTTER, int 0) line 409 + 69 bytes | |
13783 update_frame_gutters(frame * 0x0228ad90) line 639 + 15 bytes | |
13784 redisplay_frame(frame * 0x0228ad90, int 1) line 6792 + 9 bytes | |
13785 redisplay_device(device * 0x0171df00, int 1) line 6911 + 11 bytes | |
13786 redisplay_without_hooks() line 6957 + 11 bytes | |
13787 redisplay_no_pre_idle_hook() line 7029 | |
13788 redisplay() line 7011 | |
13789 mswindows_wnd_proc(HWND__ * 0x001003e2, unsigned int 5, unsigned int 0, long 10223881) line 3424 | |
13790 intercepted_wnd_proc(HWND__ * 0x001003e2, unsigned int 5, unsigned int 0, long 10223881) line 2488 | |
13791 USER32! 77e3a244() | |
13792 USER32! 77e16362() | |
13793 USER32! 77e14c1a() | |
13794 USER32! 77e1dd30() | |
13795 mswindows_wnd_proc(HWND__ * 0x001003e2, unsigned int 71, unsigned int 0, long 8578308) line 3926 + 21 bytes | |
13796 intercepted_wnd_proc(HWND__ * 0x001003e2, unsigned int 71, unsigned int 0, long 8578308) line 2488 | |
13797 USER32! 77e3a244() | |
13798 USER32! 77e14730() | |
13799 USER32! 77e174b4() | |
13800 NTDLL! KiUserCallbackDispatcher@@12 + 19 bytes | |
13801 mswindows_set_frame_size(frame * 0x0228ad90, int 265, int 156) line 355 | |
13802 internal_set_frame_size(frame * 0x0228ad90, int 265, int 156, int 0) line 2754 + 24 bytes | |
13803 Fset_frame_displayable_pixel_size(long 36220304, long 531, long 313, long 20888208) line 3004 + 32 bytes | |
13804 Ffuncall(int 4, long * 0x0082e778) line 3844 + 168 bytes | |
13805 execute_optimized_program(const unsigned char * 0x02286e48, int 40, long * 0x01529b80) line 609 + 16 bytes | |
13806 funcall_compiled_function(long 22433308, int 0, long * 0x0082ec08) line 3452 + 85 bytes | |
13807 Ffuncall(int 1, long * 0x0082ec04) line 3883 + 17 bytes | |
13808 execute_optimized_program(const unsigned char * 0x02286d40, int 6, long * 0x01548ddc) line 609 + 16 bytes | |
13809 funcall_compiled_function(long 22505864, int 11, long * 0x0082f00c) line 3452 + 85 bytes | |
13810 Ffuncall(int 12, long * 0x0082f008) line 3883 + 17 bytes | |
13811 execute_optimized_program(const unsigned char * 0x02503e38, int 47, long * 0x0152dc48) line 609 + 16 bytes | |
13812 funcall_compiled_function(long 22436784, int 0, long * 0x0082f534) line 3452 + 85 bytes | |
13813 Ffuncall(int 1, long * 0x0082f530) line 3883 + 17 bytes | |
13814 apply1(long 22436784, long 20888208) line 4458 + 11 bytes | |
13815 Fcall_interactively(long 20742816, long 20888208, long 20888208) line 460 + 13 bytes | |
13816 Ffuncall(int 2, long * 0x0082f8ec) line 3844 + 127 bytes | |
13817 call1(long 20854392, long 20742816) line 4489 + 11 bytes | |
13818 execute_command_event(command_builder * 0x01798f98, long 24439276) line 4198 + 69 bytes | |
13819 Fdispatch_event(long 24439276) line 4569 + 13 bytes | |
13820 Fcommand_loop_1() line 569 + 9 bytes | |
13821 command_loop_1(long 20888208) line 489 | |
13822 condition_case_1(long 20886024, long (long)* 0x010955a0 command_loop_1(long), long 20888208, long (long, long)* 0x01095150 cmd_error(long, long), long 20888208) line 1917 + 7 bytes | |
13823 command_loop_3() line 251 + 35 bytes | |
13824 command_loop_2(long 20888208) line 264 | |
13825 internal_catch(long 20650992, long (long)* 0x010952c0 command_loop_2(long), long 20888208, int * volatile 0x00000000, long * volatile 0x00000000) line 1527 + 7 bytes | |
13826 initial_command_loop(long 20888208) line 300 + 28 bytes | |
13827 xemacs_21_5_b10_i586_pc_win32(int 1, char * * 0x00e52620, char * * 0x00e52bb0, int 0) line 2356 | |
13828 main(int 1, char * * 0x00e52620, char * * 0x00e52bb0) line 2733 | |
13829 mainCRTStartup() line 338 + 17 bytes | |
13830 KERNEL32! 77ea847c() | |
12891 | 13831 |
12892 @node Line Start Cache, Redisplay Piece by Piece, Critical Redisplay Sections, The Redisplay Mechanism | 13832 @node Line Start Cache, Redisplay Piece by Piece, Critical Redisplay Sections, The Redisplay Mechanism |
12893 @section Line Start Cache | 13833 @section Line Start Cache |
12894 @cindex line start cache | 13834 @cindex line start cache |
12895 | 13835 |
14686 @code{begin_dont_check_for_quit()}. It makes no difference is | 15626 @code{begin_dont_check_for_quit()}. It makes no difference is |
14687 @code{QUIT} is called a zillion times in @code{next_event_internal()} or | 15627 @code{QUIT} is called a zillion times in @code{next_event_internal()} or |
14688 anywhere else, because it's blocked and will never signal. | 15628 anywhere else, because it's blocked and will never signal. |
14689 @end enumerate | 15629 @end enumerate |
14690 | 15630 |
15631 @subsection Reentrancy Problems due to QUIT Checking | |
15632 | |
15633 Checking for QUIT can do quite a long of things -- since it pumps the | |
15634 event loop, this may cause arbitrary code to get executed, garbage collection | |
15635 to happen. etc. (In fact, garbage collection cannot happen because it is inhibited.) This has led to crashes when functions get called reentrantly when not expecting it. Example: | |
15636 | |
15637 @subheading Crash -- reentrant @code{re_match_2()} | |
15638 | |
15639 @example | |
15640 /* dont_check_for_quit is set in three circumstances: | |
15641 | |
15642 (1) when we are in the process of changing the window | |
15643 configuration. The frame might be in an inconsistent state, | |
15644 which will cause assertion failures if we check for QUIT. | |
15645 | |
15646 (2) when we are reading events, and want to read the C-g | |
15647 as an event. The normal check for quit will discard the C-g, | |
15648 which would be bad. | |
15649 | |
15650 (3) when we're going down with a fatal error. we're most likely | |
15651 in an inconsistent state, and we definitely don't want to be | |
15652 interrupted. */ | |
15653 | |
15654 /* We should *not* conditionalize on Vinhibit_quit, or | |
15655 critical-quit (Control-Shift-G) won't work right. */ | |
15656 | |
15657 /* WARNING: Even calling check_quit(), without actually dispatching | |
15658 a quit signal, can result in arbitrary Lisp code getting executed | |
15659 -- at least under Windows. (Not to mention obvious Lisp | |
15660 invocations like asynchronous timer callbacks.) Here's a sample | |
15661 stack trace to demonstrate: | |
15662 | |
15663 NTDLL! DbgBreakPoint@@0 address 0x77f9eea9 | |
15664 assert_failed(const char * 0x012d036c, int 4596, const char * 0x012d0354) line 3478 | |
15665 re_match_2_internal(re_pattern_buffer * 0x012d6780, const unsigned char * 0x00000000, int 0, const unsigned char * 0x022f9328, int 34, int 0, re_registers * 0x012d53d0 search_regs, int 34) line 4596 + 41 bytes | |
15666 re_search_2(re_pattern_buffer * 0x012d6780, const char * 0x00000000, int 0, const char * 0x022f9328, int 34, int 0, int 34, re_registers * 0x012d53d0 search_regs, int 34) line 4269 + 37 bytes | |
15667 re_search(re_pattern_buffer * 0x012d6780, const char * 0x022f9328, int 34, int 0, int 34, re_registers * 0x012d53d0 search_regs) line 4031 + 37 bytes | |
15668 string_match_1(long 31222628, long 30282164, long 28377092, buffer * 0x022fde00, int 0) line 413 + 69 bytes | |
15669 Fstring_match(long 31222628, long 30282164, long 28377092, long 28377092) line 436 + 34 bytes | |
15670 Ffuncall(int 3, long * 0x008297f8) line 3488 + 168 bytes | |
15671 execute_optimized_program(const unsigned char * 0x020ddc50, int 6, long * 0x020ddf50) line 744 + 16 bytes | |
15672 funcall_compiled_function(long 34407748, int 1, long * 0x00829aec) line 516 + 53 bytes | |
15673 Ffuncall(int 2, long * 0x00829ae8) line 3523 + 17 bytes | |
15674 execute_optimized_program(const unsigned char * 0x020ddc90, int 4, long * 0x020ddf90) line 744 + 16 bytes | |
15675 funcall_compiled_function(long 34407720, int 1, long * 0x00829e28) line 516 + 53 bytes | |
15676 Ffuncall(int 2, long * 0x00829e24) line 3523 + 17 bytes | |
15677 mapcar1(long 15, long * 0x00829e48, long 34447820, long 34187868) line 2929 + 11 bytes | |
15678 Fmapcar(long 34447820, long 34187868) line 3035 + 21 bytes | |
15679 Ffuncall(int 3, long * 0x00829f20) line 3488 + 93 bytes | |
15680 execute_optimized_program(const unsigned char * 0x020c2b70, int 7, long * 0x020dd010) line 744 + 16 bytes | |
15681 funcall_compiled_function(long 34407580, int 2, long * 0x0082a210) line 516 + 53 bytes | |
15682 Ffuncall(int 3, long * 0x0082a20c) line 3523 + 17 bytes | |
15683 execute_optimized_program(const unsigned char * 0x020cf810, int 6, long * 0x020cfb10) line 744 + 16 bytes | |
15684 funcall_compiled_function(long 34407524, int 0, long * 0x0082a580) line 516 + 53 bytes | |
15685 Ffuncall(int 1, long * 0x0082a57c) line 3523 + 17 bytes | |
15686 run_hook_with_args_in_buffer(buffer * 0x022fde00, int 1, long * 0x0082a57c, int 0) line 3980 + 13 bytes | |
15687 run_hook_with_args(int 1, long * 0x0082a57c, int 0) line 3993 + 23 bytes | |
15688 Frun_hooks(int 1, long * 0x0082a57c) line 3847 + 19 bytes | |
15689 run_hook(long 34447484) line 4094 + 11 bytes | |
15690 unsafe_handle_wm_initmenu_1(frame * 0x01dbb000) line 736 + 11 bytes | |
15691 unsafe_handle_wm_initmenu(long 28377092) line 807 + 11 bytes | |
15692 condition_case_1(long 28377116, long (long)* 0x0101c827 unsafe_handle_wm_initmenu(long), long 28377092, long (long, long)* 0x01005fa4 mswindows_modal_loop_error_handler(long, long), long 28377092) line 1692 + 7 bytes | |
15693 mswindows_protect_modal_loop(long (long)* 0x0101c827 unsafe_handle_wm_initmenu(long), long 28377092) line 1194 + 32 bytes | |
15694 mswindows_handle_wm_initmenu(HMENU__ * 0x00010199, frame * 0x01dbb000) line 826 + 17 bytes | |
15695 mswindows_wnd_proc(HWND__ * 0x000501da, unsigned int 278, unsigned int 65945, long 0) line 3089 + 31 bytes | |
15696 USER32! UserCallWinProc@@20 + 24 bytes | |
15697 USER32! DispatchClientMessage@@20 + 47 bytes | |
15698 USER32! __fnDWORD@@4 + 34 bytes | |
15699 NTDLL! KiUserCallbackDispatcher@@12 + 19 bytes | |
15700 USER32! DispatchClientMessage@@20 address 0x77e163cc | |
15701 USER32! DefWindowProcW@@16 + 34 bytes | |
15702 qxeDefWindowProc(HWND__ * 0x000501da, unsigned int 274, unsigned int 61696, long 98) line 1188 + 22 bytes | |
15703 mswindows_wnd_proc(HWND__ * 0x000501da, unsigned int 274, unsigned int 61696, long 98) line 3362 + 21 bytes | |
15704 USER32! UserCallWinProc@@20 + 24 bytes | |
15705 USER32! DispatchClientMessage@@20 + 47 bytes | |
15706 USER32! __fnDWORD@@4 + 34 bytes | |
15707 NTDLL! KiUserCallbackDispatcher@@12 + 19 bytes | |
15708 USER32! DispatchClientMessage@@20 address 0x77e163cc | |
15709 USER32! DefWindowProcW@@16 + 34 bytes | |
15710 qxeDefWindowProc(HWND__ * 0x000501da, unsigned int 262, unsigned int 98, long 540016641) line 1188 + 22 bytes | |
15711 mswindows_wnd_proc(HWND__ * 0x000501da, unsigned int 262, unsigned int 98, long 540016641) line 3362 + 21 bytes | |
15712 USER32! UserCallWinProc@@20 + 24 bytes | |
15713 USER32! DispatchMessageWorker@@8 + 244 bytes | |
15714 USER32! DispatchMessageW@@4 + 11 bytes | |
15715 qxeDispatchMessage(const tagMSG * 0x0082c684 @{msg=0x00000106 wp=0x00000062 lp=0x20300001@}) line 989 + 10 bytes | |
15716 mswindows_drain_windows_queue() line 1345 + 9 bytes | |
15717 emacs_mswindows_quit_p() line 3947 | |
15718 event_stream_quit_p() line 666 | |
15719 check_quit() line 686 | |
15720 check_what_happened() line 437 | |
15721 re_match_2_internal(re_pattern_buffer * 0x012d5a18, const unsigned char * 0x00000000, int 0, const unsigned char * 0x02235000, int 23486, int 14645, re_registers * 0x012d53d0 search_regs, int 23486) line 4717 + 14 bytes | |
15722 re_search_2(re_pattern_buffer * 0x012d5a18, const char * 0x02235000, int 23486, const char * 0x0223b38e, int 0, int 14645, int 8841, re_registers * 0x012d53d0 search_regs, int 23486) line 4269 + 37 bytes | |
15723 search_buffer(buffer * 0x022fde00, long 29077572, long 13789, long 23487, long 1, int 1, long 28377092, long 28377092, int 0) line 1224 + 89 bytes | |
15724 search_command(long 29077572, long 46975, long 28377116, long 28377092, long 28377092, int 1, int 1, int 0) line 1054 + 151 bytes | |
15725 Fre_search_forward(long 29077572, long 46975, long 28377116, long 28377092, long 28377092) line 2147 + 31 bytes | |
15726 Ffuncall(int 4, long * 0x0082ceb0) line 3488 + 216 bytes | |
15727 execute_optimized_program(const unsigned char * 0x02047810, int 13, long * 0x02080c10) line 744 + 16 bytes | |
15728 funcall_compiled_function(long 34187208, int 3, long * 0x0082d1b8) line 516 + 53 bytes | |
15729 Ffuncall(int 4, long * 0x0082d1b4) line 3523 + 17 bytes | |
15730 execute_optimized_program(const unsigned char * 0x01e96a10, int 6, long * 0x020ae510) line 744 + 16 bytes | |
15731 funcall_compiled_function(long 34186676, int 3, long * 0x0082d4a0) line 516 + 53 bytes | |
15732 Ffuncall(int 4, long * 0x0082d49c) line 3523 + 17 bytes | |
15733 execute_optimized_program(const unsigned char * 0x02156b50, int 4, long * 0x020c2db0) line 744 + 16 bytes | |
15734 funcall_compiled_function(long 34186564, int 2, long * 0x0082d780) line 516 + 53 bytes | |
15735 Ffuncall(int 3, long * 0x0082d77c) line 3523 + 17 bytes | |
15736 execute_optimized_program(const unsigned char * 0x0082d964, int 3, long * 0x020c2d70) line 744 + 16 bytes | |
15737 Fbyte_code(long 29405156, long 34352480, long 7) line 2392 + 38 bytes | |
15738 Feval(long 34354440) line 3290 + 187 bytes | |
15739 condition_case_1(long 34354572, long (long)* 0x01087232 Feval(long), long 34354440, long (long, long)* 0x01084764 run_condition_case_handlers(long, long), long 28377092) line 1692 + 7 bytes | |
15740 condition_case_3(long 34354440, long 28377092, long 34354572) line 1779 + 27 bytes | |
15741 execute_rare_opcode(long * 0x0082dc7c, const unsigned char * 0x01b090af, int 143) line 1269 + 19 bytes | |
15742 execute_optimized_program(const unsigned char * 0x01b09090, int 6, long * 0x020ae590) line 654 + 17 bytes | |
15743 funcall_compiled_function(long 34186620, int 0, long * 0x0082df68) line 516 + 53 bytes | |
15744 Ffuncall(int 1, long * 0x0082df64) line 3523 + 17 bytes | |
15745 execute_optimized_program(const unsigned char * 0x02195470, int 1, long * 0x020c2df0) line 744 + 16 bytes | |
15746 funcall_compiled_function(long 34186508, int 0, long * 0x0082e23c) line 516 + 53 bytes | |
15747 Ffuncall(int 1, long * 0x0082e238) line 3523 + 17 bytes | |
15748 execute_optimized_program(const unsigned char * 0x01e5d410, int 6, long * 0x0207d410) line 744 + 16 bytes | |
15749 funcall_compiled_function(long 34186312, int 1, long * 0x0082e524) line 516 + 53 bytes | |
15750 Ffuncall(int 2, long * 0x0082e520) line 3523 + 17 bytes | |
15751 execute_optimized_program(const unsigned char * 0x02108fb0, int 2, long * 0x020c2e30) line 744 + 16 bytes | |
15752 funcall_compiled_function(long 34186340, int 0, long * 0x0082e7fc) line 516 + 53 bytes | |
15753 Ffuncall(int 1, long * 0x0082e7f8) line 3523 + 17 bytes | |
15754 execute_optimized_program(const unsigned char * 0x020fe150, int 2, long * 0x01e6f510) line 744 + 16 bytes | |
15755 funcall_compiled_function(long 31008124, int 0, long * 0x0082ebd8) line 516 + 53 bytes | |
15756 Ffuncall(int 1, long * 0x0082ebd4) line 3523 + 17 bytes | |
15757 run_hook_with_args_in_buffer(buffer * 0x022fde00, int 1, long * 0x0082ebd4, int 0) line 3980 + 13 bytes | |
15758 run_hook_with_args(int 1, long * 0x0082ebd4, int 0) line 3993 + 23 bytes | |
15759 Frun_hooks(int 1, long * 0x0082ebd4) line 3847 + 19 bytes | |
15760 Ffuncall(int 2, long * 0x0082ebd0) line 3509 + 14 bytes | |
15761 execute_optimized_program(const unsigned char * 0x01ef2210, int 5, long * 0x01da8e10) line 744 + 16 bytes | |
15762 funcall_compiled_function(long 31020440, int 2, long * 0x0082eeb8) line 516 + 53 bytes | |
15763 Ffuncall(int 3, long * 0x0082eeb4) line 3523 + 17 bytes | |
15764 execute_optimized_program(const unsigned char * 0x0082f09c, int 3, long * 0x01d89390) line 744 + 16 bytes | |
15765 Fbyte_code(long 31102388, long 30970752, long 7) line 2392 + 38 bytes | |
15766 Feval(long 31087568) line 3290 + 187 bytes | |
15767 condition_case_1(long 30961240, long (long)* 0x01087232 Feval(long), long 31087568, long (long, long)* 0x01084764 run_condition_case_handlers(long, long), long 28510180) line 1692 + 7 bytes | |
15768 condition_case_3(long 31087568, long 28510180, long 30961240) line 1779 + 27 bytes | |
15769 execute_rare_opcode(long * 0x0082f450, const unsigned char * 0x01ef23ec, int 143) line 1269 + 19 bytes | |
15770 execute_optimized_program(const unsigned char * 0x01ef2310, int 6, long * 0x01da8f10) line 654 + 17 bytes | |
15771 funcall_compiled_function(long 31020412, int 1, long * 0x0082f740) line 516 + 53 bytes | |
15772 Ffuncall(int 2, long * 0x0082f73c) line 3523 + 17 bytes | |
15773 execute_optimized_program(const unsigned char * 0x020fe650, int 3, long * 0x01d8c490) line 744 + 16 bytes | |
15774 funcall_compiled_function(long 31020020, int 2, long * 0x0082fa14) line 516 + 53 bytes | |
15775 Ffuncall(int 3, long * 0x0082fa10) line 3523 + 17 bytes | |
15776 Fcall_interactively(long 29685180, long 28377092, long 28377092) line 1008 + 22 bytes | |
15777 Fcommand_execute(long 29685180, long 28377092, long 28377092) line 2929 + 17 bytes | |
15778 execute_command_event(command_builder * 0x01be1900, long 36626492) line 4048 + 25 bytes | |
15779 Fdispatch_event(long 36626492) line 4341 + 70 bytes | |
15780 Fcommand_loop_1() line 582 + 9 bytes | |
15781 command_loop_1(long 28377092) line 495 | |
15782 condition_case_1(long 28377188, long (long)* 0x01064fb9 command_loop_1(long), long 28377092, long (long, long)* 0x010649d0 cmd_error(long, long), long 28377092) line 1692 + 7 bytes | |
15783 command_loop_3() line 256 + 35 bytes | |
15784 command_loop_2(long 28377092) line 269 | |
15785 internal_catch(long 28457612, long (long)* 0x01064b20 command_loop_2(long), long 28377092, int * volatile 0x00000000) line 1317 + 7 bytes | |
15786 initial_command_loop(long 28377092) line 305 + 25 bytes | |
15787 STACK_TRACE_EYE_CATCHER(int 1, char * * 0x01b63ff0, char * * 0x01ca5300, int 0) line 2501 | |
15788 main(int 1, char * * 0x01b63ff0, char * * 0x01ca5300) line 2938 | |
15789 XEMACS! mainCRTStartup + 180 bytes | |
15790 _start() line 171 | |
15791 KERNEL32! BaseProcessStart@@4 + 115547 bytes | |
15792 @end example | |
15793 | |
15794 [explain dont_check_for_quit() et al] | |
15795 | |
14691 @node Profiling, Asynchronous Timeouts, Control-G (Quit) Checking, Asynchronous Events; Quit Checking | 15796 @node Profiling, Asynchronous Timeouts, Control-G (Quit) Checking, Asynchronous Events; Quit Checking |
14692 @section Profiling | 15797 @section Profiling |
14693 @cindex profiling | 15798 @cindex profiling |
14694 @cindex SIGPROF | 15799 @cindex SIGPROF |
14695 | 15800 |
21877 issues, edited to include only relevant and useful stuff. Ideally over | 22982 issues, edited to include only relevant and useful stuff. Ideally over |
21878 time these could be condensed down to a single design document to go | 22983 time these could be condensed down to a single design document to go |
21879 into the normal Future Work section. | 22984 into the normal Future Work section. |
21880 | 22985 |
21881 @menu | 22986 @menu |
21882 * Discussion -- garbage collection:: | 22987 * Discussion -- Garbage Collection:: |
21883 * Discussion -- glyphs:: | 22988 * Discussion -- Glyphs:: |
21884 * Discussion -- Dialog Boxes:: | 22989 * Discussion -- Dialog Boxes:: |
21885 * Discussion -- Multilingual Issues:: | 22990 * Discussion -- Multilingual Issues:: |
22991 * Discussion -- Instantiators and Generic Property Accessors:: | |
22992 * Discussion -- Switching to C++:: | |
21886 * Discussion -- Windows External Widget:: | 22993 * Discussion -- Windows External Widget:: |
21887 * Discussion -- Packages:: | 22994 * Discussion -- Packages:: |
21888 * Discussion -- Distribution Layout:: | 22995 * Discussion -- Distribution Layout:: |
21889 @end menu | 22996 @end menu |
21890 | 22997 |
21891 @node Discussion -- garbage collection, Discussion -- glyphs, Future Work Discussion, Future Work Discussion | 22998 @node Discussion -- Garbage Collection, Discussion -- Glyphs, Future Work Discussion, Future Work Discussion |
21892 @section Discussion -- garbage collection | 22999 @section Discussion -- Garbage Collection |
21893 @cindex discussion, garbage collection | 23000 @cindex discussion, garbage collection |
21894 @cindex garbage collection, discussion | 23001 @cindex garbage collection, discussion |
23002 | |
23003 @menu | |
23004 * Discussion -- Pure Space:: | |
23005 * Discussion -- Hashtable-Based Marking and Cleanup:: | |
23006 * Discussion -- The Anti-Cons:: | |
23007 @end menu | |
23008 | |
23009 @node Discussion -- Pure Space, Discussion -- Hashtable-Based Marking and Cleanup, Discussion -- Garbage Collection, Discussion -- Garbage Collection | |
23010 @subsection Discussion -- Pure Space | |
23011 @cindex discussion, pure space | |
23012 @cindex pure space, discussion | |
21895 | 23013 |
21896 On Tue, Oct 12, 1999 at 03:36:59AM -0700, Ben Wing wrote: | 23014 On Tue, Oct 12, 1999 at 03:36:59AM -0700, Ben Wing wrote: |
21897 | 23015 |
21898 So what am I missing here? | 23016 So what am I missing here? |
21899 | 23017 |
21966 So no, it's not a _necessity_. But it helps. And the automatic | 23084 So no, it's not a _necessity_. But it helps. And the automatic |
21967 sharing of all objects until you write to them explicitely is, I | 23085 sharing of all objects until you write to them explicitely is, I |
21968 think, really cool. | 23086 think, really cool. |
21969 @end enumerate | 23087 @end enumerate |
21970 | 23088 |
23089 @node Discussion -- Hashtable-Based Marking and Cleanup, Discussion -- The Anti-Cons, Discussion -- Pure Space, Discussion -- Garbage Collection | |
23090 @subsection Discussion -- Hashtable-Based Marking and Cleanup | |
23091 @cindex discussion, hashtable-based marking and cleanup | |
23092 @cindex hashtable-based marking and cleanup, discussion | |
23093 | |
21971 On 10/12/1999 5:49 PM Ben Wing wrote: | 23094 On 10/12/1999 5:49 PM Ben Wing wrote: |
21972 | |
21973 Subject: Re: hashtable-based marking and cleanups | |
21974 | 23095 |
21975 OK, I can see the advantages. But: | 23096 OK, I can see the advantages. But: |
21976 | 23097 |
21977 @enumerate | 23098 @enumerate |
21978 @item | 23099 @item |
22013 | 23134 |
22014 @example | 23135 @example |
22015 http://www.amazon.com/exec/obidos/ASIN/0471941484/qid=939775572/sr=1-1/002-3092633-2509405 | 23136 http://www.amazon.com/exec/obidos/ASIN/0471941484/qid=939775572/sr=1-1/002-3092633-2509405 |
22016 @end example | 23137 @end example |
22017 | 23138 |
22018 @node Discussion -- glyphs, Discussion -- Dialog Boxes, Discussion -- garbage collection, Future Work Discussion | 23139 @node Discussion -- The Anti-Cons, , Discussion -- Hashtable-Based Marking and Cleanup, Discussion -- Garbage Collection |
22019 @section Discussion -- glyphs | 23140 @subsection Discussion -- The Anti-Cons |
23141 @cindex discussion, the anti-cons | |
23142 @cindex the anti-cons, discussion | |
23143 | |
23144 From: "Ben Wing" <ben@@666.com> | |
23145 Date: Tue, 14 May 2002 06:48:09 -0700 | |
23146 | |
23147 i was thinking about the proliferating types of weak hash tables -- | |
23148 e.g. now we have "key-car-value weak" hash tables due to a need in the | |
23149 glyphs code. i realized there should be a general solution, that lets | |
23150 you control exactly how the weakness of such hash tables work. | |
23151 | |
23152 and, assuming we implement a simple "reference" type, a simple | |
23153 container whose object is a weak reference and thus gets converted to | |
23154 nil (and a flag set on the reference) when the object is collected, it | |
23155 would be useful for more precisely controlling the reference, too. | |
23156 | |
23157 it's called an "anti-cons". it behaves somewhat like a cons in that | |
23158 it boxes two items, but its marking properties are very different -- | |
23159 in fact, backwards. normally, a cons, if marked, marks its children. | |
23160 in this case, if the children of an anti-cons are marked, it marks | |
23161 itself! you'd need a few different kinds of anti-cons -- probably the | |
23162 following: | |
23163 | |
23164 @example | |
23165 and [marks itself if both children marked] | |
23166 or [...] | |
23167 left [marks itself if left is marked, and then marks the right] | |
23168 right [...] | |
23169 not-left | |
23170 not-right | |
23171 @end example | |
23172 | |
23173 by putting such an object inside of a weak reference -- e.g. in a weak | |
23174 hash table -- we can set up a tree of arbitrary complexity which | |
23175 implements any boolean formula of markedness over any number of | |
23176 objects. this would easily handle key-car, and key-cadr, and | |
23177 key-car-or-cdr, and key-((caar or cadr) and cdr) etc. etc. | |
23178 | |
23179 implementing this in the current xemacs framework is mostly trivial. | |
23180 | |
23181 michael, would such an object get in the way of your new gc? | |
23182 | |
23183 From: sperber@@informatik.uni-tuebingen.de (Michael Sperber [Mr. Preprocessor]) | |
23184 Date: Tue, 14 May 2002 16:04:01 +0200 | |
23185 | |
23186 You might want to look at | |
23187 | |
23188 http://research.microsoft.com/Users/simonpj/Papers/weak.htm | |
23189 | |
23190 for a pretty comprehensive survey of what you could want in terms of | |
23191 weakness. Its weak pointers are very similar to your anti-cons. | |
23192 However, there are some problems in doing the same in a Lisp settings, | |
23193 mainly because of symbols. I intend to elaborate on this next week; | |
23194 this week is full, unfortunately. | |
23195 | |
23196 Ben> implementing this in the current xemacs framework is mostly | |
23197 Ben> trivial. | |
23198 | |
23199 Ben> michael, would such an object get in the way of your new gc? | |
23200 | |
23201 Well, our first commit will be an implementation of vanilla weak | |
23202 boxes (ready within the next few days, I hope), and we'll then try to | |
23203 replace most other instances of weakness with uses of those. We'll | |
23204 then try to find a more general solution for the rest. (Richard | |
23205 Reingruber has already done a comprehensive survey of the trouble | |
23206 spot. | |
23207 | |
23208 Can you wait until next week? I'll try to come up with a battle plan | |
23209 then. | |
23210 | |
23211 From: sperber@@informatik.uni-tuebingen.de (Michael Sperber [Mr. Preprocessor]) | |
23212 Date: Tue, 28 May 2002 16:14:20 +0200 | |
23213 | |
23214 We've now started implementing ephemerons as a building block for the | |
23215 more involved weakness-involving data structures: | |
23216 | |
23217 The relevant reference is | |
23218 | |
23219 Barry Hayes. Ephemerons: A New Finalization Mechanism. | |
23220 OOPSLA 1997. 176--183 | |
23221 | |
23222 The idea is this: | |
23223 | |
23224 an ephemeron consists of a key and a value. Through the ephemeron, | |
23225 the key is not reachable. The value is only reachable if both the | |
23226 ephemeron is reachable and the key is reachable. If the ephemeron is | |
23227 reachable and the key becomes unreachable, the value slot of the | |
23228 ephemeron will be tombstoned, i.e. overwritten with NIL or something. | |
23229 | |
23230 This allows implementing, AFAICS, the other data structures involving | |
23231 weakness, such as weak hash tables and their various mutants. | |
23232 | |
23233 We're also planning to come up with a more comprehensive solution for | |
23234 finalization, but some design snags remain to be worked out. | |
23235 | |
23236 @node Discussion -- Glyphs, Discussion -- Dialog Boxes, Discussion -- Garbage Collection, Future Work Discussion | |
23237 @section Discussion -- Glyphs | |
22020 @cindex discussion, glyphs | 23238 @cindex discussion, glyphs |
22021 @cindex glyphs, discussion | 23239 @cindex glyphs, discussion |
22022 | 23240 |
22023 Some comments (not always pretty!) by Ben: | 23241 Some comments (not always pretty!) by Ben: |
22024 | 23242 |
22241 | 23459 |
22242 the problem with this and everything you've proposed is that there's no | 23460 the problem with this and everything you've proposed is that there's no |
22243 way, of course, to get at the actual widget that you were invoked from. | 23461 way, of course, to get at the actual widget that you were invoked from. |
22244 would you propose adding widget-callback-current-widget? | 23462 would you propose adding widget-callback-current-widget? |
22245 | 23463 |
22246 @node Discussion -- Dialog Boxes, Discussion -- Multilingual Issues, Discussion -- glyphs, Future Work Discussion | 23464 @node Discussion -- Dialog Boxes, Discussion -- Multilingual Issues, Discussion -- Glyphs, Future Work Discussion |
22247 @section Discussion -- Dialog Boxes | 23465 @section Discussion -- Dialog Boxes |
22248 @cindex discussion, dialog boxes | 23466 @cindex discussion, dialog boxes |
22249 @cindex dialog boxes, discussion | 23467 @cindex dialog boxes, discussion |
22250 | 23468 |
22251 @example | 23469 @example |
22641 -- | 23859 -- |
22642 Ben | 23860 Ben |
22643 | 23861 |
22644 @end example | 23862 @end example |
22645 | 23863 |
22646 @node Discussion -- Multilingual Issues, Discussion -- Windows External Widget, Discussion -- Dialog Boxes, Future Work Discussion | 23864 @node Discussion -- Multilingual Issues, Discussion -- Instantiators and Generic Property Accessors, Discussion -- Dialog Boxes, Future Work Discussion |
22647 @section Discussion -- Multilingual Issues | 23865 @section Discussion -- Multilingual Issues |
22648 @cindex discussion, multilingual issues | 23866 @cindex discussion, multilingual issues |
22649 @cindex multilingual issues, discussion | 23867 @cindex multilingual issues, discussion |
22650 | 23868 |
22651 @example | 23869 @example |
23498 | 24716 |
23499 | 24717 |
23500 | 24718 |
23501 @end example | 24719 @end example |
23502 | 24720 |
23503 @node Discussion -- Windows External Widget, Discussion -- Packages, Discussion -- Multilingual Issues, Future Work Discussion | 24721 @node Discussion -- Instantiators and Generic Property Accessors, Discussion -- Switching to C++, Discussion -- Multilingual Issues, Future Work Discussion |
24722 @section Discussion -- Instantiators and Generic Property Accessors | |
24723 @cindex discussion, instantiators and generic property accessors | |
24724 @cindex instantiators and generic property accessors, discussion | |
24725 | |
24726 From: Ben Wing <ben@@666.com> | |
24727 Date: Sun, 05 May 2002 05:40:07 -0700 | |
24728 Subject: generic functions, new instantiator API | |
24729 | |
24730 I've been reading the C++ manual and getting polymorphism, inheritance, | |
24731 generic functions, etc. in my head. | |
24732 | |
24733 We have our own "generic function" already in terms of `get', `put', | |
24734 etc. which accept various objects. i'm thinking of extending them so | |
24735 they can accept, as well as objects, lists (either alists or plists) | |
24736 or plist-style vectors, and manipulate their properties. what do | |
24737 people think of this? | |
24738 | |
24739 Also, i'm designing a new API for "instantiators", which are objects | |
24740 whose main purpose is to hold properties and provide a way of notifying | |
24741 their containing specifiers when they change. Instantiator objects are | |
24742 used when the instantiator gets sufficiently complicated that using | |
24743 lists and vectors gets unwieldy -- e.g. when creating widget trees, such | |
24744 as would appear in dialog boxes. you want the ability to | |
24745 programmatically traipse up and down the tree and dynamically modify a | |
24746 part of the tree -- e.g. a property on a single widget -- as necessary, | |
24747 and have the internal code automatically notice this change and performs | |
24748 any necessary updates. lists and vectors are too low-level for this -- | |
24749 no way to get their parent, no way for internal code to be notified when | |
24750 changes occur, can't always maintain object identity when making | |
24751 property changes, no way to error-check illegal changes, etc. | |
24752 | |
24753 You could also extend this api to cover toolbars; it would probably make | |
24754 toolbar manipulation significantly easier. but you'd have to think | |
24755 about backward compatibility in such cases. | |
24756 | |
24757 here is what the api looks like so far -- making use of a newly-added | |
24758 facility for keyword args in primitives. comments are welcome. | |
24759 | |
24760 @example | |
24761 DEFUN ("make-instantiator", Fmake_instantiator, 1, MANY, 0, /* | |
24762 Create a new instantiator object from TYPE and PROPS. | |
24763 TYPE should be one of the image instantiator formats described in | |
24764 `make-glyph'. | |
24765 The rest of the arguments should be keyword properties and associated | |
24766 values, | |
24767 as also described in `make-glyph'. | |
24768 | |
24769 TYPE can also be an old-style vector instantiator. | |
24770 | |
24771 Instantiator objects can be used as instantiators (see `make-specifier') in | |
24772 glyphs in place of old-style vector instantiators. They are especially | |
24773 used for complicated, nested graphical elements such as widgets (buttons, | |
24774 text fields, etc.) -- in fact, widget instantiators will automatically be | |
24775 converted into instantiator objects if they are given in vector format. | |
24776 | |
24777 Individual properties on instantiators can be manipulated using | |
24778 `set-instantiator-property'. If the property's value is a list (for | |
24779 example, a list of children), you can also use `add-instantiator-item' | |
24780 to add or insert individual elements in the list. | |
24781 | |
24782 `delete-instantiator-item' can be used to delete individual items in the | |
24783 list; | |
24784 `get-instantiator-item' to locate individual items in the list; and | |
24785 `get-instantiator-item-position' to return the position of individual | |
24786 items in | |
24787 the list. | |
24788 | |
24789 `map-instantiator' can be used to (recursively or not) map over an | |
24790 instantiator and its children. | |
24791 | |
24792 `find-instantiator' can be used to (recursively or not) locate an | |
24793 instantiator | |
24794 in a tree composed of an instantiator and its descendants. | |
24795 */ | |
24796 /* (type &rest props) */ | |
24797 (int nargs, Lisp_Object *args)) | |
24798 @{ | |
24799 /* ^^#### */ return Qnil; | |
24800 @} | |
24801 | |
24802 DEFUN ("set-instantiator-property", Fset_instantiator_property, 3, 3, 0, /* | |
24803 Set property PROP to VALUE in INSTANTIATOR. | |
24804 INSTANTIATOR should have been created with `make-instantiator'. | |
24805 Valid properties depend on the instantiator type and are described in | |
24806 `make-glyph'. For properties that are lists of items, individual items | |
24807 can be added or deleted using `add-instantiator-item' and | |
24808 `delete-instantiator-item'. | |
24809 | |
24810 For compatibility, this also accepts an old-style vector instantiator, and | |
24811 destructively modifies it; in this case, adding a property requires | |
24812 creating a new vector, which is returned. You need to use | |
24813 `set-glyph-image' on glyphs, or `set-specifier-dirty-flag' on the result of | |
24814 `glyph-image', to register instantiator changes to vector | |
24815 instantiators. (New-style instantiators automatically convey property | |
24816 changes to any glyphs they have been attached to.) | |
24817 */ | |
24818 (instantiator, prop, value)) | |
24819 @{ | |
24820 Lisp_Object *elt; | |
24821 int len; | |
24822 | |
24823 /* ^^#### */ | |
24824 CHECK_VECTOR (instantiator); | |
24825 if (!KEYWORDP (prop)) | |
24826 invalid_argument ("instantiator property must be a keyword", prop); | |
24827 | |
24828 elt = XVECTOR_DATA (instantiator); | |
24829 len = XVECTOR_LENGTH (instantiator); | |
24830 | |
24831 for (len -= 2; len >= 1; len -= 2) | |
24832 @{ | |
24833 if (EQ (elt[len], prop)) | |
24834 @{ | |
24835 elt[len + 1] = value; | |
24836 break; | |
24837 @} | |
24838 @} | |
24839 | |
24840 /* Didn't find it so add it. */ | |
24841 if (len < 1) | |
24842 @{ | |
24843 Lisp_Object alist = Qnil, result; | |
24844 struct gcpro gcpro1; | |
24845 | |
24846 GCPRO1 (alist); | |
24847 alist = tagged_vector_to_alist (instantiator); | |
24848 alist = Fcons (Fcons (prop, value), alist); | |
24849 result = alist_to_tagged_vector (elt[0], alist); | |
24850 free_alist (alist); | |
24851 RETURN_UNGCPRO (result); | |
24852 @} | |
24853 | |
24854 return instantiator; | |
24855 @} | |
24856 | |
24857 DEFUN ("instantiator-property", Finstantiator_property, 2, 3, 0, /* | |
24858 Return the property PROP of INSTANTIATOR, or DEFAULT if PROP has no value. | |
24859 INSTANTIATOR should have been created with `make-instantiator'. | |
24860 */ | |
24861 (instantiator, prop, default_)) | |
24862 @{ | |
24863 /* ^^#### */ return Qnil; | |
24864 @} | |
24865 | |
24866 DEFUN ("instantiator-properties", Finstantiator_properties, 1, 1, 0, /* | |
24867 Return a plist of all defined properties in INSTANTIATOR. | |
24868 INSTANTIATOR should have been created with `make-instantiator'. | |
24869 */ | |
24870 (instantiator)) | |
24871 @{ | |
24872 /* ^^#### */ return Qnil; | |
24873 @} | |
24874 | |
24875 DEFUN ("instantiator-type", Finstantiator_type, 1, 1, 0, /* | |
24876 Return the type of INSTANTIATOR. | |
24877 INSTANTIATOR should have been created with `make-instantiator'. | |
24878 Valid types are the instantiator formats described in `make-glyph'. | |
24879 */ | |
24880 (instantiator)) | |
24881 @{ | |
24882 /* ^^#### */ return Qnil; | |
24883 @} | |
24884 | |
24885 DEFUN ("instantiator-parent", Finstantiator_parent, 1, 1, 0, /* | |
24886 Return the parent of INSTANTIATOR. | |
24887 INSTANTIATOR should have been created with `make-instantiator'. | |
24888 */ | |
24889 (instantiator)) | |
24890 @{ | |
24891 /* ^^#### */ return Qnil; | |
24892 @} | |
24893 | |
24894 DEFUN_WITH_KEYWORDS ("map-instantiator", Fmap_instantiator, 2, 2, 1, 0, | |
24895 0, /* | |
24896 Map FUN recursively over INSTANTIATOR and its descendants. | |
24897 FUN is called with one argument, the INSTANTIATOR. | |
24898 If:norecurse is non-nil, don't recurse, just map over the direct | |
24899 children (not including the instantiator itself). | |
24900 */ | |
24901 (fun, instantiator), | |
24902 (norecurse)) | |
24903 @{ | |
24904 /* ^^#### */ return Qnil; | |
24905 @} | |
24906 | |
24907 DEFUN_WITH_KEYWORDS ("find-instantiator", Ffind_instantiator, 3, 3, | |
24908 1, 0, 0, /* | |
24909 Find an instantiator by PROP and VALUE in INSTANTIATOR and its descendants. | |
24910 Returns first item which has PROP set to VALUE. | |
24911 If:norecurse is non-nil, don't recurse, just look through the direct | |
24912 children (not including the instantiator itself). | |
24913 */ | |
24914 (instantiator, prop, value), | |
24915 (norecurse)) | |
24916 @{ | |
24917 /* ^^#### */ return Qnil; | |
24918 @} | |
24919 | |
24920 DEFUN_WITH_KEYWORDS ("add-instantiator-item", Fadd_instantiator_item, 3, | |
24921 3, 7, | |
24922 0, 0, /* | |
24923 Add an item to an instantiator property that's a list of items. | |
24924 \(E.g. the children of an instantiator). PROP is the property whose list of | |
24925 items is being modified, and ITEM is the item to add. To insert somewhere | |
24926 before the end, use one of the keywords: | |
24927 | |
24928 --:position specifies a zero-based index of an item, and the new item | |
24929 will be | |
24930 inserted just before the item indicated by the position. Negative numbers | |
24931 count from the end -- thus -1 will cause insertion before the last item, -2 | |
24932 before the second-to-last item, etc. | |
24933 | |
24934 --:before-item and :after-item specify items to insert before or after. | |
24935 :test (defaults to `eq') can be used to specify the way to compare the given | |
24936 item with existing items. | |
24937 | |
24938 --:before-property and :after-property search for an item to insert | |
24939 before or | |
24940 after by looking for an item with the given property. If :value is | |
24941 given, the | |
24942 property must have that value; otherwise, it simply must exist. This method | |
24943 of insertion works if the items in PROP's list are anything that can have or | |
24944 hold properties. \("To have and to hold, for ever and ever ...") This | |
24945 includes: | |
24946 | |
24947 -- any object for which `get' works | |
24948 -- else, if object is a vector, assume it's a plist-style vector | |
24949 -- else, if object is a cons, and its first element is also a cons, | |
24950 assume it's an alist | |
24951 -- else, if object is a cons, assume it's a plist | |
24952 */ | |
24953 (instantiator, prop, item), | |
24954 (position, before_item, after_item, test, | |
24955 before_property, after_property, value)) | |
24956 @{ | |
24957 /* ^^#### */ return Qnil; | |
24958 @} | |
24959 | |
24960 DEFUN_WITH_KEYWORDS ("delete-instantiator-item", Fdelete_instantiator_item, | |
24961 2, 2, 5, 0, 0, /* | |
24962 Delete an item in an instantiator property that's a list of items. | |
24963 | |
24964 \(E.g. the children of an instantiator). PROP is the property whose list is | |
24965 being searched. One of these keywords should be given: | |
24966 | |
24967 --:position specifies a zero-based index of an item. Negative numbers | |
24968 count from the end -- thus -1 will cause insertion before the last item, -2 | |
24969 before the second-to-last item, etc. | |
24970 | |
24971 --:item specifies the item to delete. :test (defaults to `eq') can be | |
24972 used to | |
24973 specify the way to compare the given item with existing items. | |
24974 | |
24975 --:property searches for an item with the given property. If :value is | |
24976 given, the property must have that value; otherwise, it simply must exist. | |
24977 This method of insertion works if the items in PROP's list are anything that | |
24978 can have or hold properties -- see `add-instantiator-item'. | |
24979 */ | |
24980 (instantiator, prop), | |
24981 (item, test, position, property, value)) | |
24982 @{ | |
24983 /* ^^#### */ return Qnil; | |
24984 @} | |
24985 | |
24986 DEFUN_WITH_KEYWORDS ("get-instantiator-item", Fget_instantiator_item, | |
24987 2, 2, 3, 0, 0, /* | |
24988 Get an item in an instantiator property that's a list of items. | |
24989 | |
24990 \(E.g. the children of an instantiator). PROP is the property whose list is | |
24991 being searched. One of these keywords should be given: | |
24992 | |
24993 --:position specifies a zero-based index of an item. Negative numbers | |
24994 count | |
24995 from the end -- thus -1 will cause insertion before the last item, -2 before | |
24996 the second-to-last item, etc. | |
24997 | |
24998 --:property searches for an item with the given property. If :value is | |
24999 given, the property must have that value; otherwise, it simply must exist. | |
25000 This method of insertion works if the items in PROP's list are anything that | |
25001 can have or hold properties -- see `add-instantiator-item'. | |
25002 */ | |
25003 (instantiator, prop), | |
25004 (position, property, value)) | |
25005 @{ | |
25006 /* ^^#### */ return Qnil; | |
25007 @} | |
25008 | |
25009 DEFUN_WITH_KEYWORDS ("get-instantiator-item-position", | |
25010 Fget_instantiator_item_position, | |
25011 2, 2, 4, 0, 0, /* | |
25012 Return an item's position in an instantiator property that's a list of | |
25013 items. | |
25014 | |
25015 \(E.g. the children of an instantiator). PROP is the property whose list is | |
25016 being searched. One of these keywords should be given: | |
25017 | |
25018 --:item specifies the item to search for. :test (defaults to `eq') can be | |
25019 used to specify the way to compare the given item with existing items. | |
25020 | |
25021 --:property searches for an item with the given property. If :value is | |
25022 given, the property must have that value; otherwise, it simply must exist. | |
25023 This method of insertion works if the items in PROP's list are anything that | |
25024 can have or hold properties -- see `add-instantiator-item'. | |
25025 */ | |
25026 (instantiator, prop), | |
25027 (item, test, property, value)) | |
25028 @{ | |
25029 /* ^^#### */ return Qnil; | |
25030 @} | |
25031 | |
25032 DEFUN ("image-instance-instantiator", Fimage_instance_instantiator, 1, | |
25033 1, 0, /* | |
25034 Return the instantiator from which IMAGE-INSTANCE was created. | |
25035 */ | |
25036 (image_instance)) | |
25037 @{ | |
25038 /* ^^#### */ return Qnil; | |
25039 @} | |
25040 @end example | |
25041 | |
25042 some other useful stuff: | |
25043 | |
25044 @example | |
25045 DEFUN ("make-image-instance", Fmake_image_instance, 1, 4, 0, /* | |
25046 Return a new `image-instance' object. | |
25047 | |
25048 Image-instance objects encapsulate the way a particular glyph (pixmap, | |
25049 widget, etc.) is displayed on a particular device. In most circumstances, | |
25050 you do not need to directly create image instances; instead, you create a | |
25051 glyph using `make-glyph' and add settings (or "instantiators") onto it | |
25052 using `set-glyph-image', and XEmacs creates the image instances as | |
25053 necessary. However, it may occasionally be useful to explicitly create | |
25054 image instances, if you want more control over the instantiation process. | |
25055 | |
25056 For more information on instantiators and instances, see `make-specifier'. | |
25057 | |
25058 DATA is an image instantiator, which describes the image; see `make-glyph' | |
25059 for a description of the allowed values. | |
25060 | |
25061 The most likely circumstance where you need to deal directly with image | |
25062 instances is in widget callbacks -- e.g. the callback that's executed when | |
25063 a button is pressed in a dialog box of type `general' (see | |
25064 `make-dialog-box'). In this case, the widget that was activated is | |
25065 described by an image instance. (The callback is usually be written as an | |
25066 interactive function with an interactive spec of (interactive \"e\"), and a | |
25067 single `event' argument. The event will be an activate event, describing | |
25068 the user action that trigged the callback. The image instance is | |
25069 retrievable from the event using `event-image-instance'. Handling the | |
25070 action may involve setting properties on the image instance or other image | |
25071 instances in the dialog box in which the widget is usually contained -- or | |
25072 changing the instantiator that generated the image instance, if you want | |
25073 permanent changes that will be reflected the next time the dialog box is | |
25074 popped up. Properties on an image instance are set using | |
25075 `set-image-instance-property'. If the widget is part of a hierarchy of | |
25076 widgets (as is usually the case in a dialog box, but may not apply if the | |
25077 widget was inserted by itself in a buffer [by creating a glyph and | |
25078 attaching it to an extent -- see `make-glyph']), there will be a | |
25079 corresponding hierarchy of image instances to describe this particular | |
25080 instance of the dialog box. You can retrieve other image instances in the | |
25081 hierarchy using primitives such as `image-instance-parent', | |
25082 `image-instance-children', and `find-image-instance'. | |
25083 @end example | |
25084 | |
25085 ... | |
25086 | |
25087 | |
25088 | |
25089 | |
25090 | |
25091 @example | |
25092 (defun image-instance-property (image-instance property &optional default) | |
25093 "Return the given property of the given image instance. | |
25094 Returns DEFAULT if the property or the property method do not exist for | |
25095 the image instance in the domain." | |
25096 (check-argument-type 'image-instance-p image-instance) | |
25097 (get image-instance property default)) | |
25098 | |
25099 (defun set-image-instance-property (image-instance prop value) | |
25100 "Set the property PROP on IMAGE-INSTANCE to VALUE. | |
25101 Only certain properties of the image instance can be changed, and they | |
25102 represent \"temporary\" changes. If you want to make permanent changes, | |
25103 you need to change the instantiator that generated the instance -- | |
25104 retrieve the instantiator with `image-instance-instantiator', and change | |
25105 its properties with `set-instantiator-property'. | |
25106 | |
25107 This applies mostly to widgets. For example, you can set a property on | |
25108 a widget image instance to change the state of a radio or checkbox button, | |
25109 set the text currently in an edit field, etc. However, those changes apply | |
25110 only to the *currently* displayed widgets. If these widgets are in a dialog | |
25111 box, and you want to change the way the widgets in the dialog box appear | |
25112 *each* time the dialog box is displayed, you need to change the | |
25113 instantiator. | |
25114 | |
25115 Make sure you understand the difference between instantiators and | |
25116 instances. An \"instantiator\" is a specification, indicating how to | |
25117 determine the value of a setting whose value can vary in different | |
25118 circumstances or \"locales\" (buffers, frames, etc.). An \"instance\" | |
25119 is the | |
25120 resulting value in a particular circumstance. For more information, see | |
25121 `make-specifier'." | |
25122 (check-argument-type 'image-instance-p image-instance) | |
25123 (put image-instance prop value)) | |
25124 @end example | |
25125 | |
25126 From: "Stephen J. Turnbull" <stephen@@xemacs.org> | |
25127 Date: 06 May 2002 16:40:46 +0900 | |
25128 | |
25129 >>>>> "Ben" == Ben Wing <ben@@666.com> writes: | |
25130 | |
25131 Ben> We have our own "generic function" already in terms of `get', | |
25132 Ben> `put', etc. which accept various objects. | |
25133 | |
25134 I proposed extending the class to stuff like charsets about two years | |
25135 ago, and I think you were one of the folks who objected. | |
25136 | |
25137 Ben> i'm thinking of extending them so they can accept lists | |
25138 Ben> (either alists or plists) or plist-style vectors, and | |
25139 Ben> manipulate their properties. what do people think of this? | |
25140 | |
25141 I think extending to lists is something we should approach | |
25142 cautiously. For one thing, if "get" is polymorphic, "put" would have | |
25143 to be too. But how does it decide when dealing with "nil"? | |
25144 | |
25145 Ben> you want the ability to programmatically traipse up and down | |
25146 Ben> the tree and dynamically modify a part of the tree -- e.g. a | |
25147 Ben> property on a single widget -- as necessary, and have the | |
25148 Ben> internal code automatically notice this change and performs | |
25149 Ben> any necessary updates. | |
25150 | |
25151 I like this. | |
25152 | |
25153 From: "Stephen J. Turnbull" <stephen@@xemacs.org> | |
25154 Date: 07 May 2002 11:17:05 +0900 | |
25155 | |
25156 >>>>> "Neal" == Neal D Becker <nbecker@@hns.com> writes: | |
25157 | |
25158 Neal> I thought that generic polymorphism was inherent in lisp, as | |
25159 Neal> it is dynamically evaluated. Why would you need anything | |
25160 Neal> special in the way functions are written to support generic | |
25161 Neal> programming? | |
25162 | |
25163 I think it's basically a technical matter. We have a number of | |
25164 objects that have property lists besides symbols. Many of them have | |
25165 special functions (coding-system-get, coding-system-property, | |
25166 charset-property are examples I find particularly obnoxious). I would | |
25167 like to make these obsolete by allowing `get' on charsets, coding | |
25168 systems, etc. | |
25169 | |
25170 And currently we have | |
25171 | |
25172 (let ((p (symbol-plist symbol))) (plist-get p prop)) | |
25173 | |
25174 Ben would like to allow | |
25175 | |
25176 (let ((p (symbol-plist symbol))) (get p prop)) | |
25177 | |
25178 with `get' determining whether P is a plist or an alist. And where | |
25179 Michael says "why not use hash tables?", I see `(get hash key)' | |
25180 (probably to Michael's horror ;-). | |
25181 | |
25182 This isn't Lisp any more, though, in some sense. But then we haven't | |
25183 been that for years. AFAIK all real Lisps restrict `get' to symbols. | |
25184 | |
25185 From: sperber@@informatik.uni-tuebingen.de (Michael Sperber [Mr. Preprocessor]) | |
25186 Date: Tue, 07 May 2002 08:52:53 +0200 | |
25187 | |
25188 Indeed. I'll just say "goosebumps." But I don't see why it has to be | |
25189 GET that accesses the plist. You just build more dispatch into GET | |
25190 with no immediate benefit to the API. Ad-hoc genericity gets you | |
25191 something when there's some place in the code you don't know what the | |
25192 underlying object is. I don't see this being the case here. Why do | |
25193 you find them "obnoxious?" | |
25194 | |
25195 Stephen> This isn't Lisp any more, though, in some sense. But then we haven't | |
25196 Stephen> been that for years. AFAIK all real Lisps restrict `get' to symbols. | |
25197 | |
25198 Actually, Scheme (which admittedly isn't a real Lisp by many | |
25199 standards) doesn't have get/put at all. And good riddance, I might | |
25200 add:-) | |
25201 | |
25202 From: "Stephen J. Turnbull" <stephen@@xemacs.org> | |
25203 Date: 07 May 2002 20:04:50 +0900 | |
25204 | |
25205 >>>>> "ms" == Michael Sperber <sperber@@informatik.uni-tuebingen.de> writes: | |
25206 | |
25207 Stephen> special functions (coding-system-get, coding-system-property, | |
25208 Stephen> charset-property are examples I find particularly obnoxious). I would | |
25209 Stephen> like to make these obsolete by allowing `get' on charsets, coding | |
25210 Stephen> systems, etc. | |
25211 | |
25212 ms> But I don't see why it has to be GET that accesses the plist. | |
25213 ms> You just build more dispatch into GET with no immediate | |
25214 ms> benefit to the API. Ad-hoc genericity gets you something when | |
25215 ms> there's some place in the code you don't know what the | |
25216 ms> underlying object is. I don't see this being the case here. | |
25217 ms> Why do you find them "obnoxious?" | |
25218 | |
25219 Their semantics are basically `get'. Why not use that name? Of | |
25220 course I agree that it doesn't have to be `get', but why clutter | |
25221 things up? | |
25222 | |
25223 But those are particularly obnoxious because of the object/name | |
25224 confusion they have built in. Ie, my real problem with them is more | |
25225 ancient Mule idiom than the *-get or *-property names for the API. | |
25226 | |
25227 ms> Actually, Scheme (which admittedly isn't a real Lisp by many | |
25228 ms> standards) doesn't have get/put at all. | |
25229 | |
25230 What does it use instead? (And no, you can't bait _me_ with Lisp | |
25231 definition trolls, I think of XML as "declarative LISP with fat, | |
25232 flavored, fuzzy parentheses.") | |
25233 | |
25234 From: sperber@@informatik.uni-tuebingen.de (Michael Sperber [Mr. Preprocessor]) | |
25235 Date: Tue, 07 May 2002 13:26:13 +0200 | |
25236 | |
25237 Stephen> Their semantics are basically `get'. Why not use that name? | |
25238 | |
25239 Because it doesn't convey as much information in the source code as it | |
25240 could, and because it provides less type checking than it could. | |
25241 | |
25242 Stephen> What does it use instead? | |
25243 | |
25244 What for? I've never felt the desire to use them, and it seems to me | |
25245 that in Lisp, properties are usually used for one of two purposes: | |
25246 | |
25247 - As a poor man's replacement for hash tables. | |
25248 | |
25249 - To store data which should really be stored inside the object | |
25250 itself. | |
25251 | |
25252 In the former case, I use a hash table. In the latter case, I store | |
25253 the data in the object itself. | |
25254 | |
25255 @node Discussion -- Switching to C++, Discussion -- Windows External Widget, Discussion -- Instantiators and Generic Property Accessors, Future Work Discussion | |
25256 @section Discussion -- Switching to C++ | |
25257 @cindex discussion, switching to c++ | |
25258 @cindex switching to c++, discussion | |
25259 | |
25260 From: "Ben Wing" <ben@@666.com> | |
25261 Date: Fri, 10 May 2002 19:42:53 -0700 | |
25262 | |
25263 i know i'm opening up a bag of worms by suggesting this, but what | |
25264 about moving to C++? I know others advocate this (Jan, Martin), and | |
25265 the more I read Stroustrup's 3rd edition, the more I realize that | |
25266 *HUGE* armounts of code in XEmacs, and in particular most of the | |
25267 really hairy and hard-to-understand stuff -- lots of weird macros, | |
25268 faux object-oriented stuff implemented in multiple places, each | |
25269 differently (Lisp objects; methods on consoles/devices/etc; specifier | |
25270 sub-types; coding-system sub-types; image-instance device methods; | |
25271 image-instance format methds; etc.), all the GCPROS (which could go | |
25272 entirely), dynarrs, eistring, etc. etc. -- is simply superseded by | |
25273 stuff already built into C++ or supplied by the standard libraries. | |
25274 Just now, I was going through the redisplay code, and noticing the | |
25275 huge amount of duplication between gtk and X, something that's hard to | |
25276 fix [except through super ad-hoc ways like using a .c file as a .h | |
25277 file to "generate" lots of similar but slightly different code] in C, | |
25278 but is extremely easy in C++ using inheritance [and/or templates]. | |
25279 for example, instead of having just one layer of device methods, you'd | |
25280 have | |
25281 | |
25282 @example | |
25283 general -> tty | |
25284 -> windowing -> mswindows | |
25285 -> xlike -> x, gtk | |
25286 @end example | |
25287 | |
25288 which would nicely and naturally encapsulate lots of duplicated [and | |
25289 thus, hard to maintain] code. | |
25290 | |
25291 even more of a win would be the GCPRO's. Taking advantage of | |
25292 constructors and destructors, we could simply do away [COMPLETELY!] | |
25293 with explicitly gcproing, and still have everything gcpro'd. [in fact, | |
25294 much more reliably -- none of the dreaded "temporary" problem, and | |
25295 every reference is always gcpro'd so we have greater flexibility for | |
25296 GC work -- take note, Michael :-) -- e.g. we could safely garbage | |
25297 collect when allocating, and we could even implement a relocating | |
25298 garbage collector. in the few places where performance might be an | |
25299 issue [i seriously doubt there'd be many of them], we simply use a | |
25300 separate Lisp_Object_No_GCPRO class (presumably a base class of | |
25301 Lisp_Object), and manually handle the GCPRO's ourselves. If we needed | |
25302 to distinguish here between static and dynamic objects, or static | |
25303 vs. local vs. heap, we could do so easily with bit flags in the object | |
25304 pointed to -- we have space for lots of them. | |
25305 | |
25306 code reliablity and maintainability would likely substantially | |
25307 increase due to the ability to express most things in a natural C++ | |
25308 way instead of lots of weird hackish hard-to-understand C stuff | |
25309 implementing stuff the language wasn't really designed for. | |
25310 Furthermore, there are even some possibilities for increased speed -- | |
25311 many operations that can only reasonably be done now using Lisp | |
25312 objects (and the associated gc overhead and such) could be done using | |
25313 the high-level built-in facilities of C++, which in their ease of use | |
25314 approach Lisp; and C++ has `inline' built-in, so we could easily add | |
25315 various container classes to improve the understandability of the code | |
25316 without loss of performance. | |
25317 | |
25318 finally, making the "switch" is trivial, since martin did the initial | |
25319 work making XEmacs C++-safe and I've been keeping it that way -- I | |
25320 regularly build under C++ and fix any problems. All we'd need to do | |
25321 is switch the compiler and start gradually introducing C++ constructs | |
25322 as we feel like it. | |
25323 | |
25324 for those concerned that dumping might stop working, [a] i don't think | |
25325 it would, [b] the portable dumper has come of age -- i use it almost | |
25326 all the time, and it's rock-solid and not obviously slower than | |
25327 unexec. | |
25328 | |
25329 the only major concern that i see is the quality of the C++ | |
25330 implementations out there, in particular G++, which is the most widely | |
25331 available. I know that 6 years ago G++ was a bit rocky -- I went to | |
25332 interview for Netscape, and they mentioned having to rely on various | |
25333 vendor implementations of C++, whereas they would have preferred G++ | |
25334 if it was reliable, due to the sameness of environment. But that was | |
25335 *SIX YEARS* ago! Stroustrup 3rd Edition has been out for 5 years now, | |
25336 and it defines, as far as I know, ANSI Standard C++ -- so that's at | |
25337 least 5 years to implement a standard. It's hard to believe that G++ | |
25338 isn't completely reliable now; but I do not have as much experience as | |
25339 others. | |
25340 | |
25341 What do you think? I would *really* like to make this change, as it | |
25342 would immensely facilitate lots of code I'm working on and will be | |
25343 working on, plus of course add all the above benefits once we get | |
25344 around to converting the code. | |
25345 | |
25346 From: "Stephen J. Turnbull" <stephen@@xemacs.org> | |
25347 Date: 11 May 2002 15:34:08 +0900 | |
25348 | |
25349 I don't have a real problem with it, as long as we're very | |
25350 conservative about it, ie, using C++ as "clean C with classes", and | |
25351 introducing things slowly. Implement everything ourselves, avoid the | |
25352 standard class libraries. | |
25353 | |
25354 I've been following the Python lists recently, and although the bias | |
25355 is easy to guess, it's interesting to note that the people who are | |
25356 most anti-C++ are typically the ones who are world-class C++ | |
25357 programmers with big projects under their belts. Many of them | |
25358 actually advocate using C rather than C++. | |
25359 | |
25360 I do worry that with Martin currently out of the picture we don't have | |
25361 an active C++ standards bigot and implementation collector to deal | |
25362 with compiler-specific issues. We do OK with C, but C++ is a much | |
25363 more complex, subtle language. Is there anybody else to plausibly | |
25364 take on that role? | |
25365 | |
25366 From: Hrvoje Niksic <hniksic@@arsdigita.com> | |
25367 Date: Sun, 12 May 2002 20:58:50 +0200 | |
25368 | |
25369 I'm strongly opposed to this. Here are some reasons: | |
25370 | |
25371 * C++ may fix some problems, but it will introduce others, some of | |
25372 which may be much harder to fix. XEmacs is already a large program, | |
25373 hard to understand. C++ will not improve things. | |
25374 | |
25375 * XEmacs will suddenly become uncompilable and unusable in | |
25376 many environments where it used to build perfectly fine -- for | |
25377 example, those that don't ship with a C++ compiler at all. We could | |
25378 "make GCC 3 a requirement", but I don't like that idea. | |
25379 | |
25380 * People without C++ experience will no longer be able to hack XEmacs. | |
25381 I'd be the first one to leave. For example, I know quite a few | |
25382 programmers who don't care for Qt and KDE simply because it's C++. | |
25383 | |
25384 * C is the /lingua franca/ of free software development. If we're | |
25385 switching languages, it should be for a good reason and to something | |
25386 we agree is an improvement (e.g. Common Lisp). | |
25387 | |
25388 * C++ is not the be-all end-all to everything. People who undestand | |
25389 it well are usually the first ones to warn against it. It's | |
25390 possible that they were scarred by using C++ at a bad time, but I'd | |
25391 think twice before discounting their advice or blindly believing | |
25392 that C++ is now all better. | |
25393 | |
25394 If you were writing a new project, I'd say go for it. But at this | |
25395 point, this seems like a needless tweak. Do we really need *more* | |
25396 internal reorganizations? Shouldn't we work on user-visible features? | |
25397 Wasn't that what you yourself advocated when I talked to you? | |
25398 | |
25399 From: Didier Verna <didier@@xemacs.org> | |
25400 Date: Tue, 14 May 2002 11:21:32 +0200 | |
25401 | |
25402 Switching to C++ has been suggested for the first time at the M17n'99 | |
25403 conference in Japan IIRC. Although it was around a table with many empty | |
25404 bottles of beer on it :-), I've kept some hope from that time. I'm happy to | |
25405 see Ben in favor of this today. This idea coming from him is likely to have | |
25406 more impact than when it comes from me or Yan of whoever else. | |
25407 | |
25408 There are several points that make me in favor of this change: | |
25409 | |
25410 - C++ support is already there thanks to Martin. | |
25411 | |
25412 - The amount of OO simulation code written in C in XEmacs is *HUGE*. But more | |
25413 important, this code simulates *BASIC* OO features that are not any more a | |
25414 problem for any C++ compiler. I mean, by just using the basic features of | |
25415 C++ in terms of OO and data abstraction (classes, inheritance, methods (with | |
25416 inlining), operators overloading), we'll win big time in code size, | |
25417 readability, maintainability, and correctness. | |
25418 | |
25419 - the fact that *basic* OO support is already a major gain is very important | |
25420 to me. You don't have to go generic programming with templates everywhere to | |
25421 write an OO XEmacs[1]. Switching to C++ can be completely gradual, and we | |
25422 can even stop early in the C++ features we use. That will already be a big | |
25423 gain. That's also the advantage over the idea of using another more modern | |
25424 language to rewrite the core; something completely unrealistic. | |
25425 | |
25426 - there is another important aspect on the design issue: many people | |
25427 (including from the industry) have worked on abstracting common problems in | |
25428 an OO philosophy. Some people claim that the concepts that emerged from this | |
25429 kind of work of just C++ specific hackery, and they're probably right, but | |
25430 anyway that's obviously not a problem for us. Any C++ writer should have the | |
25431 "Design Patterns" book in hand. It already has good design solutions for | |
25432 many problems that we're facing in XEmacs (like, supporting more than one | |
25433 widget set), because these problems are so *common*. By using C++ we can | |
25434 directly benefit from the experience of other large applications designers. | |
25435 | |
25436 | |
25437 Footnotes: | |
25438 [1] We're working on GP in C++ in our lab here and we trigger bugs in gcc 3. | |
25439 But you should see the code in question, it's pure template and static | |
25440 programming. Things that XEmacs will never need. | |
25441 | |
25442 From: Daniel Pittman <daniel@@rimspace.net> | |
25443 Date: Sat, 11 May 2002 19:15:04 +1000 | |
25444 | |
25445 I've been following the Python lists recently, and although the bias | |
25446 > is easy to guess, it's interesting to note that the people who are | |
25447 > most anti-C++ are typically the ones who are world-class C++ | |
25448 > programmers with big projects under their belts. Many of them | |
25449 > actually advocate using C rather than C++. | |
25450 | |
25451 I wouldn't class myself as "world-class", but I can understand this | |
25452 perspective based on my experiences with large projects that aim for | |
25453 portability to vendor compilers, not just gcc. | |
25454 | |
25455 The biggest problem, assuming that you are willing to ignore platforms | |
25456 like Sinix-PC[1] and their poor compiler support[2] is that it's easy to | |
25457 shoot yourself in the foot with C++. | |
25458 | |
25459 | |
25460 The biggest portability problems are namespaces, the standard C++ | |
25461 library and template support, in about that order, followed by exception | |
25462 handling. | |
25463 | |
25464 Very few things get namespaces right, even today, with gcc being one of | |
25465 the worst. Tempting as they are, they are best avoided where possible, | |
25466 except in compiler and platform specific code.[3] | |
25467 | |
25468 | |
25469 The standard C++ library, which supports RTTI and a few other things | |
25470 including the [io]stream tools, is less than totally reliable although | |
25471 it can be used with relative safety most places. | |
25472 | |
25473 What you really need to watch out for with that is the extensions that | |
25474 every vendor in the universe has added to their collections because | |
25475 there isn't any standard way of doing common things in most of these | |
25476 areas. | |
25477 | |
25478 | |
25479 The Standard Template Library isn't. Aside from a tendency to expose | |
25480 limitations of symbol name lengths[4] the library tends to be unreliable | |
25481 in behavior between compilers and platforms. Not enough to make simple | |
25482 things fail, though, just enough to make it occasionally do odd things | |
25483 or show up obscure bugs in your code... | |
25484 | |
25485 It's also not very well designed, I think, as libraries go. That's a | |
25486 personal opinion, though, and not universal. | |
25487 | |
25488 | |
25489 C++ exceptions are an interesting issue. They can work extremely well as | |
25490 a mechanism for managing errors and improve the reliability of the | |
25491 system. | |
25492 | |
25493 They can also become an unending nightmare of epic proportions, causing | |
25494 more pain and suffering than you can imagine. :/ | |
25495 | |
25496 The main difference between the two situations, so far as I can tell, | |
25497 comes from two aspects of design that have ... far reaching | |
25498 implications. | |
25499 | |
25500 If you try adding exceptions to code that isn't ready to deal with them, | |
25501 things tend to go very badly wrong. I /think/ that the existing | |
25502 exception mechanisms in XEmacs would be similar enough that this isn't | |
25503 the case, though. | |
25504 | |
25505 The other is that you need to base your code very strongly around the | |
25506 "construction acquires, destruction releases" model of resource | |
25507 handling. This, of course, implies using exceptions everywhere because | |
25508 you /can't/ use that model in C++ without them.[5] | |
25509 | |
25510 Again, I think that the existing XEmacs model will probably work well | |
25511 with this, but I am hardly an expert at either; my only real-world | |
25512 experience is the one project where I gained these impressions and the | |
25513 knowledge of the suffering they can bring. :) | |
25514 | |
25515 | |
25516 Oh, and finally, watch out for operator overloading -- including casts. | |
25517 These are very easy to abuse into a position where your code is | |
25518 impossible for others to understand. | |
25519 | |
25520 I would also advocate avoiding multiple inheritance, but that's because | |
25521 my personal design experience says that it's almost always a sign of bad | |
25522 design. Views there vary greatly. | |
25523 | |
25524 > I do worry that with Martin currently out of the picture we don't have | |
25525 > an active C++ standards bigot and implementation collector to deal | |
25526 > with compiler-specific issues. | |
25527 | |
25528 You probably have more need of the second than the first. There are not | |
25529 many things you actually need a standards bigot for; just write good C | |
25530 and don't use too many things other than classes. | |
25531 | |
25532 > We do OK with C, but C++ is a much more complex, subtle language. | |
25533 | |
25534 C with classes, or the limited subset of C++ that doesn't include | |
25535 templates, exceptions or RTTI is not much more complex than standard C. | |
25536 | |
25537 If you add exceptions to that you will probably not notice anything but | |
25538 a syntax change in the core, given their current standing. Er, they | |
25539 probably don't work right in signal handlers, though, because they don't | |
25540 know anything about them.[6] | |
25541 | |
25542 > Is there anybody else to plausibly take on that role? | |
25543 | |
25544 I would be happy to look at things that were publicly discussed on the | |
25545 topic but I don't think I have the experience or the knowledge of the | |
25546 XEmacs development process to do anything more than that. | |
25547 | |
25548 Not, I imagine, that anyone would ask. :) | |
25549 | |
25550 Daniel | |
25551 | |
25552 Footnotes: | |
25553 [1] Archaic Unix ported to i386 from a minicomputer over a decade ago. | |
25554 | |
25555 [2] The vendor C++ would segfault on anything that had multiple | |
25556 inheritance. :) | |
25557 | |
25558 [3] I found them invaluable in resolving a few Win9x vn WinNT symbol | |
25559 conflicts, for example, but that's obviously target-specific. | |
25560 | |
25561 [4] The current record for STL-generated name length that I have seen | |
25562 is a symbol 892 characters long... | |
25563 | |
25564 [5] The lack of a return code from a class constructor is the killer | |
25565 issue here. | |
25566 | |
25567 [6] This, I believe, varies from vendor to vendor. :) | |
25568 | |
25569 | |
25570 @node Discussion -- Windows External Widget, Discussion -- Packages, Discussion -- Switching to C++, Future Work Discussion | |
23504 @section Discussion -- Windows External Widget | 25571 @section Discussion -- Windows External Widget |
23505 @cindex discussion, windows external widget | 25572 @cindex discussion, windows external widget |
23506 @cindex windows external widget, discussion | 25573 @cindex windows external widget, discussion |
23507 | 25574 |
23508 @example | 25575 @example |
23521 1 | 25588 1 |
23522 | 25589 |
23523 | 25590 |
23524 | 25591 |
23525 | 25592 |
23526 Nothing is currently done for external widget support under XEmacs but it should | 25593 Nothing is currently done for external widget support under XEmacs but |
23527 not be too hard to do and would be a great addition to XEmacs. What you would | 25594 it should not be too hard to do and would be a great addition to |
23528 probably want to do is create an XEmacs control that has an interface something | 25595 XEmacs. What you would probably want to do is create an XEmacs control |
23529 like the built-in edit control and which communicates to an existing XEmacs | 25596 that has an interface something like the built-in edit control and |
23530 process using DDE. (Basically you would modify XEmacs so that it registered | 25597 which communicates to an existing XEmacs process using DDE. (Basically |
23531 itself as a DDE server accepting external widget requests, and then the external | 25598 you would modify XEmacs so that it registered itself as a DDE server |
23532 edit control would simply send a DDE request and the result would be a handle of | 25599 accepting external widget requests, and then the external edit control |
23533 some sort used for future communication with that particular XEmacs process.) | 25600 would simply send a DDE request and the result would be a handle of |
23534 | 25601 some sort used for future communication with that particular XEmacs |
23535 There are two basic issues in getting the external widget to work, which are | 25602 process.) |
23536 display and input. Although I am not completely sure, I have a feeling that it | 25603 |
23537 is possible for one process to write into the window of another process, simply | 25604 There are two basic issues in getting the external widget to work, |
23538 by using that window's HWND handle. If so it should be extremely easy to get the | 25605 which are display and input. Although I am not completely sure, I have |
23539 output working (this is exactly the approach used under Xt). For input, you | 25606 a feeling that it is possible for one process to write into the window |
23540 would probably again want to do what is done under Xt, which is that the client | 25607 of another process, simply by using that window's HWND handle. If so |
23541 widget simply passes all of the appropriate messages to the XEmacs server | 25608 it should be extremely easy to get the output working (this is exactly |
23542 process using whatever communication channel was set up, e.g. DDE, and the | 25609 the approach used under Xt). For input, you would probably again want |
23543 XEmacs server processes them normally. Very few modifications would be needed to | 25610 to do what is done under Xt, which is that the client widget simply |
23544 the XEmacs source code and all of the necessary modifications could be done | 25611 passes all of the appropriate messages to the XEmacs server process |
23545 simply by looking for existing external widget code in XEmacs. | 25612 using whatever communication channel was set up, e.g. DDE, and the |
23546 | 25613 XEmacs server processes them normally. Very few modifications would be |
23547 If you are interested in continuing this, I will certainly give you any support | 25614 needed to the XEmacs source code and all of the necessary |
23548 you need along the way. This would be a great project to be added to XEmacs. | 25615 modifications could be done simply by looking for existing external |
25616 widget code in XEmacs. | |
25617 | |
25618 If you are interested in continuing this, I will certainly give you | |
25619 any support you need along the way. This would be a great project to | |
25620 be added to XEmacs. | |
23549 | 25621 |
23550 | 25622 |
23551 | 25623 |
23552 Timothy Fowler wrote: | 25624 Timothy Fowler wrote: |
23553 | 25625 |