File: elib.texi

package info (click to toggle)
xemacs21-packages 2009.02.17.dfsg.2-4
  • links: PTS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 116,276 kB
  • ctags: 89,333
  • sloc: lisp: 1,232,060; ansic: 16,570; java: 13,514; xml: 6,477; sh: 4,617; makefile: 4,022; asm: 3,007; perl: 840; cpp: 500; ruby: 257; csh: 96; haskell: 93; awk: 49; python: 47
file content (1490 lines) | stat: -rw-r--r-- 50,582 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
\input texinfo   @c -*-texinfo-*-

@comment $Id: elib.texi,v 1.3 2001-12-31 09:36:02 adrian Exp $
@comment Documentation for the GNU Emacs lisp library, Elib
@comment Copyright (C) 1991, 1992 Free Software Foundation

@comment This file is part of the GNU Emacs lisp library, Elib.

@comment GNU Elib is free software; you can redistribute it and/or modify
@comment it under the terms of the GNU General Public License as published by
@comment the Free Software Foundation; either version 2, or (at your option)
@comment any later version.

@comment GNU Elib is distributed in the hope that it will be useful,
@comment but WITHOUT ANY WARRANTY; without even the implied warranty of
@comment MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
@comment GNU General Public License for more details.

@comment You should have received a copy of the GNU General Public License
@comment along with GNU Emacs; see the file COPYING.  If not, write to
@comment the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@setfilename elib.info
@settitle Elib - The Emacs Lisp Library
@direntry
* Elib: (elib).      The Emacs Lisp Library.
@end direntry
@c footnotestyle separate
@c paragraphindent 2
@c %**end of header
@setchapternewpage odd
@syncodeindex fn cp
     
@ifinfo
Copyright @copyright{} 1991, 1992 Free Software Foundation
@end ifinfo
     
