-
Notifications
You must be signed in to change notification settings - Fork 84
/
emacs.guide
executable file
·12981 lines (9596 loc) · 642 KB
/
emacs.guide
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
MASSACHUSETTS INSTITUTE OF TECHNOLOGY
ARTIFICIAL INTELLIGENCE LABORATORY
AI Memo 554 2 October 1981
EMACS MANUAL FOR ITS USERSî EMACS MANUAL FOR ITS USERSî EMACS MANUAL FOR ITS USERS
BYî BYî BY
RICHARD M. STALLMANî RICHARD M. STALLMANî RICHARD M. STALLMAN
A REFERENCE MANUALî A REFERENCE MANUALî A REFERENCE MANUAL
FOR THE EXTENSIBLE, CUSTOMIZABLE, SELF-DOCUMENTINGî FOR THE EXTENSIBLE, CUSTOMIZABLE, SELF-DOCUMENTINGî FOR THE EXTENSIBLE, CUSTOMIZABLE, SELF-DOCUMENTING
REAL-TIME DISPLAY EDITORî REAL-TIME DISPLAY EDITORî REAL-TIME DISPLAY EDITOR
This manual corresponds to EMACS version 161
This report describes work done at the Artificial Intelligence
Laboratory of the Massachusetts Institute of Technology. Support
for the laboratory's research is provided in part by the Advanced
Research Projects Agency of the Department of Defense under
Office of Naval Research contract N00014-80-C-0505.î 1 EMACS Manual for ITS Users
PREFACEî PREFACEî PREFACE
This manual documents the use and simple customization of the
display editor EMACS with the ITS operating system. The reader
___î is not expected to be a programmer. Even simple customizations
do not require programming skill, but the user who is not
interested in customizing can ignore the scattered customization
hints.
This is primarily a reference manual, but can also be used as a
primer. However, I recommend that the newcomer first use the
on-line, learn-by-doing tutorial TEACHEMACS, by typing
:TEACHEMACS<cr> while in HACTRN. With it, you learn EMACS by
using EMACS on a specially designed file which describes
commands, tells you when to try them, and then explains the
results you see. This gives a more vivid introduction than a
printed manual.
On first reading, you need not make any attempt to memorize
chapters 1 and 2, which describe the notational conventions of
the manual and the general appearance of the EMACS display
screen. It is enough to be aware of what questions are answered
in these chapters, so you can refer back when you later become
interested in the answers. After reading the Basic Editing
chapter you should practice the commands there. The next few
chapters describe fundamental techniques and concepts that are
referred to again and again. It is best to understand them
thoroughly, experimenting with them if necessary.
To find the documentation on a particular command, look in the
index if you know what the command is. Both command characters
and function names are indexed. If you know vaguely what the
command does, look in the command summary. The command summary
contains a line or two about each command, and a cross reference
to the section of the manual that describes the command in more
detail; related commands are grouped together. There is also a
glossary, with a cross reference for each term.
Many user-contributed libraries accompany EMACS, and often then
have no documentation except their on-line self-documentation.
Browsing through the catalogue of libraries in this manual is a
good way to find out what is available.
This manual has in two versions, one for ITS, and one for
Twenex, DEC's "TOPS-20" system. Each version comes in three
forms: the published form, the LPT form, and the INFO form. You
can order the published form from the Publications Department ofî 2 EMACS Manual for ITS Users
the Artificial Intelligence lab for $3.25 per copy; be sure to
specify the ITS version or the Twenex version. The LPT form is
available on line as EMACS;EMACS GUIDE for printing on
unsophisticated hard copy devices such as terminals and line
printers. The INFO form is for on-line perusal with the INFO
program. All three forms are substantially the same.
EMACS is available for distribution for use on Tenex and Twenex
systems (It does not run on Bottoms-10, and the conversion would
not be easy). Mail us a 2400 foot mag tape if you want it. It
does not cost anything; instead, you must join the EMACS
software-sharing commune. The conditions of membership are that
you must send back any improvements you make to EMACS, including
any libraries you write, and that you must not redistribute the
system except exactly as you got it, complete. (You can also
distribute your customizations, separately.)
Please do not attempt to get a copy of EMACS, for yourself or
any one else, by dumping it off of your local system. It is
almost certain to be incomplete or inconsistent. It is pathetic
to hear from sites that received incomplete copies lacking the
sources, asking me years later whether sources are available. If
you wish to give away a copy of EMACS, copy a distribution tape
from MIT, or mail me a tape and get a new one.
For information on the underlying philosophy of EMACS and the
lessons learned from its development, write to me for a copy of
AI memo 519a, "EMACS, the Extensible, Customizable
Self-Documenting Display Editor", or send Arpanet mail to
RMS@MIT-AI.
Yours in hacking,
/ 2 \ 1/2
< X >
\ /
Richard M. Stallman
Artificial Intelligence Lab
545 Tech Square, Rm 913
Cambridge, MA 02139
(617) 253-6765î 3 EMACS Manual for ITS Users
INTRODUCTIONî INTRODUCTIONî INTRODUCTION
You are about to read about EMACS, an advanced,
self-documenting, customizable, extensible real-time display
editor.
We say that EMACS is a display editor because normally the text
being edited is visible on the screen and is updated
automatically as you type your commands. See section 1
[Display], page 5.
We call it a real-time editor because the display is updated
very frequently, usually after each character or pair of
characters you type. This minimizes the amount of information
you must keep in your head as you edit. See section 3 [Basic],
page 15.
We call EMACS advanced because it provides facilities that go
beyond simple insertion and deletion: filling of text; automatic
indentation of programs; viewing two files at once; and dealing
in terms of characters, words, lines, sentences, paragraphs, and
pages, as well as expressions and comments in several different
programming languages. It is much easier to type one command
meaning "go to the end of the paragraph" than to find the desired
spot with repetition of simpler commands.
Self-documenting means that at any time you can type a special
character, the "Help" key, to find out what your options are.
You can also use it to find out what any command does, or to find
all the commands that pertain to a topic. See section 7 [Help],
page 33.
Customizable means that you can change the definitions of EMACS
commands in little ways. For example, if you use a programming
language in which comments start with <** and end with **>, you
can tell the EMACS comment manipulation commands to use those
strings. Another sort of customization is rearrangement of the
command set. For example, if you prefer the four basic cursor
motion commands (up, down, left and right) on keys in a diamond
pattern on the keyboard, you can have it. See section 21.8
[Customization], page 132.
Extensible means that you can go beyond simple customization
and write entirely new commands, programs in the language TECO.
EMACS is an "on-line extensible" system, which means that it is
divided into many functions that call each other, any of which
can be redefined in the middle of an editing session. Any partî 4 EMACS Manual for ITS Users
of EMACS can be replaced without making a separate copy of all of
EMACS. Many already written extensions are distributed with
EMACS, and some (including DIRED, PAGE, PICTURE, SORT, TAGS, and
WORDAB) are documented in this manual. Although only a
programmer can write an extension, anybody can use it afterward.
Extension requires programming in TECO, a rather obscure
language. If you are clever and bold, you might wish to learn
how. See the file INFO;CONV, for advice on learning TECO. This
manual does not even try to explain how to write TECO programs,
but it does contain some notes that are useful primarily to the
extension writer.î 5 EMACS Manual for ITS Users
CHAPTER ONEî CHAPTER ONEî CHAPTER ONE
THE ORGANIZATION OF THE SCREENî THE ORGANIZATION OF THE SCREENî THE ORGANIZATION OF THE SCREEN
EMACS divides the screen into several areas, each of which
contains its own sorts of information. The biggest area, of
course, is the one in which you usually see the text you are
editing. The terminal's cursor usually appears in the middle of
_____î the text, showing the position of point, the location at which
__î editing takes place. While the cursor appears to point at a
_______î character, point should be thought of as between two characters;
______î it points before the character that the cursor appears on top of.
Terminals have only one cursor, and when output is in progress it
must appear where the typing is being done. This does not mean
that point is moving. It is only that EMACS has no way to show
you the location of point except when the terminal is idle.
The top lines of the screen are usually available for text but
_____ _______î are sometimes pre-empted by an error message, which says that
some command you gave was illegal or used improperly, or by
_______î typeout from a command (such as, a listing of a file directory).
Error messages are typically one line, end with a question mark,
and are accompanied by ringing the bell. Typeout generally has
none of those characteristics.
The error message or typeout appears there for your
information, but it is not part of the file you are editing, and
it goes away if you type any command. If you want to make it go
away immediately but not do anything else, you can type a Space.
(Usually a Space inserts itself, but when there is an error
message or typeout on the screen it does nothing but get rid of
that.) The terminal's cursor always appears at the end of the
error message or typeout, but this does not mean that point has
moved. The cursor moves back to the location of point after the
error message or typeout goes away.
If you type a question mark when an error message is on the
screen, you enter the EMACS error handler. You probably don't
want to do this unless you know how to write TECO programs. If
you do it by accident, C-] (the standard abort character) will
get you out. Enough said.
A few lines at the bottom of the screen compose what is called
____ ____î the echo area. The variable Echo Area Height controls how many
_______î lines long it is. Echoing means printing out the commands that
you type. EMACS commands are usually not echoed at all, but if
you pause for more than a second in the middle of a
multi-character command then all the characters typed so far areî 6 EMACS Manual for ITS Users
______î echoed. This is intended to prompt you for the rest of the
command. The rest of the command is echoed, too, as you type it.
This behavior is designed to give confident users optimum
response, while giving hesitant users maximum feedback.
EMACS also uses the echo area for reading and displaying the
arguments for some commands, such as searches, and for printing
brief information in response to certain commands.
1.1 The Mode Lineî 1.1 The Mode Lineî 1.1 The Mode Line
____ ____î The line above the echo area is known as the mode line. It is
the line that usually starts with "EMACS (something)". Its
purpose is to tell you anything that may affect the meaning of
your commands aside from the text itself.
Some EMACS commands read and process more commands. They are
__________ _________ _______ ______î known as subsystems or recursive editing levels. If you are
inside a subsystem or a recursive editing level, the mode line
tells you its name. Square brackets around the mode line
indicate a recursive editing level; See section 6.3 [Recursive
__________î Editing Levels], page 30. Parentheses indicate a minibuffer; See
section 23 [Minibuffer], page 156. Neither brackets nor
parentheses indicates a subsystem; See section 6.1 [Subsystems],
page 28.
Subsystems and recursive editing levels are advanced features,
and you will not initially be using them. When you are not
inside a subsystem or recursive editing level, we say that you
___ _____î are at top level; this implies that the characters you type are
interpreted as ordinary EMACS commands. When you are at top
level, the mode line tells you what file you are editing, where
you are in it, and what editing modes are enabled which may
affect the meaning of your commands. The top level mode line has
this format:
EMACS type (major minor) bfr: file (vrs) --pos-- *
____î type is usually not there. When it is there, it indicates that
the EMACS job you are using is not an ordinary one, in that it is
acting as the servant of some other job. A type of "LEDIT"
indicates an EMACS serving one or more Lisps, while a type of
"MAILT" indicates an EMACS that you got by asking for an "edit
escape" while composing mail to send. The type can also indicateî 7 EMACS Manual for ITS Users
a subsystem that is running, such as RMAIL. The type is stored
internally as a string in the variable Editor Type. The variable
is normally zero.
_____ _____ ____î major is always the name of the major mode you are in. At any
time, EMACS is in one and only one of its possible major modes.
The major modes available include Fundamental mode (which EMACS
starts out in), Text mode, Lisp mode, PASCAL mode, and others.
See section 20.1 [Major Modes], page 102, for details of how the
modes differ and how to select one. Sometimes the name of the
major mode is followed immediately with another name inside
_______î square-brackets ("[ - ]"). This name is called the submode. The
submode indicates that you are "inside" of a command that causes
your editing commands to be changed temporarily, but does not
____î change what text you are editing. A submode is a kind of
recursive editing level. See section 6.3 [Submodes], page 30.
_____ _____ _____î minor is a list of some of the minor modes that are turned on
at the moment. "Fill" means that Auto Fill mode is on. "Save"
means that Auto-saving is on. "Save(off)" means that Auto-saving
is on by default but turned off at the moment in this buffer.
"Atom" means that Atom Word mode is on. "Abbrev" means that Word
Abbrev mode is on. "Ovwrt" means that Overwrite mode is on. See
section 22.1 [Minor Modes], page 133, for more information.
"Def" means that a keyboard macro is being defined; although this
is not exactly a minor mode, it is still useful to be reminded
about. See section 22.8 [Keyboard Macros], page 152. "Narrow"
means that editing is currently restricted to only a part of the
buffer. See section 17 [Narrowing], page 93.
___ ______î bfr is the name of the currently selected buffer. Each buffer
has its own name and holds a file being edited; this is how EMACS
can hold several files at once. But at any time you are editing
________î only one of them, the selected buffer. When we speak of what
some command does to "the buffer", we are talking about the
currently selected buffer. Multiple buffers make it easy to
switch around between several files, and then it is very useful
that the mode line tells you which one you are editing at any
time. However, before you learn how to use multiple buffers, you
will always be in the buffer called "Main", which is the only one
that exists when EMACS starts up. If the name of the buffer is
the same as the first name of the file you are visiting, then the
buffer name is left out of the mode line. See section 14
[Buffers], page 83, for how to use more than one buffer in one
EMACS.
____î file is the name of the file that you are editing. It is the
last file that was visited in the buffer you are in. It is
_______ ______î followed, in parentheses, by the file version number mostî 8 EMACS Manual for ITS Users
recently visited or saved provided the second filename visited is
">", so that version numbers are allowed. "(R-O)" after the
_________î filename means that the file or buffer is read-only; a file
visited read-only will not be saved unless you insist, while a
read-only buffer does not allow you to alter its contents at all.
See section 13.1 [Visiting], page 69, for more information.
The star at the end of the mode line means that there are
changes in the buffer that have not been saved in the file. If
the file has not been changed since it was read in or saved,
there is no star.
___î pos tells you whether there is additional text above the top of
the screen, or below the bottom. If your file is small and it is
all on the screen, --pos-- is omitted. Otherwise, it is
--TOP-- if you are looking at the beginning of the file,
--BOT-- if you are looking at the end of the file, or
--nn%-- where nn is the percentage of the file above the top of
the screen.
Sometimes you will see --MORE-- instead of --nn%--. This
happens when typeout from a command is too long to fit on the
screen. It means that if you type a Space the next screenful of
information will be printed. If you are not interested, typing
anything but a Space will cause the rest of the output to be
discarded. Typing a Rubout will discard the output and do
nothing else. Typing any other command will discard the rest of
the output and also do the command. When the output is
discarded, "FLUSHED" is printed after the --MORE--.
If you are accustomed to other display editors, you may be
surprised that EMACS does not always display the page number and
line number of point in the mode line. This is because the text
is stored in a way that makes it difficult to compute this
information. Displaying them all the time would be too slow to
be borne. When you want to know the page and line number of
point, you must ask for the information with the M-X What Page
command. See section 18 [Pages], page 94. However, once you are
adjusted to EMACS, you will rarely have any reason to be
concerned with page numbers or line numbers.
If you set the variable Display Mode Line Inverse nonzero, then
the mode line is displayed in inverse video if the terminal you
are using supports it. See section 22.3 [Variables], page 137.
The libraries MODLIN and MODE2 allow you to customize the
information that is displayed in the mode line. MODLIN replaces
the standard EMACS mode line generation routines. MODE2 makes a
second mode line, above the first, whose contents are under yourî 9 EMACS Manual for ITS Users
control. Refer to the self-documentation of these libraries; See
section 22.2 [Libraries], page 135.î 10 EMACS Manual for ITS Users
CHAPTER TWOî CHAPTER TWOî CHAPTER TWO
CHARACTER SETS AND COMMAND INPUT CONVENTIONSî CHARACTER SETS AND COMMAND INPUT CONVENTIONSî CHARACTER SETS AND COMMAND INPUT CONVENTIONS
In this chapter we introduce the terminology and concepts used
to talk about EMACS commands. EMACS is designed to be used with
a kind of keyboard with two special shift keys which can type 512
different characters, instead of the 128 different characters
which ordinary ASCII keyboards can send. The terminology of
EMACS commands is formulated in terms of these shift keys. So
that EMACS can be used on ASCII terminals, we provide
two-character ASCII circumlocutions for the command characters
which are not ASCII.
2.1 The 9-bit Command Character Setî 2.1 The 9-bit Command Character Setî 2.1 The 9-bit Command Character Set
EMACS is designed ideally to be used with terminals whose
keyboards have a pair of shift keys, labeled "Control" and
"Meta", either or both of which can be combined with any
_______î character that you can type. These shift keys produce Control
____î characters and Meta characters, which are the editing commands of
EMACS. We name each of these characters by prefixing "Control-"
(or "C-"), "Meta-" (or "M-") or both to the basic character:
thus, Meta-F or M-F is the character which is F typed with the
Meta key held down. C-M-; is the Semicolon character with both
the Control and Meta keys. Control in the EMACS command
character set is not precisely the same as Control in the ASCII
character set, but the general purpose is the same.
There are 128 basic characters. Multiplied by the four
possibilities of the Control and Meta keys, this makes 512
characters in the EMACS command character set. So it is called
the 512-character set, to distinguish it from ASCII, which has
_____î only 128 characters. It is also called the 9-bit character set
because 9 bits are required to express a number from 0 to 511.
Note that the 512-character set is used only for keyboard
commands. Characters in files being edited with EMACS are ASCII
characters.
Sadly, most terminals do not have ideal EMACS keyboards. In
fact, the only ideal keyboards are at MIT. On nonideal
keyboards, the Control key is somewhat limited (it can only be
combined with some characters, not with all), and the Meta key
may not exist at all. We make it possible to use EMACS on a
nonideal terminal by providing two-character circumlocutions,î 11 EMACS Manual for ITS Users
made up of ASCII characters that you can type, for the characters
___î that you can't type. These circumlocutions start with a bit
______î prefix character; see below. For example, to use the Meta-A
command, you could type Altmode A. Also see the appendices for
more detailed information on what to do on your type of terminal.
Both the EMACS 9-bit character set and ASCII have Control
characters, but the 9-bit character set has more different ones.
In ASCII, only letters and a few punctuation marks can be made
into Control characters; in the 9-bit character set every
character has a Control version. For example, we have
Control-Space, Control-1, and Control-=. We also have two
different characters Control-A and Control-a! But they always do
the same thing in EMACS, so you can ignore the distinction
between them, unless you are doing customization. In practice,
you can forget all about the distinction between ASCII Control
and EMACS Control, except to realize that EMACS uses some
"Control" characters which ASCII keyboards cannot type.
In addition to the 9-bit command character set, there is one
additional EMACS command character called Help. It cannot be
combined with Control or Meta. Its use is to ask for
documentation, at any time. The Help character has its own key
on an ideal keyboard, but must be represented by something else
on other keyboards. The circumlocution we use is Control-_ H
(two characters). The code used internally for Help is 4110
(octal).
We have given some command characters special names which we
always capitalize. "Return" or "<cr>" stands for the carriage
return character, code 015 (all character codes are in octal).
Note that C-R means the character Control-R, never Return.
"Rubout" is the character with code 177, labeled "Delete" on some
keyboards. "Altmode" is the character with code 033, sometimes
labeled "Escape". Other command characters with special names
are Tab (code 011), Backspace (code 010), Linefeed (code 012),
Space (code 040), Excl ("!", code 041), Comma (code 054), and
Period (code 056). Control is represented in the numeric code
for a character by 200, and Meta by 400; thus, Meta-Period is
code 456 in the 9-bit character set.
2.2 Prefix Charactersî 2.2 Prefix Charactersî 2.2 Prefix Characters
A non-ideal keyboard can only send certain Control characters,
and may completely lack the ability to send Meta characters. To
use these commands on such keyboards, you need to useî 12 EMACS Manual for ITS Users
___ ______î two-character circumlocutions starting with a bit prefix
character which turns on the Control or Meta bit in the second
character. The Altmode character turns on the Meta bit, so
Altmode X can be used to type a Meta-X, and Altmode Control-O can
_______î be used to type a C-M-O. Altmode is known as the Metizer. Other
bit prefix characters are C-^ for Control, and C-C for Control
and Meta together. Thus, C-^ < is a way of typing a Control-<,
and C-C < can be used to type C-M-<. Because C-^ is awkward to
type on most keyboards, we have tried to minimize the number of
commands for which you will need it.
The bit prefix characters are simply commands which run the
functions ^R Prefix Control, ^R Prefix Meta, and ^R Prefix
Control-Meta.
There is another prefix character, Control-X which is used as
the beginning of a large set of two-character commands known as
___ ________î C-X commands. C-X is not a bit prefix character; C-X A is not a
circumlocution for any single character, and it must be typed as
two characters on any terminal. You can create new prefix
characters when you customize. See the file INFO;CONV, node
Prefix.
2.3 Commands, Functions, and Variablesî 2.3 Commands, Functions, and Variablesî 2.3 Commands, Functions, and Variables
Most of the EMACS commands documented herein are members of
this 9-bit character set. Others are pairs of characters from
that set. However, EMACS doesn't really implement commands
_________î directly. Instead, EMACS is composed of functions, which have
long names such as "^R Down Real Line" and definitions which are
________î programs that perform the editing operations. Then commands such
_______ ________î as C-N are connected to functions through the command dispatch
_____î table. When we say that C-N moves the cursor down a line, we are
glossing over a distinction which is unimportant for ordinary
use, but essential for customization: it is the function ^R Down
Real Line which knows how to move down a line, and C-N moves down
a line because it is connected to that function. We usually
ignore this subtlety to keep things simple. To give the
extension-writer the information he needs, we state the name of
the function which really does the work in parentheses after
mentioning the command name. For example: "C-N (^R Down Real
Line) moves the cursor down a line". In the EMACS wall chart,
the function names are used as a form of very brief documentation
for the command characters. See section 5.2 [Functions],
page 24.î 13 EMACS Manual for ITS Users
The "^R " which appears at the front of the function name is
simply part of the name. By convention, a certain class of
functions have names which start with "^R ".
While we are on the subject of customization information which
you should not be frightened of, it's a good time to tell you
_________î about variables. Often the description of a command will say "to
change this, set the variable Mumble Foo". A variable is a name
used to remember a value. EMACS contains many variables which
are there so that you can change them if you want to customize.
The variable's value is examined by some command, and changing
the value makes the command behave differently. Until you are
interested in customizing, you can ignore this information. When
you are ready to be interested, read the basic information on
variables, and then the information on individual variables will
make sense. See section 22.3 [Variables], page 137.
2.4 Notational Conventions for ASCII Charactersî 2.4 Notational Conventions for ASCII Charactersî 2.4 Notational Conventions for ASCII Characters
Control characters in files, your EMACS buffer, or TECO
programs, are ordinary ASCII characters. The special 9-bit
character set applies only to typing EMACS commands. ASCII
contains the printing characters, rubout, and some control
characters. Most ASCII control characters are represented in
this manual as uparrow or caret followed by the corresponding
^î non-control character: control-E is represented as |E.
Some ASCII characters have special names. These include tab
(011), backspace (010), linefeed (012), return (015), altmode
(033), space (040), and rubout (177). To make it clear whether
we are talking about a 9-bit character or an ASCII character, we
capitalize names of 9-bit characters and leave names of ASCII
characters in lower case. Note that the 9-bit characters Tab and
Control-I are different, but the ASCII characters tab and
control-I are the same.
Lines in files are separated by a sequence of two ASCII control
characters, carriage return followed by linefeed. This sequence
____î is called CRLF. Normally, EMACS treats this two-character
____ _________î sequence as if it were a single character, a line separator. A
_____î return or a linefeed which is not part of a CRLF is called stray.
EMACS usually treats them as part of the text of a line and
displays them as ^M and ^J. If the variable Display Overprinting
is zero, they display as actual carriage return or linefeed.
Most control characters when present in the EMACS buffer areî 14 EMACS Manual for ITS Users
^î displayed with a caret; thus, ^A for ASCII |A. Rubout is
displayed as ^?, because by stretching the meaning of "control"
it can be interpreted as ASCII control-?. A backspace is usually
displayed as ^H since it is ASCII control-H, because most
displays cannot do overprinting. If you want backspace and stray
return to display as overprinting, set the variable Display
Overprinting nonzero.
Altmode is the ASCII code 033, sometimes labeled "Escape" or
"Alt". Altmode is often represented by itself in this document
(remember, it is an ASCII character and can therefore appear in
files). It looks like this: $. On most terminals, altmode looks
just like the dollar sign character. If that's so on yours, you
should assume that anything you see in the on-line documentation
which looks like a dollar sign is really an altmode unless you
are specifically told it's a dollar sign. The dollar sign
character is not particularly important in EMACS and we will
rarely have reason to mention it.î 15 EMACS Manual for ITS Users
CHAPTER THREEî CHAPTER THREEî CHAPTER THREE
BASIC EDITING COMMANDSî BASIC EDITING COMMANDSî BASIC EDITING COMMANDS
We now give the basics of how to enter text, make corrections,
and save the text in a file. If this material is new to you, you
might learn it more easily by running the :TEACHEMACS program.
3.1 Inserting Textî 3.1 Inserting Textî 3.1 Inserting Text
To insert printing characters into the text you are editing,
just type them. When EMACS is at top level, all printing
characters you type are inserted into the text at the cursor
_____î (that is, at point), and the cursor moves forward. Any
characters after the cursor move forward too. If the text in the
buffer is FOOBAR, with the cursor before the B, then if you type
XX, you get FOOXXBAR, with the cursor still before the B.
To correct text you have just inserted, you can use Rubout.
______î Rubout deletes the character before the cursor (not the one that
_____î the cursor is on top of or under; that is the character after the
cursor). The cursor and all characters after it move backwards.
Therefore, if you type a printing character and then type Rubout,
they cancel out.
To end a line and start typing a new one, type Return
(Customizers, note: this runs the function ^R CRLF). Return
operates by inserting a line separator, so if you type Return in
the middle of a line, you break the line in two. Return really
inserts two characters, a carriage return and a linefeed (a
CRLF), but almost everything in EMACS makes them look like just
one character, which you can think of as a line-separator
character. For example, typing Rubout when the cursor is at the
beginning of a line rubs out the line separator before the line,
joining that line with the preceding line.
If you add too many characters to one line, without breaking it
with a Return, the line will grow to occupy two (or more) lines
on the screen, with a "!" at the extreme right margin of all but
the last of them. The "!" says that the following screen line is
____________î not really a distinct line in the file, but just the continuation
of a line too long to fit the screen.
Direct insertion works for printing characters and space, but
other characters act as editing commands and do not insertî 16 EMACS Manual for ITS Users
themselves. If you need to insert a control character, Altmode,
_____î Tab or Rubout, you must quote it by typing the Control-Q
(^R Quoted Insert) command first. See section 2 [Characters],
^î page 10. Inserting a |Z is harder because EMACS cannot even
receive the character; you must use the minibuffer as in Altmode
Altmode 26i Altmode Altmode. See section 23 [Minibuffer],
page 156.
3.2 Moving The Cursorî 3.2 Moving The Cursorî 3.2 Moving The Cursor
To do more than insert characters, you have to know how to move
the cursor. Here are a few of the commands for doing that.
C-A Move to the beginning of the line.
C-E Move to the end of the line.
C-F Move forward over one character.
C-B Move backward over one character.
C-N Move down one line, vertically. If you start in
the middle of one line, you end in the middle of
the next. From the last line of text, it creates
a new line.
C-P Move up one line, vertically.
C-L Clear the screen and reprints everything.
C-U C-L reprints just the line that the cursor is
on.
C-T Transpose two characters (the ones before and
after the cursor).
M-< Move to the top of your text.
M-> Move to the end of your text.
3.3 Erasing Textî 3.3 Erasing Textî 3.3 Erasing Text
Rubout Delete the character before the cursor.
C-D Delete the character after the cursor.
C-K Kill to the end of the line.
You already know about the Rubout command which deletes the
character before the cursor. Another command, Control-D, deletes
the character after the cursor, causing the rest of the text on
the line to shift left. If Control-D is typed at the end of a
line, that line and the next line are joined together.î 17 EMACS Manual for ITS Users
To erase a larger amount of text, use the Control-K command,
which kills a line at a time. If Control-K is done at the
beginning or middle of a line, it kills all the text up to the
end of the line. If Control-K is done at the end of a line, it
joins that line and the next line.
See section 9.1 [Killing], page 39, for more flexible ways of
killing text.
3.4 Filesî 3.4 Filesî 3.4 Files
The commands above are sufficient for creating text in the
EMACS buffer. The more advanced EMACS commands just make things
easier. But to keep any text permanently you must put it in a
____î file. Files are the objects which ITS uses for storing data for
communication between different programs or to hold onto for a
length of time. To tell EMACS to edit text in a file, choose a
________ ______î filename, such as FOO, and type C-X C-V FOO<cr>. This visits the
file FOO (actually, FOO > on your working directory) so that its
contents appear on the screen for editing. You can make changes,
____î and then save the file by typing C-X C-S. This makes the changes
permanent and actually changes the file FOO. Until then, the
changes are only inside your EMACS, and the file FOO is not
really changed. If the file FOO doesn't exist, and you want to
create it, visit it as if it did exist. When you save your text
with C-X C-S the file will be created.
Of course, there is a lot more to learn about using files. See
section 13 [Files], page 69.
3.5 Helpî 3.5 Helpî 3.5 Help
If you forget what a command does, you can find out with the
Help character. The Help character is Top-H if you have a Top
key, or Control-_ H (two characters!) otherwise. Type Help
followed by C and the command you want to know about. Help can
help you in other ways as well. See section 7 [Help], page 33.î 18 EMACS Manual for ITS Users
3.6 Using Blank Lines Can Make Editing Fasterî 3.6 Using Blank Lines Can Make Editing Fasterî 3.6 Using Blank Lines Can Make Editing Faster
C-O Insert one or more blank lines after the
cursor.
C-X C-O Delete all but one of many consecutive blank
lines.
It is much more efficient to insert text at the end of a line
than in the middle. So if you want to stick a new line before an
existing one, the best way is to make a blank line there first
and then type the text into it, rather than inserting the new
text at the beginning of the existing line and finally inserting
a line separator. Making the blank line first also makes the
meaning of the text clearer while you are typing it in.
To make a blank line, you can type Return and then C-B. But
there is a single character for this: C-O (Customizers: this is
the built-in function ^R Open Line). So, FOO Return is
equivalent to C-O FOO.
If you want to insert many lines, you can type many C-O's at
the beginning (or you can give C-O an argument to tell it how
many blank lines to make. See section 4 [Arguments], page 19,
for how). As you then insert lines of text, you will notice that
Return behaves strangely: it "uses up" the blank lines instead of
pushing them down.
If you don't use up all the blank lines, you can type C-X C-O
(the function ^R Delete Blank Lines) to get rid of all but one.
When point is on a blank line, C-X C-O replaces all the blank
lines around that one with a single blank line. When point is on
a nonblank line, C-X C-O deletes any blank lines following that
nonblank line.î 19 EMACS Manual for ITS Users
CHAPTER FOURî CHAPTER FOURî CHAPTER FOUR
GIVING NUMERIC ARGUMENTS TO EMACS COMMANDSî GIVING NUMERIC ARGUMENTS TO EMACS COMMANDSî GIVING NUMERIC ARGUMENTS TO EMACS COMMANDS
_______ ________î Any EMACS command can be given a numeric argument. Some
commands interpret the argument as a repetition count. For
example, giving an argument of ten to the C-F command (move
forward one character) moves forward ten characters. With these
commands, no argument is equivalent to an argument of 1.
Some commands care only about whether there is an argument, and
not about its value; for example, the command M-Q (^R Fill
Paragraph) with no arguments fills text, but with an argument
justifies the text as well.
Some commands use the value of the argument, but do something
peculiar when there is no argument. For example, the C-K
(^R Kill Line) command with an argument <n> kills <n> lines and
the line separators that follow them. But C-K with no argument
is special; it kills the text up to the next line separator, or,
if point is right at the end of the line, it kills the line
separator itself. Thus, two C-K commands with no arguments can
kill a nonblank line, just like C-K with an argument of one.
The fundamental way of specifying an argument is to use the C-U
(^R Universal Argument) command followed by the digits of the
argument. Negative arguments are allowed. Often they tell a
command to move or act backwards. A negative argument is entered
with C-U followed by a minus sign and the digits of the value of
the argument.
C-U followed by a character which is neither a digit nor a
minus sign has the special meaning of "multiply by four". It
multiplies the argument for the next command by four. Two such
C-U's multiply it by sixteen. Thus, C-U C-U C-F moves forward
sixteen characters. This is a good way to move forward "fast",
since it moves about 1/4 of a line on most terminals. Other
useful combinations are C-U C-N, C-U C-U C-N (move down a good
fraction of a screen), C-U C-U C-O (make "a lot" of blank lines),
and C-U C-K (kill four lines). With commands like M-Q that care
whether there is an argument but not what the value is, C-U is a
good way of saying "I want an argument".
A few commands treat a plain C-U differently from an ordinary
argument. A few others may treat an argument of just a minus
sign differently from an argument of -1. These unusual cases
will be described when they come up; they are always for reasons
of convenience of use.î 20 EMACS Manual for ITS Users
There are other, terminal-dependent ways of specifying
arguments. They have the same effect but may be easier to type.
See the appendix. If your terminal has a numeric keypad which
sends something recognizably different from the ordinary digits,
it is possible to program EMACS to allow use of the numeric
keypad for specifying arguments. The libraries VT52 and VT100
provide such a feature for those two types of terminals. See
section 22.2 [Libraries], page 135.
4.1 Autoarg Modeî 4.1 Autoarg Modeî 4.1 Autoarg Mode
Users of ASCII keyboards may prefer to use Autoarg mode.
Autoarg mode means that you don't need to type C-U to specify a
numeric argument. Instead, you type just the digits. Digits
followed by an ordinary inserting character are themselves
inserted, but digits followed by an Altmode or Control character
serve as an argument to it and are not inserted. A minus sign
can also be part of an argument, but only at the beginning. If
you type a minus sign following some digits, both the digits and
the minus sign are inserted.
To use Autoarg mode, set the variable Autoarg Mode nonzero.
See section 22.3 [Variables], page 137.
Autoargument digits echo at the bottom of the screen; the first
nondigit causes them to be inserted or uses them as an argument.
To insert some digits and nothing else, you must follow them with
a Space and then rub it out. C-G cancels the digits, while
Rubout inserts them all and then rubs out the last.î 21 EMACS Manual for ITS Users
CHAPTER FIVEî CHAPTER FIVEî CHAPTER FIVE
EXTENDED (META-X) COMMANDS AND FUNCTIONSî EXTENDED (META-X) COMMANDS AND FUNCTIONSî EXTENDED (META-X) COMMANDS AND FUNCTIONS
Not all EMACS commands are of the one or two character variety
you have seen so far. Most commands have long names composed of
English words. This is for two reasons: the long names are
easier to remember and more suggestive, and there are not enough
two-character combinations for every command to have one.
________ ________î The commands with long names are known as extended commands
because they extend the set of two-character commands.
5.1 Issuing Extended Commandsî 5.1 Issuing Extended Commandsî 5.1 Issuing Extended Commands
M-X Begin an extended command. Follow by
command name and arguments.
C-M-X Begin an extended command. Follow by the
command name only; the command will ask
for any arguments.
C-X Altmode Re-execute recent extended command.
___ ________î Extended commands are also called M-X commands, because they
all start with the character Meta-X (^R Extended Command). The
M-X is followed by the command's long, suggestive name, actually
the name of a function to be called. Terminate the name of the
function with a Return (unless you are supplying string
arguments; see below). For example, Meta-X Auto Fill Mode<cr>
invokes the function Auto Fill Mode. This function when executed
turns Auto Fill mode on or off.
We say that M-X Foo<cr> "calls the function Foo". When
documenting the individual extended commands, we will call them
_________î functions to avoid confusion between them and the one or two
________î character commands. We will also use "M-X" as a title like "Mr."
for functions, as in "use M-X Foo". The "extended command" is
what you type, starting with M-X, and what the command does is
call a function. The name that goes in the command is the name
of the command and is also the name of the function, and both
terms will be used.
Note: Extended commands and functions were once called "MM
commands", but this term is obsolete. If you see it used either
in INFO documentation of in Help documentation, please report it.î 22 EMACS Manual for ITS Users
Ordinary one or two character commands used to be known as "^R"
commands; please report any occurrences of this obsolete term
also.
There are a great many functions in EMACS for you to call.
They will be described elsewhere in the manual, according to what
they do. Here we are concerned only with extended commands in
general.
5.1.1 Typing The Command Nameî 5.1.1 Typing The Command Nameî 5.1.1 Typing The Command Name
When you type M-X, the cursor moves down to the echo area at
the bottom of the screen. "M-X" is printed there, and when you