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