@comment The titlepage section does not appear in the Info file.
@titlepage
@sp 4
@comment The title is printed in a large font.
@center @titlefont{User's Guide}
@sp 1
@center @titlefont{to}
@sp 1
@center @titlefont{Elib - The Emacs Lisp Library}
@sp 2
@center version 1.0
@c --version--
@sp 3
@center Inge Wallin
@sp 3
@center last updated 10 dec 1995
@c --date--

@comment  The following two commands start the copyright page
@comment  for the printed manual.  This will not appear in the Info file.
@page
@vskip 0pt plus 1filll
Copyright @copyright{} 1991, 1992 Free Software Foundation

Permission is granted to make and distribute verbatim copies of this
manual provided the copyright notice and this permission notice are
preserved on all copies.

Permission is granted to copy and distribute modified versions of this
manual under the conditions that the section entitled ``GNU ELIB GENERAL
PUBLIC LICENSE'' is included exactly as in the original, and provided
that the entire resulting derived work is distributed under the terms of
a permission notice identical to this one.

Permission is granted to copy and distribute translations of this manual
into another language under the above conditions for modified versions,
except that the section entitled ``GNU ELIB GENERAL PUBLIC LICENSE'' may
be included in a translation approved by the author instead of in the
original English.
@end titlepage

@comment ================================================================
@comment                   The real text starts here
@comment ================================================================

@ifinfo
@node    Top, License information, (dir), (dir)
@comment node-name, next,          previous, up
@cindex Introduction


This manual describes Elib, the GNU emacs lisp library version 1.0.
@c --version--
The functions and data types in Elib are supposed to be a common
base for all kinds of other elisp packages and are not programs, modes
or packages of their own.

@end ifinfo
@menu
* License information::         Information about terms for copying Elib.
* What is Elib?::               What is Elib?
* Container data types::        Data types which can contain other data.
* Cookie package::              The Cookie package.
* String functions::            A number of string functions.
* Read functions::              Read data from the minibuffer.

* Future enhancements::         Future enhancements of Elib.
* Reporting bugs::              Where do you report a bug you have found?

* Node index::                  Index over important all the nodes 
                                  in this manual.
@end menu

@node   License information, What is Elib?, Top, Top
@comment  node-name,    next,   previous,       up
@include gpl.texi

@node     What is Elib?, Container data types, License information, Top
@comment  node-name,     next, previous, up
@chapter What is Elib?
@cindex What is Elib?
@cindex Elib, introduction
@cindex Introduction to Elib
@cindex Require

Elib, the GNU Emacs lisp library, is a collection of elisp
functions which you can use as parts of your own elisp programs.
Each file contains functions which have something in common, e.g.
they handle a certain data type.  

Elib is designed to be both as efficient and as easy to use as
possible.  Each file in Elib uses the elisp function @code{provide}
to tell emacs when it has been loaded.  To use the functions in
the file @code{foo}, you just have to put a line such as:  

@example
(require 'foo)
@end example

into your own elisp file.  This will cause emacs to load the file
@code{foo.elc} and evaluate the functions in it.  This, of course,
requires that your system manager has installed Elib properly on your
system.

@menu
* Contributors::                Contributors to GNU Elib.
* Archives::                    Where can I get a copy of Elib?
@end menu

@node     Contributors, Archives, What is Elib?, What is Elib?
@comment  node-name,  next,  previous,  up
@section Contributors to Elib
@cindex Contributors
@cindex Inge Wallin
@cindex Wallin, Inge
@cindex Kremer, Sebastian
@cindex Sebastian Kremer
@cindex Bellman, Thomas
@cindex Thomas Bellman
@cindex Cederqvist, Per
@cindex Per Cederqvist

The following persons have made contributions to GNU Elib.

@itemize @bullet
@item
Inge Wallin wrote most of the otherwise unattributed functions in
Elib as well as all documentation.

@item
Sebastian Kremer contributed the string functions.

@item
Thomas Bellman wrote some of the code for AVL trees.

@item
Per Cederqvist wrote the cookie package and the doubly linked list.  The
first design of @file{cookie.el} was made by Inge Wallin.
@end itemize


@node     Archives,  , Contributors, What is Elib?
@comment  node-name,  next,  previous,  up
@section Where can I get Elib?
@cindex sites
@cindex Archives
@cindex Ftp
@cindex Lysator
@cindex ftp.lysator.liu.se

There will probably be a number of sites archiving Elib.
Currently the latest release can always be fetched via anonymos
ftp from @code{ftp.lysator.liu.se} 
in @file{pub/emacs}.
@c --site--

@node     Container data types, Cookie package, What is Elib?, Top
@comment  node-name,  next,  previous,  up
@chapter Container Data Types
@cindex Container Data Types
@cindex Conventions

Container data types are data types which are used to hold and organize
other data.  Since lisp is a dynamically typed language, any container
data type can hold any other data type or a mix of other data types.
This is contrary to the case for @code{C} or @code{C++} where all data in
a typical container must be of the same type.

As a convention do all names of the functions handling a certain
container data type begin in @code{<type>-}, i.e. the functions 
implementing the container data type @code{foo} all start with
@code{foo-}. 

@menu
* Stack::                       The Stack data type.
* Queue::                       The Queue data type.
* Doubly Linked List::          The Doubly Linked List Data Type.
* Binary tree::                 An ordinary binary tree.
* AVL tree::                    A balanced binary tree (AVL tree).
@end menu

@node     Stack, Queue, Container data types, Container data types
@comment  node-name,  next,  previous,  up
@section The Stack Data Type
@cindex Stack
@cindex LIFO Stack
@cindex stack-f
@cindex stack-m

The stack data type provides a simple LIFO stack.  There are two
implementations of a stack in Elib, one using macros and one using
functions.  The names of the functions/macros in the two implementations
are the same, but the efficiency of using one or the other vary greatly
under different circumstances.

The implementation using macros should be used when you want to
byte-compile your own elisp program.  This will be most efficient since
byte-compiling an elisp function using macros has the same effect as
using inline code in @code{C}.

To use the stack data type, put the line

@example
(require 'stack-f)
@end example

in your own elisp source file if you want to use the implementation
using functions or

@example
(require 'stack-m)
@end example

if you want to use the implementation using macros.  This is the only
difference between them, so it is easy to switch between them during
debugging.

The following functions are provided by the stack:

@table @code
@item (stack-create)
@findex stack-create
Create a new empty stack.

@item (stack-p stack)
@findex stack-p
Return @code{t} if @var{stack} is a stack, otherwise return @code{nil}.

@item (stack-push stack element)
@findex stack-push
Push @var{element} onto @var{stack}.

@item (stack-pop stack)
@findex stack-pop
Remove the topmost element from @var{stack} and return it. If
@var{stack} is empty, return @code{nil}.

@item (stack-empty stack)
@findex stack-empty
Return @code{t} if @var{stack} is empty, otherwise return @code{nil}.

@item (stack-top stack)
@findex stack-top
Return the top element of @var{stack}, but don't remove it from the stack.
Return @code{nil} if @var{stack} is empty.

@item (stack-nth stack n)
@findex stack-nth
Return the @var{n}th element of @var{stack} where the top stack element
has number 0.  If @var{stack} is not that long, return @code{nil}.  The
element is not removed from the stack.

@item (stack-all stack)
@findex stack-all
Return a list of all entries in @var{stack} with the topmost element first.

@item (stack-copy stack)
@findex stack-copy
Return a copy of @var{stack}.  All entries in @var{stack} are also copied.

@item (stack-length stack)
@findex stack-length
Return the number of elements in @var{stack}.

@item (stack-clear stack)
@findex stack-clear
Remove all elements from @var{stack}.

@end table


@node     Queue, Doubly Linked List, Stack, Container data types
@comment  node-name,  next,  previous,  up
@section The Queue Data Type
@cindex Queue
@cindex FIFO Queue
@cindex queue-f
@cindex queue-m

The queue data type provides a simple FIFO queue.  There are two 
implementations of a queue in Elib, one using macros and one using
functions.  The names of the functions/macros in the two implementations
are the same, but the efficiency of using one or the other vary greatly
under different circumstances.

The implementation using macros should be used when you want to
byte-compile your own elisp program.  This will be most efficient since
byte-compiling an elisp function using macros has the same effect as
using inline code in @code{C}.  

To use the queue data type, put the line

@example
(require 'queue-f)
@end example

in your own elisp source file if you want to use the implementation
using functions or

@example
(require 'queue-m)
@end example

if you want to use the implementation using macros.  This is the only
difference between them, so it is easy to switch between them during
debugging.

Not all functions in @file{queue-m.el} are implemented as macros,
only the short ones.  This does not make it less recommendable to use
the macro version in your compiled code.

The following functions are provided by the queue:

@table @code
@item (queue-create)
@findex queue-create
Create a new empty queue.

@item (queue-p queue)
@findex queue-p
Return @code{t} if @var{queue} is a queue, otherwise return @code{nil}.

@item (queue-enqueue queue element)
@findex queue-enqueue
Enter @var{element} last into @var{queue}.

@item (queue-dequeue queue)
@findex queue-dequeue
Remove the first element from @var{queue} and return it.

@item (queue-empty queue)
@findex queue-empty
Return @code{t} if @var{queue} is empty, otherwise return @code{nil}.

@item (queue-first queue)
@findex queue-first
Return the first element of @var{queue} or @code{nil} if it is empty.  The
element is not removed from the queue.

@item (queue-nth queue n)
@findex queue-nth
Return the @var{n}th element of @var{queue}, where the first element of
@var{queue} has number 0.  If the length of @var{queue} is less than
@var{n}, return @code{nil}.  The element is not removed from the queue.

@item (queue-last queue)
@findex queue-last
Return the last element of @var{queue} or @code{nil} if it is empty.  The
element is not removed from the queue. 

@item (queue-all queue)
@findex queue-all
Return a list of all elements in @var{queue}.  Return @code{nil} if
@var{queue} is empty.  The oldest element in the queue is the first in
the list.

@item (queue-copy queue)
@findex queue-copy
Return a copy of @var{queue}.  All entries in @var{queue} are also copied.

@item (queue-length queue)
@findex queue-length
Return the number of elements in @var{queue}.

@item (queue-clear queue)
@findex queue-clear
Remove all elements from @var{queue}.

@end table

@node Doubly Linked List, Binary tree, Queue, Container data types
@comment  node-name,  next,  previous,  up
@section The Doubly Linked List Data Type
@cindex Doubly linked list
@cindex List, doubly linked
@cindex dll

The doubly linked list is an efficient data structure if you need to
traverse the elements on the list in two directions, and maybe insert
new elements in the middle of the list.  You can efficiently delete any
element, and insert new elements, anywhere on the list.

A doubly linked list (@dfn{dll} for short) consists of a number of
@dfn{nodes}, each containing exactly one @dfn{element}.  Some of the
functions operate directly on the elements, while some manipulate nodes.
For instance, all of the functions that let you step forward and
backwards in the list handle nodes.  Use the function @dfn{dll-element}
to extract the element of a node.

To use the doubly linked list provided by Elib you must put the line

@example
(require 'dll)
@end example

in your elisp source file.

@menu
* Creating a dll::              Creating a Doubly Linked List
* Entering elements::           Entering elements in a dll
* Accessing elements::          Accessing elements of a dll
* Removing nodes::              Removing nodes from a dll
* Predicates::                  Predicates on a dll
* Maps and Filters::            Maps and Filters on a dll
* Misc dll operations::         Miscellaneous dll operations
* Debugging dll applications::  Debugging dll applications
@end menu

@node Creating a dll, Entering elements, Doubly Linked List, Doubly Linked List
@comment  node-name,  next,  previous,  up
@subsection Creating a Doubly Linked List

@table @code
@item (dll-create)
@findex dll-create
Create an empty doubly linked list.

@item (dll-create-from-list list)
@findex dll-create-from-list
Given the ordinary lisp list @var{list}, create a doubly linked list
with the same elements.

@item (dll-copy dll &optional element-copy-fnc)
@findex dll-copy
Return a copy of the doubly linked list @var{dll}.  If optional second
argument @var{element-copy-fnc} is non-@code{nil} it should be a
function that takes one argument, an element, and returns a copy of it.
If @var{element-copy-fnc} is not given the elements themselves are not
copied.
@end table

@node Entering elements, Accessing elements, Creating a dll, Doubly Linked List
@comment  node-name,  next,  previous,  up
@subsection Entering elements in a dll

@table @code
@item (dll-enter-first dll element)
@findex dll-enter-first
Add an element first on a doubly linked list.

@item (dll-enter-last dll element)
@findex dll-enter-last
Add an element last on a doubly linked list.

@item (dll-enter-after dll node element)
@findex dll-enter-after
In the doubly linked list @var{dll}, insert a node containing
@var{element} after @var{node}.

@item (dll-enter-before dll node element)
@findex dll-enter-before
In the doubly linked list @var{dll}, insert a node containing
@var{element} before @var{node}.
@end table

@node Accessing elements, Removing nodes, Entering elements, Doubly Linked List
@comment  node-name,  next,  previous,  up
@subsection Accessing elements of a dll

@table @code
@item (dll-element dll node)
@findex dll-element
Get the element of a @var{node} in a doubly linked list @var{dll}.

@item (dll-first dll)
@findex dll-first
Return the first element on the doubly linked list @var{dll}.  Return
@code{nil} if the list is empty. The element is not removed.

@item (dll-nth dll n)
@findex dll-nth
Return the @var{n}th node from the doubly linked list @var{dll}.
@var{n} counts from zero. If @var{dll} is not that long, @code{nil} is
returned.  If @var{n} is negative, return the -(@var{n}+1)th last
element.  Thus, @code{(dll-nth dll 0)} returns the first node, and
@code{(dll-nth dll -1)} returns the last node.

@item (dll-last dll)
@findex dll-last
Return the last element on the doubly linked list @var{dll}.  Return
@code{nil} if the list is empty. The element is not removed.

@item (dll-next dll node)
@findex dll-next
Return the last element on the doubly linked list @var{dll}.  Return
@code{nil} if the list is empty. The element is not removed.

@item (dll-previous dll node)
@findex dll-previous
Return the node before @var{node}, or @code{nil} if @var{node} is the
first node.

@item (dll-all dll)
@findex dll-all
Return all elements on the double linked list @var{dll} as an ordinary list.

@end table

@node Removing nodes, Predicates, Accessing elements, Doubly Linked List
@comment  node-name,  next,  previous,  up
@subsection Removing nodes from a dll

@table @code
@item (dll-delete dll node)
@findex dll-delete
Delete @var{node} from the doubly linked list @var{dll}.  Return the
element of @var{node}.

@item (dll-delete-first dll)
@findex dll-delete-first
Delete the first @var{node} from the doubly linked list @var{dll}.
Return the element. Returns @code{nil} if @var{dll} was empty.

@item (dll-delete-last dll)
@findex dll-delete-last
Delete the last @var{node} from the doubly linked list @var{dll}.
Return the element. Returns @code{nil} if @var{dll} was empty.

@item (dll-clear dll)
@findex dll-clear
Clear the doubly linked list @var{dll}, i.e. make it completely empty.
@end table

@node Predicates, Maps and Filters, Removing nodes, Doubly Linked List
@comment  node-name,  next,  previous,  up
@subsection Predicates on a dll

@table @code
@item (dll-p object)
@findex dll-p
Return @code{t} if @var{object} is a doubly linked list, otherwise return
@code{nil}.

@item (dll-empty dll)
@findex dll-empty
Return @code{t} if the doubly linked list @var{dll} is empty, @code{nil}
otherwise.
@end table

@node Maps and Filters, Misc dll operations, Predicates, Doubly Linked List
@comment  node-name,  next,  previous,  up
@subsection Maps and Filters on a dll

@table @code
@item (dll-map map-function dll)
@findex dll-map
Apply @var{map-function} to all elements in the doubly linked list @var{dll}.
The function is applied to the first element first.

@item (dll-map-reverse map-function dll)
@findex dll-map-reverse
Apply @var{map-function} to all elements in the doubly linked list
@var{dll}.  The function is applied to the last element first.

@item (dll-filter dll predicate)
@findex dll-filter
Remove all elements in the doubly linked list @var{dll} for which
@var{predicate} returns @code{nil}.
@end table

@node Misc dll operations, Debugging dll applications, Maps and Filters, Doubly Linked List
@comment  node-name,  next,  previous,  up
@subsection Miscellaneous dll operations

@table @code
@item (dll-length dll)
@findex dll-length
Returns the number of elements in the doubly linked list @var{dll}.

@item (dll-sort dll predicate)
@findex dll-sort
Sort the doubly linked list @var{dll}, stably, comparing elements using
@var{predicate}.  Returns the sorted list. @var{dll} is modified by side
effects.  @var{predicate} is called with two elements of @var{dll}, and
should return @code{t} if the first element is ``less'' than the second.
@end table

@node Debugging dll applications,  , Misc dll operations, Doubly Linked List
@comment  node-name,  next,  previous,  up
@subsection Debugging dll applications
@cindex Debugging dll
@cindex Doubly linked lists, debugging
@cindex dll-debug
@cindex Circular lists
@cindex Error: circular lists

The data structure used by the dll package contains both forward and
backward pointers.  The primitives in Emacs, such as @code{print}, know
nothing about dlls, so when Emacs tries to print out a dll it will think
that it found a circular structure.  Fortunately it detects this 
situation and gives an error message, instead of getting stuck in an
eternal loop.

The error message can be quite annoying when you are developing an
application that uses dlls.  Suppose your code has an error, and you
type @samp{(setq debug-on-error t)} to try to figure out exactly what
the error is.  If any function in the backtrace has a dll as an
argument, Emacs will abort printing the entire backtrace and only
respond with a "Back at top level" message (or something similar,
depending on exactly what you are doing) in the echo area.

There are two solutions to this problem: patch your emacs so that it
detects circular structures (there have been patches for this floating
around the net) or use @file{dll-debug.el}.

The file @file{dll-debug.el} implements all of the functionality that
are present in @file{dll.el}, but it uses a normal, singly linked list
instead.  This makes some operations, like @samp{dll-previous},
dreadfully slow, but it makes it possible to debug dll applications.
@file{dll-debug.el} also has more built-in sanity tests than
@file{dll.el}.

@strong{NOTE:} To use the debug package, you must load the library
@file{dll-debug} before you load any of the libraries (such as cookie)
or your program that use dll.  You must also make sure that you don't
load any byte-compiled version of any file that was compiled with the
normal dll library.  Since it contains some macros very strange results
will occur otherwise...

When the debug package is loaded, you simply run your code normally,
and any bugs should be easier to trace.

@node     Binary tree, AVL tree, Doubly Linked List, Container data types
@comment  node-name,  next,  previous,  up
@section The Binary Tree Data Type
@cindex Binary tree
@cindex bintree

The binary tree is sometimes an efficient way to store data.  When a
binary tree is created a compare function is given to the create
function (@code{bintree-create}).  This function is used throughout
all data entry and deletions into and out of the tree.

To use the binary tree in Elib you must put the line 

@example
(require 'bintree)
@end example

in your elisp source file.

The following functions are provided by the binary tree in the library:

@table @code
@item (bintree-create compare-function)
@findex bintree-create
Create a new empty binary tree.  The argument @var{compare-function} is a
function which compares two instances of the data type which is to be
entered into the tree.  The call @code{(compare-function data1 data2)}
should return non-@code{nil} if @code{data1} is less than @code{data2},
and @code{nil} otherwise.

@item (bintree-p tree)
@findex bintree-p
Return @code{t} if @var{tree} is an bintree, otherwise return @code{nil}.

@item (bintree-compare-function tree)
@findex bintree-compare-function
Return @code{compare-function} given to @code{bintree-create} when
@var{tree} was created.

@item (bintree-empty tree)
@findex bintree-empty
Return @code{t} if @var{tree} is empty, otherwise return @code{nil}.

@item (bintree-enter tree data)
@findex bintree-enter
Enter @var{data} into @var{tree}.  If there already is a data element
which is considered equal to @var{data} by @code{compare-function} given
to @code{bintree-create}, the new element will replace the old one in
the tree.

@item (bintree-delete tree data)
@findex bintree-delete
Delete the element which is considered equal to @var{data} by
@code{compare-function} given to @code{bintree-create}.  If there
is no matching element within the tree, nothing is done to the tree.

@item (bintree-member tree data)
@findex bintree-member
Return the element in @var{tree} which is considered equal to @var{data} by
@code{compare-function} given to @code{bintree-create}.  If there
is no such element in the tree, return @code{nil}.

@item (bintree-map map-function tree)
@findex bintree-map
Apply @var{map-function} to all elements in @var{tree}.  The function is applied in
the order in which the tree is sorted.

@item (bintree-first tree)
@findex bintree-first
Return the first element of @var{tree}, i.e. the one who is considered first
by @code{compare-function} given to @code{bintree-create}.  If the
tree is empty, return @code{nil}.

@item (bintree-last tree)
@findex bintree-last
Return the last element of @var{tree}, i.e. the one who is considered last
by @code{compare-function} given to @code{bintree-create}.  If the
tree is empty, return @code{nil}.

@item (bintree-copy tree)
@findex bintree-copy
Return a copy of @var{tree}.

@item (bintree-flatten tree)
@findex bintree-flatten
Return a sorted list containing all elements of @var{tree}.

@item (bintree-size tree)
@findex bintree-size
Return the number of elements in @var{tree}.

@item (bintree-clear tree)
@findex bintree-clear
Clear @var{tree}, i.e. make it totally empty.

@end table


@node     AVL tree,  , Binary tree, Container data types
@comment  node-name,  next,  previous,  up
@section The AVL Tree Data Type
@cindex AVL tree
@cindex Balanced binary tree
@cindex Binary tree, balanced
@cindex avltree

The AVL tree data types provides a balanced binary tree.  The tree will
remain balanced throughout its entire life time, regardless of in which
order elements are entered into or deleted from the tree.

Although an AVL tree is not perfectly balanced, it has almost the same
performance as if it was.  The definition of an AVL tree is that the
difference in depth of the two branches of a particular node is at most
1.  This criterium is enough to make the performance of searching in an
AVL tree very close to a perfectly balanced tree, but will simplify the
entering and deleting of data significantly.

All data that is entered into an AVL tree should be of the same type.
If they are not, there are no way to compare two elements and this is
essential for entering and deleting data from the tree.  When a tree is
created, a compare function is given to the create function.  This
function is used throughout the life of the tree in all subsequent
insertions and deletions.

To use the Elib AVL tree, you must put the line

@example
(require 'avltree)
@end example

in your elisp source file.

The following functions are provided by the AVL tree in the library:

@table @code
@item (avltree-create compare-function)
@findex avltree-create
Create a new empty AVL tree.  The argument @var{compare-function} is a
function which compares two instances of the data type which is to be
entered into the tree.  The call @code{(compare-function data1 data2)}
should return non-@code{nil} if @code{data1} is less than @code{data2},
and @code{nil} otherwise.

@item (avltree-p tree)
@findex avltree-p
Return @code{t} if @var{tree} is an avltree, otherwise return @code{nil}.

@item (avltree-compare-function tree)
@findex avltree-compare-function
Return @code{compare-function} given to @code{avltree-create} when
@var{tree} was created.

@item (avltree-empty tree)
@findex avltree-empty
Return @code{t} if @var{tree} is empty, otherwise return @code{nil}.

@item (avltree-enter tree data)
@findex avltree-enter
Enter @var{data} into @var{tree}.  If there already is a data element
which is considered equal to @var{data} by @code{compare-function} given to
@code{avltree-create}, the new element will replace the old one in the
tree.

@item (avltree-delete tree data)
@findex avltree-delete
Delete the element which is considered equal to @var{data} by
@code{compare-function} given to @code{avltree-create}.  If there
is no matching element within the tree, nothing is done to the tree.

@item (avltree-member tree data)
@findex avltree-member
Return the element in @var{tree} which is considered equal to @var{data} by
@code{compare-function} given to @code{avltree-create}.  If there
is no such element in the tree, return @code{nil}.

@item (avltree-map map-function tree)
@findex avltree-map
Apply @var{map-function} to all elements in @var{tree}.  The function is
applied in the order in which the tree is sorted.

@item (avltree-first tree)
@findex avltree-first
Return the first element of @var{tree}, i.e. the one who is considered first
by @code{compare-function} given to @code{avltree-create}.  If the
tree is empty, return @code{nil}.

@item (avltree-last tree)
@findex avltree-last
Return the last element of @var{tree}, i.e. the one who is considered last
by @code{compare-function} given to @code{avltree-create}.  If the
tree is empty, return @code{nil}.

@item (avltree-copy tree)
@findex avltree-copy
Return a copy of @var{tree}.

@item (avltree-flatten tree)
@findex avltree-flatten
Return a sorted list containing all elements of @var{tree}.

@item (avltree-size tree)
@findex avltree-size
Return the number of elements in @var{tree}.

@item (avltree-clear tree)
@findex avltree-clear
Clear @var{tree}, i.e. make it totally empty.

@end table

@node Cookie package, String functions, Container data types, Top
@comment  node-name,  next,  previous,  up
@chapter The Cookie package---nodal data in a buffer
@cindex Cookie
@cindex Nodal data

If you want to have structured nodal data in a buffer, the cookie
package can be a help to you.

Cookie is a package that implements a connection between a
dll (a doubly linked list) and the contents of a buffer.
Possible uses are @code{dired} (have all files in a list, and show them),
@code{buffer-list}, @code{kom-prioritize} (in the LysKOM elisp client) and
others.  The CVS control package @file{pcl-cvs.el} uses @file{cookie.el}.

@menu
* Cookie terminology::          Introduction to cookies.
* Cookie conventions::          Coding conventions used in the cookie package.
* Collection::                  Manipulating the entire collection.
* Inserting cookies::           Inserting cookies in the collection.
* Tins and cookies::            Tins and cookies.
* Deleting cookies::            Deleting cookies.
* Collection as a DLL::         Treating the collection as a 
                                  doubly linked list.
* Scanning the list::           Scanning the list.
* In the buffer::               Operations that affect the buffer.
* Debugging cookie applications::  Debugging cookie applications
@end menu

@node Cookie terminology, Cookie conventions, Cookie package, Cookie package
@comment  node-name,  next,  previous,  up
@section Introduction to cookie terminology
@cindex Cookie definitions
@cindex Collection
@cindex Tin

The cookie package uses its own terminology.  Here are some important
definitions.

@table @dfn
@item cookie
A @dfn{cookie} can be any lisp object.  When you use the cookie
package you specify a pretty-printer, a function that inserts
a printable representation of the cookie in the buffer.

@item collection

A @dfn{collection} consists of a doubly linked list of
cookies, a header, a footer and a pretty-printer.  It is
displayed at a certain point in a certain buffer.  (The
buffer and point are selected when the collection is
created).  The header and the footer are constant strings.
They appear before and after the cookies.  (Currently,
once set, they can not be changed).

@item tin
A @dfn{tin} is an object that contains one cookie.  There
are functions in this package that given a tin extracts
the cookie, or gives the next or previous tin.  (All tins
are linked together in a doubly linked list.  The
previous tin is the one that appears before the other in
the buffer.)  You should not do anything with a tin except
pass it to the functions in this package.

@end table

Cookie does not affect the mode of the buffer in any way.
It merely makes it easy to connect an underlying data
representation to the buffer contents.

A collection is a very dynamic thing.  You can easily add or
delete cookies.  You can sort all cookies in a collection (you
have to supply a function that compares two cookies).  You can
apply a function to all cookies in a collection, etc, etc.

Remember that a cookie can be anything.  Your imagination is the
limit!  It is even possible to have another collection as a
cookie.  In that way some kind of tree hierarchy can be created.

@node Cookie conventions, Collection, Cookie terminology, Cookie package
@comment  node-name,  next,  previous,  up
@section Coding conventions used in the cookie package
@cindex Cookie conventions
@cindex Prefixes

All functions that are intended for external use begin
with one of the prefixes @samp{cookie-},
@samp{collection-} or @samp{tin-}.  The prefix
@samp{elib-} is used for internal functions
and macros.  Currently, no global or buffer-local
variables are used.

Many functions operate on tins instead of cookies.  For
most functions, the prefix used should help tell which
kind of object the function uses.

Most doc-strings contains an "Args:" line that lists the
arguments.

@node Collection, Inserting cookies, Cookie conventions, Cookie package
@comment  node-name,  next,  previous,  up
@section Manipulating the entire collection

@table @code
@item (collection-create buffer pretty-printer &optional header footer pos)
@findex collection-create
Create a collection that is displayed in @var{buffer}.
@var{buffer} may be a buffer or a buffer name. It is created if
it does not exist.

@var{pretty-printer} should be a function that takes one
argument, a cookie, and inserts a string representing it
in the buffer (at point). The string @var{pretty-printer}
inserts may be empty or span several lines. A trailing
newline will always be inserted automatically. The
@var{pretty-printer} should use @code{insert}, and not
@code{insert-before-markers}.

Optional third argument @var{header} is a string that will
always be present at the top of the collection.
@var{header} should end with a newline.  Optional fourth
argument @var{footer} is similar, and will always be
inserted at the bottom of the collection.

Optional fifth argument @var{pos} is a buffer position,
specifying where the collection will be inserted.  It
defaults to the beginning of the buffer.  @var{pos} will probably default
to the current value of @code{(point)} in future releases of Elib, so
you should not depend on this default in cases where it matters.

@item (collection-empty collection)
@findex collection-empty
Return true if there are no cookies in @var{collection}.

@item (collection-length collection)
@findex collection-length
Return the number of cookies in @var{collection}.

@item (collection-list-cookies collection)
@findex collection-list-cookies
Return a list of all cookies in @var{collection}.
@end table

@node Inserting cookies, Tins and cookies, Collection, Cookie package
@comment  node-name,  next,  previous,  up
@section Inserting cookies in the collection

These functions can be used to insert one or more cookies
into a collection.  The printed representation will
immediately and automatically be updated by the cookie
package.  (It will call the pretty-printer that was
specified to @code{collection-create}).

@table @code
@item (cookie-enter-first collection cookie)
@findex cookie-enter-first
Enter @var{cookie} first in the cookie collection @var{collection}.

@item (cookie-enter-last collection cookie)
@findex cookie-enter-last
Enter @var{cookie} last in the cookie collection @var{collection}.

@item (cookie-enter-after-tin collection tin cookie)
@findex cookie-enter-after-tin
Enter @var{cookie} into @var{collection}, immediately
after @var{tin}.

@item (cookie-enter-before-tin collection tin cookie)
@findex cookie-enter-before-tin
Enter @var{cookie} into @var{collection}, immediately
before @var{tin}.

@item (collection-append-cookies (collection cookie-list))
@findex collection-append-cookies
Insert all cookies in the list @var{cookie-list} last in
@var{collection}.
@end table

@node Tins and cookies, Deleting cookies, Inserting cookies, Cookie package
@comment  node-name,  next,  previous,  up
@section Tins and cookies

@table @code
@item (tin-cookie collection tin)
@findex tin-cookie
This function can be used to extract a cookie from
@var{tin}.  The collection that @var{tin} is present in
must also be specified as @var{collection}.
@end table

@node Deleting cookies, Collection as a DLL, Tins and cookies, Cookie package
@comment  node-name,  next,  previous,  up
@section Deleting cookies

There are a couple of different ways to delete cookies
from the collection.

@table @code
@item (tin-delete collection tin)
@findex tin-delete
Delete @var{tin} from @var{collection}. The cookie that is
stored in @var{tin} is returned.

@item (cookie-delete-first collection)
@findex cookie-delete-first
Delete first cookie in @var{collection} and return it.
Returns @code{nil} if there are no cookies left in
@var{collection}.

@item (cookie-delete-last collection)
@findex cookie-delete-last
Delete last cookie in @var{collection} and return it.
Returns @code{nil} if there are no cookies left in
@var{collection}.
@end table

The following two functions can be used to delete several
cookies that fulfills certain criteria.

@table @code
@item (collection-filter-cookies collection predicate &rest extra-args)
@findex collection-filter-cookies
Remove all cookies in @var{collection} for which
@var{predicate} returns nil.  Note that the buffer for
@var{collection} will be current-buffer when
@var{predicate} is called. @var{predicate} must restore
the current buffer before it returns if it changes it.

The @var{predicate} is called with @var{cookie} as its
first argument. If any @var{extra-args} are given to
@code{collection-filter-cookies} they will be passed
unmodified to @var{predicate}.

@item (collection-filter-tins collection predicate &rest extra-args)
@findex collection-filter-tins
This is like @code{collection-filter-cookies}, but
@var{predicate} is called with a tin instead of a cookie.
@end table

And finally, a way to delete all cookies in one swift
function call:

@table @code
@item (collection-clear collection)
@findex collection-clear
Remove all cookies in @var{collection}.
@end table

@node Collection as a DLL, Scanning the list, Deleting cookies, Cookie package
@comment  node-name,  next,  previous,  up
@section Collection as a Doubly linked list

The functions in this section treat the collection as a
doubly linked list.

@table @code
@item (tin-nth collection n)
@findex tin-nth
Return the @var{n}th tin.  @var{n} counts from zero.
@code{nil} is returned if there is less than @var{n}
cookies.  If @var{n} is negative, return the
-(@var{n}+1)th last element.  Thus, @code{(tin-nth dll 0)}
returns the first node, and @code{(tin-nth dll -1)}
returns the last node.

Use @code{tin-cookie} to extract the cookie from the tin (or use
@code{cookie-nth} instead).

@item (cookie-nth collection n)
@findex cookie-nth
Like @code{tin-nth}, but the cookie is returned instead of
the tin.

@item (tin-next collection tin)
@findex tin-next
Get the next tin.  Returns nil if @var{tin} is @code{nil}
or refers to the last cookie in @var{collection}.

@item (tin-previous collection tin)
@findex tin-previous
Get the previous tin.  Returns nil if @var{tin} is
@code{nil} or refers to the first cookie in
@var{collection}.

@item (cookie-sort collection predicate)
@findex cookie-sort
Sort the cookies in @var{collection}, stably, comparing
elements using @var{predicate}.  @var{predicate} is called
with two cookies, and should return @samp{t} if the first
cookie is @dfn{less} than the second.

The screen representaion of the collection will refreshed after the sort
is complete.

@item (cookie-first collection)
@findex cookie-first
Return the first cookie in @var{collection}. The cookie is
not removed.

@item (cookie-last collection)
@findex cookie-last
Return the last cookie in @var{collection}. The cookie is
not removed.
@end table

@node Scanning the list, In the buffer, Collection as a DLL, Cookie package
@comment  node-name,  next,  previous,  up
@section Scanning the list

@table @code
@item (cookie-map map-function collection &rest map-args)
@findex cookie-map
Apply @var{map-function} to all cookies in
@var{collection}.  @var{map-function} is applied to the
first element first.  If @var{map-function} returns
non-@code{nil} the cookie will be refreshed (its
pretty-printer will be called once again).

Note that the buffer for @var{collection} will be current
buffer when @var{map-function} is called.
@var{map-function} must restore the current buffer to
@var{buffer} before it returns, if it changes it.

If more than two arguments are given to @code{cookie-map}, remaining
arguments will be passed to @var{map-function}.

@item (cookie-map-reverse map-function collection &rest map-args)
@findex cookie-map-reverse
Like @code{cookie-map}, but @var{map-function} will be
applied to the last cookie first.

@item (collection-collect-tin collection predicate &rest predicate-args)
@findex collection-collect-tin
Select cookies from @var{collection} using @var{predicate}.
Return a list of all selected tins.

@var{predicate} is a function that takes a cookie as its
first argument.

The tins on the returned list will appear in the same
order as in the buffer.  You should not rely on in which
order @var{predicate} is called.

Note that the buffer the @var{collection} is displayed in
is current-buffer when @var{predicate} is called.
@var{predicate} must restore current-buffer if it changes
it.

If more than two arguments are given to
@code{collection-collect-tin} the remaining arguments will
be passed to @var{predicate}.

@item (collection-collect-cookie collection predicate &rest predicate-args)
@findex collection-collect-cookie
Like @code{collection-collect-tin}, but a list of cookies
is returned.
@end table

@node In the buffer, Debugging cookie applications, Scanning the list, Cookie package
@comment  node-name,  next,  previous,  up
@section Operations that affect the buffer

@table @code
@item (collection-buffer collection)
@findex collection-buffer
Return the buffer that @var{collection} is displayed in.

@item (collection-refresh collection)
@findex collection-refresh
Refresh all cookies in @var{collection}.

The pretty-printer that was specified when the
@var{collection} was created will be called for all
cookies in @var{collection}.

Note that @code{tin-invalidate} is more efficient if only
a small number of cookies needs to be refreshed.

@item (tin-invalidate collection &rest tins)
@findex tin-invalidate
Refresh some cookies.  The pretty-printer for
@var{collection} will be called for all @var{tins}.

@item (collection-set-goal-column collection goal)
@findex collection-set-goal-column
Set goal-column for @var{collection}.  goal-column is made buffer-local.
This function will be obsoleted in the next release of Elib.  Instead,
there is going to be a function that given a cookie will return a
position where the cursor should be stored.  The details are not yet
decided.

@item (tin-goto-previous collection pos arg)
@findex tin-goto-previous
Move point to the @var{arg}th previous cookie.  Don't move if we are at
the first cookie, or if @var{collection} is empty.  Returns the tin we
move to.

@item (tin-goto-next collection pos arg)
@findex tin-goto-next
Like @code{tin-goto-previous}, but move towards the end of
the buffer instead.

@item (tin-goto collection tin)
@findex tin-goto
Move point to @var{tin}.

@item (tin-locate collection pos &optional guess)
@findex tin-locate
Return the tin that @var{pos} (a buffer position) is within.

@var{pos} may be a marker or an integer.  @var{guess}
should be a tin that it is likely that @var{pos} is near.

If @var{pos} points before the first cookie, the first
cookie is returned.  If @var{pos} points after the last
cookie, the last cookie is returned.  If @var{collection}
is empty, @code{nil} is returned.
@end table

@node Debugging cookie applications,  , In the buffer, Cookie package
@comment  node-name,  next,  previous,  up
@section Debugging cookie applications

Since the cookie package uses dll, cookie applications can be hard to
debug.  Fortunately, the same technique can be used here---just load
dll-debug prior to loading cookie. @xref{Debugging dll applications}.

@emph{Warning!}  Don't load a byte-compiled @file{cookie.elc} that was
compiled using dll (as opposed to dll-debug) when you have dll-debug in
memory.  Your Emacs will be seriously confused.

@node     String functions, Read functions, Cookie package, Top
@comment  node-name,  next,  previous,  up
@chapter String functions
@cindex String functions
@cindex string

To use the string functions in Elib you have to put the following line
into your elisp source file:  

@example
(require 'string)
@end example

The following string functions are provided with Elib.

@table @code
@item (string-replace-match regexp string newtext &optional literal global)
@findex string-replace-match

This function tries to be a string near-equivalent to the elisp function
@code{replace-match}.  It returns a string with the first text matched
by @var{regexp} in @var{string} replaced by @var{newtext}.  If no match
is found, @code{nil} is returned.  If optional argument @var{global} is
non-@code{nil}, all occurances matching @var{regexp} are replaced
instead of only the first one.

If optional argument @var{literal} is non-@code{nil}, then @var{newtext}
is inserted exactly as it is.  If it is @code{nil} (which is the
default), then the character @kbd{\} is treated specially.  If a @kbd{\}
appears in @var{newtext}, it can start any one of the following sequences:

@table @kbd
@item \&
@kbd{\&} stands for the entire text being replaced.

@item \@var{n}
@kbd{\@var{n}} stands for the @var{n}th subexpression in the original regexp.
Subexpressions are those expressions grouped inside of @code{\(...\)}.
@var{n} is a digit.

@item \\
@kbd{\\} stands for a single @kbd{\} in @var{newtext}.
@end table

Any other character after the @key{\} will just be copied into the
string. 

@item (string-split pattern string &optional limit)

Split the string @var{string} on the regexp @var{pattern} and return a
list of the strings between the matches.  If the optional numerical
argument @var{limit} is >= 1, only the first @var{limit} elements of the list are
returned.

For example, the call

@example
(string-split "[ \t]+" "Elisp programming is fun.")
@end example

will return @code{("Elisp" "programming" "is" "fun.")}, but the call

@example
(string-split " " "Elisp programming is fun." 3)
@end example

will return @code{("Elisp" "programming" "is")}.

@end table

@node Read functions, Future enhancements, String functions, Top
@comment  node-name,  next,  previous,  up
@chapter Read functions
@cindex Read functions
@cindex read

Elib provides a number of functions for reading data from the
minibuffer.  To use them in your own elisp programs, put the following
line into you source file:

@example
(require 'read)
@end example

The following functions are provided by @file{read}.

@table @code
@item (read-number &optional prompt default)
@findex read-number
Read a number from the minibuffer. If optional argument @var{prompt} is
non-@code{nil}, the user is prompted using @var{prompt}, otherwise the
prompt string @code{Enter a number:} is used.  If optional argument
@var{default} is non-@code{nil}, it is written within parenthesis after
the prompt string.  @var{default} can be either a number or of the type which
@code{(interactive "P")} generates.

@item (read-num-range low high &optional prompt show-range)
@findex read-num-range
Read a number from the minibuffer.  The number returned will be forced
to lie between @var{low} and @var{high}.  If @var{prompt} is
non-@code{nil}, the user is prompted using @var{prompt}, otherwise the
prompt string @code{Enter a number:} is used.  If @var{show-range} is
non-@code{nil}, the prompt will show the range within parenthesis to the
user.

@item (read-silent prompt &optional showchar)
@findex read-silent
Read a string in the minibuffer without echoing.  The following
characters are special when entering the string:

@table @kbd
@item DEL
Delete the last character in the input buffer.

@item C-u
Clear the input buffer.

@item RET
End the reading of the string.

@item Newline
Same as @kbd{RET}.

@end table

If optional argument @var{showchar} is non-@code{nil}, one of these characters
will be displayed for each character input by the user.

This function is well suited to read a password from the user, but
beware of the function @code{(view-lossage)} which displays the last 100
keystrokes, even hidden ones.

@end table


@node     Future enhancements, Reporting bugs, Read functions, Top
@comment  node-name,  next,  previous,  up
@chapter Future enhancements
@cindex Enhancements

Elib needs a number of enhancements to be
called complete.  Here is a list of wishes of functions and data
types which we would like to enter into Elib in future releases:

@itemize @bullet
@item
More container data types such as Priority queues, 2-3-trees, Hash
tables, Sets, etc.  Much inspiration can be gotten from libg++ and the
standard C++ library, STL.

@item
Other implementations of old container data types.  For instance, are
vector implementations of stacks and queues faster than the current ones
using cons cells?

@item
Miscellaneous other small functions.

@item
More tests for all code in the library, especially the untested
container data types.  See the TODO file.
@end itemize


@section Contributions

We are grateful for all donations of code that we can receive.  However,
your code will be still more useful if you also provide documentation
and code to test your new library functions.


@node     Reporting bugs, Node index, Future enhancements, Top
@comment  node-name,  next,  previous,  up
@chapter Reporting bugs
@cindex Reporting bugs

Undoubtedly there are numerous bugs remaining, both in the elisp source
code and in the documentation.  If you find a bug in either, please send
a bug report to @code{elib-maintainers@@lysator.liu.se}.  We will try to
be as quick as possible in fixing the bugs and redistributing the fixes.

@ifinfo
@node    Node index,  , Reporting bugs, Top
@comment node-name,    next,  previous,      up
@unnumbered Node index

@printindex cp
@end ifinfo

@contents
@bye