|
|
1.1 root 1: How is this Emacs different from all other Emacses? -*-Outline-*-
2: (Actually, from Twenex Emacs)
3:
4: * Copyright (c) 1985 Richard M. Stallman
5:
6: Permission is granted to anyone to make or distribute verbatim copies
7: of this document as received, in any medium, provided that the
8: copyright notice and permission notice are preserved,
9: and that the distributor grants the recipient permission
10: for further redistribution as permitted by this notice.
11:
12: Permission is granted to distribute modified versions
13: of this document, or of portions of it,
14: under the above conditions, provided also that they
15: carry prominent notices stating who last changed them.
16:
17: * Fundamental concepts.
18:
19: ** There is no concept of "typeout" in GNU Emacs.
20:
21: Any time that a command wants to display some output,
22: it creates a buffer (usually with a name surrounded by asterisks)
23: and displays it in a window.
24:
25: This provides some advantages:
26: you can edit some more while looking at the output;
27: you can copy parts of the output into other buffers.
28:
29: It also has a disadvantage that you must type a command
30: in order to make the output disappear.
31: You can use C-x 1 to get rid of all windows except the
32: selected one. To be more selective, you can switch to
33: the window you want to get rid of and then type C-x 0
34: (delete-window).
35:
36: You also need to type a command to scroll the other
37: window if not all the output fits in it. Meta-Control-v
38: will usually do the job.
39:
40: ** There is no concept of a "subsystem" in GNU Emacs.
41:
42: Where Twenex Emacs would use a subsystem, GNU Emacs
43: instead creates a buffer and redefines commands in it.
44:
45: For example, when you send mail in GNU Emacs, you use
46: a buffer named *mail* which is in Mail Mode. You can
47: switch away from this buffer to any other buffer and
48: resume normal editing; then switch back and resume
49: composing mail. You do not have to "exit" from
50: composing mail in order to do ordinary editing.
51:
52: This has many advantages, but it also has a disadvantage:
53: Subsystems in Emacs tend to have "exit" commands that return you
54: to whatever you were doing before entering the subsystem.
55: In GNU Emacs the idea of what to return to is not well defined,
56: so it is not clear what an "exit" command should do.
57: The only way to "exit" in general is to type C-x b, C-x C-f, or
58: some other suitable command to switch buffers. Some
59: subsystem-like major modes, such as Info and Mail mode, provide
60: commands to "exit" by switching to the previously selected
61: buffer.
62:
63: ** Files are always visited in their own buffers.
64:
65: Beginning users of Twenex Emacs were told how to edit
66: using a single buffer and reading one file after another
67: into that buffer. Use of a new buffer for each file was
68: regarded as a more advanced mode.
69:
70: In GNU Emacs, the idea of using a single buffer for various
71: files, one by one, has been dropped, given that the address
72: space is expected to be large enough for many buffers. C-x
73: C-f (find-file), which behaves nearly the same as in Twenex
74: Emacs, is in GNU Emacs the canonical way for all users to
75: visit files.
76:
77: Various commands need to read files into Emacs in the course
78: of their execution. In Twenex Emacs the user must tell them
79: whether to reuse buffers or create new ones, using the variable
80: Tags Find File. In GNU Emacs, these commands always use
81: C-x C-f.
82:
83: The command C-x C-v does still exist; it kills the current
84: buffer and reads the specified file into a new buffer.
85: It is equivalent to kill-buffer followed by find-file.
86:
87: Since there is no reusing of buffers, there is no point in
88: calling the initial buffer "main". So the initial buffer
89: in GNU Emacs is called "*scratch*" and is intended for typing
90: Lisp expressions to be evaluated.
91:
92: ** File name defaulting.
93:
94: GNU Emacs records a separate working directory for each buffer.
95: Normally this is the directory on which the buffer's file
96: resides; for buffers not visiting any file, it is copied from
97: the buffer that was current when it was created. The current buffer's
98: working directory can be printed with M-x pwd and set with M-x cd.
99:
100: GNU Emacs shows you the default directory by inserting it in
101: the minibuffer when a file name is being read. You can type
102: the filename you want at the end of the default as if the
103: default were not there, or you can edit and alter the default.
104:
105: If you want file /lose/big when the default /foo/defaultdir/
106: has been inserted for you, you need not kill the default; simply
107: type at the end of it: /foo/defaultdir//lose/big. Such a file
108: name is not ordinarily considered valid, but GNU Emacs
109: considers it equivalent to /lose/big.
110:
111: Likewise, if you want file quux in your home directory, just add
112: ~/quux to the end of the supplied text, to get
113: /foo/defaultdir/~/quux. GNU Emacs sees "/~" and throws away
114: everything before the "~".
115:
116: You can refer to environment variables also within file names.
117: $ followed by the environment variable name is replaced by the
118: variable's value. The variable name should either be followed
119: by a nonalphanumeric character (which counts as part of the
120: file name) or be surrounded by braces {...} (which do not count
121: as part of the file name). Thus, if variable USER has value "rms",
122: "x/$USER-foo" is expanded to "x/rms-foo", and "x${USER}foo"
123: is expanded to "xrmsfoo". Note that this substitution is not
124: performed by the primitive file operation functions of GNU Emacs,
125: but rather by the interactive file name reader. It is also
126: available as a separate primitive, in the function
127: substitute-in-file-name.
128:
129: ** Exit commands C-z, C-x C-c and C-x C-z.
130:
131: There are two ways to exit GNU Emacs: killing and suspending.
132: Killing is like what Control-c does to ordinary Unix programs.
133: In GNU Emacs, you type C-x C-c to kill it. (This offers to
134: save any modified file buffers before really killing Emacs.)
135: Suspending is like what Control-z does to ordinary Unix programs.
136: To suspend GNU Emacs, type C-x C-z, or type just C-z.
137: Note that C-z suspends ordinary programs instantly, but
138: Emacs does not suspend until it reads the C-z.
139:
140: Usually it is better to suspend: once a system is smart
141: enough to have job control, why ever kill an editor?
142: You'll just have to make a new one in a minute.
143: This is why the convenient command C-z is provided for
144: suspending.
145:
146: C-c is used as a prefix key for mode-specific commands and for users'
147: own commands. We deliberately do not make C-c ever kill Emacs,
148: because it should not be so easy to do something irreversible.
149:
150: ** Quitting with C-g.
151:
152: If you type C-g while GNU Emacs is waiting for input, it
153: is an ordinary command (which is defined to beep). If you
154: type C-g while Lisp code is executing, it sets a flag which
155: causes a special signal, nearly the same as an error, to
156: happen atthe next safe place in Lisp execution. This usually
157: has the effect of aborting the current command in a safe way.
158:
159: Because at times there have been bugs causing GNU Emacs to loop
160: without checking the quit flag, a special feature causes
161: GNU Emacs to be suspended immediately if you type a second C-g
162: while the flag is already set. So you can always get out
163: of GNU Emacs. Normally GNU Emacs recognizes and clears the quit flag
164: quickly enough to prevent this from happening.
165:
166: When you resume GNU Emacs after a suspension caused by multiple C-g, it
167: asks two questions before resuming execution:
168: Checkpoint?
169: Dump core?
170: Answer each one with `y' or `n' and a Return.
171: `y' to Checkpoint? causes immediate auto-saving of all
172: buffers in which auto-saving is enabled.
173: `y' to Dump core? causes an illegal instruction to be executed.
174: This is to enable a wizard to figure out why GNU Emacs was
175: looping without checking for quits. Execution does not continue
176: after a core dump. If you answer `n', execution continues.
177: With luck, GNU Emacs will ultimately check the quit flag,
178: and quit normally. If not, and you type another C-g, it
179: is suspended again.
180:
181: If GNU Emacs is not really hung, just slow, you may invoke
182: the double C-g feature without really meaning to. Then just
183: resume and answer `n' to both questions, and you will
184: arrive at your former state. Presumably the quit you
185: wanted will finish happening soon.
186:
187: These questions are not asked if you suspend GNU Emacs with the C-z
188: command. Continuing GNU Emacs after a C-z takes you straight back
189: into editing.
190:
191: ** Undoing with C-x u or C-_
192:
193: You can undo many commands--up to 10,000 characters worth.
194: Each time you type C-x u or C-_, another command or batch of change
195: is undone. Undo information is stored per buffer, and the undo
196: command always applies to the current buffer. A numeric argument
197: serves as a repeat count.
198:
199: Consecutive self-inserting characters are undone in groups of twenty.
200:
201: ** Different character set.
202:
203: GNU Emacs does not expect anyone ever to have a keyboard in which
204: the Control key sets an independent bit which may accompany any
205: character. The only control characters that can exist are the
206: ASCII control characters.
207:
208: There is, as a result, no "control prefix" character.
209:
210: ** Control-h is the Help character.
211:
212: I'm amazed it took me so long to get this idea. In Twenex Emacs, C-h
213: and C-b are equivalent commands, making C-h redundant. C-h is not
214: only easy to type, it is mnemonic for "Help". So in GNU Emacs the
215: Help character is C-h.
216:
217: ** Completion is done by TAB, not ESC.
218:
219: ESC in the minibuffer is a Meta prefix, same as at top level.
220:
221: ** The string-argument reader is the minibuffer is an editor window.
222:
223: In GNU Emacs, the line at the bottom of the screen is the minibuffer.
224: Commands that want string arguments always use this line to read them,
225: and you can use the ordinary Emacs editing commands to edit the
226: input. You can terminate input with Return because Return is defined
227: as the exit-minibuffer command when in the minibuffer. If you
228: are using a command that needs several arguments, terminate each
229: one with Return. You cannot separate arguments with Escape
230: the way you would in Twenex Emacs.
231:
232: The minibuffer window does not overlay other editor windows;
233: it is a nearly ordinary editor window which lacks a mode line
234: and is "turned off" when not in use. While it IS in use, you
235: can switch windows to and from the minibuffer, kill text in other
236: windows and yank in the minibuffer, etc.
237:
238: You can even issue a command that uses the minibuffer while in the
239: minibuffer. This gets you temporarily into a recursive minibuffer.
240: However, this is allowed only if you enable it, since it could be
241: confusing for beginners.
242:
243: When you exit the minibuffer, the cursor immediately moves back to
244: column zero of the minibuffer line, to show you that the exit
245: command has been obeyed. The minibuffer contents remain on the screen
246: until the end of the command, unless some other text is displayed there.
247:
248: A single Control-g exits the minibuffer.
249:
250: ** There are no &'s or ^R's or spaces in function names.
251:
252: For example, the function which is called ^R Forward Word
253: in Twenex Emacs is called forward-word in GNU Emacs.
254:
255: ** The extension language is Lisp rather than TECO.
256:
257: Libraries must be written in Lisp. Meta-ESC reads a Lisp
258: expression, evaluates it, and prints the result. Note that
259: Meta-ESC is "disabled" by default, so that beginning users
260: do not get into the minibuffer by accident in a confusing way.
261:
262: Data types available include integers (which double as characters),
263: strings, symbols, lists, vectors, buffers, buffer pointers,
264: windows, and process channels.
265:
266: For now, to learn about writing Lisp code for GNU Emacs, read some of
267: the source code, which is in directory ../lisp. Also, all Lisp
268: primitives have self-documentation you can read with C-h f.
269:
270: ** Enabling the error handler.
271:
272: GNU Emacs has a Lisp debugger/stepper/trace package, but normally
273: errors do not enter the debugger because that is slow, and unlikely to
274: be of interest to most users. Set the variable debug-on-error to t to
275: cause errors to invoke the debugger. Set debug-on-quit to cause quit
276: signals (caused by C-g) to invoke the debugger.
277:
278: * Other changes.
279:
280: ** More than two windows are allowed.
281:
282: C-x 2 splits the current window into two windows,
283: one above the other. Initially they both display
284: the same buffer.
285:
286: C-x 2 now accepts a numeric argument to specify the number of
287: lines to give to the uppermost of the two windows it makes.
288:
289: C-x 0 kills the current window, making all others larger.
290: C-x 1 kills all windows except the current one.
291: C-x O switches to the next window down.
292: It rotates from the bottom one to the top one.
293: An argument serves as a repeat count; negative arguments
294: circulate in the reverse order.
295:
296: If the same buffer is displayed in several windows,
297: changes made in it are redisplayed in all of them.
298:
299: ** Side by side windows are supported.
300:
301: The command C-x 5 splits the current window into
302: two side-by-side windows.
303:
304: C-x } makes the selected window ARG columns wider at the
305: expense of the windows at its sides. C-x { makes the selected
306: window ARG columns narrower. An argument to C-x 5 specifies
307: how many columns to give to the leftmost of the two windows made.
308:
309: ** Horizontal scrolling of the lines in a window is implemented.
310:
311: C-x < (scroll-left) scrolls all displayed lines left,
312: with the numeric argument (default 1) saying how far to scroll.
313: When the window is scrolled left, some amount of the beginning
314: of each nonempty line is replaced by an "$".
315: C-x > scrolls right. If a window has no text hidden at the left
316: margin, it cannot be scrolled any farther right than that.
317: When nonzero leftwards scrolling is in effect in a window.
318: lines are automatically truncated at the window's right margin
319: regardless of the value of the variable truncate-lines in the
320: buffer being displayed.
321:
322: ** Return key does not use up empty lines.
323:
324: In Twenex Emacs, the Return command advances over an existing
325: empty line in some cases. In GNU Emacs, the Return command always
326: makes inserts a newline. Twenex Emacs was designed at a time when
327: most display terminals did not have the ability to scroll part
328: of the screen, and using existing empty lines made redisplay faster.
329: Nowadays, terminals that cannot scroll part of the screen are rare,
330: so there is no need to make Return behave in a more complicated manner.
331:
332: ** Help m.
333:
334: Typing C-h m displays documentation of the current major mode.,
335: telling you what special commands and features are available
336: and how to use them or get more information on them.
337:
338: This is simply the documentation, as a function, of the
339: symbol which is the value of major-mode. Each major mode
340: function has been given documentation intended for C-h m.
341:
342: ** Display-hiding features.
343:
344: *** Hiding indented lines
345:
346: The command C-x $ with numeric argument N causes lines indented by N
347: or more columns to become invisible. All you see is " ..." appended
348: to the previous line, in place of any number of consecutive invisible
349: lines.
350:
351: *** Outline Mode.
352:
353: Outline mode is designed for editing outline-structured
354: files, such as this one.
355:
356: Headings should be lines starting with one or more asterisks.
357: Major headings have one asterisk, subheadings two, etc.
358: Lines not starting with asterisks are body text.
359:
360: You can make the body under a heading, or the subheadings
361: under a heading, temporarily invisible, or visible again.
362: Invisible lines are attached to the end of the previous line
363: so they go with it if you kill it and yank it back.
364:
365: Commands:
366: Meta-} next-visible-heading move by visible headings
367: Meta-{ previous-visible-heading move by visible headings
368:
369: Meta-x hide-body make all body text invisible (not headings).
370: Meta-x show-all make everything in buffer visible.
371:
372: The remaining commands are used when dot is on a heading line.
373: They apply to some of the body or subheadings of that heading.
374: C-c C-h hide-subtree make text and subheadings invisible.
375: C-c C-s show-subtree make text and subheadings visible.
376: C-c C-i show-children make direct subheadings visible.
377: No effect on body, or subheadings 2 or more levels down.
378: With arg N, affects subheadings N levels down.
379: M-x hide-entry make immediately following body invisible.
380: M-x show-entry make it visible.
381: M-x hide-leaves make text under heading and under its subheadings invisible.
382: The subheadings remain visible.
383: M-x show-branches make all subheadings at all levels visible.
384:
385: ** C mode is fancy.
386:
387: C mode assumes that you put the initial open-brace of
388: a function definition at the beginning of a line.
389: If you use the popular indenting style that puts this
390: open-brace at the end of a line containing a type declaration,
391: YOU WILL LOSE: C mode does not know a function starts there.
392:
393: Open-brace at the beginning of a line makes it possible
394: for C mode to find function boundaries with total reliability;
395: something I consider vital and which cannot be done
396: if the other style is used.
397:
398: The Tab command indents C code very cleverly.
399: I know of only one cases in which Tab does not indent C code nicely:
400: Expressions continued over several lines with few parentheses.
401: Tab does not know the precedences of C operators, so it does
402: not know which lines of the expression should go where.
403: Using parentheses to indicate the nesting of operators
404: except within a line makes this problem go away.
405:
406: The indenting algorithm is entirely written in Lisp.
407:
408: Tab with a numeric argument in Twenex Emacs indents
409: that many lines. It is different in GNU Emacs: it means
410: to shift all the lines of a bracketed expression by the
411: same amount as the line being indented. For example, if you have
412: if (foo)
413: {
414: hack ();
415: /** Well? */
416: }
417: and type C-u Tab on the line with the open brace, you get
418: if (foo)
419: {
420: hack ();
421: /* Well? */
422: }
423: from indenting the brace line and then shifting the
424: lines within the braces rigidly with the first one.
425:
426: Meta-Control-q works as in Lisp mode; it should be
427: used with dot just before a bracketed grouping, and
428: indents each line INSIDE that grouping using Tab.
429: If used instead of C-u Tab in the previous example, it makes
430: if (foo)
431: {
432: hack ();
433: /* Well? */
434: }
435:
436: Meta-Control-h puts mark at the end of the current C function
437: and puts dot before it.
438:
439: Most other Meta-Control commands intended for Lisp expressions
440: work usefully in C mode as well.
441:
442: ** Meta-g (fill-region) is different.
443:
444: In Twenex Emacs, Meta-g fills the region with no paragraph
445: boundaries except for blank and indented lines. In GNU Emacs,
446: it divides the region into paragraphs in the same manner as
447: Meta-], and fills each paragraph separately. There is also
448: the function fill-region-as-paragraph which fills the region
449: regarding at as a single paragraph regardless even of blank
450: or indented lines.
451:
452: ** Indented Text Mode instead of Edit Indented Text.
453:
454: Twenex Emacs has a command Edit Indented Text which temporarily
455: alters some commands for editing indented paragraphs.
456: GNU Emacs has instead a separate major mode, Indented Text Mode,
457: which is different from ordinary Text Mode in just the same
458: alterations. Specifically, in Indented Text Mode,
459: Tab runs the function indent-relative, and auto filling indents
460: the newly created lines.
461:
462: ** But rectangle commands are implemented.
463:
464: C-x r stores the rectangle described by dot and mark
465: into a register; it reads the register name from the keyboard.
466: C-x g, the command to insert the contents of a register,
467: can be used to reinsert the rectangle elsewhere.
468:
469: Other rectangle commands include
470: open-rectangle:
471: insert a blank rectangle in the position and size
472: described by dot and mark, at its corners;
473: the existing text is pushed to the right.
474: clear-rectangle:
475: replace the rectangle described by dot ane mark
476: with blanks. The previous text is deleted.
477: delete-rectangle:
478: delete the text of the specified rectangle,
479: moving the text beyond it on each line leftward.
480: kill-rectangle
481: like delete-rectangle but also stores the text of
482: the rectangle in the "rectangle kill buffer".
483: More precisely, it stores the text as a list of strings
484: (one string for each line) in the variable killed-rectangle.
485: yank-rectangle
486: inserts the text of the last killed rectangle.
487: extract-rectangle and delete-extract-rectangle
488: these functions return the text of a rectangle
489: as a list of strings. They are for use in writing
490: other functions that operate on rectangles.
491:
492: ** Keyboard Macros
493:
494: The C-x ( command for defining a keyboard macro can in GNU Emacs
495: be given a numeric argument, which means that the new macro
496: starts out not empty but rather as the same as the last
497: keyboard macro entered. In addition, that last keyboard
498: macro is replayed when the C-x ( is typed. C-x ( with an
499: argument is thus equivalent to typing plain C-x ( and then
500: retyping the last keyboard macro entered.
501:
502: The command write-kbd-macro and append-kbd-macro can be used to
503: save a keyboard macro definition in a file. It is represented as
504: a Lisp expression which, when evaluated, will define the keyboard
505: macro. write-kbd-macro writes the specified file from scratch,
506: whereas append-kbd-macro adds to any existing text in the file.
507: Both expect the keyboard macro to be saved to be specified by
508: name; this means you must use the command name-last-kbd-macro to
509: give the macro a name before you can save it.
510:
511: ** The command to resume a terminated tags-search or tags-query-replace
512:
513: is Meta-comma in GNU Emacs.
514:
515: ** Auto Save is on by default.
516:
517: Auto Save mode is enabled by default in all buffers
518: that are visiting files.
519:
520: The file name used for auto saving is made by prepending
521: "#" to the file name visited.
522:
523: ** Backup files.
524:
525: Since Unix stupidly fails to have file version numbers,
526: GNU Emacs compensates slightly in the customary fashion:
527: when a file is modified and saved for the first time in
528: a particular GNU Emacs run, the original file is renamed,
529: appending "~" to its name. Thus, foo.c becomes foo.c~.
530:
531: Emacs can also put a version number into the name of the backup file,
532: as in foo.c.~69~ for version number 69. This is an optional feature
533: that the user has to enable.
534:
535: ** Mode Line differences.
536:
537: Each window in GNU Emacs has its own mode line, which always
538: displays the status of that window's buffer and nothing else.
539: The mode line appears at the bottom of the window. It is
540: full of dashes, to emphasize the boundaries between windows,
541: and is displayed in inverse video if the terminal supports it.
542: The information usually available includes:
543:
544: ** Local Modes feature changed slightly.
545:
546: GNU Emacs supports local mode lists much like those in Twenex Emacs,
547: but you can only set variables, not commands. You write
548:
549: Local variables:
550: tab-width: 10
551: end:
552:
553: in the last page of a file, if you want to make tab-width be ten in a
554: file's buffer. The value you specify must be a Lisp object!
555: It will be read, but not evaluated. So, to specify a string,
556: you MUST use doublequotes. For "false", in variables whose
557: meanings are true or false, you MUST write nil .
558:
559: Two variable names are special: "mode" and "eval".
560: Mode is used for specifying the major mode (as in Twenex Emacs).
561:
562: mode: text
563:
564: specifies text mode. Eval is used for requesting the evaluation
565: of a Lisp expression; its value is ignored. Thus,
566:
567: eval: (set-syntax-table lisp-mode-syntax-table)
568:
569: causes Lisp Mode syntax to be used.
570:
571:
572: Note that GNU Emacs looks for the string "Local variables:"
573: whereas Twenex Emacs looks for "Local modes:". This incompatibility
574: id deliberate, so that neither one will see local settings
575: intended for the other.
576:
577: ** Lisp code libraries.
578:
579: Libraries of commands, and init files, are written in Lisp.
580: libraries conventionally have names ending in .el, while the
581: init file is named .emacs and is in your home directory.
582:
583: Use Meta-x load to load a library. Most standard libararies load
584: automatically if you try to use the commands in them.
585:
586: Meta-x byte-compile-file filename
587: compiles the file into byte code which loads and runs faster
588: than Lisp source code. The file of byte code is given a name
589: made by appending "c" to the end of the input file name.
590:
591: Meta-x byte-recompile-directory directoryname
592: compiles all files in the specified directory (globbing not allowed)
593: which have been compiled before but have been changed since then.
594:
595: Meta-x load automatically checks for a compiled file
596: before loading the source file.
597:
598: Libraries once loaded do not retain their identity within GNU
599: Emacs. Therefore, you cannot tell just what was loaded from a
600: library, and you cannot un-load a library. Normally, libraries
601: are written so that loading one has no effect on the editing
602: operations that you would have used if you had not loaded the
603: library.
604:
605: ** Dired features.
606:
607: You can do dired on partial directories --- any pattern
608: the shell can glob. Dired creates a buffer named after
609: the directory or pattern, so you can dired several different
610: directories. If you repeat dired on the same directory or
611: pattern, it just reselects the same buffer. Use Meta-x Revert
612: on that buffer to read in the current contents of the directory.
613:
614: ** Directory listing features.
615:
616: C-x C-d now uses the default output format of `ls',
617: which gives just file names in multiple columns.
618: C-u C-x C-d passes the -l switch to `ls'.
619:
620: Both read a directory spec from the minibuffer. It can
621: be any pattern that the shell can glob.
622:
623: ** Compiling other programs.
624:
625: Meta-x compile allows you to run make, or any other compilation
626: command, underneath GNU Emacs. Error messages go into a buffer whose
627: name is *compilation*. If you get error messages, you can use the
628: command C-x ` (that is a backquote) to find the text of the next
629: error message.
630:
631: You must specify the command to be run as an argument to M-x compile.
632: A default is placed in the minibuffer; you can kill it and start
633: fresh, edit it, or just type Return if it is what you want.
634: The default is the last compilation command you used; initially,
635: it is "make -k".
636:
637: ** Searching multiple files.
638:
639: Meta-x grep searches many files for a regexp by invoking grep
640: and reading the output of grep into a buffer. You can then
641: move to the text lines that grep found, using the C-x ` command
642: just as after M-x compile.
643:
644: ** Running inferior shells.
645:
646: Do Meta-x shell to make an inferior shell together with a buffer
647: which serves to hold "terminal" input and output of the shell.
648: The shell used is specified by the environment variable ESHELL,
649: or by SHELL if ESHELL is not set.
650:
651: Use C-h m whilst in the *shell* buffer to get more detailed info.
652:
653: The inferior shell loads the file .emacs_csh or.emacs_sh
654: (or similar using whatever name the shell has) when it starts up.
655:
656: M-! executes a shell command in an inferior shell
657: and displays the output from it. With a prefix argument,
658: it inserts the output in the current buffer after dot
659: and sets the mark after the output. The shell command
660: gets /dev/null as its standard input.
661:
662: M-| is like M-! but passes the contents of the region
663: as input to the shell command. A prefix argument makes
664: the output from the command replace the contents of the region.
665:
666: ** Sending mail.
667:
668: Once you enter Mail Mode using C-x m or C-x 4 m or M-x mail,
669: C-c becomes a prefix character for mail-related editing commands.
670: C-c C-s is vital; that's how you send the message. C-c C-c sends
671: and then switches buffers or kills the current window.
672: Use C-h m to get a list of the others.
673:
674: ** Regular expressions.
675:
676: GNU Emacs has regular expression facilities like those of most
677: Unix editors, but more powerful:
678:
679: *** -- + --
680:
681: + specifies repetition of the preceding expression 1 or more
682: times. It is in other respect like *, which specifies repetition
683: 0 or more times.
684:
685: *** -- ? --
686:
687: ? is like * but matches at most one repetition of the preceding
688: expression.
689:
690: *** -- \| --
691:
692: \| specifies an alternative. Two regular expressions A and B with \| in
693: between form an expression that matches anything that either A or B will
694: match. Thus, "foo\|bar" matches either "foo" or "bar" but no other
695: string.
696:
697: \| applies to the larges possible surrounding expressions. Only a
698: surrounding \( ... \) grouping can limit the grouping power of \|.
699:
700: Full backtracking capability exists when multiple \|'s are used.
701:
702: *** -- \( ... \) --
703:
704: \( ... \) are a grouping construct that serves three purposes:
705:
706: 1. To enclose a set of \| alternatives for other operations.
707: Thus, "\(foo\|bar\)x" matches either "foox" or "barx".
708: 2. To enclose a complicated expression for * to operate on.
709: Thus, "ba\(na\)*" matches "bananana", etc., with any number
710: of na's (zero or more).
711: 3. To mark a matched substring for future reference.
712:
713: Application 3 is not a consequence of the idea of a parenthetical
714: grouping; it is a separate feature which happens to be assigned as a
715: second meaning to the same \( ... \) construct because there is no
716: conflict in practice between the two meanings. Here is an explanation
717: of this feature.
718:
719: -- \digit --
720:
721: After the end of a \( ... \) construct, the matcher remembers the
722: beginning and end of the text matched by that construct. Then, later on
723: in the regular expression, you can use \ followed by a digit to mean,
724: ``match the same text matched this time by the \( ... \) construct.''
725: The first nine \( ... \) constructs that appear in a regular expression
726: are assigned numbers 1 through 9 in order of their beginnings. \1
727: through \9 can be used to refer to the text matched by the corresponding
728: \( ... \) construct.
729:
730: For example, "\(.*\)\1" matches any string that is composed of two
731: identical halves. The "\(.*\)" matches the first half, which can be
732: anything, but the \1 that follows must match the same exact text.
733:
734: *** -- \` --
735:
736: Matches the empty string, but only if it is at the beginning of the buffer.
737:
738: *** -- \' --
739:
740: Matches the empty string, but only if it is at the end of the buffer.
741:
742: *** -- \b --
743:
744: Matches the empty string, but only if it is at the beginning or end of
745: a word. Thus, "\bfoo\b" matches any occurrence of "foo" as a separate word.
746: "\bball\(s\|\)\b" matches "ball" or "balls" as a separate word.
747:
748: *** -- \B --
749:
750: Matches the empty string, provided it is NOT at the beginning or end of
751: a word.
752:
753: *** -- \< --
754:
755: Matches the empty string, provided it is at the beginning of a word.
756:
757: *** -- \> --
758:
759: Matches the empty string, provided it is at the end of a word.
760:
761: *** -- \w --
762:
763: Matches any word-constituent character. The editor syntax table determines
764: which characters these are.
765:
766: *** -- \W --
767:
768: Matches any character that is not a word-constituent.
769:
770: *** -- \s<code> --
771:
772: Matches any character whose syntax is <code>. <code> is a letter that
773: represents a syntax code: thus, "w" for word constituent, "-" for
774: whitespace, "(" for open-parenthesis, etc. Thus, "\s(" matches any
775: character with open-parenthesis syntax.
776:
777: *** -- \S<code> --
778:
779: Matches any character whose syntax is not <code>.
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.