📄 other.emacses
字号:
\| specifies an alternative. Two regular expressions A and B with \| inbetween form an expression that matches anything that either A or B willmatch. Thus, "foo\|bar" matches either "foo" or "bar" but no otherstring.\| applies to the larges possible surrounding expressions. Only asurrounding \( ... \) grouping can limit the grouping power of \|.Full backtracking capability exists when multiple \|'s are used.**** -- \( ... \) --\( ... \) are a grouping construct that serves three purposes:1. To enclose a set of \| alternatives for other operations. Thus, "\(foo\|bar\)x" matches either "foox" or "barx".2. To enclose a complicated expression for * to operate on. Thus, "ba\(na\)*" matches "bananana", etc., with any number of na's (zero or more).3. To mark a matched substring for future reference.Application 3 is not a consequence of the idea of a parentheticalgrouping; it is a separate feature which happens to be assigned as asecond meaning to the same \( ... \) construct because there is noconflict in practice between the two meanings. Here is an explanationof this feature. -- \digit --After the end of a \( ... \) construct, the matcher remembers thebeginning and end of the text matched by that construct. Then, later onin the regular expression, you can use \ followed by a digit to mean,``match the same text matched this time by the \( ... \) construct.''The first nine \( ... \) constructs that appear in a regular expressionare assigned numbers 1 through 9 in order of their beginnings. \1through \9 can be used to refer to the text matched by the corresponding\( ... \) construct.For example, "\(.*\)\1" matches any string that is composed of twoidentical halves. The "\(.*\)" matches the first half, which can beanything, but the \1 that follows must match the same exact text.**** -- \` --Matches the empty string, but only if it is at the beginning of the buffer.**** -- \' --Matches the empty string, but only if it is at the end of the buffer.**** -- \b --Matches the empty string, but only if it is at the beginning or end ofa word. Thus, "\bfoo\b" matches any occurrence of "foo" as a separate word."\bball\(s\|\)\b" matches "ball" or "balls" as a separate word.**** -- \B --Matches the empty string, provided it is NOT at the beginning or end ofa word.**** -- \< --Matches the empty string, provided it is at the beginning of a word.**** -- \> --Matches the empty string, provided it is at the end of a word.**** -- \w --Matches any word-constituent character. The editor syntax table determineswhich characters these are.**** -- \W --Matches any character that is not a word-constituent.**** -- \s<code> --Matches any character whose syntax is <code>. <code> is a letter thatrepresents a syntax code: thus, "w" for word constituent, "-" forwhitespace, "(" for open-parenthesis, etc. Thus, "\s(" matches anycharacter with open-parenthesis syntax.**** -- \S<code> --Matches any character whose syntax is not <code>.* How is this Emacs different from Gosling Emacs?** Advantages of Gosling Emacs:1. The program itself is much smaller.GNU Emacs uses about 250k more pure storage.As a result, Gosling Emacs can run on machinesthat cannot run GNU Emacs. There is not much differencein the amount of impure storage in the two programs.2. In some versions there is support for other forks toestablish communications channels to Emacs (using sockets?).3. There is a direct interface to dbm (data bases).** Advantages of GNU Emacs:*** True Lisp, not Mocklisp.GNU Emacs's extension language has real symbols, listsand vectors. Many extensions are much simpler, and somebecome possible that were nearly impossible in Gosling Emacs.Many primitives can have cleaner interfaces, and some featuresneed not be put in as special primitives because you can dothem easily yourself.*** But Mocklisp still works.An automatic conversion package plus a run-time libraryallows you to convert a Mocklisp library into a Lisp library.*** Commands are better crafted.For example, nearly every editing function for which anumeric argument would make sense as a repeat count doesaccept a repeat count, and does handle a negative argumentin the way you would expect.*** The manual is clearer.Everyone tells me it is a very good manual.*** Better on-line documentation.Both functions and variables have documentation strings thatdescribe exactly how to use them.*** C mode is smart.It really knows how to indent each line correctly,for most popular indentation styles. (Some variablescontrol which style is used; popular named styles are also supported.)*** Compatible with PDP-10 Emacs, Multics Emacs and Zmacs.The commands in GNU Emacs are nearly the same as in theoriginal Emacs and the other Emacses which imitated it.(A few have been changed to fit the Unix environment better.)*** Support for Gosling's Emacs commands.M-x set-gosmacs-bindings rebinds many editing commands forcompatibility with Gosling's Emacs.M-x set-gnu-bindings reverses the change.*** Side-by-side windows.You can split a GNU Emacs window either horizontally orvertically.*** Redisplay is faster.GNU Emacs sends about the same stuff to the terminal thatGosling's does, but GNU Emacs uses much less CPU time todecide what to do.*** Entirely termcap-driven.GNU Emacs has nearly no special code for any terminal type. Variousnew termcap strings make it possible to handle all terminals nearly asfast as they could be handled by special-case code.*** Display-hiding features.For example, Outline Mode makes it possible for you to editan outline, making entire sub-branches of the outline visibleor invisible when you wish.*** You can interrupt with Control-G.Even a looping Lisp program can be stopped this way.And even a loop in C code does not stop you from killingEmacs and getting back to your shell.*** Per-buffer Undo.You can undo the last several changes, in each bufferindependently.*** The editor code itself is clean.Many people have remarked on how much they enjoy readingthe code for GNU Emacs.One other note: The program etc/cvtmail that comes with GNU Emacs canbe used to convert a mail directory for Gosling Emacs's Rmail into aUnix mail file that you could read into GNU Emacs's Rmail.* How is this Emacs different from CCA Emacs?** GNU Emacs Lisp vs CCA Elisp.GNU Emacs Lisp does not have a distinction between Lisp functionsand Emacs functions, or between Lisp variables and Emacs variables.The Lisp and the editor are integrated. A Lisp function definedwith defun is callable as an editor command if you put aninteractive calling spec in it; for example, (defun forward-character (n) (interactive "p") (goto-char (+ (point) n)))defines a function of one argument that moves point forward bya specified number of characters. Programs could call this function,as in (forward-character 6), or it could be assigned to a key,in which case the "p" says to pass the prefix numeric arg asthe function's argument. As a result of this feature, you oftenneed not have two different functions, one to be called by programsand another to read arguments from the user conveniently; the samefunction can do both.CCA Elisp tries to be a subset of Common Lisp and tries tohave as many Common Lisp functions as possible (though it is stillonly a small fraction of full Common Lisp). GNU Emacs Lispis somewhat similar to Common Lisp just because of my Maclispand Lisp Machine background, but it has several distinct incompatibilitiesin both syntax and semantics. Also, I have not attempted toprovide many Common Lisp functions that you could write in Lisp,or others that provide no new capability in the circumstances.GNU Emacs Lisp does not have packages, readtables, or character objects(it uses integers to represent characters).On the other hand, windows, buffers, relocatable markers and processesare first class objects in GNU Emacs Lisp. You can get information about themand do things to them in a Lispy fashion. Not so in CCA Emacs.In GNU Emacs Lisp, you cannot open a file and read or write charactersor Lisp objects from it. This feature is painful to support, andis not fundamentally necessary in an Emacs, because instead youcan read the file into a buffer, read or write characters orLisp objects in the buffer, and then write the buffer into the file.On the other hand, GNU Emacs Lisp does allow you to rename, delete, addnames to, and copy files; also to find out whether a file is adirectory, whether it is a symbolic link and to what name, whetheryou can read it or write it, find out its directory component,expand a relative pathname, find completions of a file name, etc.,which you cannot do in CCA Elisp.GNU Emacs Lisp uses dynamic scope exclusively. This enables you tobind variables which affect the execution of the editor, such asindent-tabs-mode.GNU Emacs Lisp code is normally compiled into byte code. Most of thestandard editing commands are written in Lisp, and many aredumped, pure, in the Emacs that users normally run.GNU Emacs allows you to interrupt a runaway Lisp program withControl-g.** GNU Emacs Editing AdvantagesGNU Emacs is faster for many things, especially insertion of textand file I/O.GNU Emacs allows you to undo more than just the last commandwith the undo command (C-x u, or C-_). You can undo quite a ways back.Undo information is separate for each buffer; changes in one bufferdo not affect your ability to undo in another buffer.GNU Emacs commands that want to display some output do so by puttingit in a buffer and displaying that buffer in a window. Thistechnique comes from Gosling Emacs. It has both advantages anddisadvantages when compared with the technique, copied by CCA Emacsfrom my original Emacs which inherited it from TECO, of having "typeout" which appears on top of the text in the current window butdisappears automatically at the next input character.GNU Emacs does not use the concept of "subsystems". Instead, it useshighly specialized major modes. For example, dired in GNU Emacs hasthe same commands as dired does in other versions of Emacs, give ortake a few, but it is a major mode, not a subsystem. The advantageof this is that you do not have to "exit" from dired and lose thestate of dired in order to edit files again. You can simply switchto another buffer, and switch back to the dired buffer later. Youcan also have several dired buffers, looking at different directories.It is still possible to write a subsystem--your own command loop--in GNU Emacs, but it is not recommended, since writing a major modefor a special buffer is better.Recursive edits are also rarely used, for the same reason: it is betterto make a new buffer and put it in a special major mode. Sendingmail is done this way.GNU Emacs expects everyone to use find-file (C-x C-f) for readingin files; its C-x C-v command kills the current buffer and then findsthe specified file.As a result, users do not need to think about the complexitiesof subsystems, recursive edits, and various ways to read in filesor what to do if a buffer contains changes to some other file.GNU Emacs uses its own format of tag table, made by the "etags"program. This format makes finding a tag much faster.Dissociated Press is supported.** GNU Emacs Editing Disadvantages.GNU Emacs does not display the location of the mark.GNU Emacs does not have a concept of numbers of buffers,or a permanent ordering of buffers, or searching through multiplebuffers. The tags-search command provides a way to searchthrough several buffers automatically.GNU Emacs does not provide commands to visit files withoutsetting the buffer's default directory. Users can write suchcommands in Lisp by copying the code of the standard filevisiting commands and modifying them.GNU Emacs does not support "plus options" in the commandarguments or in buffer-selection commands, except for line numbers.GNU Emacs does not support encryption. Down with security!GNU Emacs does not support replaying keystroke files,and does not normally write keystroke files.** Neutral DifferencesGNU Emacs uses TAB, not ESC, to complete file names, buffer names,command names, etc.GNU Emacs uses LFD to terminate searches, instead ofthe C-d uses by CCA Emacs. (Actually, this character is controlledby a parameter in GNU Emacs.) C-M-s in GNU Emacs is an interactiveregular expression search, but you can get to a noninteractiveone by typing ESC right after the C-M-s.In GNU Emacs, C-x s asks, for each modified file buffer, whetherto save it.GNU Emacs indicates line continuation with "\" and linetruncation (at either margin) with "$".The command to resume a tags-search or tags-query-replace inGNU Emacs is Meta-Comma.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -