File: building.texi

package info (click to toggle)
emacs-manual-ja 20.5-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 2,964 kB
  • ctags: 12
  • sloc: lisp: 119; ansic: 69; makefile: 43; sh: 28
file content (1366 lines) | stat: -rw-r--r-- 66,865 bytes parent folder | download
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
@c =============================================================
@c = $B85(B $BK](B $BLu(B: $BGt@n@5=<!w$*Cc$N?e=w;RBg3X(B
@c = $B2CI.=$@5(B: $BBgLZFXM:!wBgDM(B.$BC^GHBg3X(B = 1998/11/25
@c =============================================================
@c This is part of the Emacs manual.
@c Copyright (C) 1985, 86, 87, 93, 94, 95, 1997 Free Software Foundation, Inc.
@c See file emacs.texi for copying conditions.
@node Building, Abbrevs, Programs, Top
@c @chapter Compiling and Testing Programs
@chapter $B%W%m%0%i%`$N%3%s%Q%$%k$H%F%9%H(B
@c @cindex building programs
@cindex $B%W%m%0%i%`$N%3%s%Q%$%k(B
@c @cindex program building
@c @cindex running Lisp functions
@cindex Lisp$B4X?t$N<B9T(B

@c   The previous chapter discusses the Emacs commands that are useful for
@c making changes in programs.  This chapter deals with commands that assist
@c in the larger process of developing and maintaining programs.
$BA0>O$G$O%W%m%0%i%`$NJQ99$KJXMx$J(BEmacs$B%3%^%s%I$r@bL@$7$^$7$?!#(B
$BK\>O$G$O%W%m%0%i%`$NBg5,LO$J3+H/$dJ]<i$r=u$1$k%3%^%s%I$r@bL@$7$^$9!#(B

@menu
* Compilation::         Compiling programs in languages other
                          than Lisp (C, Pascal, etc.).
* Grep Searching::      Running grep as if it were a compiler.
* Compilation Mode::    The mode for visiting compiler errors.
* Compilation Shell::   Customizing your shell properly
                          for use in the compilation buffer.
* Debuggers::	        Running symbolic debuggers for non-Lisp programs. 
* Executing Lisp::      Various modes for editing Lisp programs, 
                          with different facilities for running
                          the Lisp programs. 
* Libraries: Lisp Libraries.      Creating Lisp programs to run in Emacs.
* Interaction: Lisp Interaction.  Executing Lisp in an Emacs buffer.
* Eval: Lisp Eval.      Executing a single Lisp expression in Emacs.
* External Lisp::         Communicating through Emacs with a separate Lisp. 
@end menu

@node Compilation
@c @section Running Compilations under Emacs
@section Emacs$B2<$G$N%3%s%Q%$%i$N<B9T(B
@c @cindex inferior process
@cindex $B2<0L%W%m%;%9(B
@cindex make
@c @cindex compilation errors
@cindex $B%3%s%Q%$%k%(%i!<(B
@c @cindex error log
@cindex $B%(%i!<%m%0(B

@c   Emacs can run compilers for noninteractive languages such as C and
@c Fortran as inferior processes, feeding the error log into an Emacs buffer.
@c It can also parse the error messages and show you the source lines where
@c compilation errors occurred.
Emacs$B$O(BC$B$d(BFortran$B$N$h$&$JHsBPOCE*$J8@8l$N%3%s%Q%$%i$r(B
$B2<0L%W%m%;%9$H$7$F<B9T$G$-!"(B
$B$=$N%(%i!<%m%0$r(BEmacs$B%P%C%U%!$K<h$j9~$a$^$9!#(B
$B$^$?!"%(%i!<%a%C%;!<%8$r2r@O$7$F!"(B
$B%3%s%Q%$%k%(%i!<$r5/$3$7$?%=!<%99T$rDs<($9$k$3$H$b$G$-$^$9!#(B

@table @kbd
@item M-x compile
@c Run a compiler asynchronously under Emacs, with error messages to
@c @samp{*compilation*} buffer.
Emacs$B2<$G%3%s%Q%$%i$rHsF14|$K<B9T$7!"(B
$B%(%i!<%a%C%;!<%8$r(B@samp{*compilation*}$B%P%C%U%!$K<h$j9~$`!#(B
@item M-x grep
@c Run @code{grep} asynchronously under Emacs, with matching lines
@c listed in the buffer named @samp{*grep*}.
Emacs$B2<$G(B@code{grep}$B$rHsF14|$K<B9T$7!"(B
$B0lCW$7$?9T$r(B@samp{*grep*}$B%P%C%U%!$K<h$j9~$`!#(B
@item M-x grep-find
@c Run @code{grep} via @code{find}, with user-specified arguments, and
@c collect output in the buffer named @samp{*grep*}.
$B;XDj$7$?0z?t$G(B@code{find}$B$H(B@code{grep}$B$r<B9T$7!"(B
$B=PNO$r(B@samp{*grep*}$B%P%C%U%!$K<h$j9~$`!#(B
@item M-x kill-compilation
@itemx M-x kill-grep
@c Kill the running compilation or @code{grep} subprocess.
$B<B9TCf$N%3%s%Q%$%i$d(B@code{grep}$B$N%5%V%W%m%;%9$rDd;_$5$;$k!#(B
@end table

@findex compile
@c   To run @code{make} or another compilation command, do @kbd{M-x
@c compile}.  This command reads a shell command line using the minibuffer,
@c and then executes the command in an inferior shell, putting output in
@c the buffer named @samp{*compilation*}.  The current buffer's default
@c directory is used as the working directory for the execution of the
@c command; normally, therefore, the compilation happens in this
@c directory.
@code{make}$B$dB>$N%3%s%Q%$%k%3%^%s%I$r<B9T$9$k$K$O!"(B
@kbd{M-x compile}$B$HBG$A$^$9!#(B
$B$3$N%3%^%s%I$O!"%_%K%P%C%U%!$G%7%'%k%3%^%s%I$rFI$_<h$j!"(B
$B$=$N%3%^%s%I$r2<0L%7%'%k$G<B9T$7!"(B
$B=PNO7k2L$r(B@samp{*compilation*}$B$H$$$&L>$N%P%C%U%!$K<h$j9~$_$^$9!#(B
$B%+%l%s%H%P%C%U%!$N%G%U%)%k%H%G%#%l%/%H%j$r(B
$B%7%'%k%3%^%s%I<B9T;~$N:n6H%G%#%l%/%H%j$H$7$FMQ$$$^$9!#(B
$B$=$N$?$a!"DL>o$O$3$N%G%#%l%/%H%j$K$"$k$b$N$r%3%s%Q%$%k$7$^$9!#(B

@vindex compile-command
@c   When the shell command line is read, the minibuffer appears containing
@c a default command line, which is the command you used the last time you
@c did @kbd{M-x compile}.  If you type just @key{RET}, the same command
@c line is used again.  For the first @kbd{M-x compile}, the default is
@c @samp{make -k}.  The default compilation command comes from the variable
@c @code{compile-command}; if the appropriate compilation command for a
@c file is something other than @samp{make -k}, it can be useful for the
@c file to specify a local value for @code{compile-command} (@pxref{File
@c Variables}).
$B%7%'%k%3%^%s%I9T$rFI$_<h$k$H$-!"(B
$B%_%K%P%C%U%!$K$O%G%U%)%k%H$N%7%'%k%3%^%s%I9T$,I=<($5$l$^$9$,!"(B
$B$3$l$OA02s(B@kbd{M-x compile}$B$r;H$C$?$H$-$N%3%^%s%I$G$9!#(B
$BC1$K(B@key{RET}$B$@$1$rBG80$9$k$H!"F1$8%7%'%k%3%^%s%I9T$r:F;HMQ$7$^$9!#(B
$B:G=i$N(B@kbd{M-x compile}$B$G$O!"%G%U%)%k%H$O(B@samp{make -k}$B$G$9!#(B
$B%G%U%)%k%H$N%3%s%Q%$%k%3%^%s%I$OJQ?t(B@code{compile-command}$B$+$i<h$j$^$9!#(B
$BE,@Z$J%3%s%Q%$%k%3%^%s%I$,B>$K$"$k>l9g$K$O!"(B
$B%U%!%$%k$G$3$NJQ?t$N%m!<%+%k$JCM$r;XDj$9$k$HJXMx$G$7$g$&(B
$B!J(B@pxref{File Variables}$B!K!#(B

@c   Starting a compilation displays the buffer @samp{*compilation*} in
@c another window but does not select it.  The buffer's mode line tells you
@c whether compilation is finished, with the word @samp{run} or @samp{exit}
@c inside the parentheses.  You do not have to keep this buffer visible;
@c compilation continues in any case.  While a compilation is going on, the
@c string @samp{Compiling} appears in the mode lines of all windows.  When
@c this string disappears, the compilation is finished.
$B%3%s%Q%$%k$,;O$^$k$H!"%P%C%U%!(B@samp{*compilation*}$B$OJL$N%&%#%s%I%&$K(B
$BI=<($5$l$^$9$,!"A*Br$5$l$k$o$1$G$O$"$j$^$;$s!#(B
$B$3$N%P%C%U%!$N%b!<%I9T$G$O!"(B
$B3g8L$NCf$KC18l(B@samp{run}$B$+(B@samp{exit}$B$rI=<($7$F(B
$B%3%s%Q%$%k$,=*N;$7$?$+$I$&$+<($7$^$9!#(B
$B$3$N%P%C%U%!$r8+$($k$h$&$K$7$F$*$/I,MW$O$"$j$^$;$s!#(B
$B$$$:$l$K$7$F$b!"%3%s%Q%$%k$O7QB3$5$l$^$9!#(B
$B%3%s%Q%$%kCf$O!"$9$Y$F$N%&%#%s%I%&$N%b!<%I9T$K(B
$BJ8;zNs(B@samp{Compiling}$B$,I=<($5$l$^$9!#(B
$B$3$NJ8;zNs$,>C$($l$P!"%3%s%Q%$%k$O=*N;$7$F$$$^$9!#(B

@c   If you want to watch the compilation transcript as it appears, switch
@c to the @samp{*compilation*} buffer and move point to the end of the
@c buffer.  When point is at the end, new compilation output is inserted
@c above point, which remains at the end.  If point is not at the end of
@c the buffer, it remains fixed while more compilation output is added at
@c the end of the buffer.
$B%3%s%Q%$%k$N?J9T>u67$r8+$?$$>l9g$K$O!"(B
@samp{*compilation*}$B%P%C%U%!$K@Z$jBX$($F%]%$%s%H$r%P%C%U%!$NKvHx$K0\F0$7$^$9!#(B
$B%]%$%s%H$,%P%C%U%!$NKvHx$K$"$k$H!"(B
$B?7$i$?$J%3%s%Q%$%k=PNO$O%]%$%s%H$N$^$($KA^F~$5$l%]%$%s%H$OKvHx$KN1$^$j$^$9!#(B
$B%]%$%s%H$,%P%C%U%!$NKvHx$K$J$$$H!"(B
$B%3%s%Q%$%k=PNO$O%P%C%U%!$NKvHx$KDI2C$5$l$^$9$,(B
$B%]%$%s%H$OESCf$N>l=j$KN1$^$C$?$^$^$G$9!#(B

@vindex compilation-scroll-output
@c   If you set the variable @code{compilation-scroll-output} to a
@c non-@code{nil} value, then the compilation buffer always scrolls to
@c follow output as it comes in.
$BJQ?t(B@code{compilation-scroll-output}$B$K(B@code{nil}$B0J30$NCM$r@_Dj$9$k$H!"(B
$B=PNO$,E~Ce$9$k$?$S$K=PNO$KDI=>$9$k$h$&$K(B
$B%3%s%Q%$%k%P%C%U%!$r$D$M$K%9%/%m!<%k$7$^$9!#(B

@findex kill-compilation
@c   To kill the compilation process, do @kbd{M-x kill-compilation}.  When
@c the compiler process terminates, the mode line of the
@c @samp{*compilation*} buffer changes to say @samp{signal} instead of
@c @samp{run}.  Starting a new compilation also kills any running
@c compilation, as only one can exist at any time.  However, @kbd{M-x
@c compile} asks for confirmation before actually killing a compilation
@c that is running.
$B%3%s%Q%$%k%W%m%;%9$r;_$a$k$K$O!"(B
@kbd{M-x kill-compilation}$B$r<B9T$7$^$9!#(B
$B%3%s%Q%$%k%W%m%;%9$,=*N;$9$k$H!"(B@samp{*compilation*}$B%P%C%U%!$N(B
$B%b!<%I9T$NI=<($,(B@samp{run}$B$+$i(B@samp{signal}$B$KJQ$o$j$^$9!#(B
$B0lEY$K<B9T2DG=$J%3%s%Q%$%k$O(B1$B$D$@$1$J$N$G!"(B
$B?7$7$/%3%s%Q%$%k$r;O$a$k$H<B9TCf$N%3%s%Q%$%k$ODd;_$5$;$i$l$^$9!#(B
$B$7$+$7!"(B@kbd{M-x compile}$B$O!"(B
$B<B9TCf$N%3%s%Q%$%k$r<B:]$KDd;_$5$;$k$+$I$&$+J9$$$F$-$^$9!#(B

@node Grep Searching
@c @section Searching with Grep under Emacs
@section Emacs$B2<$G$N(Bgrep$B$K$h$kC5:w(B

@findex grep
@c   Just as you can run a compiler from Emacs and then visit the lines
@c where there were compilation errors, you can also run @code{grep} and
@c then visit the lines on which matches were found.  This works by
@c treating the matches reported by @code{grep} as if they were ``errors.''
Emacs$B$+$i%3%s%Q%$%i$r<B9T$7!"%3%s%Q%$%k%(%i!<$r5/$3$7$?9T$r(B
$BK,$l$k$3$H$,$G$-$k$h$&$K!"(B@code{grep}$B$r<B9T$7$F(B
$B0lCW$7$?9T$rK,$l$k$3$H$,$G$-$^$9!#(B
$B$3$l$O!"(B@code{grep}$B$,Js9p$7$?0lCW$r!X%(%i!<!Y$H$7$F07$&$3$H$G9T$$$^$9!#(B

@c   To do this, type @kbd{M-x grep}, then enter a command line that
@c specifies how to run @code{grep}.  Use the same arguments you would give
@c @code{grep} when running it normally: a @code{grep}-style regexp
@c (usually in single-quotes to quote the shell's special characters)
@c followed by file names, which may use wildcards.  The output from
@c @code{grep} goes in the @samp{*grep*} buffer.  You can find the
@c corresponding lines in the original files using @kbd{C-x `} and
@c @key{RET}, as with compilation errors.
$B$=$l$K$O!"(B@kbd{M-x grep}$B$HBG80$7$F$+$i!"(B
@code{grep}$B$r$I$N$h$&$K<B9T$9$k$+$r;XDj$9$k%3%^%s%I9T$rF~NO$7$^$9!#(B
$BIaDL$K(B@code{grep}$B$r<B9T$9$k$H$-$K;XDj$9$k0z?t$HF1$8$b$N$r;H$$$^$9!#(B
$B$D$^$j!"(B@code{grep}$BN.$N(B
$B!JIaDL!"%7%'%k$NFC<lJ8;z$r%/%)!<%H$9$k$?$a$K%7%s%0%k%/%)!<%H$G0O$s$@!K(B
$B@55,I=8=$KB3$1$F!"%o%$%k%I%+!<%I$J$I$rMQ$$$?%U%!%$%kL>$r;XDj$7$^$9!#(B
@code{grep}$B$N=PNO$O(B@samp{*grep*}$B%P%C%U%!$KF~$j$^$9!#(B
$B%U%!%$%kFb$NBP1~$9$k9T$rC5$9$K$O!"%3%s%Q%$%k%(%i!<$N>l9g$HF1MM$K!"(B
@kbd{C-x `}$B$H(B@key{RET}$B$r;H$$$^$9!#(B

@c   If you specify a prefix argument for @kbd{M-x grep}, it figures out
@c the tag (@pxref{Tags}) around point, and puts that into the default
@c @code{grep} command.
@kbd{M-x grep}$B$KA0CV0z?t$r;XDj$9$k$H!"(B
$B%]%$%s%H$N<~$j$+$i!JC5$9$Y$-!K%?%0$r?dB,$7$F(B
$B%G%U%)%k%H$N(B@code{grep}$B%3%^%s%I$K$=$l$r4^$a$^$9!#(B

@findex grep-find
@c   The command @kbd{M-x grep-find} is similar to @kbd{M-x grep}, but it
@c supplies a different initial default for the command---one that runs
@c both @code{find} and @code{grep}, so as to search every file in a
@c directory tree.  See also the @code{find-grep-dired} command,
@c in @ref{Dired and Find}.
@kbd{M-x grep-find}$B$O(B@kbd{M-x grep}$B%3%^%s%I$HF1MM$G$9$,!"(B
$B%7%'%k%3%^%s%I$KM?$($k:G=i$N%G%U%)%k%H$,0c$$$^$9!#(B
@code{find}$B$H(B@code{grep}$B$NN>J}$r<B9T$7$F!"(B
$B%G%#%l%/%H%jLZ9=B$2<$N3F%U%!%$%k$rC5:w$7$^$9!#(B
@ref{Dired and Find}$B$N(B@code{find-grep-dired}$B%3%^%s%I$b;2>H$7$F$/$@$5$$!#(B

@node Compilation Mode
@c @section Compilation Mode
@section $B%3%s%Q%$%k%b!<%I(B

@findex compile-goto-error
@c @cindex Compilation mode
@cindex $B%3%s%Q%$%k%b!<%I(B
@c @cindex mode, Compilation
@cindex $B%b!<%I!"(BCompilation
@c   The @samp{*compilation*} buffer uses a special major mode, Compilation
@c mode, whose main feature is to provide a convenient way to look at the
@c source line where the error happened.
@samp{*compilation*}$B%P%C%U%!$O!"(B
$B%3%s%Q%$%k!J(Bcompilation$B!K%b!<%I$H8F$P$l$kFCJL$J%a%8%c!<%b!<%I$K$J$j$^$9!#(B
$B$3$N%b!<%I$N<g$J5!G=$O!"%(%i!<$,5/$-$?%=!<%99T$r4JC1$K;2>H$G$-$k$3$H$G$9!#(B 

@table @kbd
@item C-x `
@c Visit the locus of the next compiler error message or @code{grep} match.
$B$D$.$N%3%s%Q%$%k%(%i!<$d(B@code{grep}$B$N$D$.$N0lCW$K(B
$BBP1~$9$k2U=j$rK,$l$k!#(B
@item @key{RET}
@c Visit the locus of the error message that point is on.
@c This command is used in the compilation buffer.
$B%]%$%s%H$,0LCV$9$k%(%i!<%a%C%;!<%8$KBP1~$9$k2U=j$rK,$l$k!#(B
$B$3$N%3%^%s%I$O!"%3%s%Q%$%k%P%C%U%!$G;H$&!#(B
@item Mouse-2
@c Visit the locus of the error message that you click on.
$B%^%&%9$G%/%j%C%/$7$?%(%i!<%a%C%;!<%8$KBP1~$9$k2U=j$rK,$l$k!#(B
@end table

@kindex C-x `
@findex next-error
@c   You can visit the source for any particular error message by moving
@c point in @samp{*compilation*} to that error message and typing @key{RET}
@c (@code{compile-goto-error}).  Or click @kbd{Mouse-2} on the error message;
@c you need not switch to the @samp{*compilation*} buffer first.
@samp{*compilation*}$B$G%(%i!<%a%C%;!<%8$K%]%$%s%H$r;}$C$F$$$C$F(B
@key{RET}$B!J(B@code{compile-goto-error}$B!K$rBG80$9$l$P!"(B
$B$=$N%(%i!<$N860x$H$J$C$?%=!<%9$rK,Ld$G$-$^$9!#(B
$B$"$k$$$O!"%(%i!<%a%C%;!<%8$r(B@kbd{Mouse-2}$B$G%/%j%C%/$7$^$9$,!"(B
$B$3$N$H$-$O!"$"$i$+$8$a(B@samp{*compilation*}$B%P%C%U%!$K(B
$B@Z$jBX$($F$*$/I,MW$O$"$j$^$;$s!#(B

@c   To parse the compiler error messages sequentially, type @kbd{C-x `}
@c (@code{next-error}).  The character following the @kbd{C-x} is the
@c backquote or ``grave accent,'' not the single-quote.  This command is
@c available in all buffers, not just in @samp{*compilation*}; it displays
@c the next error message at the top of one window and source location of
@c the error in another window.
$B%3%s%Q%$%i$N%(%i!<%a%C%;!<%8$r=gHV$K2r@O$9$k$K$O!"(B
@kbd{C-x `}$B!J(B@code{next-error}$B!K$HBG80$7$^$9!#(B
@kbd{C-x}$B$KB3$/J8;z$O!"%7%s%0%k%/%)!<%H$G$O$J$/(B
$B%P%C%/%/%)!<%H!"$9$J$o$A!"!X%"%/%5%s%0%l!<%V!Y$G$9!#(B
$B$3$N%3%^%s%I$O(B@samp{*compilation*}$B$@$1$G$J$/!"(B
$B$9$Y$F$N%P%C%U%!$G;HMQ2DG=$G$9!#(B
$B$3$N%3%^%s%I$O!"0lJ}$N%&%#%s%I%&$N@hF,$K%(%i!<%a%C%;!<%8$rI=<($7!"(B
$BJL$N%&%#%s%I%&$K%(%i!<$H$J$C$?%=!<%9%3!<%I$rI=<($7$^$9!#(B

@c   The first time @kbd{C-x `} is used after the start of a compilation,
@c it moves to the first error's location.  Subsequent uses of @kbd{C-x `}
@c advance down to subsequent errors.  If you visit a specific error
@c message with @key{RET} or @kbd{Mouse-2}, subsequent @kbd{C-x `}
@c commands advance from there.  When @kbd{C-x `} gets to the end of the
@c buffer and finds no more error messages to visit, it fails and signals
@c an Emacs error.
$B%3%s%Q%$%k3+;O8e$K:G=i$K(B@kbd{C-x `}$B$r;H$&$H!"(B
$B:G=i$N%(%i!<2U=j$K0\F0$7$^$9!#(B
$BB3$1$F(B@kbd{C-x `}$B$r<B9T$9$k$H!"<!!9$K%(%i!<2U=j$K0\F0$7$F$$$-$^$9!#(B
@key{RET}$B$d(B@kbd{Mouse-2}$B$GFCDj$N%(%i!<2U=j$K0\F0$7$?$"$H$K(B
@kbd{C-x `}$B%3%^%s%I$r<B9T$9$k$H!"$=$N>l=j$N$D$.$N%(%i!<2U=j$K0\F0$7$^$9!#(B
$B%P%C%U%!$NKvHx$KE~C#$7$F$b$&%(%i!<%a%C%;!<%8$,$J$$$H!"(B
@kbd{C-x `}$B%3%^%s%I$O<:GT$7!"%(%i!<$rDLCN$7$^$9!#(B

@c   @kbd{C-u C-x `} starts scanning from the beginning of the compilation
@c buffer.  This is one way to process the same set of errors again.
@kbd{C-u C-x `}$B$O!"%3%s%Q%$%k%P%C%U%!$N@hF,$+$i2r@O$r;O$a$^$9!#(B
$B%3%s%Q%$%k$r$d$jD>$5$:$K0lO"$N%(%i!<$N2r@O$r$b$&0lEY9T$&J}K!$N(B1$B$D$G$9!#(B

@c   Compilation mode also redefines the keys @key{SPC} and @key{DEL} to
@c scroll by screenfuls, and @kbd{M-n} and @kbd{M-p} to move to the next or
@c previous error message.  You can also use @kbd{M-@{} and @kbd{M-@}} to
@c move up or down to an error message for a different source file.
$B%3%s%Q%$%k!J(Bcompilation$B!K%b!<%I$G$O!"(B
@key{SPC}$B%-!<$H(B@key{DEL}$B%-!<$r(B1$B2hLLJ,$N%9%/%m!<%k$K!"(B
@kbd{M-n}$B$H(B@kbd{M-p}$B$r(B1$B$D$D$.!?$^$($N%(%i!<%a%C%;!<%8$X$N0\F0$K:FDj5A$7$^$9!#(B
$B$^$?!"JL$N%=!<%9%U%!%$%k$N%(%i!<%a%C%;!<%8$X$N0\F0$K$O!"(B
@kbd{M-@{}$B$H(B@kbd{M-@}}$B%3%^%s%I$r;H$($^$9!#(B

@c   The features of Compilation mode are also available in a minor mode
@c called Compilation Minor mode.  This lets you parse error messages in
@c any buffer, not just a normal compilation output buffer.  Type @kbd{M-x
@c compilation-minor-mode} to enable the minor mode.  This defines the keys
@c @key{RET} and @kbd{Mouse-2}, as in the Compilation major mode.
$B%3%s%Q%$%k!J(Bcompilation$B!K%b!<%I$N5!G=$O!"(B
$B%3%s%Q%$%k%^%$%J!J(Bcompilation-minor$B!K%b!<%I$H8F$P$l$k%^%$%J%b!<%I$G$b(B
$B;H$($^$9!#(B
$B$3$l$K$h$j!"IaDL$N%3%s%Q%$%k%P%C%U%!$@$1$G$J$/G$0U$N%P%C%U%!Fb$N(B
$B%(%i!<%a%C%;!<%8$r2r@O$G$-$^$9!#(B
$B$3$N%^%$%J%b!<%I$r%*%s$K$9$k$K$O!"(B
 @kbd{M-x compilation-minor-mode}$B$HBG80$7$^$9!#(B
$B$9$k$H!"%a%8%c!<%b!<%I$N%3%s%Q%$%k!J(Bcompilation$B!K%b!<%I$HF1MM$K(B
@key{RET}$B%-!<$H(B@kbd{Mouse-2}$B$rDj5A$7$^$9!#(B

@c   Compilation minor mode works in any buffer, as long as the contents
@c are in a format that it understands.  In an Rlogin buffer (@pxref{Remote
@c Host}), Compilation minor mode automatically accesses remote source
@c files by FTP (@pxref{File Names}).
$B%P%C%U%!$NFbMF$,G'<1$G$-$k7A<0$G$"$k8B$j!"(B
$B%3%s%Q%$%k%^%$%J!J(Bcompilation-minor$B!K%b!<%I$OG$0U$N%P%C%U%!$GF0:n$7$^$9!#(B
rlogin$B%P%C%U%!!J(B@pxref{Remote Host}$B!K$G$O!"(B
$B%3%s%Q%$%k%^%$%J!J(Bcompilation-minor$B!K%b!<%I$O(B
$B%j%b!<%H$N%=!<%9%U%!%$%k$r(BFTP$B$G<+F0E*$K<h$C$F$-$^$9!J(B@pxref{File Names}$B!K!#(B

@node Compilation Shell
@c @section Subshells for Compilation
@section $B%3%s%Q%$%k$N$?$a$N%5%V%7%'%k(B

@c   Emacs uses a shell to run the compilation command, but specifies
@c the option for a noninteractive shell.  This means, in particular, that
@c the shell should start with no prompt.  If you find your usual shell
@c prompt making an unsightly appearance in the @samp{*compilation*}
@c buffer, it means you have made a mistake in your shell's init file by
@c setting the prompt unconditionally.  (This init file's name may be
@c @file{.bashrc}, @file{.profile}, @file{.cshrc}, @file{.shrc}, or various
@c other things, depending on the shell you use.)  The shell init file
@c should set the prompt only if there already is a prompt.  In csh, here
@c is how to do it:
Emacs$B$O%7%'%k$r;H$C$F%3%s%Q%$%k%3%^%s%I$r<B9T$7$^$9$,!"(B
$BHsBPOCE*$J%7%'%k$K$J$k$h$&$J%*%W%7%g%s$r;XDj$7$^$9!#(B
$B$D$^$j!"%7%'%k$O%W%m%s%W%H$r=P$5$:$K<B9T$r3+;O$9$k$O$:$G$9!#(B
@samp{*compilation*}$B%P%C%U%!$KDL>o$N%7%'%k%W%m%s%W%H$,$V$6$^$K8=$l$k>l9g$O!"(B
$B8D?M$N%7%'%k=i4|2=%U%!%$%k$G%W%m%s%W%H$rL5>r7o$K@_Dj$7$F$$$k$3$H$r(B
$B0UL#$7$^$9!#(B
$B!J%7%'%k=i4|2=%U%!%$%k$NL>A0$O!"(B@file{.bashrc}$B!"(B@file{.profile}$B!"(B
@file{.cshrc}$B!"(B@file{.shrc}$B$J$I$@$,!"(B
$B;H$C$F$$$k%7%'%k$K$h$C$F$5$^$6$^$J>l9g$,$"$k!#!K(B
$B%7%'%k=i4|2=%U%!%$%k$G$O!"%W%m%s%W%H$,$9$G$K@_Dj$5$l$F$$$k$H$-$@$1(B
$B%W%m%s%W%H$r:F@_Dj$9$k$Y$-$G$9!#(B
$B$?$H$($P!"(B@samp{csh}$B$G$O0J2<$N$h$&$K$7$^$9!#(B

@example
if ($?prompt) set prompt = @dots{}
@end example

@noindent
@c And here's how to do it in bash:
bash$B$G$O0J2<$N$h$&$K$7$^$9!#(B

@example
if [ "$@{PS1+set@}" = set ]
then PS1=@dots{}
fi
@end example

@c   There may well be other things that your shell's init file
@c ought to do only for an interactive shell.  You can use the same
@c method to conditionalize them.
$BFI<T$N%7%'%k=i4|2=%U%!%$%k$K$O!"BPOCE*$J%7%'%k$KBP$7$F$@$1(B
$BK\Mh$O@_Dj$9$k$Y$-$3$H$,$^$@$"$k$+$b$7$l$^$;$s!#(B
$BF1$8J}K!$rMQ$$$F!"$=$l$i$r>u67$K1~$8$F@_Dj$9$k$h$&$K$G$-$^$9!#(B

@c   The MS-DOS ``operating system'' does not support asynchronous
@c subprocesses; to work around this lack, @kbd{M-x compile} runs the
@c compilation command synchronously on MS-DOS.  As a consequence, you must
@c wait until the command finishes before you can do anything else in
@c Emacs.  @xref{MS-DOS}.
MS-DOS$B!X%*%Z%l!<%F%#%s%0%7%9%F%`!Y$G$O!"(B
$BHsF14|$N%5%V%W%m%;%9$r;H$($^$;$s!#(B
$BBP1~:v$H$7$F!"(BMS-DOS$B$G$O(B@kbd{M-x compile}$B$O(B
$B%3%s%Q%$%k%3%^%s%I$rF14|E*$K<B9T$7$^$9!#(B
$B$=$N7k2L!"(BEmacs$B>e$GB>$N:n6H$r9T$&$K$O!"(B
$B%3%s%Q%$%k%3%^%s%I$N=*N;$rBT$DI,MW$,$"$j$^$9!#(B
@xref{MS-DOS}$B!#(B

@node Debuggers
@c @section Running Debuggers Under Emacs
@section Emacs$B2<$G$N%G%P%C%,$N<B9T(B
@c @cindex debuggers
@cindex $B%G%P%C%,(B
@c @cindex GUD library
@cindex GUD$B%i%$%V%i%j(B
@cindex GDB
@cindex DBX
@cindex SDB
@cindex XDB
@cindex Perldb
@cindex JDB
@cindex PDB

@c @c Do you believe in GUD?
@c The GUD (Grand Unified Debugger) library provides an interface to
@c various symbolic debuggers from within Emacs.  We recommend the debugger
@c GDB, which is free software, but you can also run DBX, SDB or XDB if you
@c have them.  GUD can also serve as an interface to the Perl's debugging
@c mode, the Python debugger PDB, and to JDB, the Java Debugger.
GUD$B!J(BGrand Unified Debugger$B!"BgE}0l%G%P%C%,!K%i%$%V%i%j$O!"(B
Emacs$B$+$i$5$^$6$^$J%G%P%C%,$X$N%$%s%?!<%U%'%$%9$rDs6!$7$^$9!#(B
$B%U%j!<%=%U%H%&%'%"$G$"$k(BGDB$B$r$*4+$a$7$^$9$,!"(B
DBX$B!"(BSDB$B!"(BXDB$B$r;}$C$F$$$k$J$i$P$=$l$i$r;H$&$3$H$b$G$-$^$9!#(B
GUD$B$O!"(BPerl$B$N%G%P%C%0%b!<%I!"(B
Python$B$N%G%P%C%,(BPDB$B!"(BJava$B%G%P%C%,(BJDB$B$KBP$9$k%$%s%?!<%U%'%$%9$K$b$J$j$^$9!#(B

@menu
* Starting GUD::	How to start a debugger subprocess.
* Debugger Operation::	Connection between the debugger and source buffers.
* Commands of GUD::	Key bindings for common commands.
* GUD Customization::	Defining your own commands for GUD.
@end menu

@node Starting GUD
@c @subsection Starting GUD
@subsection GUD$B$N5/F0(B

@c   There are several commands for starting a debugger, each corresponding
@c to a particular debugger program.
$B%G%P%C%,$r3+;O$9$k%3%^%s%I$O$$$/$D$+$"$j!"(B
$B$=$l$>$l!"FCDj$N%G%P%C%,$KBP1~$7$F$$$^$9!#(B

@table @kbd
@item M-x gdb @key{RET} @var{file} @key{RET}
@findex gdb
@c Run GDB as a subprocess of Emacs.  This command creates a buffer for
@c input and output to GDB, and switches to it.  If a GDB buffer already
@c exists, it just switches to that buffer.
Emacs$B$N%5%V%W%m%;%9$H$7$F(BGDB$B$r<B9T$9$k!#(B
$B$3$N%3%^%s%I$O!"(BGDB$B$X$NF~=PNOMQ$N%P%C%U%!$r?7$?$K:n$j!"(B
$B$=$N%P%C%U%!$X@Z$jBX$($k!#(B
GDB$B%P%C%U%!$,4{B8$N>l9g$O!"$=$N%P%C%U%!$X@Z$jBX$($k$@$1!#(B

@item M-x dbx @key{RET} @var{file} @key{RET}
@findex dbx
@c Similar, but run DBX instead of GDB.
$BF1MM$K!"(BGDB$B$N$+$o$j$K(BDBX$B$r<B9T$9$k!#(B

@item M-x xdb @key{RET} @var{file} @key{RET}
@findex xdb
@vindex gud-xdb-directories
@c Similar, but run XDB instead of GDB.  Use the variable
@c @code{gud-xdb-directories} to specify directories to search for source
@c files.
$BF1MM$K!"(BGDB$B$N$+$o$j$K(BXDB$B$r<B9T$9$k!#(B
$B%=!<%9%U%!%$%k$rC5:w$9$k%G%#%l%/%H%j72$r;XDj$9$k$K$O!"(B
$BJQ?t(B@code{gud-xdb-directories}$B$r;H$&!#(B

@item M-x sdb @key{RET} @var{file} @key{RET}
@findex sdb
@c Similar, but run SDB instead of GDB.
$BF1MM$K!"(BGDB$B$N$+$o$j$K(BSDB$B$r<B9T$9$k!#(B

@c   Some versions of SDB do not mention source file names in their
@c messages.  When you use them, you need to have a valid tags table
@c (@pxref{Tags}) in order for GUD to find functions in the source code.
@c If you have not visited a tags table or the tags table doesn't list one
@c of the functions, you get a message saying @samp{The sdb support
@c requires a valid tags table to work}.  If this happens, generate a valid
@c tags table in the working directory and try again.
SDB$B$N%P!<%8%g%s$K$h$C$F$O!"%a%C%;!<%8$K%=!<%9%U%!%$%kL>$r(B
$B4^$a$J$$$b$N$,$"$k!#(B
$B$=$N$h$&$J(BSDB$B$r;H$&>l9g$K$O!"(BGUD$B$,%=!<%9%3!<%I$+$i4X?t$rC5$;$k$h$&$K(B
$B@5$7$$%?%0%F!<%V%k!J(B@pxref{Tags}$B!K$,I,MW$G$"$k!#(B
$B%?%0%F!<%V%k$rK,Ld$7$F$$$J$+$C$?$j!"(B
$B%?%0%F!<%V%k$KEv3:4X?t$,$J$+$C$?$j$9$k$H!"(B
@samp{The sdb support requires a valid tag table to work}$B$H$$$&(B
$B%a%C%;!<%8$,I=<($5$l$k!#(B
$B$3$N$h$&$J>l9g$K$O!":n6H%G%#%l%/%H%j$K@5$7$$%?%0%U%!%$%k$r@8@.$7$F$+$i(B
$B$d$jD>$9!#(B

@item M-x perldb @key{RET} @var{file} @key{RET}
@findex perldb
@c Run the Perl interpreter in debug mode to debug @var{file}, a Perl program.
Perl$B%W%m%0%i%`(B@var{file}$B$r%G%P%C%0$9$k$?$a$K(B
Perl$B%$%s%?!<%W%j%?$r%G%P%C%0%b!<%I$G<B9T$9$k!#(B

@item M-x jdb @key{RET} @var{file} @key{RET}
@findex jdb
@c Run the Java debugger to debug @var{file}.
@var{file}$B$r%G%P%C%0$9$k$?$a$K(BJava$B%G%P%C%,$r<B9T$9$k!#(B

@item M-x pdb @key{RET} @var{file} @key{RET}
@findex pdb
@c Run the Python debugger to debug @var{file}.
@var{file}$B$r%G%P%C%0$9$k$?$a$K(BPython$B%G%P%C%,$r<B9T$9$k!#(B
@end table

@c   Each of these commands takes one argument: a command line to invoke
@c the debugger.  In the simplest case, specify just the name of the
@c executable file you want to debug.  You may also use options that the
@c debugger supports.  However, shell wildcards and variables are not
@c allowed.  GUD assumes that the first argument not starting with a
@c @samp{-} is the executable file name.
$B$3$l$i$N%3%^%s%I$O0z?t$r(B1$B$D!"(B
$B$D$^$j!"%G%P%C%,$r5/F0$9$k%3%^%s%I9T$r<h$j$^$9!#(B
$B$b$C$H$bC1=c$J>l9g$O!"%G%P%C%0$7$?$$<B9T%U%!%$%k$NL>A0$r;XDj$7$^$9!#(B
$B%G%P%C%,$K;XDj$G$-$k%*%W%7%g%s$r;H$&$3$H$b$G$-$^$9!#(B
$B$7$+$7!"%7%'%k$N%o%$%k%I%+!<%I$dJQ?tL>$O;H$($^$;$s!#(B
GUD$B$O!"(B@samp{-}$B$G;O$^$i$J$$:G=i$N0z?t$r%G%P%C%0$9$k<B9T%U%!%$%kL>$G$"$k$H(B
$B2>Dj$7$^$9!#(B

@c   Emacs can only run one debugger process at a time.
Emacs$B$O%G%P%C%,%W%m%;%9$r0lEY$K(B1$B$D$@$1<B9T$G$-$^$9!#(B

@node Debugger Operation
@c @subsection Debugger Operation
@subsection $B%G%P%C%,$NA`:n(B

@c   When you run a debugger with GUD, the debugger uses an Emacs buffer
@c for its ordinary input and output.  This is called the GUD buffer.  The
@c debugger displays the source files of the program by visiting them in
@c Emacs buffers.  An arrow (@samp{=>}) in one of these buffers indicates
@c the current execution line.  Moving point in this buffer does not move
@c the arrow.
GUD$B$N2<$G%G%P%C%,$r<B9T$9$k$H!"(B
$B%G%P%C%,$ODL>o$NF~=PNO$K(BEmacs$B%P%C%U%!$r;H$$$^$9!#(B
$B$3$N%P%C%U%!$r(BGUD$B%P%C%U%!$H8F$S$^$9!#(B
$B%G%P%C%,$O(BEmacs$B%P%C%U%!$G%U%!%$%k$rK,Ld$7$F!"(B
$B%W%m%0%i%`$N%=!<%9%U%!%$%k$rI=<($7$^$9!#(B
$B$3$N$h$&$J%P%C%U%!$N(B1$B$D$KLp0u!J(B@samp{=>}$B!K$,I=<($5$l!"(B
$B8=:_<B9T$7$F$$$k9T$rI=<($7$^$9!#(B
$B$3$N%P%C%U%!$G%]%$%s%H$rF0$+$7$F$bLp0u$OF0$-$^$;$s!#(B

@c   You can start editing these source files at any time in the buffers
@c that were made to display them.  The arrow is not part of the file's
@c text; it appears only on the screen.  If you do modify a source file,
@c keep in mind that inserting or deleting lines will throw off the arrow's
@c positioning; GUD has no way of figuring out which line corresponded
@c before your changes to the line number in a debugger message.  Also,
@c you'll typically have to recompile and restart the program for your
@c changes to be reflected in the debugger's tables.
$B%=!<%9%U%!%$%k$rI=<($7$?%P%C%U%!$G$O!"$$$D$G$b%=!<%9%U%!%$%k$rJT=8$G$-$^$9!#(B
$BLp0u$O%U%!%$%k$N%F%-%9%H$N0lIt$G$O$J$/!"2hLL>e$KI=<($5$l$F$$$k$@$1$G$9!#(B
$B%=!<%9%U%!%$%k$rJQ99$9$k$H$-!"(B
$B9T$rA^F~!?:o=|$9$k$HLp0u$NI=<(0LCV>pJs$,<:$o$l$k$3$H$KCm0U$7$F$/$@$5$$!#(B
GUD$B$K$O!"JQ99A0$N%G%P%C%,%a%C%;!<%8$+$iJQ998e$NBP1~$9$k9THV9f$rCN$k=Q$O(B
$B$"$j$^$;$s!#(B
$B$^$?!"%G%P%C%,$K%=!<%9$NJQ99$rH?1G$9$k$K$O!"(B
$B%W%m%0%i%`$r:F%3%s%Q%$%k$7$F$+$i:F<B9T$9$kI,MW$,$"$j$^$9!#(B

@c   If you wish, you can control your debugger process entirely through the
@c debugger buffer, which uses a variant of Shell mode.  All the usual
@c commands for your debugger are available, and you can use the Shell mode
@c history commands to repeat them.  @xref{Shell Mode}.
$B$*9%$_$J$i$P!"%7%'%k!J(Bshell$B!K%b!<%I$NJQ7A$rMQ$$$?(B
$B%G%P%C%,%P%C%U%!$r2p$7$F!"%G%P%C%,%W%m%;%9$r40A4$K@)8f$9$k$3$H$b$G$-$^$9!#(B
$B$3$&$9$l$P!"%G%P%C%,$N$9$Y$F$N%3%^%s%I$rMxMQ$G$-!"(B
$B%7%'%k!J(Bshell$B!K%b!<%I$NMzNr5!G=$rMQ$$$F(B
$B%3%^%s%I$r7+$jJV$7<B9T$G$-$^$9!#(B
@xref{Shell Mode}$B!#(B

@node Commands of GUD
@c @subsection Commands of GUD
@subsection GUD$B$N%3%^%s%I(B

@c   The GUD interaction buffer uses a variant of Shell mode, so the
@c commands of Shell mode are available (@pxref{Shell Mode}).  GUD mode
@c also provides commands for setting and clearing breakpoints, for
@c selecting stack frames, and for stepping through the program.  These
@c commands are available both in the GUD buffer and globally, but with
@c different key bindings.
GUD$BBPOC%P%C%U%!$O%7%'%k!J(Bshell$B!K%b!<%I$NJQ7A$r;H$&$N$G!"(B
$B%7%'%k!J(Bshell$B!K%b!<%I$N%3%^%s%I$r;H$($^$9!J(B@pxref{Shell Mode}$B!K!#(B
GUD$B%b!<%I$G$O!"%V%l!<%/%]%$%s%H$N@_Dj$H2r=|!"%9%?%C%/%U%l!<%`$NA*Br!"(B
$B%W%m%0%i%`$N%9%F%C%W<B9T$J$I$N%3%^%s%I$b$"$j$^$9!#(B
$B$3$l$i$N%3%^%s%I$O(BGUD$B%P%C%U%!$G$b$=$l0J30$G$b;H$($^$9$,!"(B
$B%-!<%P%$%s%I$O0[$J$j$^$9!#(B

@c   The breakpoint commands are usually used in source file buffers,
@c because that is the way to specify where to set or clear the breakpoint.
@c Here's the global command to set a breakpoint:
$B%V%l!<%/%]%$%s%H%3%^%s%I$O!"IaDL!"%=!<%9%U%!%$%k$N%P%C%U%!$G;H$$$^$9!#(B
$B$H$$$&$N$O!"%=!<%9>e$G%V%l!<%/%]%$%s%H$r@_Dj!?2r=|$9$k$N$,<+A3$@$+$i$G$9!#(B
$B0J2<$O%V%l!<%/%]%$%s%H$r@_Dj$9$k%0%m!<%P%k%3%^%s%I$G$9!#(B

@table @kbd
@item C-x @key{SPC}
@kindex C-x SPC
@c Set a breakpoint on the source line that point is on.
$B%]%$%s%H$,$"$k%=!<%99T$K%V%l!<%/%]%$%s%H$r@_Dj$9$k!#(B   
@end table

@c @kindex C-x C-a @r{(GUD)}
@kindex C-x C-a @r{$B!J(BGUD$B!K(B}
@c   Here are the other special commands provided by GUD.  The keys
@c starting with @kbd{C-c} are available only in the GUD interaction
@c buffer.  The key bindings that start with @kbd{C-x C-a} are available in
@c the GUD interaction buffer and also in source files.
$B0J2<$O$=$NB>$N(BGUD$B%b!<%IFCM-$N%3%^%s%I$G$9!#(B
@kbd{C-c}$B$G;O$^$k%-!<Ns$O!"(BGUD$BBPOC%P%C%U%!$@$1$G;H$($^$9!#(B
@kbd{C-x C-a}$B$G;O$^$k%-!<Ns$O!"(B
GUD$BBPOC%P%C%U%!$H%=!<%9%U%!%$%k!J$N%P%C%U%!!K$NN>J}$G;H$($^$9!#(B

@table @kbd
@item C-c C-l
@c @kindex C-c C-l @r{(GUD)}
@kindex C-c C-l @r{$B!J(BGUD$B!K(B}
@itemx C-x C-a C-l
@findex gud-refresh
@c Display in another window the last line referred to in the GUD
@c buffer (that is, the line indicated in the last location message).
@c This runs the command @code{gud-refresh}.
GUD$B%P%C%U%!$G;2>H$7$?:G8e$N9T$rJL$N%&%#%s%I%&$KI=<($9$k(B
$B!J$D$^$j!":G?7$N<B9T0LCV%a%C%;!<%8$,;X$99T$rI=<($9$k!K!#(B
$B$3$l$O!"%3%^%s%I(B@code{gud-refresh}$B$r<B9T$9$k!#(B

@item C-c C-s
@c @kindex C-c C-s @r{(GUD)}
@kindex C-c C-s @r{$B!J(BGUD$B!K(B}
@itemx C-x C-a C-s
@findex gud-step
@c Execute a single line of code (@code{gud-step}).  If the line contains
@c a function call, execution stops after entering the called function.
$B%=!<%9%3!<%I(B1$B9TJ,$r<B9T$9$k!J(B@code{gud-step}$B!K!#(B
$B$=$N9T$K4X?t8F$S=P$7$,4^$^$l$k>l9g$O!"8F$S=P$5$l$?4X?t$KF~$C$F$+$iDd;_$9$k!#(B

@item C-c C-n
@c @kindex C-c C-n @r{(GUD)}
@kindex C-c C-n @r{$B!J(BGUD$B!K(B}
@itemx C-x C-a C-n
@findex gud-next
@c Execute a single line of code, stepping across entire function calls
@c at full speed (@code{gud-next}).
$B%=!<%9%3!<%I(B1$B9TJ,$r<B9T$7!"4X?t8F$S=P$7$G$b(B
$BDd;_$;$:$K%U%k%9%T!<%I$G<B9T$9$k!J(B@code{gud-next}$B!K!#(B

@item C-c C-i
@c @kindex C-c C-i @r{(GUD)}
@kindex C-c C-i @r{$B!J(BGUD$B!K(B}
@itemx C-x C-a C-i
@findex gud-stepi
@c Execute a single machine instruction (@code{gud-stepi}).
$B5!3#8l(B1$BL?Na$r<B9T$9$k!J(B@code{gud-stepi}$B!K!#(B

@need 3000
@item C-c C-r
@c @kindex C-c C-r @r{(GUD)}
@kindex C-c C-r @r{$B!J(BGUD$B!K(B}
@itemx C-x C-a C-r
@findex gud-cont
@c Continue execution without specifying any stopping point.  The program
@c will run until it hits a breakpoint, terminates, or gets a signal that
@c the debugger is checking for (@code{gud-cont}).
$BDd;_0LCV$r;XDj$;$:$K<B9T$r7QB3$9$k!#(B
$B%W%m%0%i%`$N<B9T$O!"%V%l!<%/%]%$%s%H$K=P2q$&!"(B
$B%W%m%0%i%`$,=*N;$9$k!"(B
$B%G%P%C%,$,4F;k$7$F$$$k%7%0%J%k$r<u$1<h$k$^$G<B9T$r7QB3$9$k!#(B

@need 1000
@item C-c C-d
@c @kindex C-c C-d @r{(GUD)}
@kindex C-c C-d @r{$B!J(BGUD$B!K(B}
@itemx C-x C-a C-d
@findex gud-remove
@c Delete the breakpoint(s) on the current source line, if any
@c (@code{gud-remove}).  If you use this command in the GUD interaction
@c buffer, it applies to the line where the program last stopped.
$B8=:_$N%=!<%99T$K%V%l!<%/%]%$%s%H$,$"$k$J$i$P$=$l$r:o=|$9$k(B
$B!J(B@code{gud-remove}$B!K!#(B
GUD$BBPOC%P%C%U%!$G$3$N%3%^%s%I$r;H$&$H!"(B
$B%W%m%0%i%`$,:G8e$KDd;_$7$?9T$KE,MQ$5$l$k!#(B

@item C-c C-t
@c @kindex C-c C-t @r{(GUD)}
@kindex C-c C-t @r{$B!J(BGUD$B!K(B}
@itemx C-x C-a C-t
@findex gud-tbreak
@c Set a temporary breakpoint on the current source line, if any.
@c If you use this command in the GUD interaction buffer,
@c it applies to the line where the program last stopped.
$B8=:_$N%=!<%99T$K0l;~E*$J%V%l!<%/%]%$%s%H$r@_Dj$9$k!#(B
GUD$BBPOC%P%C%U%!$G$3$N%3%^%s%I$r;H$&$H!"(B
$B%W%m%0%i%`$,:G8e$KDd;_$7$?9T$KE,MQ$5$l$k!#(B
@end table

@c   The above commands are common to all supported debuggers.  If you are
@c using GDB or (some versions of) DBX, these additional commands are available:
$B>e$K$"$2$?%3%^%s%I$O!"!J(BGUD$B$+$i;H$($k!K$9$Y$F$N%G%P%C%,$K6&DL$G$9!#(B
GDB$B$d(BDBX$B!J$N$"$k%P!<%8%g%s!K$G$O!"$5$i$K0J2<$N%3%^%s%I$b;H$($^$9!#(B

@table @kbd
@item C-c <
@c @kindex C-c < @r{(GUD)}
@kindex C-c < @r{$B!J(BGUD$B!K(B}
@itemx C-x C-a <
@findex gud-up
@c Select the next enclosing stack frame (@code{gud-up}).  This is
@c equivalent to the @samp{up} command.
1$B$D30B&$N%9%?%C%/%U%l!<%`$rA*Br$9$k!J(B@code{gud-up}$B!K!#(B
$B$3$l$O(B@samp{up}$B%3%^%s%I$HEy2A!#(B

@item C-c >
@c @kindex C-c > @r{(GUD)}
@kindex C-c > @r{$B!J(BGUD$B!K(B}
@itemx C-x C-a >
@findex gud-down
@c Select the next inner stack frame (@code{gud-down}).  This is
@c equivalent to the @samp{down} command.
1$B$DFbB&$N%9%?%C%/%U%l!<%`$rA*Br$9$k!J(B@code{gud-down}$B!K!#(B
$B$3$l$O(B@samp{down}$B%3%^%s%I$HEy2A!#(B
@end table

@c   If you are using GDB, these additional key bindings are available:
GDB$B$r;H$&>l9g$K$O0J2<$N%3%^%s%I$b;HMQ$G$-$^$9!#(B

@table @kbd
@item @key{TAB}
@c @kindex TAB @r{(GUD)}
@kindex TAB @r{$B!J(BGUD$B!K(B}
@findex gud-gdb-complete-command
@c With GDB, complete a symbol name (@code{gud-gdb-complete-command}).
@c This key is available only in the GUD interaction buffer, and requires
@c GDB versions 4.13 and later.
GDB$B$G$O!"%7%s%\%kL>$rJd40$9$k!J(B@code{gud-gdb-complete-command}$B!K!#(B
$B$3$N%-!<$O(BGUD$B$NBPOC%P%C%U%!$G$@$1;H$($k!#(B
$B$^$?!"(BGDB$B$N%P!<%8%g%s$O(B4.13$B0J9_$G$"$k$3$H!#(B

@item C-c C-f
@c @kindex C-c C-f @r{(GUD)}
@kindex C-c C-f @r{$B!J(BGUD$B!K(B}
@itemx C-x C-a C-f
@findex gud-finish
@c Run the program until the selected stack frame returns (or until it
@c stops for some other reason).
$B$"$i$+$8$aA*Br$7$?%9%?%C%/%U%l!<%`$+$iLa$k(B
$B!J$"$k$$$O!"B>$NM}M3$GDd;_$9$k!K$^$G%W%m%0%i%`$r<B9T$9$k!#(B
@end table

@c   These commands interpret a numeric argument as a repeat count, when
@c that makes sense.
$B$3$l$i$N%3%^%s%I$O!"0UL#$,$"$k>l9g$K$O?t0z?t$rH?I|2s?t$H$7$F2r<a$7$^$9!#(B

@c   Because @key{TAB} serves as a completion command, you can't use it to
@c enter a tab as input to the program you are debugging with GDB.
@c Instead, type @kbd{C-q @key{TAB}} to enter a tab.
@key{TAB}$B$O!"Jd40%3%^%s%I$H$7$FF/$/$?$a!"(B
GDB$B$G%G%P%C%0$7$F$$$k%W%m%0%i%`$X$N%?%V$NF~NO$K$O;H$($^$;$s!#(B
$B%?%V$rF~NO$9$k$K$O(B@kbd{C-q @key{TAB}}$B$HBG80$7$^$9!#(B

@node GUD Customization
@c @subsection GUD Customization
@subsection GUD$B$N%+%9%?%^%$%:(B

@vindex gdb-mode-hook
@vindex dbx-mode-hook
@vindex sdb-mode-hook
@vindex xdb-mode-hook
@vindex perldb-mode-hook
@vindex pdb-mode-hook
@vindex jdb-mode-hook
@c   On startup, GUD runs one of the following hooks: @code{gdb-mode-hook},
@c if you are using GDB; @code{dbx-mode-hook}, if you are using DBX;
@c @code{sdb-mode-hook}, if you are using SDB; @code{xdb-mode-hook}, if you
@c are using XDB; @code{perldb-mode-hook}, for Perl debugging mode;
@c @code{jdb-mode-hook}, for PDB; @code{jdb-mode-hook}, for JDB.  You can
@c =     ~~~ pdb-
@c use these hooks to define custom key bindings for the debugger
@c interaction buffer.  @xref{Hooks}.
GUD$B$,<B9T$r3+;O$9$k$H!"(B
GDB$B$N>l9g$O(B@code{gdb-mode-hook}$B!"(B
DBX$B$N>l9g$O(B@code{dbx-mode-hook}$B!"(B
SDB$B$N>l9g$O(B@code{sdb-mode-hook}$B!"(B
XDB$B$N>l9g$O(B@code{xdb-mode-hook}$B!"(B
Perl$B$N%G%P%C%0%b!<%I$N>l9g$O(B@code{perldb-mode-hook}$B!"(B
PDB$B$N>l9g$O(B@code{pdb-mode-hook}$B!"(B
JDB$B$N>l9g$O(B@code{jdb-mode-hook}$B$N%U%C%/$r<B9T$7$^$9!#(B
$B$3$l$i$N%U%C%/$r;H$C$F!"%G%P%C%,$NBPOC%P%C%U%!MQ$K(B
$B<+A0$N%-!<%P%$%s%I$rDj5A$G$-$^$9!#(B
@xref{Hooks}$B!#(B

@c   Here is a convenient way to define a command that sends a particular
@c command string to the debugger, and set up a key binding for it in the
@c debugger interaction buffer:
$B0J2<$O!"FCDj$N%3%^%s%IJ8;zNs$r%G%P%C%,$KAw$k%3%^%s%I$rDj5A$7!"$+$D!"(B
$B$=$N%3%^%s%I$KBP$9$k%-!<%P%$%s%I$r%G%P%C%,$NBPOC%P%C%U%!$K@_Dj$9$k(B
$BJXMx$JJ}K!$G$9!#(B

@findex gud-def
@example
(gud-def @var{function} @var{cmdstring} @var{binding} @var{docstring})
@end example

@c   This defines a command named @var{function} which sends
@c @var{cmdstring} to the debugger process, and gives it the documentation
@c string @var{docstring}.  You can use the command thus defined in any
@c buffer.  If @var{binding} is non-@code{nil}, @code{gud-def} also binds
@c the command to @kbd{C-c @var{binding}} in the GUD buffer's mode and to
@c @kbd{C-x C-a @var{binding}} generally.
$B$3$l$O!"%G%P%C%,%W%m%;%9$K(B@var{cmdstring}$B$rAw$k(B
@var{function}$B$H$$$&L>A0$N%3%^%s%I$rDj5A$7!"(B
$B$=$N%3%^%s%I$N@bL@J8;zNs$r(B@var{docstring}$B$H$7$^$9!#(B
$B$3$N$h$&$KDj5A$7$?%3%^%s%I$O!"$I$N%P%C%U%!$G$b;H$($^$9!#(B
@var{binding}$B$,(B@code{nil}$B0J30$N>l9g!"(B
@code{gud-def}$B$O(BGUD$B%P%C%U%!$N%b!<%I$KBP$7$F$O(B
$B$3$N%3%^%s%I$r(B@kbd{C-c @var{binding}}$B$K%P%$%s%I$7!"(B
$B$=$l0J30$KBP$7$F$O(B@kbd{C-x C-a @var{binding}}$B$K%P%$%s%I$7$^$9!#(B

@c   The command string @var{cmdstring} may contain certain
@c @samp{%}-sequences that stand for data to be filled in at the time
@c @var{function} is called:
$B%3%^%s%IJ8;zNs(B@var{cmdstring}$B$K$O!"(B
@var{function}$B$,8F$S=P$5$l$?$H$-$K%G!<%?$,Kd$a9~$^$l$k(B
@samp{%}$B7ONs$r4^$a$k$3$H$b$G$-$^$9!#(B

@table @samp
@item %f
@c The name of the current source file.  If the current buffer is the GUD
@c buffer, then the ``current source file'' is the file that the program
@c stopped in.
@c @c This said, ``the name of the file the program counter was in at the last breakpoint.''
@c @c But I suspect it is really the last stop file.
$B8=:_$N%=!<%9%U%!%$%k$NL>A0!#(B
$B%+%l%s%H%P%C%U%!$,(BGUD$B%P%C%U%!$@$C$?>l9g$K$O!"(B
$B!X8=:_$N%=!<%9%U%!%$%k!Y$H$O(B
$B%W%m%0%i%`$,Dd;_$7$?2U=j$KBP1~$9$k%=!<%9%U%!%$%k!#(B

@item %l
@c The number of the current source line.  If the current buffer is the GUD
@c buffer, then the ``current source line'' is the line that the program
@c stopped in.
$B8=:_$N%=!<%99THV9f!#(B
$B%+%l%s%H%P%C%U%!$,(BGUD$B%P%C%U%!$@$C$?>l9g$K$O!"(B
$B!X8=:_$N%=!<%99THV9f!Y$H$O(B
$B%W%m%0%i%`$,Dd;_$7$?2U=j$KBP1~$9$k%=!<%9%U%!%$%k$N9THV9f!#(B

@item %e
@c The text of the C lvalue or function-call expression at or adjacent to point.
$B%]%$%s%H0LCV$"$k$$$O%]%$%s%H$KNY@\$9$k(B
C$B$N:8JUCM$+4X?t8F$S=P$7<0!#(B

@item %a
@c The text of the hexadecimal address at or adjacent to point.
$B%]%$%s%H0LCV$"$k$$$O%]%$%s%H$KNY@\$9$k(B
$B2U=j$N(B16$B?J?tI=5-%"%I%l%9!#(B

@item %p
@c The numeric argument of the called function, as a decimal number.  If
@c the command is used without a numeric argument, @samp{%p} stands for the
@c empty string.
@var{function}$B$r8F$V$H$-$K;XDj$5$l$??t0z?t$r(B10$B?JCMI=5-$7$?$b$N!#(B
$B?t0z?t$J$7$G8F$P$l$?>l9g!"(B@samp{%p}$B$O6uJ8;zNs!#(B

@c If you don't use @samp{%p} in the command string, the command you define
@c ignores any numeric argument.
@var{cmdstring}$B$G(B@samp{%p}$B$r;HMQ$7$J$1$l$P!"(B
$BDj5A$7$h$&$H$7$F$$$k(B@var{function}$B$O?t0z?t$rL5;k$9$k!#(B
@end table

@node Executing Lisp
@c @section Executing Lisp Expressions
@section Lisp$B<0$N<B9T(B

@c   Emacs has several different major modes for Lisp and Scheme.  They are
@c the same in terms of editing commands, but differ in the commands for
@c executing Lisp expressions.  Each mode has its own purpose.
Emacs$B$K$O!"(BLisp$B$d(BScheme$B$N$?$a$N0[$J$C$?%a%8%c!<%b!<%I$,$$$/$D$+$"$j$^$9!#(B
$B$3$l$i$OJT=8%3%^%s%I$H$$$&0UL#$G$OF1$8$G$9$,!"(B
Lisp$B<0$r<B9T$9$k%3%^%s%I$,0[$J$j$^$9!#(B
$B3F%b!<%I$K$O8GM-$NL\E*$,$"$j$^$9!#(B

@table @asis
@c @item Emacs-Lisp mode
@item emacs-lisp$B%b!<%I(B
@c The mode for editing source files of programs to run in Emacs Lisp.
@c This mode defines @kbd{C-M-x} to evaluate the current defun.
@c @xref{Lisp Libraries}.
$B$3$N%b!<%I$O(BEmacs Lisp$B$G<B9T$9$k%W%m%0%i%`$N%=!<%9%U%!%$%kJT=8MQ!#(B
$B$3$N%b!<%I$G$O!"8=:_$N4X?tDj5A$rI>2A$9$k(B@kbd{C-M-x}$B$rDj5A$9$k!#(B
@pxref{Lisp Libraries}$B!#(B
@c @item Lisp Interaction mode
@item lisp$BBPOC%b!<%I!J(BLisp Interaction mode$B!K(B
@c The mode for an interactive session with Emacs Lisp.  It defines
@c @kbd{C-j} to evaluate the sexp before point and insert its value in the
@c buffer.  @xref{Lisp Interaction}.
$B$3$N%b!<%I$O(BEmacs Lisp$B$NBPOC%;%C%7%g%sMQ!#(B
$B%]%$%s%H$ND>A0$N(BS$B<0$rI>2A$7!"$=$NCM$r%P%C%U%!$KA^F~$9$k(B@kbd{C-j}$B$rDj5A$9$k!#(B
@pxref{Lisp Interaction}$B!#(B
@c @item Lisp mode
@item lisp$B%b!<%I(B
@c The mode for editing source files of programs that run in Lisps other
@c than Emacs Lisp.  This mode defines @kbd{C-M-x} to send the current defun
@c to an inferior Lisp process.  @xref{External Lisp}.
$B$3$N%b!<%I$O(BEmacs Lisp$B0J30$N(BLisp$B$G<B9T$9$k%W%m%0%i%`$N%=!<%9%3!<%IJT=8MQ!#(B
$B$3$N%b!<%I$G$O!"(B
$B8=:_$N4X?tDj5A$r2<0L$N(BLisp$B%W%m%;%9$KAw$k(B@kbd{C-M-x}$B$rDj5A$9$k!#(B
@pxref{External Lisp}$B!#(B
@c @item Inferior Lisp mode
@item $B2<0L(Blisp$B%b!<%I!J(BInferior Lisp mode$B!K(B
@c The mode for an interactive session with an inferior Lisp process.
@c This mode combines the special features of Lisp mode and Shell mode
@c (@pxref{Shell Mode}).
$B$3$N%b!<%I$O2<0L(BLisp$B%W%m%;%9$H$NBPOC%;%C%7%g%sMQ!#(B
$B$3$N%b!<%I$O!"(Blisp$B%b!<%I$H%7%'%k!J(Bshell$B!K%b!<%I!J(B@pxref{Shell Mode}$B!K(B
$B$NFCJL$J5!G=$NAH$_9g$o$;!#(B
@c @item Scheme mode
@item scheme$B%b!<%I(B
@c Like Lisp mode but for Scheme programs.
lisp$B%b!<%I$HF1MM$@$,!"(BScheme$B%W%m%0%i%`JT=8MQ!#(B
@c @item Inferior Scheme mode
@item $B2<0L(BScheme$B%b!<%I!J(BInferior Scheme mode$B!K(B
@c The mode for an interactive session with an inferior Scheme process.
$B$3$N%b!<%I$O2<0L$N(BScheme$B%W%m%;%9$H$NBPOC%;%C%7%g%sMQ!#(B
@end table

@c   Most editing commands for working with Lisp programs are in fact
@c available globally.  @xref{Programs}.
Lisp$B%W%m%0%i%`MQ$NJT=8%3%^%s%I$NBgItJ,$O;v<B>e$I$3$G$b;H$($^$9!#(B
@xref{Programs}$B!#(B

@node Lisp Libraries
@c @section Libraries of Lisp Code for Emacs
@section Emacs$BMQ$N(BLisp$B%3!<%I$N%i%$%V%i%j(B
@c @cindex libraries
@cindex $B%i%$%V%i%j(B
@c @cindex loading Lisp code
@cindex Lisp$B%3!<%I$N%m!<%I(B
@cindex $B%m!<%I!J(BLisp$B%3!<%I!K(B

@c   Lisp code for Emacs editing commands is stored in files whose names
@c conventionally end in @file{.el}.  This ending tells Emacs to edit them in
@c Emacs-Lisp mode (@pxref{Executing Lisp}).
Emacs$BJT=8%3%^%s%I$N(BLisp$B%3!<%I$O!"=,47E*$K(B@file{.el}$B$G=*$kL>A0$N(B
$B%U%!%$%k$K3JG<$5$l$F$$$^$9!#(B
$B$3$l$i$N3HD%;R$O!"(B
emacs-lisp$B%b!<%I$GJT=8$9$k$h$&$K(BEmacs$B$K;X<($7$^$9(B
$B!J(B@pxref{Executing Lisp}$B!K!#(B

@findex load-file
@c   To execute a file of Emacs Lisp code, use @kbd{M-x load-file}.  This
@c command reads a file name using the minibuffer and then executes the
@c contents of that file as Lisp code.  It is not necessary to visit the
@c file first; in any case, this command reads the file as found on disk,
@c not text in an Emacs buffer.
Emacs Lisp$B%3!<%I$N%U%!%$%k$r<B9T$9$k$K$O!"(B
@kbd{M-x load-file}$B$r;H$$$^$9!#(B
$B$3$N%3%^%s%I$O!"%_%K%P%C%U%!$G%U%!%$%kL>$rFI$_<h$j!"(B
$B$=$N%U%!%$%k$NFbMF$r(BLisp$B%3!<%I$H$7$F<B9T$7$^$9!#(B
$B$"$i$+$8$a%U%!%$%k$rK,Ld$7$F$*$/I,MW$O$"$j$^$;$s!#(B
$B$$$:$l$K$7$F$b!"$3$N%3%^%s%I$O%G%#%9%/>e$N%U%!%$%k$rFI$`$N$G$"$C$F!"(B
Emacs$B%P%C%U%!$N%F%-%9%H$rFI$`$N$G$O$"$j$^$;$s!#(B

@findex load
@findex load-library
@c   Once a file of Lisp code is installed in the Emacs Lisp library
@c directories, users can load it using @kbd{M-x load-library}.  Programs can
@c load it by calling @code{load-library}, or with @code{load}, a more primitive
@c function that is similar but accepts some additional arguments.
Lisp$B%3!<%I$N%U%!%$%k$r(BEmacs Lisp$B%i%$%V%i%j$N%G%#%l%/%H%j$KCV$$$F$*$1$P!"(B
$B$=$N%U%!%$%k$O(B@kbd{M-x load-library}$B$G%m!<%I$G$-$^$9!#(B
$B%W%m%0%i%`$+$i$O!"(B@code{load-library}$B$r8F$s$G%m!<%I$9$k$+!"$"$k$$$O!"(B
$B$h$j4pK\E*$JN`;w$N4X?t$GM>J,$J0z?t$b;XDj$G$-$k(B@code{load}$B$G%m!<%I$7$^$9!#(B

@c   @kbd{M-x load-library} differs from @kbd{M-x load-file} in that it
@c searches a sequence of directories and tries three file names in each
@c directory.  Suppose your argument is @var{lib}; the three names are
@c @file{@var{lib}.elc}, @file{@var{lib}.el}, and lastly just
@c @file{@var{lib}}.  If @file{@var{lib}.elc} exists, it is by convention
@c the result of compiling @file{@var{lib}.el}; it is better to load the
@c compiled file, since it will load and run faster.
@kbd{M-x load-library}$B$,(B@kbd{M-x load-file}$B$H0[$J$kE@$O!"(B
$B0lO"$N%G%#%l%/%H%j$K$D$$$F(B3$B$D$N%U%!%$%kL>$r=g$KD4$Y$k$H$$$&$3$H$G$9!#(B
$B0z?t$,(B@var{lib}$B$@$H$9$k$H!"(B3$B$D$N%U%!%$%kL>$H$O!"(B
@file{@var{lib}.elc}$B!"(B@file{@var{lib}.el}$B!"$=$7$F:G8e$K(B@file{@var{lib}}$B$G$9!#(B
@file{@var{lib}.elc}$B$H$$$&%U%!%$%k$,B8:_$9$l$P!"(B
$B$3$l$O=,47$H$7$F(B@file{@var{lib}.el}$B$r%3%s%Q%$%k$7$?$b$N$G$9!#(B
$B%3%s%Q%$%k:Q$_$N%U%!%$%k$O%m!<%I$H<B9T$,B.$$$N$G!"(B
$B$3$A$i$r%m!<%I$9$k$[$&$,M-Mx$G$9!#(B

@c   If @code{load-library} finds that @file{@var{lib}.el} is newer than
@c @file{@var{lib}.elc} file, it prints a warning, because it's likely that
@c somebody made changes to the @file{.el} file and forgot to recompile
@c it.
@code{load-library}$B$,(B@file{@var{lib}.elc}$B$h$j$b?7$7$$(B
@file{@var{lib}.el}$B$r$_$D$1$k$H!"7Y9p$r=PNO$7$^$9!#(B
$B$H$$$&$N$O!"(B@file{.el}$B%U%!%$%k$rJQ998e$K:F%3%s%Q%$%k$7K:$l$F$$$k(B
$B2DG=@-$,$"$k$+$i$G$9!#(B

@c   Because the argument to @code{load-library} is usually not in itself
@c a valid file name, file name completion is not available.  Indeed, when
@c using this command, you usually do not know exactly what file name
@c will be used.
@code{load-library}$B$N0z?t$O!"DL>o!"$=$l<+BN$G$O(B
$B@5$7$$%U%!%$%kL>$G$J$$$3$H$,B?$$$?$a!"%U%!%$%kL>$NJd40$O$G$-$^$;$s!#(B
$B$b$A$m$s!"$3$N%3%^%s%I$r;H$&$H$-!"(B
$B;XDj$9$Y$-@53N$J%U%!%$%kL>$rIaDL$OCN$i$J$$$G$7$g$&$,!#(B

@vindex load-path
@c   The sequence of directories searched by @kbd{M-x load-library} is
@c specified by the variable @code{load-path}, a list of strings that are
@c directory names.  The default value of the list contains the directory where
@c the Lisp code for Emacs itself is stored.  If you have libraries of
@c your own, put them in a single directory and add that directory
@c to @code{load-path}.  @code{nil} in this list stands for the current default
@c directory, but it is probably not a good idea to put @code{nil} in the
@c list.  If you find yourself wishing that @code{nil} were in the list,
@c most likely what you really want to do is use @kbd{M-x load-file}
@c this once.
@kbd{M-x load-library}$B$,C5:w$9$k%G%#%l%/%H%j$N=gHV$O!"(B
$BJQ?t(B@code{load-path}$B$G;XDj$7$^$9!#(B
$B$=$NCM$O!"%G%#%l%/%H%jL>$NJ8;zNs$+$i@.$k%j%9%H$G$9!#(B
$B%j%9%H$N%G%U%)%k%HCM$K$O!"(BEmacs$B<+?H$N(BLisp$B%3!<%I$r<}$a$?%G%#%l%/%H%j$,(B
$B4^$^$l$^$9!#(B
$B8D?MMQ$N(BLisp$B%i%$%V%i%j$,$"$k$J$i$P!"$=$l$i$r(B1$B$D$N%G%#%l%/%H%j$K$^$H$a!"(B
$B$=$N%G%#%l%/%H%jL>$r(B@code{load-path}$B$KDI2C$7$F$/$@$5$$!#(B
$B%j%9%HFb$N(B@code{nil}$B$O%+%l%s%H%G%U%)%k%H%G%#%l%/%H%j$rI=$7$^$9$,!"(B
$B%j%9%H$K(B@code{nil}$B$r2C$($k$3$H$O$"$^$j4+$a$i$l$^$;$s!#(B
$B%j%9%H$K(B@code{nil}$B$,K\Ev$KI,MW$@$H46$8$?$H$-$K$O!"(B
$B$=$l$K$D$$$F$O(B@kbd{M-x load-file}$B$r<B9T$9$k$N$G$O(B
$B$$$1$J$$$@$m$&$+$H9M$($F$_$F$/$@$5$$!#(B

@c @cindex autoload
@cindex $B<+F0%m!<%I(B
@c   Often you do not have to give any command to load a library, because
@c the commands defined in the library are set up to @dfn{autoload} that
@c library.  Trying to run any of those commands calls @code{load} to load
@c the library; this replaces the autoload definitions with the real ones
@c from the library.
$B%i%$%V%i%j$NCf$GDj5A$5$l$F$$$k%3%^%s%I$KBP$7$F$O!"(B
$B$=$N%i%$%V%i%j$r(B@dfn{$B<+F0E*$K%m!<%I(B}$B!J(Bautoload$B!K$9$k$h$&$K(B
$B@_Dj$5$l$F$$$k$N$G!"$[$H$s$I$N>l9g!"%i%$%V%i%j$r%m!<%I$9$k%3%^%s%I$r(B
$B;XDj$9$kI,MW$O$J$$$G$7$g$&!#(B
$B%i%$%V%i%j$r%m!<%I$9$k$?$a$K(B@code{load}$B$r8F$S=P$9$h$&$J%3%^%s%I$r(B1$B$D(B
$B;n$7$F$_$F$/$@$5$$!#(B
$B$3$&$9$k$H!"!V<+F0E*$K%m!<%I$9$k!W$H$$$&Dj5A$,(B
$B%i%$%V%i%jFb$N<B:]$NDj5A$GCV$-49$o$j$^$9!#(B

@c @cindex byte code
@cindex $B%P%$%H%3!<%I(B
@c   Emacs Lisp code can be compiled into byte-code which loads faster,
@c takes up less space when loaded, and executes faster.  @xref{Byte
@c Compilation,, Byte Compilation, elisp, the Emacs Lisp Reference Manual}.
@c By convention, the compiled code for a library goes in a separate file
@c whose name consists of the library source file with @samp{c} appended.
@c Thus, the compiled code for @file{foo.el} goes in @file{foo.elc}.
@c That's why @code{load-library} searches for @samp{.elc} files first.
Emacs Lisp$B%3!<%I$O%P%$%H%3!<%I$K%3%s%Q%$%k$G$-$^$9!#(B
$B%3%s%Q%$%k$9$k$H!"%m!<%I$,B.$/$J$j!"%m!<%I$7$F$bI,MW$J5-21MFNL$,>/$J$/$J$j!"(B
$B<B9T$bB.$/$J$j$^$9!#(B
@xref{Byte Compilation,, Byte Compilation, elisp, The Emacs Lisp Reference Manual}$B!#(B
$B=,47$H$7$F!"%i%$%V%i%j$N%3%s%Q%$%k:Q$_$N%3!<%I$O!"(B
$B%i%$%V%i%j$N%=!<%9%U%!%$%kL>$K(B@samp{c}$B$rIU$1$?L>A0$N(B
$BJL$N%U%!%$%k$KF~$j$^$9!#(B
$B$7$?$,$C$F!"(B@file{foo.el}$B$N%3%s%Q%$%k:Q$_$N%3!<%I$O!"(B@file{foo.elc}$B$KF~$j$^$9!#(B
$B$3$l$,!"(B@code{load-library}$B$O$^$:(B@samp{.elc}$B$H$$$&%U%!%$%k$rC5$9M}M3$G$9!#(B

@node Lisp Eval
@c @section Evaluating Emacs-Lisp Expressions
@section Emacs Lisp$B<0$NI>2A(B
@c @cindex Emacs-Lisp mode
@cindex emacs-lisp$B%b!<%I(B
@c @cindex mode, Emacs-Lisp
@cindex $B%b!<%I!"(BEmacs-Lisp

@findex emacs-lisp-mode
@c   Lisp programs intended to be run in Emacs should be edited in
@c Emacs-Lisp mode; this happens automatically for file names ending in
@c @file{.el}.  By contrast, Lisp mode itself is used for editing Lisp
@c programs intended for other Lisp systems.  To switch to Emacs-Lisp mode
@c explicitly, use the command @kbd{M-x emacs-lisp-mode}.
Emacs$BFb$GF0$+$9$D$b$j$N(BLisp$B%W%m%0%i%`$O!"(Bemacs-lisp$B%b!<%I$GJT=8$7$^$7$g$&!#(B
$B%U%!%$%kL>$,(B@file{.el}$B$G=*$C$F$$$k%U%!%$%k$rJT=8$9$k$H!"(B
$B<+F0E*$K$3$N%b!<%I$K$J$j$^$9!#(B
$B0lJ}!"(Blisp$B%b!<%I$O!"B>$N(BLisp$B%7%9%F%`8~$1$N(BLisp$B%W%m%0%i%`$rJT=8$9$k(B
$B$?$a$N%b!<%I$G$9!#(B
$BM[$K(Bemacs-lisp$B%b!<%I$K0\$k$K$O!"%3%^%s%I(B@kbd{M-x emacs-lisp-mode}$B$r;H$$$^$9!#(B

@c   For testing of Lisp programs to run in Emacs, it is often useful to
@c evaluate part of the program as it is found in the Emacs buffer.  For
@c example, after changing the text of a Lisp function definition,
@c evaluating the definition installs the change for future calls to the
@c function.  Evaluation of Lisp expressions is also useful in any kind of
@c editing, for invoking noninteractive functions (functions that are
@c not commands).
Emacs$BFb$GF0$/%W%m%0%i%`$N%F%9%H$K$O!"(B
Emacs$B%P%C%U%!$K$"$k%W%m%0%i%`$N0lIt$rI>2A$9$k$HJXMx$G$9!#(B
$B$?$H$($P!"(BLisp$B$N4X?tDj5A$N%F%-%9%H$rJQ99$7$F$+$i$=$NDj5A$rI>2A$9$k$H!"(B
$B$=$l0J9_$K$=$N4X?t$r8F$S=P$9$H;H$o$l$k$h$&$K%$%s%9%H!<%k$5$l$^$9!#(B
Lisp$B<0$rI>2A$9$k$HHsBPOCE*$J!J%3%^%s%I$G$O$J$$!K4X?t$r5/F0$G$-$k$N$G!"(B
$B$I$s$J<oN`$NJT=8:n6H$K$bJXMx$G$9!#(B

@table @kbd
@item M-:
@c Read a single Lisp expression in the minibuffer, evaluate it, and print
@c the value in the echo area (@code{eval-expression}).
$B%_%K%P%C%U%!$G(B1$B$D$N(BLisp$B<0$rFI$_<h$j!"$=$l$rI>2A$7!"(B
$B$=$NCM$r%(%3!<NN0h$KI=<($9$k(B
$B!J(B@code{eval-expression}$B!K!#(B
@item C-x C-e
@c Evaluate the Lisp expression before point, and print the value in the
@c echo area (@code{eval-last-sexp}).
$B%]%$%s%H$ND>A0$N(BLisp$B<0$rI>2A$7!"$=$NCM$r%(%3!<NN0h$KI=<($9$k(B
$B!J(B@code{eval-last-sexp}$B!K!#(B
@item C-M-x
@c Evaluate the defun containing or after point, and print the value in
@c the echo area (@code{eval-defun}).
$B%]%$%s%H$r4^$`$+D>8e$K$"$k4X?tDj5A!J(Bdefun$B!K$rI>2A$7!"(B
$B$=$NCM$r%(%3!<NN0h$KI=<($9$k!J(B@code{eval-defun}$B!K!#(B
@item M-x eval-region
@c Evaluate all the Lisp expressions in the region.
$B%j!<%8%g%sFb$N$9$Y$F$N(BLisp$B<0$rI>2A$9$k!#(B
@item M-x eval-current-buffer
@c Evaluate all the Lisp expressions in the buffer.
$B%P%C%U%!Fb$N$9$Y$F$N(BLisp$B<0$rI>2A$9$k!#(B
@end table

@kindex M-:
@findex eval-expression
@c   @kbd{M-:} (@code{eval-expression}) is the most basic command for evaluating
@c a Lisp expression interactively.  It reads the expression using the
@c minibuffer, so you can execute any expression on a buffer regardless of
@c what the buffer contains.  When the expression is evaluated, the current
@c buffer is once again the buffer that was current when @kbd{M-:} was
@c typed.
@kbd{M-:}$B!J(B@code{eval-expression}$B!K$O!"(BLisp$B<0$rBPOCE*$KI>2A$9$k(B
$B$b$C$H$b4pK\E*$J%3%^%s%I$G$9!#(B
$B$3$l$O!"%_%K%P%C%U%!$G<0$r(B1$B$DFI$_<h$j$^$9$+$i!"(B
$B%P%C%U%!$NFbMF$K4X78$J$/%P%C%U%!Fb$G$I$s$J<0$G$b<B9T$G$-$^$9!#(B
$B<0$,I>2A$5$l$?$"$H$O!"(B
@kbd{M-:}$B$rBG80$7$?$H$-$N%+%l%s%H%P%C%U%!$,!"$U$?$?$S%+%l%s%H%P%C%U%!$K$J$j$^$9!#(B

@c @kindex C-M-x @r{(Emacs-Lisp mode)}
@kindex C-M-x @r{$B!J(Bemacs-lisp$B%b!<%I!K(B}
@findex eval-defun
@c   In Emacs-Lisp mode, the key @kbd{C-M-x} is bound to the command
@c @code{eval-defun}, which parses the defun containing or following point
@c as a Lisp expression and evaluates it.  The value is printed in the echo
@c area.  This command is convenient for installing in the Lisp environment
@c changes that you have just made in the text of a function definition.
emacs-lisp$B%b!<%I$G$O!"%-!<(B@kbd{C-M-x}$B$O%3%^%s%I(B@code{eval-defun}$B$K%P%$%s%I(B
$B$5$l$F$$$^$9!#(B
$B$3$N%3%^%s%I$O%]%$%s%H$r4^$`$+D>8e$K$"$k4X?tDj5A$r(B
Lisp$B<0$H$7$F2r@O$7I>2A$7$^$9!#(B
$B$=$NCM$O%(%3!<NN0h$KI=<($5$l$^$9!#(B
$B$3$N%3%^%s%I$O!"4X?tDj5A$N%F%-%9%H$NJQ99$r(B
Lisp$B4D6-$KH?1G$9$k$N$KJXMx$G$9!#(B

@c   @kbd{C-M-x} treats @code{defvar} expressions specially.  Normally,
@c evaluating a @code{defvar} expression does nothing if the variable it
@c defines already has a value.  But @kbd{C-M-x} unconditionally resets the
@c variable to the initial value specified in the @code{defvar} expression.
@c This special feature is convenient for debugging Lisp programs.
@kbd{C-M-x}$B$O(B@code{defvar}$B<0$rFCJL07$$$7$^$9!#(B
$BDL>o!"JQ?t$K$9$G$KCM$,Dj5A$5$l$F$$$k>l9g$K$O!"(B
@code{defvar}$B<0$rI>2A$7$F$b2?$b$7$^$;$s!#(B
$B$7$+$7!"(B@kbd{C-M-x}$B$O!"(B@code{defvar}$B<0$G;XDj$5$l$F$$$k(B
$B=i4|CM$KJQ?t$NCM$rLa$7$^$9!#(B
$B$3$NFCJL$J5!G=$O!"(BLisp$B%W%m%0%i%`$r%G%P%C%0$9$k$H$-$KJXMx$G$9!#(B

@kindex C-x C-e
@findex eval-last-sexp
@c   The command @kbd{C-x C-e} (@code{eval-last-sexp}) evaluates the Lisp
@c expression preceding point in the buffer, and displays the value in the
@c echo area.  It is available in all major modes, not just Emacs-Lisp
@c mode.  It does not treat @code{defvar} specially.
$B%3%^%s%I(B@kbd{C-x C-e}$B!J(B@code{eval-last-sexp}$B!K$O!"(B
$B%]%$%s%H$N$^$($K$"$k(BLisp$B<0$rI>2A$7(B
$B$=$NCM$r%(%3!<NN0h$KI=<($7$^$9!#(B
$B$3$N%3%^%s%I$O(Bemacs-lisp$B%b!<%I$@$1$G$J$/!"(B
$B$9$Y$F$N%a%8%c!<%b!<%I$G;H$($^$9!#(B
$B$3$N%3%^%s%I$O!"(B@code{defvar}$B$rFCJL07$$$7$^$;$s!#(B

@c   If @kbd{C-M-x}, @kbd{C-x C-e}, or @kbd{M-:} is given a numeric
@c argument, it inserts the value into the current buffer at point, rather
@c than displaying it in the echo area.  The argument's value does not
@c matter.
@kbd{C-M-x}$B!"(B@kbd{C-x C-e}$B!"(B@kbd{M-:}$B$K?t0z?t$r;XDj$9$k$H!"(B
$BCM$r%(%3!<NN0h$KI=<($9$k$+$o$j$K%+%l%s%H%P%C%U%!$N%]%$%s%H0LCV$KA^F~$7$^$9!#(B
$B0z?t$NCM$O4X78$"$j$^$;$s!#(B

@findex eval-region
@findex eval-current-buffer
@c   The most general command for evaluating Lisp expressions from a buffer
@c is @code{eval-region}.  @kbd{M-x eval-region} parses the text of the
@c region as one or more Lisp expressions, evaluating them one by one.
@c @kbd{M-x eval-current-buffer} is similar but evaluates the entire
@c buffer.  This is a reasonable way to install the contents of a file of
@c Lisp code that you are just ready to test.  Later, as you find bugs and
@c change individual functions, use @kbd{C-M-x} on each function that you
@c change.  This keeps the Lisp world in step with the source file.
$B%P%C%U%!$G(BLisp$B<0$rI>2A$9$k$b$C$H$b0lHLE*$J%3%^%s%I$O(B@code{eval-region}$B$G$9!#(B
@kbd{M-x eval-region}$B$O!"%j!<%8%g%sFb$N(B1$B$D0J>e$N(BLisp$B<0$r2r@O$7$F!"(B
$B$=$l$i$r(B1$B$D$:$D=g$KI>2A$7$^$9!#(B
@kbd{M-x eval-current-buffer}$B$bF1MM$G$9$,!"%P%C%U%!A4BN$rI>2A$7$^$9!#(B
$B$3$l$O!"(B
$B%F%9%H=`Hw$,@0$C$?(BLisp$B%3!<%I$N%U%!%$%k$NFbMF$r<h$j9~$`$&$^$$J}K!$G$9!#(B
$B8D!9$N4X?t$N%P%0$rH/8+$7$F=$@5$7$?$i!"(B
$BJQ99$7$?4X?t$=$l$>$l$K(B@kbd{C-M-x}$B$r;H$$$^$9!#(B
$B$3$l$K$h$C$F!"(BLisp$B$N4D6-$H%=!<%9%U%!%$%k$,0lCW$7$^$9!#(B

@node Lisp Interaction
@c @section Lisp Interaction Buffers
@section lisp$BBPOC%P%C%U%!(B

@c   The buffer @samp{*scratch*} which is selected when Emacs starts up is
@c provided for evaluating Lisp expressions interactively inside Emacs.
Emacs$B$,F0$-;O$a$?$H$-$KA*Br$5$l$k%P%C%U%!(B@samp{*scratch*}$B$O!"(B
Emacs$BFb$G(BLisp$B<0$rBPOCE*$KI>2A$9$k$?$a$N$b$N$G$9!#(B

@c   The simplest way to use the @samp{*scratch*} buffer is to insert Lisp
@c expressions and type @kbd{C-j} after each expression.  This command
@c reads the Lisp expression before point, evaluates it, and inserts the
@c value in printed representation before point.  The result is a complete
@c typescript of the expressions you have evaluated and their values.
@samp{*scratch*}$B%P%C%U%!$r;H$&$b$C$H$b4JC1$JJ}K!$O!"(B
Lisp$B<0$rA^F~$7$F$+$i3F<0$NKvHx$G(B@kbd{C-j}$B$HBG$D$3$H$G$9!#(B
$B$3$N%3%^%s%I$O!"%]%$%s%H$ND>A0$N(BLisp$B<0$rFI$_<h$j!"(B
$B$=$l$rI>2A$7!"$=$NCM$rI=<(7A<0$G%]%$%s%H$N$^$($KA^F~$7$^$9!#(B
$B$3$N7k2L$O!"I>2A$7$?<0$H$=$NCM$N40A4$J(Btypescript
@footnote{$B!ZLuCm![(B
$BF~NO$H=PNO$r$9$Y$F5-O?$7$?BPOC5-O?(B}$B$G$9!#(B

@c   The @samp{*scratch*} buffer's major mode is Lisp Interaction mode, which
@c is the same as Emacs-Lisp mode except for the binding of @kbd{C-j}.
@samp{*scratch*}$B%P%C%U%!$N%a%8%c!<%b!<%I$O(B
lisp$BBPOC!J(Blisp interaction$B!K%b!<%I$G$"$j!"(B
@kbd{C-j}$B$N%P%$%s%G%#%s%0$r=|$1$P(B
emacs-lisp$B%b!<%I$HF1$8$G$9!#(B

@findex lisp-interaction-mode
@c   The rationale for this feature is that Emacs must have a buffer when
@c it starts up, but that buffer is not useful for editing files since a
@c new buffer is made for every file that you visit.  The Lisp interpreter
@c typescript is the most useful thing I can think of for the initial
@c buffer to do.  Type @kbd{M-x lisp-interaction-mode} to put the current
@c buffer in Lisp Interaction mode.
$B$3$N5!G=$,B8:_$9$kM}M3$r@bL@$7$^$7$g$&!#(B
Emacs$B$,<B9T$r3+;O$9$k$H2?$+$7$i%P%C%U%!$,I,MW$G$9!#(B
$B$7$+$7!"%U%!%$%k$rK,Ld$9$k$?$S$K?7$?$K%P%C%U%!$,:n$i$l$k$N$G!"(B
$B$3$N%P%C%U%!$O%U%!%$%k$rJT=8$9$k$N$K$OE,$7$^$;$s!#(B
$B:G=i$N%P%C%U%!$r(BLisp$B%$%s%?!<%W%j%?$N(Btypescript$B$K$9$k$H$$$&$N$,(B
$B:n<T$,9M$($D$$$?$b$C$H$b$h$$J}K!$G$7$?!#(B
@kbd{M-x lisp-interaction-mode}$B$HBG$D$H!"(B
$B%+%l%s%H%P%C%U%!$O(Blisp$BBPOC!J(Blisp interaction$B!K%b!<%I$K$J$j$^$9!#(B

@findex ielm
@c   An alternative way of evaluating Emacs Lisp expressions interactively
@c is to use Inferior Emacs-Lisp mode, which provides an interface rather
@c like Shell mode (@pxref{Shell Mode}) for evaluating Emacs Lisp
@c expressions.  Type @kbd{M-x ielm} to create an @samp{*ielm*} buffer
@c which uses this mode.
Emacs Lisp$B<0$rBPOCE*$KI>2A$9$kJL$NJ}K!$O!"(B
$B2<0L(Bemacs-lisp$B%b!<%I$r;H$&$3$H$G$9!#(B
$B$3$N%b!<%I$O!"%7%'%k!J(Bshell$B!K%b!<%I!J(B@pxref{Shell Mode}$B!K$K;w$?(B
$B%$%s%?!<%U%'%$%9$G(BEmacs Lisp$B<0$rI>2A$G$-$^$9!#(B
@kbd{M-x ielm}$B$HBG$F$P!"(B
$B2<0L(Bemacs-lisp$B%b!<%I$r;H$&(B@samp{*ielm*}$B%P%C%U%!$,:n$i$l$^$9!#(B

@node External Lisp
@c @section Running an External Lisp
@section $B30It(BLisp$B$N<B9T(B

@c   Emacs has facilities for running programs in other Lisp systems.  You can
@c run a Lisp process as an inferior of Emacs, and pass expressions to it to
@c be evaluated.  You can also pass changed function definitions directly from
@c the Emacs buffers in which you edit the Lisp programs to the inferior Lisp
@c process.
Emacs$B$K$OB>$N(BLisp$B%7%9%F%`>e$G%W%m%0%i%`$r<B9T$9$k5!G=$,$"$j$^$9!#(B
Lisp$B%W%m%;%9$r(BEmacs$B$N2<0L%W%m%;%9$H$7$F<B9T$7!"(B
$B$=$l$K<0$rEO$7$FI>2A$5$;$k$3$H$,$G$-$^$9!#(B
$B$^$?!"(BLisp$B%W%m%0%i%`$rJT=8$9$k(BEmacs$B%P%C%U%!$NCf$GJQ99$7$?(B
$B4X?tDj5A$r$=$N$^$^2<0L$N(BLisp$B%W%m%;%9$KEO$9$3$H$b$G$-$^$9!#(B

@findex run-lisp
@vindex inferior-lisp-program
@kindex C-x C-z
@c   To run an inferior Lisp process, type @kbd{M-x run-lisp}.  This runs
@c the program named @code{lisp}, the same program you would run by typing
@c @code{lisp} as a shell command, with both input and output going through
@c an Emacs buffer named @samp{*lisp*}.  That is to say, any ``terminal
@c output'' from Lisp will go into the buffer, advancing point, and any
@c ``terminal input'' for Lisp comes from text in the buffer.  (You can
@c change the name of the Lisp executable file by setting the variable
@c @code{inferior-lisp-program}.)
$B2<0L$N(BLisp$B%W%m%;%9$r<B9T$9$k$K$O!"(B@kbd{M-x run-lisp}$B$HBG$A$^$9!#(B
$B$3$N%3%^%s%I$O!"%7%'%k%3%^%s%I$H$7$F(B@code{lisp}$B$HF~NO$9$k$N$HF1$8(B
@code{lisp}$B$H$$$&L>A0$N%W%m%0%i%`$r<B9T$7!"(B
$B%W%m%0%i%`$NF~=PNO$O(B@samp{*lisp*}$B$H$$$&L>A0$N(BEmacs$B%P%C%U%!$r(B
$B2p$7$F$d$j$H$j$5$l$^$9!#(B
$B$D$^$j!"(BLisp$B$+$i$N!XC<Kv=PNO!Y$O%P%C%U%!$KF~$j%]%$%s%H$r?J$a!"(B
Lisp$B$X$N!XC<KvF~NO!Y$O%P%C%U%!$N%F%-%9%H$+$i<h$i$l$^$9!#(B
$B!J<B9T$7$?$$(BLisp$B<B9T%U%!%$%k$NL>A0$rJQ$($k$K$O!"(B
$BJQ?t(B@code{inferior-lisp-program}$B$r@_Dj$9$k!#!K(B

@c   To give input to Lisp, go to the end of the buffer and type the input,
@c terminated by @key{RET}.  The @samp{*lisp*} buffer is in Inferior Lisp
@c mode, which combines the special characteristics of Lisp mode with most
@c of the features of Shell mode (@pxref{Shell Mode}).  The definition of
@c @key{RET} to send a line to a subprocess is one of the features of Shell
@c mode.
Lisp$B$KF~NO$rM?$($k$K$O!"%P%C%U%!$NKvHx$K0\F0$7$F$+$iF~NO$rBG80$7!"(B
$B:G8e$K(B@key{RET}$B$rBG$A$^$9!#(B
@samp{*lisp*}$B%P%C%U%!$O2<0L(Blisp$B!J(Binferior lisp$B!K%b!<%I$K$J$C$F$$$F!"(B
$B%7%'%k!J(Bshell$B!K%b!<%I!J(B@pxref{Shell Mode}$B!K(B
$B$N$[$H$s$I$N5!G=$K(Blisp$B%b!<%I$NFCJL$JFC@-$rAH$_9g$o$;$F$$$^$9!#(B
$B%5%V%W%m%;%9$K(B1$B9T$rAw$k$H$$$&(B@key{RET}$B$NDj5A$O!"(B
$B%7%'%k!J(Bshell$B!K%b!<%I$N5!G=$N(B1$B$D$G$9!#(B

@findex lisp-mode
@c   For the source files of programs to run in external Lisps, use Lisp
@c mode.  This mode can be selected with @kbd{M-x lisp-mode}, and is used
@c automatically for files whose names end in @file{.l}, @file{.lsp}, or
@c @file{.lisp}, as most Lisp systems usually expect.
$B30It(BLisp$B$G<B9T$9$k%W%m%0%i%`$N%=!<%9%U%!%$%k$K$O(Blisp$B%b!<%I$r;H$$$^$9!#(B
$B$3$N%b!<%I$O(B@kbd{M-x lisp-mode}$B$GA*Br$G$-$^$9!#(B
$B$^$?!"$[$H$s$I$N(BLisp$B%7%9%F%`$G;H$o$l$k(B
@file{.l}@footnote{$B!ZLuCm![(B
$B$3$N3HD%;R$O(Blex$B$d(Bflex$B$N%=!<%9%U%!%$%k$K$b;H$o$l$k!#(B}
$B$d(B@file{.lsp}$B$d(B@file{.lisp}$B$G=*$kL>A0$N%U%!%$%k$K$O(B
$B$3$N%b!<%I$,<+F0E*$K;H$o$l$^$9!#(B

@c @kindex C-M-x @r{(Lisp mode)}
@kindex C-M-x @r{$B!J(Blisp$B%b!<%I!K(B}
@findex lisp-eval-defun
@c   When you edit a function in a Lisp program you are running, the easiest
@c way to send the changed definition to the inferior Lisp process is the key
@c @kbd{C-M-x}.  In Lisp mode, this runs the function @code{lisp-eval-defun},
@c which finds the defun around or following point and sends it as input to
@c the Lisp process.  (Emacs can send input to any inferior process regardless
@c of what buffer is current.)
$B<B9TCf$N(BLisp$B%W%m%0%i%`$N4X?t$rJT=8$7$F$$$k$H$-!"(B
$BJQ99$7$?Dj5A$r2<0L$N(BLisp$B%W%m%;%9$KAw$k$b$C$H$b4JC1$JJ}K!$O(B
$B%-!<(B@kbd{C-M-x}$B$G$9!#(B
lisp$B%b!<%I$G$O!"$3$N%-!<$O4X?t(B@code{lisp-eval-defun}$B$r<B9T$7$^$9!#(B
$B$3$N4X?t$O!"%]%$%s%H$N<~$j$dD>8e$N4X?tDj5A$rC5$7!"(B
$B$=$l$r(BLisp$B%W%m%;%9$NF~NO$XAw$j$^$9!#(B
$B!J(BEmacs$B$O%+%l%s%H%P%C%U%!$,2?$G$"$k$+$K4X$o$j$J$/!"(B
$B$I$s$J2<0L%W%m%;%9$K$bF~NO$rAw$k$3$H$,$G$-$k!#!K(B

@c   Contrast the meanings of @kbd{C-M-x} in Lisp mode (for editing programs
@c to be run in another Lisp system) and Emacs-Lisp mode (for editing Lisp
@c programs to be run in Emacs): in both modes it has the effect of installing
@c the function definition that point is in, but the way of doing so is
@c different according to where the relevant Lisp environment is found.
@c @xref{Executing Lisp}.
@kbd{C-M-x}$B%3%^%s%I$N(B
$B!JG$0U$N(BLisp$B%7%9%F%`$G<B9T$9$k%W%m%0%i%`$NJT=8MQ!K(Blisp$B%b!<%I$G$N0UL#$H(B
$B!J(BEmacs$B$G<B9T$9$k(BLisp$B%W%m%0%i%`$NJT=8MQ!K(Bemacs-lisp$B%b!<%I$G$N0UL#$r(B
$BHf3S$7$F$_$^$7$g$&!#(B
$B$I$A$i$N%b!<%I$G$b%]%$%s%H$r4^$`4X?tDj5A$r%$%s%9%H!<%k$7$^$9$,!"(B
$B4XO"$9$k(BLisp$B4D6-$,$I$3$K$"$k$+$K1~$8$F!"$=$NJ}K!$O0[$J$j$^$9!#(B
@xref{Executing Lisp}$B!#(B