📄 diff
字号:
How is this Emacs different from all other Emacses? -*-Outline-*- (Actually, from Twenex Emacs)* Copyright (c) 1985 Richard M. Stallman Permission is granted to anyone to make or distribute verbatim copies of this document as received, in any medium, provided that the copyright notice and permission notice are preserved, and that the distributor grants the recipient permission for further redistribution as permitted by this notice. Permission is granted to distribute modified versions of this document, or of portions of it, under the above conditions, provided also that they carry prominent notices stating who last changed them.* Fundamental concepts.** There is no concept of "typeout" in GNU Emacs.Any time that a command wants to display some output,it creates a buffer (usually with a name surrounded by asterisks)and displays it in a window.This provides some advantages: you can edit some more while looking at the output; you can copy parts of the output into other buffers.It also has a disadvantage that you must type a commandin order to make the output disappear.You can use C-x 1 to get rid of all windows except theselected one. To be more selective, you can switch tothe window you want to get rid of and then type C-x 0(delete-window).You also need to type a command to scroll the otherwindow if not all the output fits in it. Meta-Control-vwill usually do the job.** There is no concept of a "subsystem" in GNU Emacs.Where Twenex Emacs would use a subsystem, GNU Emacsinstead creates a buffer and redefines commands in it.For example, when you send mail in GNU Emacs, you usea buffer named *mail* which is in Mail Mode. You canswitch away from this buffer to any other buffer andresume normal editing; then switch back and resumecomposing mail. You do not have to "exit" fromcomposing mail in order to do ordinary editing.This has many advantages, but it also has a disadvantage:Subsystems in Emacs tend to have "exit" commands that return youto whatever you were doing before entering the subsystem.In GNU Emacs the idea of what to return to is not well defined,so it is not clear what an "exit" command should do.The only way to "exit" in general is to type C-x b, C-x C-f, orsome other suitable command to switch buffers. Somesubsystem-like major modes, such as Info and Mail mode, providecommands to "exit" by switching to the previously selectedbuffer.** Files are always visited in their own buffers.Beginning users of Twenex Emacs were told how to editusing a single buffer and reading one file after anotherinto that buffer. Use of a new buffer for each file wasregarded as a more advanced mode.In GNU Emacs, the idea of using a single buffer for variousfiles, one by one, has been dropped, given that the addressspace is expected to be large enough for many buffers. C-xC-f (find-file), which behaves nearly the same as in TwenexEmacs, is in GNU Emacs the canonical way for all users tovisit files.Various commands need to read files into Emacs in the courseof their execution. In Twenex Emacs the user must tell themwhether to reuse buffers or create new ones, using the variableTags Find File. In GNU Emacs, these commands always useC-x C-f.The command C-x C-v does still exist; it kills the currentbuffer and reads the specified file into a new buffer.It is equivalent to kill-buffer followed by find-file.Since there is no reusing of buffers, there is no point incalling the initial buffer "main". So the initial bufferin GNU Emacs is called "*scratch*" and is intended for typingLisp expressions to be evaluated.** File name defaulting.GNU Emacs records a separate working directory for each buffer.Normally this is the directory on which the buffer's fileresides; for buffers not visiting any file, it is copied fromthe buffer that was current when it was created. The current buffer'sworking directory can be printed with M-x pwd and set with M-x cd.GNU Emacs shows you the default directory by inserting it inthe minibuffer when a file name is being read. You can typethe filename you want at the end of the default as if thedefault were not there, or you can edit and alter the default.If you want file /lose/big when the default /foo/defaultdir/has been inserted for you, you need not kill the default; simplytype at the end of it: /foo/defaultdir//lose/big. Such a filename is not ordinarily considered valid, but GNU Emacsconsiders it equivalent to /lose/big.Likewise, if you want file quux in your home directory, just add~/quux to the end of the supplied text, to get/foo/defaultdir/~/quux. GNU Emacs sees "/~" and throws awayeverything before the "~".You can refer to environment variables also within file names.$ followed by the environment variable name is replaced by thevariable's value. The variable name should either be followedby a nonalphanumeric character (which counts as part of thefile name) or be surrounded by braces {...} (which do not countas part of the file name). Thus, if variable USER has value "rms","x/$USER-foo" is expanded to "x/rms-foo", and "x${USER}foo"is expanded to "xrmsfoo". Note that this substitution is notperformed by the primitive file operation functions of GNU Emacs,but rather by the interactive file name reader. It is alsoavailable as a separate primitive, in the functionsubstitute-in-file-name.** Exit commands C-z, C-x C-c and C-x C-z.There are two ways to exit GNU Emacs: killing and suspending.Killing is like what Control-c does to ordinary Unix programs.In GNU Emacs, you type C-x C-c to kill it. (This offers tosave any modified file buffers before really killing Emacs.)Suspending is like what Control-z does to ordinary Unix programs.To suspend GNU Emacs, type C-x C-z, or type just C-z.Note that C-z suspends ordinary programs instantly, butEmacs does not suspend until it reads the C-z.Usually it is better to suspend: once a system is smartenough to have job control, why ever kill an editor?You'll just have to make a new one in a minute.This is why the convenient command C-z is provided forsuspending.C-c is used as a prefix key for mode-specific commands and for users'own commands. We deliberately do not make C-c ever kill Emacs,because it should not be so easy to do something irreversible.** Quitting with C-g.If you type C-g while GNU Emacs is waiting for input, itis an ordinary command (which is defined to beep). If youtype C-g while Lisp code is executing, it sets a flag whichcauses a special signal, nearly the same as an error, tohappen atthe next safe place in Lisp execution. This usuallyhas the effect of aborting the current command in a safe way.Because at times there have been bugs causing GNU Emacs to loopwithout checking the quit flag, a special feature causesGNU Emacs to be suspended immediately if you type a second C-gwhile the flag is already set. So you can always get outof GNU Emacs. Normally GNU Emacs recognizes and clears the quit flagquickly enough to prevent this from happening.When you resume GNU Emacs after a suspension caused by multiple C-g, itasks two questions before resuming execution: Checkpoint? Dump core?Answer each one with `y' or `n' and a Return. `y' to Checkpoint? causes immediate auto-saving of all buffers in which auto-saving is enabled. `y' to Dump core? causes an illegal instruction to be executed. This is to enable a wizard to figure out why GNU Emacs was looping without checking for quits. Execution does not continue after a core dump. If you answer `n', execution continues.With luck, GNU Emacs will ultimately check the quit flag,and quit normally. If not, and you type another C-g, itis suspended again.If GNU Emacs is not really hung, just slow, you may invokethe double C-g feature without really meaning to. Then justresume and answer `n' to both questions, and you willarrive at your former state. Presumably the quit youwanted will finish happening soon.These questions are not asked if you suspend GNU Emacs with the C-zcommand. Continuing GNU Emacs after a C-z takes you straight backinto editing.** Undoing with C-x u or C-_You can undo many commands--up to 10,000 characters worth.Each time you type C-x u or C-_, another command or batch of changeis undone. Undo information is stored per buffer, and the undocommand always applies to the current buffer. A numeric argumentserves as a repeat count.Consecutive self-inserting characters are undone in groups of twenty.** Different character set.GNU Emacs does not expect anyone ever to have a keyboard in whichthe Control key sets an independent bit which may accompany anycharacter. The only control characters that can exist are theASCII control characters.There is, as a result, no "control prefix" character.** Control-h is the Help character.I'm amazed it took me so long to get this idea. In Twenex Emacs, C-hand C-b are equivalent commands, making C-h redundant. C-h is notonly easy to type, it is mnemonic for "Help". So in GNU Emacs theHelp character is C-h.** Completion is done by TAB, not ESC.ESC in the minibuffer is a Meta prefix, same as at top level.** The string-argument reader is the minibuffer is an editor window.In GNU Emacs, the line at the bottom of the screen is the minibuffer.Commands that want string arguments always use this line to read them,and you can use the ordinary Emacs editing commands to edit theinput. You can terminate input with Return because Return is definedas the exit-minibuffer command when in the minibuffer. If youare using a command that needs several arguments, terminate eachone with Return. You cannot separate arguments with Escapethe way you would in Twenex Emacs.The minibuffer window does not overlay other editor windows;it is a nearly ordinary editor window which lacks a mode lineand is "turned off" when not in use. While it IS in use, youcan switch windows to and from the minibuffer, kill text in otherwindows and yank in the minibuffer, etc.You can even issue a command that uses the minibuffer while in theminibuffer. This gets you temporarily into a recursive minibuffer.However, this is allowed only if you enable it, since it could beconfusing for beginners.When you exit the minibuffer, the cursor immediately moves back tocolumn zero of the minibuffer line, to show you that the exitcommand has been obeyed. The minibuffer contents remain on the screenuntil the end of the command, unless some other text is displayed there.A single Control-g exits the minibuffer.** There are no &'s or ^R's or spaces in function names.For example, the function which is called ^R Forward Wordin Twenex Emacs is called forward-word in GNU Emacs.** The extension language is Lisp rather than TECO.Libraries must be written in Lisp. Meta-ESC reads a Lispexpression, evaluates it, and prints the result. Note thatMeta-ESC is "disabled" by default, so that beginning usersdo not get into the minibuffer by accident in a confusing way.Data types available include integers (which double as characters),strings, symbols, lists, vectors, buffers, buffer pointers,windows, and process channels.For now, to learn about writing Lisp code for GNU Emacs, read some ofthe source code, which is in directory ../lisp. Also, all Lispprimitives have self-documentation you can read with C-h f.** Enabling the error handler.GNU Emacs has a Lisp debugger/stepper/trace package, but normallyerrors do not enter the debugger because that is slow, and unlikely tobe of interest to most users. Set the variable debug-on-error to t tocause errors to invoke the debugger. Set debug-on-quit to cause quitsignals (caused by C-g) to invoke the debugger.* Other changes.** More than two windows are allowed.C-x 2 splits the current window into two windows, one above the other. Initially they both display the same buffer. C-x 2 now accepts a numeric argument to specify the number of lines to give to the uppermost of the two windows it makes.C-x 0 kills the current window, making all others larger.C-x 1 kills all windows except the current one.C-x O switches to the next window down. It rotates from the bottom one to the top one. An argument serves as a repeat count; negative arguments circulate in the reverse order.If the same buffer is displayed in several windows,changes made in it are redisplayed in all of them.** Side by side windows are supported.The command C-x 5 splits the current window intotwo side-by-side windows.C-x } makes the selected window ARG columns wider at theexpense of the windows at its sides. C-x { makes the selectedwindow ARG columns narrower. An argument to C-x 5 specifieshow many columns to give to the leftmost of the two windows made.** Horizontal scrolling of the lines in a window is implemented.C-x < (scroll-left) scrolls all displayed lines left,with the numeric argument (default 1) saying how far to scroll.When the window is scrolled left, some amount of the beginningof each nonempty line is replaced by an "$".C-x > scrolls right. If a window has no text hidden at the leftmargin, it cannot be scrolled any farther right than that.When nonzero leftwards scrolling is in effect in a window.lines are automatically truncated at the window's right marginregardless of the value of the variable truncate-lines in thebuffer being displayed.** Return key does not use up empty lines.In Twenex Emacs, the Return command advances over an existingempty line in some cases. In GNU Emacs, the Return command alwaysmakes inserts a newline. Twenex Emacs was designed at a time whenmost display terminals did not have the ability to scroll partof the screen, and using existing empty lines made redisplay faster.Nowadays, terminals that cannot scroll part of the screen are rare,so there is no need to make Return behave in a more complicated manner.** Help m.Typing C-h m displays documentation of the current major mode.,telling you what special commands and features are availableand how to use them or get more information on them.This is simply the documentation, as a function, of thesymbol which is the value of major-mode. Each major modefunction has been given documentation intended for C-h m.** Display-hiding features.*** Hiding indented linesThe command C-x $ with numeric argument N causes lines indented by Nor more columns to become invisible. All you see is " ..." appendedto the previous line, in place of any number of consecutive invisiblelines.*** Outline Mode.Outline mode is designed for editing outline-structuredfiles, such as this one.Headings should be lines starting with one or more asterisks.Major headings have one asterisk, subheadings two, etc.Lines not starting with asterisks are body text.You can make the body under a heading, or the subheadingsunder a heading, temporarily invisible, or visible again.Invisible lines are attached to the end of the previous lineso they go with it if you kill it and yank it back.Commands:Meta-} next-visible-heading move by visible headingsMeta-{ previous-visible-heading move by visible headingsMeta-x hide-body make all body text invisible (not headings).Meta-x show-all make everything in buffer visible.The remaining commands are used when dot is on a heading line.They apply to some of the body or subheadings of that heading.C-c C-h hide-subtree make text and subheadings invisible.C-c C-s show-subtree make text and subheadings visible.C-c C-i show-children make direct subheadings visible. No effect on body, or subheadings 2 or more levels down. With arg N, affects subheadings N levels down.M-x hide-entry make immediately following body invisible.M-x show-entry make it visible.M-x hide-leaves make text under heading and under its subheadings invisible. The subheadings remain visible.M-x show-branches make all subheadings at all levels visible.** C mode is fancy.C mode assumes that you put the initial open-brace ofa function definition at the beginning of a line.If you use the popular indenting style that puts thisopen-brace at the end of a line containing a type declaration,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -