New directory
[bpt/emacs.git] / etc / OTHER.EMACSES
CommitLineData
a933dad1
DL
1How is this Emacs different from all other Emacses? -*-Outline-*-
2
3This file describes the differences between GNU Emacs 19, Twenex
4Emacs, Gosling Emacs (including the commercial versions by Unipress)
5and CCA Emacs.
6
7* Copyright (c) 1985 Richard M. Stallman
8
9 Permission is granted to anyone to make or distribute verbatim copies
10 of this document as received, in any medium, provided that the
11 copyright notice and permission notice are preserved,
12 and that the distributor grants the recipient permission
13 for further redistribution as permitted by this notice.
14
15 Permission is granted to distribute modified versions
16 of this document, or of portions of it,
17 under the above conditions, provided also that they
18 carry prominent notices stating who last changed them.
19
20Updated March 1993 for Emacs 19 by Eric S. Raymond
21
22
23* How is this Emacs different from Twenex Emacs?
24
25** Fundamental concepts.
26
27*** There is no concept of "typeout" in GNU Emacs.
28
29Any time that a command wants to display some output,
30it creates a buffer (usually with a name surrounded by asterisks)
31and displays it in a window.
32
33This provides some advantages:
34 you can edit some more while looking at the output;
35 you can copy parts of the output into other buffers.
36
37It also has a disadvantage that you must type a command
38in order to make the output disappear.
39You can use C-x 1 to get rid of all windows except the
40selected one. To be more selective, you can switch to
41the window you want to get rid of and then type C-x 0
42(delete-window).
43
44You also need to type a command to scroll the other
45window if not all the output fits in it. Meta-Control-v
46will usually do the job.
47
48*** There is no concept of a "subsystem" in GNU Emacs.
49
50Where Twenex Emacs would use a subsystem, GNU Emacs
51instead creates a buffer and redefines commands in it.
52
53For example, when you send mail in GNU Emacs, you use
54a buffer named *mail* which is in Mail Mode. You can
55switch away from this buffer to any other buffer and
56resume normal editing; then switch back and resume
57composing mail. You do not have to "exit" from
58composing mail in order to do ordinary editing.
59
60This has many advantages, but it also has a disadvantage:
61Subsystems in Emacs tend to have "exit" commands that return you
62to whatever you were doing before entering the subsystem.
63In GNU Emacs the idea of what to return to is not well defined,
64so it is not clear what an "exit" command should do.
65The only way to "exit" in general is to type C-x b, C-x C-f, or
66some other suitable command to switch buffers. Some
67subsystem-like major modes, such as Info and Mail mode, provide
68commands to "exit" by switching to the previously selected
69buffer.
70
71*** Files are always visited in their own buffers.
72
73Beginning users of Twenex Emacs were told how to edit
74using a single buffer and reading one file after another
75into that buffer. Use of a new buffer for each file was
76regarded as a more advanced mode.
77
78In GNU Emacs, the idea of using a single buffer for various
79files, one by one, has been dropped, given that the address
80space is expected to be large enough for many buffers. C-x
81C-f (find-file), which behaves nearly the same as in Twenex
82Emacs, is in GNU Emacs the canonical way for all users to
83visit files.
84
85Various commands need to read files into Emacs in the course
86of their execution. In Twenex Emacs the user must tell them
87whether to reuse buffers or create new ones, using the variable
88Tags Find File. In GNU Emacs, these commands always use
89C-x C-f.
90
91The command C-x C-v does still exist; it kills the current
92buffer and reads the specified file into a new buffer.
93It is equivalent to kill-buffer followed by find-file.
94
95Since there is no reusing of buffers, there is no point in
96calling the initial buffer "main". So the initial buffer
97in GNU Emacs is called "*scratch*" and is intended for typing
98Lisp expressions to be evaluated.
99
100*** File name defaulting.
101
102GNU Emacs records a separate working directory for each buffer.
103Normally this is the directory on which the buffer's file
104resides; for buffers not visiting any file, it is copied from
105the buffer that was current when it was created. The current buffer's
106working directory can be printed with M-x pwd and set with M-x cd.
107
108GNU Emacs shows you the default directory by inserting it in
109the minibuffer when a file name is being read. You can type
110the filename you want at the end of the default as if the
111default were not there, or you can edit and alter the default.
112
113If you want file /lose/big when the default /foo/defaultdir/
114has been inserted for you, you need not kill the default; simply
115type at the end of it: /foo/defaultdir//lose/big. Such a file
116name is not ordinarily considered valid, but GNU Emacs
117considers it equivalent to /lose/big.
118
119Likewise, if you want file quux in your home directory, just add
120~/quux to the end of the supplied text, to get
121/foo/defaultdir/~/quux. GNU Emacs sees "/~" and throws away
122everything before the "~".
123
124You can refer to environment variables also within file names.
125$ followed by the environment variable name is replaced by the
126variable's value. The variable name should either be followed
127by a nonalphanumeric character (which counts as part of the
128file name) or be surrounded by braces {...} (which do not count
129as part of the file name). Thus, if variable USER has value "rms",
130"x/$USER-foo" is expanded to "x/rms-foo", and "x${USER}foo"
131is expanded to "xrmsfoo". Note that this substitution is not
132performed by the primitive file operation functions of GNU Emacs,
133but rather by the interactive file name reader. It is also
134available as a separate primitive, in the function
135substitute-in-file-name.
136
137*** Exit commands C-z, C-x C-c and C-x C-z.
138
139There are two ways to exit GNU Emacs: killing and suspending.
140Killing is like what Control-c does to ordinary Unix programs.
141In GNU Emacs, you type C-x C-c to kill it. (This offers to
142save any modified file buffers before really killing Emacs.)
143Suspending is like what Control-z does to ordinary Unix programs.
144To suspend GNU Emacs, type C-x C-z, or type just C-z.
145Note that C-z suspends ordinary programs instantly, but
146Emacs does not suspend until it reads the C-z.
147
148Usually it is better to suspend: once a system is smart
149enough to have job control, why ever kill an editor?
150You'll just have to make a new one in a minute.
151This is why the convenient command C-z is provided for
152suspending.
153
154C-c is used as a prefix key for mode-specific commands and for users'
155own commands. We deliberately do not make C-c ever kill Emacs,
156because it should not be so easy to do something irreversible.
157
158*** Quitting with C-g.
159
160If you type C-g while GNU Emacs is waiting for input, it
161is an ordinary command (which is defined to beep). If you
162type C-g while Lisp code is executing, it sets a flag which
163causes a special signal, nearly the same as an error, to
164happen at the next safe place in Lisp execution. This usually
165has the effect of aborting the current command in a safe way.
166
167Because at times there have been bugs causing GNU Emacs to loop
168without checking the quit flag, a special feature causes
169GNU Emacs to be suspended immediately if you type a second C-g
170while the flag is already set. So you can always get out
171of GNU Emacs. Normally GNU Emacs recognizes and clears the quit flag
172quickly enough to prevent this from happening.
173
174When you resume GNU Emacs after a suspension caused by multiple C-g, it
175asks two questions before resuming execution:
176 Checkpoint?
177 Dump core?
178Answer each one with `y' or `n' and a Return.
179 `y' to Checkpoint? causes immediate auto-saving of all
180 buffers in which auto-saving is enabled.
181 `y' to Dump core? causes an illegal instruction to be executed.
182 This is to enable a wizard to figure out why GNU Emacs was
183 looping without checking for quits. Execution does not continue
184 after a core dump. If you answer `n', execution continues.
185With luck, GNU Emacs will ultimately check the quit flag,
186and quit normally. If not, and you type another C-g, it
187is suspended again.
188
189If GNU Emacs is not really hung, just slow, you may invoke
190the double C-g feature without really meaning to. Then just
191resume and answer `n' to both questions, and you will
192arrive at your former state. Presumably the quit you
193wanted will finish happening soon.
194
195These questions are not asked if you suspend GNU Emacs with the C-z
196command. Continuing GNU Emacs after a C-z takes you straight back
197into editing.
198
199*** Undoing with C-x u or C-_
200
201You can undo many commands--up to 10,000 characters worth.
202Each time you type C-x u or C-_, another command or batch of change
203is undone. Undo information is stored per buffer, and the undo
204command always applies to the current buffer. A numeric argument
205serves as a repeat count.
206
207Consecutive self-inserting characters are undone in groups of twenty.
208
209*** Different character set.
210
211GNU Emacs does not expect anyone ever to have a keyboard in which
212the Control key sets an independent bit which may accompany any
213character. The only control characters that can exist are the
214ASCII control characters.
215
216There is, as a result, no "control prefix" character.
217
218*** Control-h is the Help character.
219
220I'm amazed it took me so long to get this idea. In Twenex Emacs, C-h
221and C-b are equivalent commands, making C-h redundant. C-h is not
222only easy to type, it is mnemonic for "Help". So in GNU Emacs the
223Help character is C-h.
224
225*** Completion is done by TAB, not ESC.
226
227ESC in the minibuffer is a Meta prefix, same as at top level.
228
229*** The string-argument reader is the minibuffer is an editor window.
230
231In GNU Emacs, the line at the bottom of the screen is the minibuffer.
232Commands that want string arguments always use this line to read them,
233and you can use the ordinary Emacs editing commands to edit the
234input. You can terminate input with Return because Return is defined
235as the exit-minibuffer command when in the minibuffer. If you
236are using a command that needs several arguments, terminate each
237one with Return. You cannot separate arguments with Escape
238the way you would in Twenex Emacs.
239
240The minibuffer window does not overlay other editor windows;
241it is a nearly ordinary editor window which lacks a mode line
242and is "turned off" when not in use. While it IS in use, you
243can switch windows to and from the minibuffer, kill text in other
244windows and yank in the minibuffer, etc.
245
246You can even issue a command that uses the minibuffer while in the
247minibuffer. This gets you temporarily into a recursive minibuffer.
248However, this is allowed only if you enable it, since it could be
249confusing for beginners.
250
251When you exit the minibuffer, the cursor immediately moves back to
252column zero of the minibuffer line, to show you that the exit
253command has been obeyed. The minibuffer contents remain on the screen
254until the end of the command, unless some other text is displayed there.
255
256A single Control-g exits the minibuffer.
257
258*** There are no &'s or ^R's or spaces in function names.
259
260For example, the function which is called ^R Forward Word
261in Twenex Emacs is called forward-word in GNU Emacs.
262
263*** The extension language is Lisp rather than TECO.
264
265Libraries must be written in Lisp. Meta-ESC reads a Lisp
266expression, evaluates it, and prints the result. Note that
267Meta-ESC is "disabled" by default, so that beginning users
268do not get into the minibuffer by accident in a confusing way.
269
270Data types available include integers (which double as characters),
271strings, symbols, lists, vectors, buffers, buffer pointers,
272windows, and process channels.
273
274For now, to learn about writing Lisp code for GNU Emacs, read some of
275the source code, which is in directory ../lisp. Read the GNU Emacs Lisp
276Reference Manual. Also, all Lisp primitives have self-documentation you can
277read with C-h f.
278
279*** Enabling the error handler.
280
281GNU Emacs has a Lisp debugger/stepper/trace package, but normally
282errors do not enter the debugger because that is slow, and unlikely to
283be of interest to most users. Set the variable debug-on-error to t to
284cause errors to invoke the debugger. Set debug-on-quit to cause quit
285signals (caused by C-g) to invoke the debugger.
286
287** Other changes.
288
289*** More than two windows are allowed.
290
291C-x 2 splits the current window into two windows,
292 one above the other. Initially they both display
293 the same buffer.
294
295 C-x 2 now accepts a numeric argument to specify the number of
296 lines to give to the uppermost of the two windows it makes.
297
298C-x 0 kills the current window, making all others larger.
299C-x 1 kills all windows except the current one.
300C-x O switches to the next window down.
301 It rotates from the bottom one to the top one.
302 An argument serves as a repeat count; negative arguments
303 circulate in the reverse order.
304
305If the same buffer is displayed in several windows,
306changes made in it are redisplayed in all of them.
307
308*** Side by side windows are supported.
309
310The command C-x 3 splits the current window into
311two side-by-side windows.
312
313C-x } makes the selected window ARG columns wider at the
314expense of the windows at its sides. C-x { makes the selected
315window ARG columns narrower. An argument to C-x 5 specifies
316how many columns to give to the leftmost of the two windows made.
317
318*** Horizontal scrolling of the lines in a window is implemented.
319
320C-x < (scroll-left) scrolls all displayed lines left,
321with the numeric argument (default 1) saying how far to scroll.
322When the window is scrolled left, some amount of the beginning
323of each nonempty line is replaced by an "$".
324C-x > scrolls right. If a window has no text hidden at the left
325margin, it cannot be scrolled any farther right than that.
326When nonzero leftwards scrolling is in effect in a window.
327lines are automatically truncated at the window's right margin
328regardless of the value of the variable truncate-lines in the
329buffer being displayed.
330
331*** Return key does not use up empty lines.
332
333In Twenex Emacs, the Return command advances over an existing
334empty line in some cases. In GNU Emacs, the Return command always
335makes inserts a newline. Twenex Emacs was designed at a time when
336most display terminals did not have the ability to scroll part
337of the screen, and using existing empty lines made redisplay faster.
338Nowadays, terminals that cannot scroll part of the screen are rare,
339so there is no need to make Return behave in a more complicated manner.
340
341*** Help m.
342
343Typing C-h m displays documentation of the current major mode.,
344telling you what special commands and features are available
345and how to use them or get more information on them.
346
347This is simply the documentation, as a function, of the
348symbol which is the value of major-mode. Each major mode
349function has been given documentation intended for C-h m.
350
351*** Display-hiding features.
352
353**** Hiding indented lines
354
355The command C-x $ with numeric argument N causes lines indented by N
356or more columns to become invisible. All you see is " ..." appended
357to the previous line, in place of any number of consecutive invisible
358lines.
359
360**** Outline Mode.
361
362Outline mode is designed for editing outline-structured
363files, such as this one.
364
365Headings should be lines starting with one or more asterisks.
366Major headings have one asterisk, subheadings two, etc.
367Lines not starting with asterisks are body text.
368
369You can make the body under a heading, or the subheadings
370under a heading, temporarily invisible, or visible again.
371Invisible lines are attached to the end of the previous line
372so they go with it if you kill it and yank it back.
373
374Commands:
375Meta-} next-visible-heading move by visible headings
376Meta-{ previous-visible-heading move by visible headings
377
378Meta-x hide-body make all body text invisible (not headings).
379Meta-x show-all make everything in buffer visible.
380
381The remaining commands are used when dot is on a heading line.
382They apply to some of the body or subheadings of that heading.
383C-c C-h hide-subtree make text and subheadings invisible.
384C-c C-s show-subtree make text and subheadings visible.
385C-c C-i show-children make direct subheadings visible.
386 No effect on body, or subheadings 2 or more levels down.
387 With arg N, affects subheadings N levels down.
388M-x hide-entry make immediately following body invisible.
389M-x show-entry make it visible.
390M-x hide-leaves make text under heading and under its subheadings invisible.
391 The subheadings remain visible.
392M-x show-branches make all subheadings at all levels visible.
393
394*** C mode is fancy.
395
396C mode assumes that you put the initial open-brace of
397a function definition at the beginning of a line.
398If you use the popular indenting style that puts this
399open-brace at the end of a line containing a type declaration,
400YOU WILL LOSE: C mode does not know a function starts there.
401
402Open-brace at the beginning of a line makes it possible
403for C mode to find function boundaries with total reliability;
404something I consider vital and which cannot be done
405if the other style is used.
406
407The Tab command indents C code very cleverly.
408I know of only one cases in which Tab does not indent C code nicely:
409 Expressions continued over several lines with few parentheses.
410 Tab does not know the precedences of C operators, so it does
411 not know which lines of the expression should go where.
412 Using parentheses to indicate the nesting of operators
413 except within a line makes this problem go away.
414
415The indenting algorithm is entirely written in Lisp.
416
417Tab with a numeric argument in Twenex Emacs indents
418that many lines. It is different in GNU Emacs: it means
419to shift all the lines of a bracketed expression by the
420same amount as the line being indented. For example, if you have
421 if (foo)
422 {
423 hack ();
424 /** Well? */
425 }
426and type C-u Tab on the line with the open brace, you get
427 if (foo)
428 {
429 hack ();
430 /* Well? */
431 }
432from indenting the brace line and then shifting the
433lines within the braces rigidly with the first one.
434
435Meta-Control-q works as in Lisp mode; it should be
436used with dot just before a bracketed grouping, and
437indents each line INSIDE that grouping using Tab.
438If used instead of C-u Tab in the previous example, it makes
439 if (foo)
440 {
441 hack ();
442 /* Well? */
443 }
444
445Meta-Control-h puts mark at the end of the current C function
446and puts dot before it.
447
448Most other Meta-Control commands intended for Lisp expressions
449work usefully in C mode as well.
450
451*** Meta-g (fill-region) is different.
452
453In Twenex Emacs, Meta-g fills the region with no paragraph
454boundaries except for blank and indented lines. In GNU Emacs,
455it divides the region into paragraphs in the same manner as
456Meta-], and fills each paragraph separately. There is also
457the function fill-region-as-paragraph which fills the region
458regarding at as a single paragraph regardless even of blank
459or indented lines.
460
461*** Indented Text Mode instead of Edit Indented Text.
462
463Twenex Emacs has a command Edit Indented Text which temporarily
464alters some commands for editing indented paragraphs.
465GNU Emacs has instead a separate major mode, Indented Text Mode,
466which is different from ordinary Text Mode in just the same
467alterations. Specifically, in Indented Text Mode,
468Tab runs the function indent-relative, and auto filling indents
469the newly created lines.
470
471*** But rectangle commands are implemented.
472
473C-x r r stores the rectangle described by dot and mark
474into a register; it reads the register name from the keyboard.
475C-x r g, the command to insert the contents of a register,
476can be used to reinsert the rectangle elsewhere.
477
478Other rectangle commands include
479 open-rectangle:
480 insert a blank rectangle in the position and size
481 described by dot and mark, at its corners;
482 the existing text is pushed to the right.
483 clear-rectangle:
484 replace the rectangle described by dot ane mark
485 with blanks. The previous text is deleted.
486 delete-rectangle:
487 delete the text of the specified rectangle,
488 moving the text beyond it on each line leftward.
489 kill-rectangle
490 like delete-rectangle but also stores the text of
491 the rectangle in the "rectangle kill buffer".
492 More precisely, it stores the text as a list of strings
493 (one string for each line) in the variable killed-rectangle.
494 yank-rectangle
495 inserts the text of the last killed rectangle.
496 extract-rectangle and delete-extract-rectangle
497 these functions return the text of a rectangle
498 as a list of strings. They are for use in writing
177c0ea7 499 other functions that operate on rectangles.
a933dad1
DL
500
501*** Keyboard Macros
502
503The C-x ( command for defining a keyboard macro can in GNU Emacs
504be given a numeric argument, which means that the new macro
505starts out not empty but rather as the same as the last
506keyboard macro entered. In addition, that last keyboard
507macro is replayed when the C-x ( is typed. C-x ( with an
508argument is thus equivalent to typing plain C-x ( and then
509retyping the last keyboard macro entered.
510
511The command write-kbd-macro and append-kbd-macro can be used to
512save a keyboard macro definition in a file. It is represented as
513a Lisp expression which, when evaluated, will define the keyboard
514macro. write-kbd-macro writes the specified file from scratch,
515whereas append-kbd-macro adds to any existing text in the file.
516Both expect the keyboard macro to be saved to be specified by
517name; this means you must use the command name-last-kbd-macro to
518give the macro a name before you can save it.
519
520*** The command to resume a terminated tags-search or tags-query-replace
521
522is Meta-comma in GNU Emacs.
523
524*** Auto Save is on by default.
525
526Auto Save mode is enabled by default in all buffers
527that are visiting files.
528
529The file name used for auto saving is made by prepending
530"#" to the file name visited.
531
532*** Backup files.
533
534Since Unix stupidly fails to have file version numbers,
535GNU Emacs compensates slightly in the customary fashion:
536when a file is modified and saved for the first time in
537a particular GNU Emacs run, the original file is renamed,
538appending "~" to its name. Thus, foo.c becomes foo.c~.
539
540Emacs can also put a version number into the name of the backup file,
541as in foo.c.~69~ for version number 69. This is an optional feature
542that the user has to enable.
543
544*** Mode Line differences.
545
546Each window in GNU Emacs has its own mode line, which always
547displays the status of that window's buffer and nothing else.
548The mode line appears at the bottom of the window. It is
549full of dashes, to emphasize the boundaries between windows,
550and is displayed in inverse video if the terminal supports it.
551The information usually available includes:
552
553*** Local Modes feature changed slightly.
554
555GNU Emacs supports local mode lists much like those in Twenex Emacs,
556but you can only set variables, not commands. You write
557
558Local variables:
559tab-width: 10
560end:
561
562in the last page of a file, if you want to make tab-width be ten in a
563file's buffer. The value you specify must be a Lisp object!
564It will be read, but not evaluated. So, to specify a string,
565you MUST use doublequotes. For "false", in variables whose
566meanings are true or false, you MUST write nil .
567
568Two variable names are special: "mode" and "eval".
569Mode is used for specifying the major mode (as in Twenex Emacs).
570
571mode: text
572
573specifies text mode. Eval is used for requesting the evaluation
574of a Lisp expression; its value is ignored. Thus,
575
576eval: (set-syntax-table lisp-mode-syntax-table)
577
578causes Lisp Mode syntax to be used.
579
580
581Note that GNU Emacs looks for the string "Local variables:"
582whereas Twenex Emacs looks for "Local modes:". This incompatibility
583id deliberate, so that neither one will see local settings
584intended for the other.
585
586*** Lisp code libraries.
587
588Libraries of commands, and init files, are written in Lisp.
589libraries conventionally have names ending in .el, while the
590init file is named .emacs and is in your home directory.
591
592Use Meta-x load-library to load a library. Most standard libraries
593load automatically if you try to use the commands in them.
594
595Meta-x byte-compile-file filename
596compiles the file into byte code which loads and runs faster
597than Lisp source code. The file of byte code is given a name
598made by appending "c" to the end of the input file name.
599
600Meta-x byte-recompile-directory directoryname
601compiles all files in the specified directory (globbing not allowed)
602which have been compiled before but have been changed since then.
603
604Meta-x load-library automatically checks for a compiled file
605before loading the source file.
606
607Libraries once loaded do not retain their identity within GNU
608Emacs. Therefore, you cannot tell just what was loaded from a
609library, and you cannot un-load a library. Normally, libraries
610are written so that loading one has no effect on the editing
611operations that you would have used if you had not loaded the
612library.
613
614*** Dired features.
615
616You can do dired on partial directories --- any pattern
617the shell can glob. Dired creates a buffer named after
618the directory or pattern, so you can dired several different
619directories. If you repeat dired on the same directory or
620pattern, it just reselects the same buffer. Use Meta-x Revert
621on that buffer to read in the current contents of the directory.
622
623*** Directory listing features.
624
625C-x C-d now uses the default output format of `ls',
626which gives just file names in multiple columns.
627C-u C-x C-d passes the -l switch to `ls'.
628
629Both read a directory spec from the minibuffer. It can
630be any pattern that the shell can glob.
631
632*** Compiling other programs.
633
634Meta-x compile allows you to run make, or any other compilation
635command, underneath GNU Emacs. Error messages go into a buffer whose
636name is *compilation*. If you get error messages, you can use the
637command C-x ` (that is a backquote) to find the text of the next
638error message.
639
640You must specify the command to be run as an argument to M-x compile.
641A default is placed in the minibuffer; you can kill it and start
642fresh, edit it, or just type Return if it is what you want.
643The default is the last compilation command you used; initially,
644it is "make -k".
645
646*** Searching multiple files.
647
648Meta-x grep searches many files for a regexp by invoking grep
649and reading the output of grep into a buffer. You can then
650move to the text lines that grep found, using the C-x ` command
651just as after M-x compile.
652
653*** Running inferior shells.
654
655Do Meta-x shell to make an inferior shell together with a buffer
656which serves to hold "terminal" input and output of the shell.
657The shell used is specified by the environment variable ESHELL,
658or by SHELL if ESHELL is not set.
659
660Use C-h m whilst in the *shell* buffer to get more detailed info.
661
662The inferior shell loads the file .emacs_csh or.emacs_sh
663(or similar using whatever name the shell has) when it starts up.
664
665M-! executes a shell command in an inferior shell
666and displays the output from it. With a prefix argument,
667it inserts the output in the current buffer after dot
668and sets the mark after the output. The shell command
669gets /dev/null as its standard input.
670
671M-| is like M-! but passes the contents of the region
672as input to the shell command. A prefix argument makes
673the output from the command replace the contents of the region.
674
675*** Sending mail.
676
677Once you enter Mail Mode using C-x m or C-x 4 m or M-x mail,
678C-c becomes a prefix character for mail-related editing commands.
679C-c C-s is vital; that's how you send the message. C-c C-c sends
680and then switches buffers or kills the current window.
681Use C-h m to get a list of the others.
682
683*** Regular expressions.
684
685GNU Emacs has regular expression facilities like those of most
686Unix editors, but more powerful:
687
688**** -- + --
689
690+ specifies repetition of the preceding expression 1 or more
691times. It is in other respect like *, which specifies repetition
6920 or more times.
693
694**** -- ? --
695
696? is like * but matches at most one repetition of the preceding
697expression.
698
699**** -- \| --
700
701\| specifies an alternative. Two regular expressions A and B with \| in
702between form an expression that matches anything that either A or B will
703match. Thus, "foo\|bar" matches either "foo" or "bar" but no other
704string.
705
706\| applies to the larges possible surrounding expressions. Only a
707surrounding \( ... \) grouping can limit the grouping power of \|.
708
709Full backtracking capability exists when multiple \|'s are used.
710
711**** -- \( ... \) --
712
713\( ... \) are a grouping construct that serves three purposes:
714
7151. To enclose a set of \| alternatives for other operations.
716 Thus, "\(foo\|bar\)x" matches either "foox" or "barx".
7172. To enclose a complicated expression for * to operate on.
718 Thus, "ba\(na\)*" matches "bananana", etc., with any number
719 of na's (zero or more).
7203. To mark a matched substring for future reference.
721
722Application 3 is not a consequence of the idea of a parenthetical
723grouping; it is a separate feature which happens to be assigned as a
724second meaning to the same \( ... \) construct because there is no
725conflict in practice between the two meanings. Here is an explanation
726of this feature.
727
728 -- \digit --
729
730After the end of a \( ... \) construct, the matcher remembers the
731beginning and end of the text matched by that construct. Then, later on
732in the regular expression, you can use \ followed by a digit to mean,
733``match the same text matched this time by the \( ... \) construct.''
734The first nine \( ... \) constructs that appear in a regular expression
735are assigned numbers 1 through 9 in order of their beginnings. \1
736through \9 can be used to refer to the text matched by the corresponding
737\( ... \) construct.
738
739For example, "\(.*\)\1" matches any string that is composed of two
740identical halves. The "\(.*\)" matches the first half, which can be
741anything, but the \1 that follows must match the same exact text.
742
743**** -- \` --
744
745Matches the empty string, but only if it is at the beginning of the buffer.
746
747**** -- \' --
748
749Matches the empty string, but only if it is at the end of the buffer.
750
751**** -- \b --
752
753Matches the empty string, but only if it is at the beginning or end of
754a word. Thus, "\bfoo\b" matches any occurrence of "foo" as a separate word.
755"\bball\(s\|\)\b" matches "ball" or "balls" as a separate word.
756
757**** -- \B --
758
759Matches the empty string, provided it is NOT at the beginning or end of
760a word.
761
762**** -- \< --
763
764Matches the empty string, provided it is at the beginning of a word.
765
766**** -- \> --
767
768Matches the empty string, provided it is at the end of a word.
769
770**** -- \w --
771
772Matches any word-constituent character. The editor syntax table determines
773which characters these are.
774
775**** -- \W --
776
777Matches any character that is not a word-constituent.
778
779**** -- \s<code> --
780
781Matches any character whose syntax is <code>. <code> is a letter that
782represents a syntax code: thus, "w" for word constituent, "-" for
783whitespace, "(" for open-parenthesis, etc. Thus, "\s(" matches any
784character with open-parenthesis syntax.
785
786**** -- \S<code> --
787
788Matches any character whose syntax is not <code>.
789
790* How is this Emacs different from Gosling Emacs?
791
792** Advantages of Gosling Emacs:
793
7941. The program itself is much smaller.
795GNU Emacs uses about 250k more pure storage.
796As a result, Gosling Emacs can run on machines
797that cannot run GNU Emacs. There is not much difference
798in the amount of impure storage in the two programs.
799
8002. In some versions there is support for other forks to
801establish communications channels to Emacs (using sockets?).
802
8033. There is a direct interface to dbm (data bases).
804
805** Advantages of GNU Emacs:
806
807*** True Lisp, not Mocklisp.
808
809GNU Emacs's extension language has real symbols, lists
810and vectors. Many extensions are much simpler, and some
811become possible that were nearly impossible in Gosling Emacs.
812Many primitives can have cleaner interfaces, and some features
813need not be put in as special primitives because you can do
814them easily yourself.
815
816*** But Mocklisp still works.
817
818An automatic conversion package plus a run-time library
819allows you to convert a Mocklisp library into a Lisp library.
820
821*** Commands are better crafted.
822
823For example, nearly every editing function for which a
824numeric argument would make sense as a repeat count does
825accept a repeat count, and does handle a negative argument
826in the way you would expect.
827
828*** The manual is clearer.
829
830Everyone tells me it is a very good manual.
831
832*** Better on-line documentation.
833
834Both functions and variables have documentation strings that
835describe exactly how to use them.
836
837*** C mode is smart.
838
839It really knows how to indent each line correctly,
840for most popular indentation styles. (Some variables
841control which style is used; popular named styles are also supported.)
842
843*** Compatible with PDP-10 Emacs, Multics Emacs and Zmacs.
844
845The commands in GNU Emacs are nearly the same as in the
846original Emacs and the other Emacses which imitated it.
847(A few have been changed to fit the Unix environment better.)
848
849*** Support for Gosling's Emacs commands.
850
851M-x set-gosmacs-bindings rebinds many editing commands for
852compatibility with Gosling's Emacs.
853M-x set-gnu-bindings reverses the change.
854
855*** Side-by-side windows.
856
857You can split a GNU Emacs window either horizontally or
858vertically.
859
860*** Redisplay is faster.
861
862GNU Emacs sends about the same stuff to the terminal that
863Gosling's does, but GNU Emacs uses much less CPU time to
864decide what to do.
865
866*** Entirely termcap-driven.
867
868GNU Emacs has nearly no special code for any terminal type. Various
869new termcap strings make it possible to handle all terminals nearly as
870fast as they could be handled by special-case code.
871
872*** Display-hiding features.
873
874For example, Outline Mode makes it possible for you to edit
875an outline, making entire sub-branches of the outline visible
876or invisible when you wish.
877
878*** You can interrupt with Control-G.
879
880Even a looping Lisp program can be stopped this way.
881And even a loop in C code does not stop you from killing
882Emacs and getting back to your shell.
883
884*** Per-buffer Undo.
885
886You can undo the last several changes, in each buffer
887independently.
888
889*** The editor code itself is clean.
890
891Many people have remarked on how much they enjoy reading
892the code for GNU Emacs.
893
894One other note: The program etc/cvtmail that comes with GNU Emacs can
895be used to convert a mail directory for Gosling Emacs's Rmail into a
896Unix mail file that you could read into GNU Emacs's Rmail.
897
898* How is this Emacs different from CCA Emacs?
899
900** GNU Emacs Lisp vs CCA Elisp.
901
902GNU Emacs Lisp does not have a distinction between Lisp functions
903and Emacs functions, or between Lisp variables and Emacs variables.
904The Lisp and the editor are integrated. A Lisp function defined
905with defun is callable as an editor command if you put an
177c0ea7 906interactive calling spec in it; for example,
a933dad1
DL
907 (defun forward-character (n)
908 (interactive "p")
909 (goto-char (+ (point) n)))
910defines a function of one argument that moves point forward by
911a specified number of characters. Programs could call this function,
912as in (forward-character 6), or it could be assigned to a key,
913in which case the "p" says to pass the prefix numeric arg as
914the function's argument. As a result of this feature, you often
915need not have two different functions, one to be called by programs
916and another to read arguments from the user conveniently; the same
917function can do both.
918
919CCA Elisp tries to be a subset of Common Lisp and tries to
920have as many Common Lisp functions as possible (though it is still
921only a small fraction of full Common Lisp). GNU Emacs Lisp
922is somewhat similar to Common Lisp just because of my Maclisp
923and Lisp Machine background, but it has several distinct incompatibilities
924in both syntax and semantics. Also, I have not attempted to
925provide many Common Lisp functions that you could write in Lisp,
926or others that provide no new capability in the circumstances.
927
928GNU Emacs Lisp does not have packages, readtables, or character objects
929(it uses integers to represent characters).
930
931On the other hand, windows, buffers, relocatable markers and processes
932are first class objects in GNU Emacs Lisp. You can get information about them
933and do things to them in a Lispy fashion. Not so in CCA Emacs.
934
935In GNU Emacs Lisp, you cannot open a file and read or write characters
936or Lisp objects from it. This feature is painful to support, and
937is not fundamentally necessary in an Emacs, because instead you
938can read the file into a buffer, read or write characters or
939Lisp objects in the buffer, and then write the buffer into the file.
940
941On the other hand, GNU Emacs Lisp does allow you to rename, delete, add
942names to, and copy files; also to find out whether a file is a
943directory, whether it is a symbolic link and to what name, whether
944you can read it or write it, find out its directory component,
945expand a relative pathname, find completions of a file name, etc.,
946which you cannot do in CCA Elisp.
947
948GNU Emacs Lisp uses dynamic scope exclusively. This enables you to
949bind variables which affect the execution of the editor, such as
950indent-tabs-mode.
951
952GNU Emacs Lisp code is normally compiled into byte code. Most of the
953standard editing commands are written in Lisp, and many are
954dumped, pure, in the Emacs that users normally run.
955
956GNU Emacs allows you to interrupt a runaway Lisp program with
957Control-g.
958
959** GNU Emacs Editing Advantages
960
961GNU Emacs is faster for many things, especially insertion of text
962and file I/O.
963
964GNU Emacs allows you to undo more than just the last command
965with the undo command (C-x u, or C-_). You can undo quite a ways back.
966Undo information is separate for each buffer; changes in one buffer
967do not affect your ability to undo in another buffer.
968
969GNU Emacs commands that want to display some output do so by putting
970it in a buffer and displaying that buffer in a window. This
971technique comes from Gosling Emacs. It has both advantages and
972disadvantages when compared with the technique, copied by CCA Emacs
973from my original Emacs which inherited it from TECO, of having "type
974out" which appears on top of the text in the current window but
975disappears automatically at the next input character.
976
977GNU Emacs does not use the concept of "subsystems". Instead, it uses
978highly specialized major modes. For example, dired in GNU Emacs has
979the same commands as dired does in other versions of Emacs, give or
980take a few, but it is a major mode, not a subsystem. The advantage
981of this is that you do not have to "exit" from dired and lose the
982state of dired in order to edit files again. You can simply switch
983to another buffer, and switch back to the dired buffer later. You
984can also have several dired buffers, looking at different directories.
985
986It is still possible to write a subsystem--your own command loop--
987in GNU Emacs, but it is not recommended, since writing a major mode
988for a special buffer is better.
989
990Recursive edits are also rarely used, for the same reason: it is better
991to make a new buffer and put it in a special major mode. Sending
992mail is done this way.
993
994GNU Emacs expects everyone to use find-file (C-x C-f) for reading
995in files; its C-x C-v command kills the current buffer and then finds
996the specified file.
997
998As a result, users do not need to think about the complexities
999of subsystems, recursive edits, and various ways to read in files
1000or what to do if a buffer contains changes to some other file.
1001
1002GNU Emacs uses its own format of tag table, made by the "etags"
1003program. This format makes finding a tag much faster.
1004
1005Dissociated Press is supported.
1006
1007
1008** GNU Emacs Editing Disadvantages.
1009
1010GNU Emacs does not display the location of the mark.
1011
1012GNU Emacs does not have a concept of numbers of buffers,
1013or a permanent ordering of buffers, or searching through multiple
1014buffers. The tags-search command provides a way to search
1015through several buffers automatically.
1016
1017GNU Emacs does not provide commands to visit files without
1018setting the buffer's default directory. Users can write such
1019commands in Lisp by copying the code of the standard file
1020visiting commands and modifying them.
1021
1022GNU Emacs does not support "plus options" in the command
1023arguments or in buffer-selection commands, except for line numbers.
1024
1025GNU Emacs does not support encryption. Down with security!
1026
1027GNU Emacs does not support replaying keystroke files,
1028and does not normally write keystroke files.
1029
1030
1031** Neutral Differences
1032
1033GNU Emacs uses TAB, not ESC, to complete file names, buffer names,
1034command names, etc.
1035
1036GNU Emacs uses LFD to terminate searches, instead of
1037the C-d uses by CCA Emacs. (Actually, this character is controlled
1038by a parameter in GNU Emacs.) C-M-s in GNU Emacs is an interactive
1039regular expression search, but you can get to a noninteractive
1040one by typing ESC right after the C-M-s.
1041
1042In GNU Emacs, C-x s asks, for each modified file buffer, whether
1043to save it.
1044
1045GNU Emacs indicates line continuation with "\" and line
1046truncation (at either margin) with "$".
1047
1048The command to resume a tags-search or tags-query-replace in
1049GNU Emacs is Meta-Comma.