Difference between revisions of "Emacs (简体中文)"

From ArchWiki
Jump to navigation Jump to search
(add translation status)
(before Multiplexing emacs and emacsclient)
 
(59 intermediate revisions by 13 users not shown)
Line 1: Line 1:
[[Category:Text editors]]
+
[[Category:Text editors (简体中文)]]
 +
[[de:Emacs]]
 +
[[en:Emacs]]
 +
[[es:Emacs]]
 +
[[fr:Emacs]]
 +
[[ja:Emacs]]
 
[[sr:Emacs]]
 
[[sr:Emacs]]
[[zh-CN:Emacs]]
+
{{TranslationStatus (简体中文)|Emacs|2018-03-07|229169}}
{{TranslationStatus (简体中文)|Emacs|2012-10-17|23776}}
+
[[Wikipedia:Emacs|Emacs]]是一个可扩展、可定制、自文档化的实时显示编辑器。Emacs的核心构建在[[Wikipedia:Emacs Lisp|Emacs Lisp]]解释器之上,Emacs Lisp是大部分Emacs内建函数和拓展模块的实现语言。在图形界面系统下,Emacs使用GTK作为默认的X工具,在命令行界面下(CLI),Emacs也可以工作良好。在文本编辑能力上,Emacs常被拿来和[[vim]]比较。
{{Translateme (简体中文)}}
 
{{Article summary start|Summary}}
 
{{Article summary text|Tutorial on acquiring and using the Emacs text editor.}}
 
{{Article summary end}}
 
 
 
[[Wikipedia:Emacs|Emacs]]是一个可拓展,可自定制,自带文档的实时显示编辑器。Emacs的核心构建在[[Wikipedia:Emacs Lisp|Emacs Lisp]]解释器之上,其中Emacs Lisp是大部分Emacs的内建函数和拓展模块的实现语言。尽管Emacs在命令行界面下(CLI)工作良好,但还是将GTK作为GNU Emacs22的默认X工具包。在文本编辑能力上,Emacs常常拿来和[[vim]]比较。
 
  
 
== 安装 ==
 
== 安装 ==
Emacs comes in several variants (sometimes referred to as ''emacsen''). The most common of these is [http://www.gnu.org/software/emacs/ GNU Emacs].
+
Emacs有众多发行版本(有时候称作''emacsen'')。 最常见的莫过于 [http://www.gnu.org/software/emacs/ GNU Emacs]
 
 
[[pacman|Install]] {{Pkg|emacs}}, available in the [[Official Repositories]].
 
  
Another common variant is {{Pkg|xemacs}}.
+
在 [[official repositories]] 中可以[[安装]] {{Pkg|emacs}} 。如果你经常使用命令行,你可能更喜欢没有GTK+支持的 {{Pkg|emacs-nox}}(也没有声音或其它花哨的东西)。值得注意的是,文字模式的Emacs有一些缺点:它支持的颜色和字体设置功能都要更少(实时改变字体大小,单文档多字体,等等)。而且emacs-nox存在一些高级功能上的缺陷,比如Speedbar和GUD(调试环境),处理复杂的外观(face,文本在Emacs中呈现的样子)的时候速度也会变慢。
  
== 快速入门 ==
+
如果你想体验Emacs的所有扩展功能而不用安装大量依赖项的话,可以使用PKGBUILD来按你的需求定制Emacs。不使用 {{ic|gtk3}}, 可以让Emacs避免使用gconf。图像和声音的支持也可以禁用。在Emacs源目录下运行 {{ic|./configure --help}} 可以列出所有可用选项。
Although Emacs is complex, it will not take long to begin to understand the benefits which the level of customization and extensibility bring. Furthermore, the comprehensive variety of extensions already available allows  it to be transformed into a powerful environment for almost any form of text-editing.
+
{{hc|PKGBUILD|<nowiki>
 +
# ...
 +
  ./configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib \
 +
    --localstatedir=/var --with-x-toolkit=gtk2 --with-xft \
 +
    --without-gconf --without-sound
 +
# ...
 +
</nowiki>}}
  
Emacs has an excellent built-in tutorial which can be accessed by clicking the first link on the splash screen; by selecting ''Help->Emacs Tutorial'' from the menu or by pressing 'F1' followed by 't'.  This page is designed to be an additional resource for getting started with Emacs.
+
== 运行Emacs ==
  
Emacs also includes a set of reference cards, useful for beginners and experts alike, see {{ic|/usr/share/emacs/<version>/etc/refcards/}} (substitute <version> for your version of emacs).
+
启动Emacs之前,你应该知道怎样关掉它(特别是你在终端里运行时):使用 {{ic|Ctrl+x}}{{ic|Ctrl+c}} 按键顺序。
  
===运行Emacs===
+
启动Emacs:
====常见方式====
 
To start Emacs run:
 
  
 
  $ emacs
 
  $ emacs
  
or, to use it from the console:
+
或者以文字模式启动:
  
 
  $ emacs -nw
 
  $ emacs -nw
  
A file name can also be provided to open that file immediately:
+
又或者,快速启动(不解析.emacs文件)并以文字模式启动:
  
  $ emacs filename.txt
+
  $ emacs -Q -nw
  
====作为守护进程====
+
如果你安装的是nox版本,'emacs' 和 'emacs -nw' 效果是一样的。
Emacs can take some time to start since it has to load the .emacs file each time. Since version 23, Emacs is capable to run as a daemon to which users can connect. To run Emacs as a daemon:
 
  
$ emacs --daemon
+
可以提供文件名直接打开文件:
  
You are likely to start the daemon at startup time and to connect a window to the daemon. Besides, it is possible to connect ''both'' graphical and console clients to the daemon at the same time and make the GUI to start quickly.
+
$ emacs filename.txt
  
If you want to connect to the daemon simply use the folowing command (note that it will start a graphical client if called in a graphical environment or a console client if called in a console like a tty):
+
=== 没有颜色 ===
  
$ emacsclient
+
默认情况下,Emacs以颜色主题开始,显示超链接为深蓝色。
  
If you still want a console client no matter you are in a graphical environment then use:
+
以文本模式,不使用任何颜色主题启动Emacs:
  
  $ emacsclient -t
+
  $ emacs -nw --color=no
  
Furthermore, you can add the {{ic|-a ""}} parameter.
+
这将导致所有的文本采用终端的字体颜色 &ndash;&ndash; 通常是黑色背景之上的白色文本,或白色背景上的黑色文本。
Now, the first time you call the command, it will start emacs as a daemon, so that it remains running in background to improve startup time for future calls (and to remember buffers as well).
 
  
In the end, you could use the following alias:
+
=== 作为守护进程 ===
  
$ alias emacs='emacsclient -t -a ""'
+
如过不想让Emacs每次启动都读取配置文件的话,可以以守护进程运行Emacs:
  
With xfce, if you want to tell it to use emacsclient -c instead of emacs %f when opening a new file, you can change your /usr/share/applications/emacs.desktop and change the line
+
$ emacs --daemon
  
$ Exec=emacs %f
+
连接到守护进程:
  
To
+
$ emacsclient -nc
  
$ Exec=emacsclient -c
+
这个命令会创建一个新的frame {{ic|-c}}(如果你更喜欢文字模式,使用 {{ic|-t}} )并且不会独占终端 {{ic|-n}} ({{ic|--no-wait}})。
 +
有的程序,如Mutt和Git,(为了提交信息)会等待编辑器完成编辑,所以不能使用 {{ic|-n}} 参数。
 +
如果你的默认编辑器是默认使用{{ic|-n}},你需要为那些程序指定一个替代编辑器(比如 {{ic|emacsclient -a "" -t}})。
  
This way, a client will be called each time you open up a file and so be very fast!
+
=== 作为systemd单元 ===
  
===基本术语和约定===
+
旧的systemd单元方法有一些需要注意的地方。 它给了一个限制shell调用的有限的shell环境,所以我们需要使用一个user单元,它往往比调用''emacs --daemon''好得多。
Emacs uses some terminology and conventions which may seem unusual at first and will be introduced where appropriate.  However, there is some terminology which should be introduced before-hand, as it is fundamental to working with Emacs.
+
为Emacs创建一个systemd单元:
  
The one piece of terminology which must be introduced early is the concept of ''buffers''. A buffer is a representation of data within Emacs. For example, when a file is opened in Emacs, that file is read from disk and its contents stored in a buffer, which allows it to be edited and saved back to disk later. Buffers are not limited to text, and can also contain images and widgets. Work is in progress to allow buffers to even display applications!  Another way to think of it: data available on disk is referred to as a 'file', whereas data available in Emacs is referred to as a 'buffer'.
+
{{注意|1=这样一个单元文件将会包含在Emacs 26.1中, 参见 [https://debbugs.gnu.org/cgi/bugreport.cgi?bug=16507 emacs bug 16507].}}
  
The convention for key sequences in Emacs may be unfamiliar.  Namely:
+
{{hc|~/.config/systemd/user/emacs.service|<nowiki>
 +
[Unit]
 +
Description=Emacs: the extensible, self-documenting text editor
  
'''C-x''' refers to Control-x
+
[Service]
 +
Type=forking
 +
ExecStart=/usr/bin/emacs --daemon
 +
ExecStop=/usr/bin/emacsclient --eval "(kill-emacs)"
 +
Restart=always
  
'''M-x''' refers to Meta-x
+
[Install]
 +
WantedBy=default.target
 +
</nowiki>}}
  
{{Note|'Meta' corresponds to the Alt key in most cases.  Alternatively, the Esc key can be used.}}
+
需要启动并启用该单元,以便其在每次电脑启动时启动(请注意 - 请勿“以root运行” - 我们希望它以user,而不是根root user运行):
  
For example, to exit Emacs use the following key sequence: '''C-x C-c'''.  This can be read as "Hold Control and press 'x'.  Release.  Hold Control and press 'c'."  Although Emacs provides a menu bar, it is recommended practise to focus on learning the key sequences.  This guide will refer to keybindings with the convention used in Emacs from now on.
+
$ systemctl --user enable --now emacs
  
===移动===
+
请注意,systemd user单元不会从登录shell(例如{{ic|〜/.bash_profile}})继承环境变量,因此你可能需要在{{ic |〜/.pam_environment}}中设置变量。有关更多信息,请参见[[Systemd/User]]。
Cursor movement is very similar to other graphical editors. The mouse and arrow keys can be used to change the position of the cursor (referred to as ''point'' in Emacs).  The standard movement commands performed by the arrow keys also have more accessible bindings in Emacs.  To move forward one character, use '''C-f''' and to move one character backward, '''C-b'''. '''C-n''' and '''C-p''' can be used to move to the next and previous lines, respectively.  Again, it is generally recommended to use these key-sequences in preference to the mouse and/or arrow keys.
 
  
As might be expected, Emacs provides more advanced movement commands, including moving by word and sentence.  '''M-f''' moves forward one word and '''M-b''' will move point one word backward.  Similarly, '''M-e''' moves point one sentence forward and '''M-a''' one sentence backward.
+
如启动emacs作为守护程序,你可能会想把{{ic|VISUAL}}和{{ic|EDITOR}}环境变量设置为{{ic|emacsclient}},以便启动编辑器的程序使用emacsclient而不是一个完整的编辑器。使用外部编辑器的程序,包括电子邮件程序(用于编辑消息),Git(用于编辑提交消息)和less(用于编辑显示文件的{{ic|v}}命令)。 不要对emacsclient使用{{ic|-n}}({{ic|--nowait}})选项,因为程序通常要求在编辑器退出时编辑完成。
  
Until now, all of the movement commands introduced have been relative to point.  '''M-<''' can be used to move point to the beginning of the buffer, with its counterpart, '''M->''', moving to the end of the buffer.  To move point to a specific line number, use '''M-g g'''.  '''M-g g''' will prompt for the desired line number.  Also, to move to the start or end of the current line, use '''C-a''' or '''C-e''', respectively.
+
建议将Emacs的任何GUI开始菜单条目(或等效条目)更改为指向emacsclient而不是emacs,以便使用emacs守护程序而不是启动新的emacs进程。
  
{{Note|Keybindings for these commands, or indeed any command, may differ ''slightly'' depending on which modes are currently active.  However, it is unusual for the replacement command not to provide equivalent functionality.  See [[Emacs#Modes|Modes]] for more information.}}
+
==使用==
 +
尽管Emacs很复杂,但了解定制和可扩展性带来的好处并不需要很长时间。此外,已有的各种扩展允许将其转变为针对几乎任何形式的强大文本编辑环境。
  
===文件和缓冲区===
+
Emacs有一个很好的内置教程,可以通过点击启动画面上的第一个链接进行访问; 通过从菜单中选择''帮助-> Emacs 教程''或按'F1'然后按't'
Emacs provides a series of commands to act upon files, the most common of which will be detailed here.  '''C-x C-f''' is used to open a file (this command is called 'find-file' in Emacs).  Should the file specified not exist, Emacs will open an empty buffer.  Saving a buffer will create the file with the buffer's contents.  '''C-x C-s''' can be used to save a buffer.  To save a buffer with a different filename, use '''C-x C-w''' (this is a mnemonic for the command 'write-file'), which will prompt for the new filename before writing it to disk.  It is also possible to ensure all buffers are saved with '''C-x s''', which, should a buffer be modified since its last save, a prompt will be displayed asking which action to take.
 
  
{{Note|'''C-x C-f''' does not read the file from disk again if a buffer corresponding to the file is still opened.  To re-read the file from disk, kill the buffer ('''C-x k''') prior to '''C-x C-f''' or use '''M-x revert-buffer'''.}}
+
Emacs设计为自文档化。 因此,大量的信息可用于确定特定命令的名称或其按键绑定。 使用'''C-h C-h'''查看所有当前环境绑定。
  
Many interactive commands such as "find-file" or "write-file" prompt for input in the bottom-most line of the Emacs window.  This line is referred to as the ''minibuffer''.  The minibuffer supports many basic editing commands as well as tab-completion similar to that which is available in many *nix shells.  '''<TAB>''' can be pressed twice in succession to display a list of completions, and if desired, the mouse can be also be used to select a completion from that list.  Completion in the minibuffer is available for many forms of input including commands and filenames.
+
Emacs还包含一组参考卡,对初学者和专家都很有用,请参阅{{ic|/usr/share/emacs/<version>/etc/refcards/}}(用您的emacs版本替换<version>)。
  
The minibuffer also provides a history feature. The previous items entered for a command can be recalled using the '''Up Arrow''' or '''C-p'''.
+
Emacs为用户提供了大量的功能,其中包括:键盘宏,矩形区域,空白清理,书签,桌面会话,各种shell,拼写检查,表格,语义分析...
  
To exit the minibuffer at any time, press '''C-g'''.
+
===手册===
 +
如果你真的想要掌握Emacs,最推荐的文档来源仍然是官方手册:
  
After opening several files, a way to switch between them is needed.  Opening a file corresponding to a buffer already available in Emacs, will cause Emacs to switch to that buffer.  But this is not the most effective way.  Emacs provides '''C-x b''', which prompts for the new buffer to be displayed (tab-completion is available here).  By entering the name of a buffer which does not exist, a new buffer with that name will be created.
+
* Emacs:完整的Emacs用户手册。
 +
* Emacs 常见问题。
 +
* Emacs Lisp简介:如果你以前从未使用任何编程语言。
 +
* Elisp:如果你已经熟悉一门编程语言。
  
{{Note|To switch to the previous buffer use '''C-x b <RET>''', as the previous buffer is the default.}}
+
通过内置'info'阅读器,你可以从GNU.org将其作为PDF查看或直接从Emacs本身访问:C-h i。按m选择相应章节。
  
A list of all open buffers can be displayed using '''C-x C-b'''.  Should a buffer no longer be required, it can be removed with '''C-x k'''.
+
有些用户更喜欢使用'info'来阅读章节,因为它具有方便的快捷方式,其段落会适应窗口宽度,字体会适应当前屏幕分辨率。有些人觉得这样不那么刺激眼睛。最后,你可以轻松地将章节中的内容复制到任何Emacs缓冲区,甚至可以直接从示例中执行Lisp代码片段。
  
===编辑===
+
你可能想要阅读信息手册以了解更多信息:C-h i m info <RET>。 按 ? 在info模式下可以快速查看快捷键列表。
Many editing commands exist within Emacs.  Perhaps the most important command which has not yet been introduced is 'undo', which can be performed via '''C-_''' or '''C-/'''.  Movement commands generally also have a corresponding delete command.  For example, '''M-<backspace>''' can be used to delete a word backwards, and '''M-d''' to delete a word forwards.  To delete to the end of the line, or the end of the sentence, use '''C-k''' or '''M-k''', respectively.
 
  
It is a rule-of-thumb that no line be allowed to exceed 80 characters.  This aids readability, especially in cases where the line wraps at the edge of a window.  Automatically inserting (or removing) line separator(s) is known as ''filling'' in Emacs.  A paragraph can be filled using '''M-q'''.
+
==提示和技巧==
  
Characters and words can be transposed using '''C-t''' and '''M-t''', respectively.  For example: <code>Hello World!</code> → <code>World! Hello</code>
+
===TRAMP===
 +
TRAMP (Transparent Remote Access, Multiple Protocols) ,顾名思义,是一个可以通过很多协议透明访问远程文件的一个扩展。当提示输入文件名时,输入特定的格式就可以使用TRAMPP。比如:
  
The case of words is also readily adjustable.  '''M-l''' downcases a word from point (<code>HELLO</code> → <code>hello</code>); '''M-u''' upcases a word from point (<code>hello</code> → <code>HELLO</code>) and '''M-c''' capitalizes the first character of a word from point while downcasing the remainder (<code>hElLo</code> → <code>Hello</code>).
+
在打开{{ic|/etc/hosts}}文件之前提示输入root的密码以获取root权限:
  
===移除,召回和区域===
+
  C-x C-f /su::/etc/hosts
A region is a section of text between two positions. One of those positions is referred to as ''mark'', and the other is point.  '''C-<SPC>''' is used to set the position of mark, after which point can be moved to create a region.  Within GNU Emacs 23.1 onwards, this region is visible by default.  There are a number of commands which act upon regions, among the most commonly used are ''killing'' commands.
 
 
 
In Emacs, cut and paste are referred to as ''kill'' and ''yank'', respectively.  Many commands which delete more than one character (including many of those in the above section, such as '''C-k''' and '''M-d''') actually cut the text and append it to what is known as the ''kill-ring''.  The kill-ring is simply a list of killed text.  The kill-ring stores up to the last 60 kills by default.  Successive kills are concatenated and stored at the head of the list.
 
 
 
'''C-w''' and '''M-w''' can be used to kill and copy a region, respectively.
 
 
 
To insert killed text into a buffer (known as 'yanking'), use '''C-y'''.  '''C-y''' can be used multiple times in succession to yank text repeatedly.  As mentioned, previous kills are stored in a list, however '''C-y''' only retrieves the first of them.  The earlier kills can be accessed via '''M-y'''.  This will remove the text inserted by 'yank' initially, replacing it with the text killed earlier.  '''M-y''' must be used immediately following '''C-y''' and can be used in many times succession to cycle through the kill-ring.
 
 
 
===查找和替换===
 
Searching for a string is common practise in text-editing.  This can be performed using '''C-s''' (to search forward) or '''C-r''' (to search backward).  These commands prompt for the string for which to search.  Searching is performed incrementally, and so it will match the next (or previous) occurrence as you type.  To move to the next or previous match, press '''C-s''' or '''C-r''' again, respectively.  Once a match has been found, '''<RET>''' can be used to end the search.  Alternatively, should you wish to return to the location you initiated the search, use '''C-g'''.
 
 
 
Once a search is completed (i.e., was not aborted with '''C-g''' or similar), the string which was searched for will be the default for any following search.  To make use of this, press '''C-s C-s''' or '''C-r C-r''' to search forward or backward again, respectively.
 
 
 
Regular Expression searches behave identically to the searching described above except for the command to initiate the search.  Use '''C-M-s''' or '''C-M-r''' to initiate a regexp search forward or backward, respectively.  Once a Regular Expression search has commenced, '''C-s''' and '''C-r''' can be used to search forward or backward, just as with string searches.
 
 
 
In addition to searching, it is also possible to perform string and regular expression replacement (via '''M-%''' and '''C-M-%''', respectively).  Prompts are provided for both the initial and replacement text, and then another prompt for the action to perform on the highlighted match.  Although many options are available (the full list is available by pressing '''?'''), the most commonly used are '''y''', to perform replacement, '''n''', to skip this match, and '''!''' to replace this, and all following matches.
 
 
 
===缩进和前缀参数===
 
Indentation is usually performed with either '''<TAB>''', to indent a single line, or with '''C-M-\''', to indent a region.
 
 
 
Exactly how text is indented usually depends on the ''major-mode'' which is active.  Major-modes often define indentation styles specialising in indenting a certain type of text.  (See [[Emacs#Modes|Modes]] for more information.)
 
 
 
In some cases, a suitable major-mode may not exist for a file type, in which case, manual indentation may be necessary.  Create a region (see [[Emacs#Killing, yanking and regions|Killing, yanking and regions]]) then perform indentation with '''C-u <n> C-x <TAB>''' (where '<n>' is the number of columns which the text within the region should be indented). For example:
 
 
 
Increase the region's indentation by four columns:
 
 
 
C-u 4 C-x <TAB>
 
 
 
Decrease the region's indentation by two columns.
 
 
 
C-u -2 C-x <TAB>
 
 
 
{{Note|The trick behind this is '''C-u''', which corresponds to the 'universal-argument' command.  Providing a 'universal-argument' is a way to provide more information to a command (this information is referred to as a 'prefix argument').  In this case, we provided the amount of indentation desired to the command invoked by '''C-x <TAB>'''. Without providing an argument, '''C-x <TAB>''' will only increase indentation by 1 column.}}
 
 
 
===窗口和外框架===
 
Emacs is designed for convenient editing of many files at a time. This is achieved by dividing the Emacs interface into three levels.  Namely, buffers, which have already been introduced, as well as ''windows'' and ''frames''.
 
 
 
A ''window'' is a viewport used for displaying a buffer.  A window can display only one buffer at a time, however one buffer can be displayed in many windows.  Beneath each window exists a ''mode-line'', which displays information for that buffer.
 
 
 
A ''frame'' is an Emacs "window" (in standard terminology.  i.e., 'window' in the sense of the modern desktop paradigm) which contains a title bar, menu bar and one or more 'windows' (in Emacs terminology.  i.e., the above definition of 'window').
 
 
 
From now on the definition of these terms as they exist in Emacs will be used.
 
 
 
To split the window vertically or horizontally, use '''C-x 2''' or '''C-x 3''', respectively.  This has the effect of creating another window in the current frame.  To cycle between multiple windows, use '''C-x o'''.
 
 
 
The opposite of splitting a window, is deleting it.  To delete the current window, use '''C-x 0''' and '''C-x 1''' to delete all windows except the current.
 
 
 
As with windows, it is also possible to create and delete frames.  '''C-x 5 2''' creates a frame.  With '''C-x 5 0''' to delete the current frame and '''C-x 5 1''' to delete all except the current frame.
 
 
 
{{Note|These commands do not affect buffers.  For example, deleting a window does not kill the buffer it displays.}}
 
 
 
===获得帮助===
 
Emacs is self-documenting by design.  As such, a great deal of information is available to determine the name of a specific command or its keybinding, for example.  The following is a listing of some of the most helpful of these:
 
  
'''C-h t'''        Start the Emacs tutorial
+
要通过SSH使用'you'用户名登录'remotehost'主机打开文件{{ic|~/example.txt}}:
 
'''C-h b'''        List all active keybindings
 
 
'''C-h k'''        Find which command a key is bound to
 
 
'''C-h w'''        Find which key(s) a command is bound to
 
 
'''C-h a'''        Find a command matching a description
 
 
'''C-h m'''        Display information regarding the currently active modes
 
 
'''C-h f'''        Describe the given function
 
  
===模式===
+
C-x C-f /ssh:you@remotehost:~/example.txt
An Emacs mode is an extension written in Emacs Lisp that controls the behaviour of the buffer it is attached to. Usually it provides indentation, syntax highlighting and keybindings for editing that form of text. Sophisticated modes can turn Emacs into a full-fledged IDE (Integrated Development Environment). Emacs will generally use a file's extension to determine which mode should be loaded.
 
  
Useful modes for editing shell scripts are sh-mode, line-number-mode and column-number-mode. They can be used in parallel and are invoked by:
+
TRAMP的路径一般是这种格式'/[protocol]:[[user@]host]:<file>'。
  
'''M-x sh-mode <RET>'''
+
作为用户'you'连接至'myhost'并以sudo编辑{{ic|/etc/hosts}}:
 +
/ssh:you@remotehost|sudo:remotehost:/etc/hosts
  
'''M-x column-number-mode <RET>'''
+
TRAMP支持的不只上面的两个简单例子。请查看Emacs里面的TRAMPP info手册了解更多的信息。
  
line-number-mode is enabled by default, though, it can be toggled on/off by issuing the command again:
+
===使用Emacs作为git mergetool===
 +
默认情况下,Git支持使用Emacs的Emerge模式作为合并工具。但是你可能更喜欢Ediff模式。不幸的是,由于技术原因,这种模式不被git支持。通过在emacs调用时对一些elisp代码赋值,仍然有一种方法可以使用Ediff。
  
'''M-x line-number-mode <RET>'''
+
{{hc|.gitconfig|<nowiki>
 +
[mergetool.ediff]
 +
    cmd = emacs --eval \" (progn (defun ediff-write-merge-buffer () (let ((file ediff-merge-store-file)) (set-buffer ediff-buffer-C) (write-region (point-min) (point-max) file) (message \\\"Merge buffer saved in: %s\\\" file) (set-buffer-modified-p nil) (sit-for 1))) (setq ediff-quit-hook 'kill-emacs ediff-quit-merge-hook 'ediff-write-merge-buffer) (ediff-merge-files-with-ancestor \\\"$LOCAL\\\" \\\"$REMOTE\\\" \\\"$BASE\\\" nil \\\"$MERGED\\\"))\"
  
sh-mode is a ''major-mode''.  Major-modes adjust Emacs, and often also provide a specialised set of commands, for editing a particular type of text.  Only one major-mode can be active in each buffer.  In addition to syntax highlighting, and indentation support, sh-mode defines several commands to help write shell scripts.  The following shows a few of those commands:
+
[merge]
 +
tool = ediff
 +
</nowiki>}}
  
'''C-c (''' Insert a function definition
+
请注意,该命令必须在同一行上。在上面的例子中,我们启动了一个Emacs的新实例。你可能想要使用emacsclient更快地启动; 不建议这样做,因为Ediff调用不是很干净:它可能会打断当前的Emacs会话。
 
'''C-c C-f''' Insert a 'for' loop
 
 
'''C-c TAB''' Insert an 'if' statement
 
 
'''C-c C-w''' Insert a 'while' loop
 
 
'''C-c C-l''' Insert an indexed loop from 1 to n
 
  
'line-number-mode' and 'column-number-mode', are ''minor-modes''. Minor-modes can be used to extend a major-mode and any number of minor-modes can be enabled at once.
+
如果你想要一个即时启动,可以使用-q参数。如果想在保留至少一部分配置的情况下快速启动Emacs,则可以这样使用Emacs:
 +
emacs -q -l ~/.emacs-light
 +
light配置文件仅加载Ediff所需的内容。
  
==提示和技巧==
+
关于这个技巧的细节和Ediff问题,参见[http://kerneltrap.org/mailarchive/git/2007/7/1/250424 kerneltrap.org]{{Dead link|2017|06|02}}和 [http://stackoverflow.com/questions/1817370/using-ediff-as-git-mergetool stackoverflow]。
While the previous sections has given an overview of the basic editing commands available, it has not given an indication of the possibilities of Emacs. This section will cover some more advanced techniques and functionality.
 
  
===TRAMP===
+
===使用大写锁定作为控制键===
TRAMP (Transparent Remote Access, Multiple Protocols) is an extension which, as its name suggests, provides transparent access to remote files across a number of protocols. When prompted for a filename, entering a specific form will invoke TRAMP. Some examples:
+
一些用户喜欢这种个修改,以避免所谓的'emacs pinky'。如果你想在X上试用它,运行
 +
  $ setxkbmap -option 'ctrl:nocaps'
 +
或者,'''交换'''键值,运行
 +
  $ setxkbmap -option 'ctrl:swapcaps'
 +
要永久更改它,请考虑将其添加到.xinitrc文件中。
  
To prompt for the root password before opening /etc/hosts with root permissions:
+
如果要将一个区域变为大写,只需使用默认的C-x C-u键绑定,调用upcase-region函数。
  
C-x C-f /su::/etc/hosts
+
参见[http://ergoemacs.org/emacs/swap_CapsLock_Ctrl.html]了解另一种方法。
  
To connect to 'myhost' as 'myuser' via SSH and open the file ~/example.txt:
+
如果缺少Caps Lock功能,请同时将其映射为“Shift”。
  
  C-x C-f /ssh:myuser@myhost:~/example.txt
+
  $ setxkbmap -option "shift:both_capslock"
  
The path for TRAMP is typically of the form '/[protocol]:[[user@]host]:<file>'.  TRAMP supports much more than the examples above might indicate.  For more information refer to the TRAMP info manual, which is distributed with Emacs.
+
某些桌面环境包含图形工具以简化键盘重新映射。 例如,在[[Plasma|Plasma 5]]中打开系统设置并点击输入设备。选择键盘,然后在高级选项卡中会看到Caps Lock设置,可以在其中选择Caps Lock也是一个Ctrl。
  
 
===键盘宏和寄存器===
 
===键盘宏和寄存器===
This section will provide a practical demonstration of the use of a couple of more powerful editing features.  Namely, ''keyboard macros'' and ''registers''.
+
这一部分会提供一个实用的指南来使用一些更强大的编辑特性。也就是“键盘宏”和“寄存器”。
  
The aim will be to produce a listing of a series of characters and their corresponding position in this list.  While it is possible to format each of them by hand, this would be slow and error-prone.  Alternatively, some of Emacs' more powerful editing functionality could be leveraged.  Before describing a solution, some details behind the techniques which will be used follow.
+
我们的目标是产生一个字符列表和它们在这个列表中对应的位置。虽然这可以通过手工格式化来完成,但是这样会很慢而且容易出错。如果我们采用一些Emacs更高级的编辑功能却可以起到四两拨千斤的功效。在介绍这个方法之前,需要先了解一些技术背后的细节。
  
The first feature which will be introduced is ''registers''.  Registers are used to store and retrieve a variety of data types ranging from numbers to window configurations.  Each register is given a name of a single character: this character is used to access the register.
+
要介绍的第一个特性就是''寄存器''。寄存器的功能是用来保存和获取各种各样的数据。每个寄存器用一个字母来命名,这个字母就是用来调用这个寄存器的。
  
The other which will be demonstrated is ''keyboard macros''.  A keyboard macro stores a sequence of commands so they can be easily repeated later.  These changes will now be performed step-by-step.
+
另一个要介绍的就是''键盘宏''。一个键盘宏存储了一个命令序列以便以后可以重复使用。下面就一步一步地讲解这个方法。
  
Starting with a buffer containing our set of characters:
+
首先我们从一个包含如下字符的缓冲区开始:
 
  ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
 
  ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
  
Prepare a register by invoking the `number-to-register' command ('''C-x r n''') then storing the number '0' in register 'k':
+
通过`number-to-register' 命令 ('''C-x r n''')我们来准备一个寄存器,把数字'0'存储在寄存器'k'中:
  
 
  C-x r n k
 
  C-x r n k
  
With point at the beginning of the buffer, start a keyboard macro ('''C-x (''') and begin to format the characters:
+
当光标在缓冲区开头的时候,开始录制键盘宏 ('''C-x (''') 然后开始对字符串进行格式化:
  
 
  C-x ( C-f M-4 .
 
  C-x ( C-f M-4 .
  
Insert ('''C-x r i''') and increment ('''C-x r +''') the register 'k'. The prefix argument ('''C-u''') is used to leave point positioned after the inserted text:
+
插入 ('''C-x r i''') 然后将寄存器'k'加1 ('''C-x r +''') 。开头的 ('''C-u''') 命令是用来在插入文字之后让光标移到插入的文字后面:
  
 
  C-u C-x r i k C-x r + k
 
  C-u C-x r i k C-x r + k
  
Complete the formatting by inserting a newline.  Emacs can then repeat that process, beginning from the point where we started defining the keyboard macro, for the rest of the characters.  '''C-x e''' completes then invokes the keyboard macro.  The prefix argument, '''M-0''', causes the macro to repeat until it comes across an error.  In this case it aborts once it reaches the end of the buffer.
+
最后我们来插入一个回车来结束格式化。Emacs可以重复以上过程,从我们定义键盘宏的位置开始,直到最后一个字符。'''C-x e'''命令停止宏的录制并开始执行这段宏。开头的 '''M-0''' 命令是用来让宏在出错的时候停下来,这样在它走到这行的结尾就会停下来。
  
 
  <RET> M-0 C-x e
 
  <RET> M-0 C-x e
  
The result:
+
下面是结果:
  
 
   A....0
 
   A....0
Line 273: Line 222:
 
From the Emacs Manual: "A regular expression, or ''regexp'' for short, is a pattern that denotes a (possibly infinite) set of strings."  This section will not go into any detail regarding regular expressions themselves (as there is simply too much to cover).  It will however provide a quick demonstration of their power.  See [http://www.gnu.org/software/emacs/manual/html_node/elisp/Regular-Expressions.html#Regular-Expressions Regular Expressions] section in the Emacs Manual for further reading.
 
From the Emacs Manual: "A regular expression, or ''regexp'' for short, is a pattern that denotes a (possibly infinite) set of strings."  This section will not go into any detail regarding regular expressions themselves (as there is simply too much to cover).  It will however provide a quick demonstration of their power.  See [http://www.gnu.org/software/emacs/manual/html_node/elisp/Regular-Expressions.html#Regular-Expressions Regular Expressions] section in the Emacs Manual for further reading.
  
Given the same scenario presented above: A list of characters which are to be formatted to represent their respective position in the list. (see [[Emacs#Keyboard macros and registers|Keyboard macros and registers]]).  Again, starting with a buffer containing.
+
Given the same scenario presented above: A list of characters which are to be formatted to represent their respective position in the list. (see [[Emacs#Keyboard macros and registers|Keyboard macros and registers]]{{Broken section link}}).  Again, starting with a buffer containing.
  
 
  ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
 
  ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
Line 286: Line 235:
 
Finally, press '''!''' to apply this across the entire buffer.  All of the formatting that was performed in the previous section was performed with a single regexp replacement.
 
Finally, press '''!''' to apply this across the entire buffer.  All of the formatting that was performed in the previous section was performed with a single regexp replacement.
  
===定制===
+
==定制==
Emacs can configured by editing '~/.emacs' or using '''M-x customize'''. This section will focus on editing ~/.emacs by hand, and provide some example customizations to demonstrate commonly-configured aspects of Emacs.  The customize command provides a simple interface to make adjustments, though it may become restricting as you grow more familiar with Emacs.
+
Emacs能通过~/.emacs或者'''M-x customize'''来定制。本段落将着眼于手动定制 ~/.emacs,并且提供了一些常用配置的样例。配置命令提供了一个适应的途径,通过它你能够渐渐熟悉Emacs。
 
 
All of the examples here can be performed while Emacs is running.  To evaluate the expression within Emacs, use:
 
  
'''C-M-x''' with point anywhere within the expression.
+
这里的所有例子都能在Emacs中奏效。比如,在Emacs中计算表达式:
 +
'''C-M-x''' 同时指到任何需要求值的地方。
  
or
+
或者
  
'''C-x C-e''' with point following the last ')'
+
'''C-x C-e''' 指到最后的“)”。
  
For some users, typing 'yes' and 'no' in prompts can quickly become tiring.  To instead use the 'y' and 'n' keys at these prompts:
+
'y''n'来代替频繁地输入'yes’和'no‘是一个好的方法:
  
 
  (defalias 'yes-or-no-p 'y-or-n-p)
 
  (defalias 'yes-or-no-p 'y-or-n-p)
  
To stop the cursor blinking, use:
+
取消光标闪烁:
  
 
  (blink-cursor-mode -1)
 
  (blink-cursor-mode -1)
  
Similarly, to enable column-number-mode, as discussed in the previous section:
+
类似地,开启上一节提到的列号模式:
  
 
  (column-number-mode 1)
 
  (column-number-mode 1)
  
The similarities between the previous two commands are not a coincidence: blink-cursor-mode and column-number-mode are both minor-modes.  As a rule, minor-modes can be enabled given positive argument or disabled with a negative argument.  Should the argument be omitted, the minor-mode will be toggled on/off.
+
它们两者之间的相似不是偶然:光标闪烁模式和列号模式都是'副参模式',按照规则,'副参模式’能通过正负值来设置。如果参数省略,'副参模式'将被开/关。
 
 
Here are some more examples of minor-modes.  The following will disable the scroll bars, menu-bar and tool-bar, respectively.
 
  
 +
这里有其他一些'副参模式'的例子,下面的参数将会关闭滚动栏、菜单栏、工具栏。
 
  (scroll-bar-mode -1)
 
  (scroll-bar-mode -1)
 
  (menu-bar-mode -1)
 
  (menu-bar-mode -1)
 
  (tool-bar-mode -1)
 
  (tool-bar-mode -1)
  
The variable, 'auto-mode-alist', can be modified to change the major-mode used by default for certain file names.  The following example will make the default major-mode for '.tut' and '.req' files 'text-mode'.
+
变量'auto-mode-alist'修改之后能够改变默认的“主参模式”。下面的例子把'.tut''.req'修改成了'.text-mode'
  
 
  (setq auto-mode-alist
 
  (setq auto-mode-alist
Line 345: Line 292:
 
Almost anything within Emacs can be configured.  Browsing through the [http://emacswiki.org/ Emacs Wiki] should give a solid place to start.
 
Almost anything within Emacs can be configured.  Browsing through the [http://emacswiki.org/ Emacs Wiki] should give a solid place to start.
  
=== 拓展模块 ===
 
  
While Emacs includes hundreds of modes, libraries and other extensions, there are many more available to further Emacs' capabilitiesThe majority of these come with instructions detailing any changes needed to be made to ~/.emacs. These instructions are generally found in the comment block at the beginning of an elisp source file, or in a README (or similar) should the extension consist of multiple source files.
+
=== 多种配置 ===
 +
 
 +
你可以使用少量配置然后告诉Emacs来加载其他配置。
 +
 
 +
例如,我们来定义两个配置文件。
 +
 
 +
{{hc|.emacs|
 +
(load "~/.emacs.d/main" nil t)
 +
(load "~/.emacs.d/functions" nil t)
 +
(load "~/.emacs.d/modes" nil t)
 +
(load "~/.emacs.d/plugins" nil t)
 +
(load "~/.emacs.d/theme" nil t)
 +
}}
 +
 
 +
这是我们在后台载入的完整配置。但是plugins文件太大导致载入太慢,如果我们要打开一个新的Emacs窗口,可能就不会使用plugins配置,每次加载它实在是太笨重了。
 +
 
 +
{{hc|.emacs-light|
 +
(load "~/.emacs.d/main" nil t)
 +
(load "~/.emacs.d/functions" nil t)
 +
(load "~/.emacs.d/modes" nil t)
 +
(load "~/.emacs.d/theme" nil t)
 +
}}
 +
 
 +
现在我们这样来加载Emacs:
 +
 
 +
  emacs -q -l ~/.emacs-light
 +
 
 +
你可以为这个命令创建一个别名。
 +
 
 +
=== 加载扩展程序 ===
 +
 
 +
你能用require来加载扩展程序,例如这样:
 +
 
 +
(require 'mediawiki)
 +
 
 +
如果你试着在一个买有安装mediawiki的机器上使用相同的配置,Emacs会提示错误。并且,所有制定的扩展代码都会失效。
 +
 
 +
一个小的技巧是测试require的返回值。
 +
 
 +
  (if (require 'mediawiki nil t)
 +
    (progn
 +
      (setq mediawiki-site-alist '(
 +
              ("ArchLinux" "https://wiki.archlinux.org/" "UserName" "" "Main Page")
 +
              )
 +
            )
 +
      (setq mediawiki-mode-hook
 +
            (lambda ()
 +
              (visual-line-mode 1)
 +
              (turn-off-auto-fill)
 +
              ))
 +
  ))
  
A number of popular extensions are available as packages in the 'community' repository, and more still are available via the [[AUR]].  The name of such packages have a 'emacs-' prefix (for example, emacs-lua-mode).  In many cases, the changes which need to be made to ~/.emacs are shown during the installation of the package.
+
=== Local and custom variables ===
  
Should instructions describing how to activate a specific extension not be available in the aforementioned location(s), check for a corresponding page in the [http://emacswiki.org/ Emacs Wiki], which will almost certainly provide an example configuration.  The Emacs Wiki is also an excellent resource for discovering even more extensions.
+
You can define variables in your configuration file that can be later one modified locally for a file.
  
You can also use the [http://tromey.com/elpa/ Emacs Lisp Package Archive (ELPA)] to automatically install packages.  See the website for instructions. ELPA is included with Emacs 24 (the newest version of Emacs); it is an accepted part of the Emacs ecosystem.
+
  (defcustom my-compiler "gcc" "Some documentation")
  
== 问题的解决方法 ==
+
Now in any file you can define local variables in two ways:
 +
* On the very first line, write
 +
// -*- my-compiler:g++; mode:c++ -*-
 +
* If you cannot (or do not want to) write this on the first line, you can put it at the end:
 +
// Local Variables:
 +
// my-compiler: g++
 +
// mode: c++
 +
// End:
 +
 
 +
Note that the beginning characters need to be comments for the current language, that's why here we used two backslashes for C++. For Elisp you would use
 +
;; -*- mode:emacs-lisp -*-
 +
 
 +
There is two functions that may help you in defining the variables: ''add-file-local-variable'' and ''add-file-local-variable-prop-line''.
 +
 
 +
Finally, custom variable are considered insecure by default. If you try to open a file that contains local variable redefining insecure custom variables, Emacs will ask you for confirmation.
 +
 
 +
If you know what you are doing, you can declare the variable as secure, thus removing the Emacs prompt for confirmation. You need to specify a predicate that any new value has to verify so that it can be considered safe.
 +
 
 +
(defcustom my-compiler "gcc" "Some documentation" :safe 'stringp)
 +
 
 +
In the previous example, if you attempt to set anything else than a string, Emacs will consider it insecure.
 +
 
 +
=== Custom colors and theme ===
 +
 
 +
Colors can be easily customized using the ''face'' facility.
 +
(set-face-background  'region                "color-17")
 +
(set-face-foreground  'region                "white")
 +
(set-face-bold-p      'font-lock-builtin-face t )
 +
 
 +
You can have let Emacs tell you the name of the face where the point is. Use the ''customize-face'' function for that. The facility will show you how to set colors, bold, underline, etc.
 +
 
 +
Emacs in console can handle 256 colors, but you will have to use an appropriate terminal for that. For instance URxvt has support for 256 colors. You can use the ''list-colors-display'' for a comprehensive list of supported colors. This is highly terminal-dependent.
 +
 
 +
=== SyncTeX support ===
 +
 
 +
Emacs is definitely one of the most powerful LaTeX editor. This is mostly due to the fact you can adapt or create a LaTeX mode to fit your needs best.
 +
 
 +
Still, there might be some challenges, like SyncTeX support. First you need to make sure your TeX distribution has it. If you installed TeX Live manually, you may need to install the ''synctex'' package.
 +
# umask 022 && tlmgr install synctex
 +
 
 +
SyncTeX support is viewer-dependent. Here we will use Zathura as an example, so the code needs to be adapted if you want to use another PDF viewer.
 +
 
 +
(defcustom tex-my-viewer "zathura --fork -s -x \"emacsclient --eval '(progn (switch-to-buffer  (file-name-nondirectory \"'\"'\"%{input}\"'\"'\")) (goto-line %{line}))'\""
 +
  "PDF Viewer for TeX documents. You may want to fork the viewer
 +
so that it detects when the same document is launched twice, and
 +
persists when Emacs gets closed.
 +
 +
Simple command:
 +
 +
  zathura --fork
 +
 +
We can use
 +
 +
  emacsclient --eval '(progn (switch-to-buffer  (file-name-nondirectory \"%{input}\")) (goto-line %{line}))'
 +
 +
to reverse-search a pdf using SyncTeX. Note that the quotes and double-quotes matter and must be escaped appropriately."
 +
:safe 'stringp)
 +
 
 +
Here we define our custom variable. If you are using AucTeX or Emacs default LaTeX-mode, you will have to set the viewer accordingly.
 +
 
 +
Now open a LaTeX source file with Emacs, compile the document, and launch the viewer. Zathura will spawn. If you press {{ic|Ctrl+Left click}} Emacs should place the point at the corresponding position.
 +
 
 +
== Documentation ==
 +
 
 +
You may find yourself overwhelmed by the amount of Emacs features. You may find it difficult to know how to use Emacs Lisp to customize your favorite modes, or even to create your own modes / packages. Thankfully Emacs takes a strong point to auto-documenting everything: its internals, current configuration, bindings, etc. Almost everything is documented.
 +
 
 +
=== Contextual help ===
 +
 
 +
Emacs is self-documenting by design.  As such, a great deal of information is available to determine the name of a specific command or its keybinding, for example.  The following is a listing of some of the most helpful of these:
 +
 +
'''C-h a'''        Find a command matching a description.
 +
 
 +
'''C-h b'''        List all active keybindings.
 +
 
 +
'''C-h f'''        Describe the given function.
 +
 
 +
'''C-h k'''        Find which command a key is bound to.
 +
 
 +
'''C-h m'''        Display information regarding the currently active modes.
 +
 
 +
'''C-h t'''        Start the Emacs tutorial.
 +
 
 +
'''C-h v'''        Describe the given variable.
 +
 
 +
'''C-h w'''        Find which key(s) a command is bound to.
 +
 
 +
== 拓展模块 ==
 +
 
 +
虽然Emacs包含了成百上千种模式(mode),库和其它扩展,还有更多的扩展来增强Emacs。大多数扩展会详细说明安装它的时候要对~/.emacs作什么改动。这些说明一般会在一个elisp源文件开头的注释中,或者在一个README中(如果这个扩展包含了多个源文件)。
 +
 
 +
在'community'仓库中有很多流行的扩展,更多的扩展还放在了[[AUR]]。这些软件包的名字有一个'emacs-'前缀(比如emacs-lua-mode)。在很多情况下,在安装的过程会显示怎样修改~/.emacs以安装该扩展到Emacs中。
 +
 
 +
想知道怎样激活一个不在上面提到的地方的扩展,查看[http://emacswiki.org/ Emacs Wiki]中的相应页面,一般会提供一个配置的例子。Emacs Wiki也是一个寻找扩展的优秀资源。
 +
 
 +
你也可以使用[http://tromey.com/elpa/ Emacs Lisp Package Archive (ELPA)] 来自动安装软件包。打开那个网站看说明。ELPA已经包括在了Emacs24中;它已经作为Emacs生态系统中的一部分了。
 +
 
 +
== 疑难杂症 ==
  
 
===彩色输出的问题===
 
===彩色输出的问题===
By default, the Emacs shell will show raw escape sequences used to print colors. In other words, it will display strange symbols in place of the desired colored output.
+
Emacs默认使用原生的转义串来输出颜色。也就是说,它会在要显示颜色的地方显示奇怪的字符。
  
Including the following into {{ic|~/.emacs}} amends the problem:
+
{{ic|~/.emacs}}中加入下面的代码解决这个问题:
 
  (add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
 
  (add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
  
 
===菜单显示为空===
 
===菜单显示为空===
A bug exists in GNU Emacs 23.1 (using the GTK toolkit) which may cause some menus to appear empty.  This appears to be fixed in Emacs' CVS trunk.  The corresponding [http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=550541 Debian bug report] contains a workaround.
+
一些菜单显示为空,这是GNU Emacs 23.1的一个bug(使用GTK toolkit的时候)。好像在Emacs的CVS trunk中已经修复了。对应的[http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=550541 Debian bug report] 有一个应对措施。
  
 
=== X 窗口下的字符显示问题 ===
 
=== X 窗口下的字符显示问题 ===
If when you start emacs in X windows all the characters in the main window are white boxes with black borders (the ones you see if you try to view characters for which you do not have the correct font installed), you need to install {{pkg|xorg-fonts-75dpi}} and/or {{pkg|xorg-fonts-100dpi}} and restart X windows.
+
当你使用X窗口启动emacs时,如果发现主窗口中的所有字符都是黑框白块(就像你没有安装正确的字体看到的字符一样),那么你需要安装 {{pkg|xorg-fonts-75dpi}} 或者 {{pkg|xorg-fonts-100dpi}} 并且重启X窗口。
  
 
=== 启动速度慢 ===
 
=== 启动速度慢 ===
Slow startup times are often caused by one of two things.
+
启动速度慢经常是由下面两种情况引起的。
  
To determine which it might be, run Emacs with:
+
要确定是哪种情况,这样打开Emacs:
  
 
  $ emacs -q
 
  $ emacs -q
  
If Emacs still starts slowly, refer to [[Emacs#Incorrect network configuration|Incorrect network configuration]].  If not, it is almost certainly a [[Emacs#Init file loads slowly|problem in your .emacs]].
+
如果Emacs还是启动很慢,则是[[Emacs#Incorrect network configuration|错误的网络配置]]{{Broken section link}}。如果不是,则可以确定是[[Emacs#Init file loads slowly|.emacs的问题]]{{Broken section link}}。
  
 
====错误的网络配置====
 
====错误的网络配置====
  
Mistakes, particularly in /etc/hosts, will often result in a 5+ second delay when starting Emacs.  Refer to '[[Configuring_network#Set_the_hostname|set the hostname]]' in the network configuration guide for information.
+
当启动Emacs的时候,一些错误,特别是在/etc/hosts中的,经常会导致5秒以上的延迟。在网络配置指南中查看'[[Configuring_network#Set_the_hostname|set the hostname]]' 了解更多内容。
  
 
====初始化文件加载慢====
 
====初始化文件加载慢====
  
A simple way to search for the cause is to comment-out (i.e., prefix lines with ';') suspect sections of your ~/.emacs (or ~/.emacs.d/init.el) then start Emacs again to see if there's any change.  Keep in mind use of "require" and "load" can slow the startup down, especially when used with larger extensions.  They should, as a rule, only be used when their target is either: needed once Emacs starts or provides little more than "autoloads" for an extension.  Otherwise, use the 'autoload function directly.  For example, instead of:
+
一个很简单的方法查找原因是注释掉(比如在行开头使用';')你的~/.emacs(或者~/.emacs.d/init.el)里面可疑的地方,然后再启动Emacs,看速度是否有改善。记住,使用"require""load"会减慢启动速度,特别是用在很大的插件上。一般来说,他们应该用在当目标是Emacs启动的时候就需要或者提供仅仅是一个扩展的"autoloads"。否则,直接使用'autoload'函数。比如,不是这样:
  
 
  (require 'anything)
 
  (require 'anything)
  
you might use:
+
你应该这样:
  
 
  (autoload 'anything "anything" "Select anything" t)
 
  (autoload 'anything "anything" "Select anything" t)
  
=== 不能打开文件: ... ===
+
=== 不能打开配置文件: ... ===
  
The most common cause of this error is the 'load-path' variable not including the path to the directory within which the extension is located.  To solve this, add the appropriate path to the list to be searched prior to attempting to load the extension:
+
这个错误最常见的原因是'load-path'变量没有包含某些插件的目录。要解决这个问题,在加载插件前,把需要加载的插件目录加入到要搜索的list中:
  
 
   (add-to-list 'load-path "/path/to/directory/")
 
   (add-to-list 'load-path "/path/to/directory/")
  
When attempting to use packages for extensions and Emacs has been configured with a prefix other than '/usr', the load-path will need to be updated.  Place the following in ~/.emacs prior to the instructions provided by the package:
+
当尝试使用一个插件的包,而这个包又被Emacs加上了非'/usr'的前缀时,load-path需要更新。把下面的代码放到使用这个插件的包的代码的前面:
  
 
   (add-to-list 'load-path "/usr/share/emacs/site-lisp")
 
   (add-to-list 'load-path "/usr/share/emacs/site-lisp")
  
If compiling Emacs by hand, keep in mind that the default prefix is '/usr/local'.
+
如果手动编译Emacs,记住默认的前缀是'/usr/local'。
 +
 
 +
=== Dead-accent keys problem: '<dead-acute> is undefined' ===
 +
 
 +
Searching about this bug on Google, we find this link:
 +
http://lists.gnu.org/archive/html/help-gnu-emacs/2009-05/msg00167.html
 +
 
 +
Explaining the problem: in recent versions of
 +
b72
 +
Emacs, the normal way to use accent keys doesn't work as expected. Trying to accent a word like 'fiancé' will produce the message above.
 +
 
 +
A way to solve it is just put the line above on your startup file, {{ic|~/.emacs}}:
 +
 
 +
  (require 'iso-transl)
 +
 
 +
And no, it isn't a bug, but a feature of new Emacs versions. Reading the subsequent messages about it on the mail list, we found it (http://lists.gnu.org/archive/html/help-gnu-emacs/2009-05/msg00179.html):
 +
 
 +
:''It seems that nothing is loaded automatically because there is a choice betwee iso-transl and iso-acc. Both seem to provide an input method with C-x 8 or Alt-<accent> prefix, but what you and I are doing is just pressing a dead key (^, ´, `, ~, ¨) for the accent and then another key to "compose" the accented character. And there is no Alt key used in this! And according to documentation it seems be appropriate for 8-bit encodings, so it should be pretty useless in UTF-8. I reported this bug when it was introduced, but the bug seems to be
 +
a3b
 +
classified as a feature ... Maybe it's just because the file is auto-loaded though pretty useless. ''
 +
 
 +
=== C-M-% and some other bindings do not work in emacs nox ===
 +
 
 +
This is because terminals are more limited than Xorg. Some terminals may handle more bindings than other, though. Two solutions:
 +
* either use the graphical version,
 +
* or change the binding to a supported one.
 +
 
 +
Example:
 +
{{hc|.emacs|
 +
(global-set-key (kbd "C-M-y") 'query-replace-regexp)
 +
}}
 +
 
 +
=== Emacs client gets stuck when switching back to it ===
 +
 
 +
If you are using Emacs daemon, then you should know that input is blocking. If one Emacs instance is in the minibuffer (after an '''M-x''' for instance), then all other instance will wait for it to finish. Press '''C-g''' to cancel any input to make sure this Emacs session is not blocking.
 +
 
 +
=== Emacs-nox output gets messy ===
 +
 
 +
When working in a terminal, the color, indentation, or anything related to the output might become crazy. This is (probably?) because Emacs was sent a special character at some point which may conflict with the current terminal.
 +
There is not much to be done but restarting emacs. If someone has a workaround or a more detailed explanation on the issue, feel free to contribute.
 +
 
 +
Graphical Emacs does not suffer from this issue.
 +
 
 +
=== Shift + Arrow keys not working in emacs within tmux ===
 +
 
 +
First you must enable xterm-keys in your [[tmux]] config.
 +
{{hc|.tmux.conf|
 +
setw -g xterm-keys on
 +
}}
 +
 
 +
But, this will break other key combinations. To fix them, put the following in your emacs config.
 +
{{hc|.emacs|
 +
;; handle tmux's xterm-keys
 +
;; put the following line in your ~/.tmux.conf:
 +
;;  setw -g xterm-keys on
 +
(if (getenv "TMUX")
 +
    (progn
 +
      (let ((x 2) (tkey ""))
 +
(while (<&#61; x 8)
 +
  ;; shift
 +
  (if (&#61; x 2)
 +
      (setq tkey "S-"))
 +
  ;; alt
 +
  (if (&#61; x 3)
 +
      (setq tkey "M-"))
 +
  ;; alt + shift
 +
  (if (&#61; x 4)
 +
      (setq tkey "M-S-"))
 +
  ;; ctrl
 +
  (if (&#61; x 5)
 +
      (setq tkey "C-"))
 +
  ;; ctrl + shift
 +
  (if (&#61; x 6)
 +
      (setq tkey "C-S-"))
 +
  ;; ctrl + alt
 +
  (if (&#61; x 7)
 +
      (setq tkey "C-M-"))
 +
  ;; ctrl + alt + shift
 +
  (if (&#61; x 8)
 +
      (setq tkey "C-M-S-"))
 +
 
 +
  ;; arrows
 +
  (define-key key-translation-map (kbd (format "M-[ 1 ; %d A" x)) (kbd (format "%s<up>" tkey)))
 +
  (define-key key-translation-map (kbd (format "M-[ 1 ; %d B" x)) (kbd (format "%s<down>" tkey)))
 +
  (define-key key-translation-map (kbd (format "M-[ 1 ; %d C" x)) (kbd (format "%s<right>" tkey)))
 +
  (define-key key-translation-map (kbd (format "M-[ 1 ; %d D" x)) (kbd (format "%s<left>" tkey)))
 +
  ;; home
 +
  (define-key key-translation-map (kbd (format "M-[ 1 ; %d H" x)) (kbd (format "%s<home>" tkey)))
 +
  ;; end
 +
  (define-key key-translation-map (kbd (format "M-[ 1 ; %d F" x)) (kbd (format "%s<end>" tkey)))
 +
  ;; page up
 +
  (define-key key-translation-map (kbd (format "M-[ 5 ; %d ~" x)) (kbd (format "%s<prior>" tkey)))
 +
  ;; page down
 +
  (define-key key-translation-map (kbd (format "M-[ 6 ; %d ~" x)) (kbd (format "%s<next>" tkey)))
 +
  ;; insert
 +
  (define-key key-translation-map (kbd (format "M-[ 2 ; %d ~" x)) (kbd (format "%s<delete>" tkey)))
 +
  ;; delete
 +
  (define-key key-translation-map (kbd (format "M-[ 3 ; %d ~" x)) (kbd (format "%s<delete>" tkey)))
 +
  ;; f1
 +
  (define-key key-translation-map (kbd (format "M-[ 1 ; %d P" x)) (kbd (format "%s<f1>" tkey)))
 +
  ;; f2
 +
  (define-key key-translation-map (kbd (format "M-[ 1 ; %d Q" x)) (kbd (format "%s<f2>" tkey)))
 +
  ;; f3
 +
  (define-key key-translation-map (kbd (format "M-[ 1 ; %d R" x)) (kbd (format "%s<f3>" tkey)))
 +
  ;; f4
 +
  (define-key key-translation-map (kbd (format "M-[ 1 ; %d S" x)) (kbd (format "%s<f4>" tkey)))
 +
  ;; f5
 +
  (define-key key-translation-map (kbd (format "M-[ 15 ; %d ~" x)) (kbd (format "%s<f5>" tkey)))
 +
  ;; f6
 +
  (define-key key-translation-map (kbd (format "M-[ 17 ; %d ~" x)) (kbd (format "%s<f6>" tkey)))
 +
  ;; f7
 +
  (define-key key-translation-map (kbd (format "M-[ 18 ; %d ~" x)) (kbd (format "%s<f7>" tkey)))
 +
  ;; f8
 +
  (define-key key-translation-map (kbd (format "M-[ 19 ; %d ~" x)) (kbd (format "%s<f8>" tkey)))
 +
  ;; f9
 +
  (define-key key-translation-map (kbd (format "M-[ 20 ; %d ~" x)) (kbd (format "%s<f9>" tkey)))
 +
  ;; f10
 +
  (define-key key-translation-map (kbd (format "M-[ 21 ; %d ~" x)) (kbd (format "%s<f10>" tkey)))
 +
  ;; f11
 +
  (define-key key-translation-map (kbd (format "M-[ 23 ; %d ~" x)) (kbd (format "%s<f11>" tkey)))
 +
  ;; f12
 +
  (define-key key-translation-map (kbd (format "M-[ 24 ; %d ~" x)) (kbd (format "%s<f12>" tkey)))
 +
  ;; f13
 +
  (define-key key-translation-map (kbd (format "M-[ 25 ; %d ~" x)) (kbd (format "%s<f13>" tkey)))
 +
  ;; f14
 +
  (define-key key-translation-map (kbd (format "M-[ 26 ; %d ~" x)) (kbd (format "%s<f14>" tkey)))
 +
  ;; f15
 +
  (define-key key-translation-map (kbd (format "M-[ 28 ; %d ~" x)) (kbd (format "%s<f15>" tkey)))
 +
  ;; f16
 +
  (define-key key-translation-map (kbd (format "M-[ 29 ; %d ~" x)) (kbd (format "%s<f16>" tkey)))
 +
  ;; f17
 +
  (define-key key-translation-map (kbd (format "M-[ 31 ; %d ~" x)) (kbd (format "%s<f17>" tkey)))
 +
  ;; f18
 +
  (define-key key-translation-map (kbd (format "M-[ 32 ; %d ~" x)) (kbd (format "%s<f18>" tkey)))
 +
  ;; f19
 +
  (define-key key-translation-map (kbd (format "M-[ 33 ; %d ~" x)) (kbd (format "%s<f19>" tkey)))
 +
  ;; f20
 +
  (define-key key-translation-map (kbd (format "M-[ 34 ; %d ~" x)) (kbd (format "%s<f20>" tkey)))
 +
 
 +
  (setq x (+ x 1))
 +
  ))
 +
      )
 +
  )
 +
}}
  
 
== 替代方案 ==
 
== 替代方案 ==
  
There are numerous implementations of Emacs. GNU/Emacs is probably the most popular. <br>
+
有很多Emacs的实现。GNU/Emacs 可能是最受欢迎的了。<br>
Lighter Emacs compatibile alternatives can be found in Arch repositories or in [https://aur.archlinux.org/ AUR].
+
更轻量的兼容性较好的Emacs可以在Arch仓库或在[https://aur.archlinux.org/ AUR]中找到。
  
 
=== mg ===
 
=== mg ===
  
mg (originally called MicroGnuEmacs) is lightweight implementation of Emacs written in C.
+
'''mg'''(原来叫MicroGnuEmacs),是用C语言实现的轻量级Emacs。
  
It's possible to install mg right away from {{ic|community}}
+
{{Pkg|mg}} 在 [[official repositories]] 中,也可以从上游下载源码[http://homepage.boetes.org/software/mg/ page]。注意,'''mg''' 没有UTF-8支持。
# pacman -S mg
 
or download source from official [http://homepage.boetes.org/software/mg/ page].
 
  
 
=== zile ===
 
=== zile ===
  
According to the offical web [https://www.gnu.org/software/zile/ page] "GNU Zile is a lightweight Emacs clone. Zile is short for Zile Is Lossy Emacs. Zile has been written to be as similar as possible to Emacs; every Emacs user should feel at home.".
+
引用官方网站[https://www.gnu.org/software/zile/ page]的描述,"GNU Zile is a lightweight Emacs clone. Zile is short for Zile Is Lossy Emacs. Zile has been written to be as similar as possible to Emacs; every Emacs user should feel at home.",意思是'GNU Zile'是一个轻量级的Emacs的克隆。Zile是'Zile Is Lossy Emacs'的缩写。
 +
Zile的实现与Emacs如此相似以至于每个Emacs用户使用Zile一定会有一种宾至如归的感觉。
  
zile can be found in {{ic|extra}}
+
{{Pkg|zile}} 可以在官方仓库中找到。
  
# pacman -S zile
+
最新的tarball可以在GNU的官方源[http://ftp.sh.cvut.cz/MIRRORS/gnu/pub/gnu/zile/ mirrors]中找到。
  
the latest taballs can be found in official GNU [http://ftp.sh.cvut.cz/MIRRORS/gnu/pub/gnu/zile/ mirrors].
+
=== uemacs ===
  
=== uemacs ===
+
'''uemacs''' 是由Linus Torvalds定制的微型Emacs版本。在 [[AUR]] 中名为{{AUR|uemacs-git}}。
 +
 
 +
=== remacs ===
  
uemacs is "Micro-emacs version customized by Linus Torvalds".
+
'''remacs''' 是一个用Rust写成的社区驱动的Emacs移植版。在 [[AUR]] 中名为 {{AUR|remacs-git}}。
It can be found in [https://aur.archlinux.org/ AUR] as [https://aur.archlinux.org/packages.php?ID=31502 uemacs].
 
  
 
== 资源 ==
 
== 资源 ==
 
* [http://www.gnu.org/software/emacs/ GNU Emacs home page]
 
* [http://www.gnu.org/software/emacs/ GNU Emacs home page]
* [http://www.gnu.org/software/emacs/manual/emacs.html GNU Emacs Manual]
+
* [http://www.gnu.org/software/emacs/manual/emacs.html GNU Emacs manual]
* [http://www.emacswiki.org/cgi-bin/wiki/ Emacs Wiki]
+
* [http://www.emacswiki.org/cgi-bin/wiki/ Emacs Wiki]{{Dead link|2017|06|02}}
* [http://wikemacs.org WikEmacs - a more readable, but less complete Emacs Wiki]
+
* [http://wikemacs.org WikEmacs - a more readable, but less complete Emacs wiki]
 
* [http://www2.lib.uchicago.edu/keith/tcl-course/emacs-tutorial.html Useful introduction to Emacs and its shortcuts]
 
* [http://www2.lib.uchicago.edu/keith/tcl-course/emacs-tutorial.html Useful introduction to Emacs and its shortcuts]
* [http://www.dina.kvl.dk/~abraham/religion/ The Church of Emacs]
+
* [https://d0edfcdc0ccc1cd13cdab5eb986fb92e8660dbef.googledrive.com/host/0B6LMD0u8OhYYZEotN2QyR1hwR1k/ The Church of Emacs (via Google drive)]{{Dead link|2017|06|02}}
* [http://repo.or.cz/w/emacs.git/blob/HEAD:/etc/refcards/refcard.pdf Official reference card]
+
* [http://www.gnu.org/software/emacs/refcards/pdf/refcard.pdf Official reference card]
 +
* [[EXWM]], the Emacs X Window Manager

Latest revision as of 23:34, 8 March 2018

翻译状态: 本文是英文页面 Emacs翻译,最后翻译时间:2018-03-07,点击这里可以查看翻译后英文页面的改动。

Emacs是一个可扩展、可定制、自文档化的实时显示编辑器。Emacs的核心构建在Emacs Lisp解释器之上,Emacs Lisp是大部分Emacs内建函数和拓展模块的实现语言。在图形界面系统下,Emacs使用GTK作为默认的X工具,在命令行界面下(CLI),Emacs也可以工作良好。在文本编辑能力上,Emacs常被拿来和vim比较。

安装

Emacs有众多发行版本(有时候称作emacsen)。 最常见的莫过于 GNU Emacs

official repositories 中可以安装 emacs 。如果你经常使用命令行,你可能更喜欢没有GTK+支持的 emacs-nox(也没有声音或其它花哨的东西)。值得注意的是,文字模式的Emacs有一些缺点:它支持的颜色和字体设置功能都要更少(实时改变字体大小,单文档多字体,等等)。而且emacs-nox存在一些高级功能上的缺陷,比如Speedbar和GUD(调试环境),处理复杂的外观(face,文本在Emacs中呈现的样子)的时候速度也会变慢。

如果你想体验Emacs的所有扩展功能而不用安装大量依赖项的话,可以使用PKGBUILD来按你的需求定制Emacs。不使用 gtk3, 可以让Emacs避免使用gconf。图像和声音的支持也可以禁用。在Emacs源目录下运行 ./configure --help 可以列出所有可用选项。

PKGBUILD
# ...
  ./configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib \
    --localstatedir=/var --with-x-toolkit=gtk2 --with-xft \
    --without-gconf --without-sound
# ...

运行Emacs

启动Emacs之前,你应该知道怎样关掉它(特别是你在终端里运行时):使用 Ctrl+xCtrl+c 按键顺序。

启动Emacs:

$ emacs

或者以文字模式启动:

$ emacs -nw

又或者,快速启动(不解析.emacs文件)并以文字模式启动:

$ emacs -Q -nw

如果你安装的是nox版本,'emacs' 和 'emacs -nw' 效果是一样的。

可以提供文件名直接打开文件:

$ emacs filename.txt

没有颜色

默认情况下,Emacs以颜色主题开始,显示超链接为深蓝色。

以文本模式,不使用任何颜色主题启动Emacs:

$ emacs -nw --color=no

这将导致所有的文本采用终端的字体颜色 –– 通常是黑色背景之上的白色文本,或白色背景上的黑色文本。

作为守护进程

如过不想让Emacs每次启动都读取配置文件的话,可以以守护进程运行Emacs:

$ emacs --daemon

连接到守护进程:

$ emacsclient -nc

这个命令会创建一个新的frame -c(如果你更喜欢文字模式,使用 -t )并且不会独占终端 -n--no-wait)。 有的程序,如Mutt和Git,(为了提交信息)会等待编辑器完成编辑,所以不能使用 -n 参数。 如果你的默认编辑器是默认使用-n,你需要为那些程序指定一个替代编辑器(比如 emacsclient -a "" -t)。

作为systemd单元

旧的systemd单元方法有一些需要注意的地方。 它给了一个限制shell调用的有限的shell环境,所以我们需要使用一个user单元,它往往比调用emacs --daemon好得多。 为Emacs创建一个systemd单元:

注意: 这样一个单元文件将会包含在Emacs 26.1中, 参见 emacs bug 16507.
~/.config/systemd/user/emacs.service
[Unit]
Description=Emacs: the extensible, self-documenting text editor

[Service]
Type=forking
ExecStart=/usr/bin/emacs --daemon
ExecStop=/usr/bin/emacsclient --eval "(kill-emacs)"
Restart=always

[Install]
WantedBy=default.target

需要启动并启用该单元,以便其在每次电脑启动时启动(请注意 - 请勿“以root运行” - 我们希望它以user,而不是根root user运行):

$ systemctl --user enable --now emacs

请注意,systemd user单元不会从登录shell(例如〜/.bash_profile)继承环境变量,因此你可能需要在〜/.pam_environment中设置变量。有关更多信息,请参见Systemd/User

如启动emacs作为守护程序,你可能会想把VISUALEDITOR环境变量设置为emacsclient,以便启动编辑器的程序使用emacsclient而不是一个完整的编辑器。使用外部编辑器的程序,包括电子邮件程序(用于编辑消息),Git(用于编辑提交消息)和less(用于编辑显示文件的v命令)。 不要对emacsclient使用-n--nowait)选项,因为程序通常要求在编辑器退出时编辑完成。

建议将Emacs的任何GUI开始菜单条目(或等效条目)更改为指向emacsclient而不是emacs,以便使用emacs守护程序而不是启动新的emacs进程。

使用

尽管Emacs很复杂,但了解定制和可扩展性带来的好处并不需要很长时间。此外,已有的各种扩展允许将其转变为针对几乎任何形式的强大文本编辑环境。

Emacs有一个很好的内置教程,可以通过点击启动画面上的第一个链接进行访问; 通过从菜单中选择帮助-> Emacs 教程或按'F1'然后按't'。

Emacs设计为自文档化。 因此,大量的信息可用于确定特定命令的名称或其按键绑定。 使用C-h C-h查看所有当前环境绑定。

Emacs还包含一组参考卡,对初学者和专家都很有用,请参阅/usr/share/emacs/<version>/etc/refcards/(用您的emacs版本替换<version>)。

Emacs为用户提供了大量的功能,其中包括:键盘宏,矩形区域,空白清理,书签,桌面会话,各种shell,拼写检查,表格,语义分析...

手册

如果你真的想要掌握Emacs,最推荐的文档来源仍然是官方手册:

  • Emacs:完整的Emacs用户手册。
  • Emacs 常见问题。
  • Emacs Lisp简介:如果你以前从未使用任何编程语言。
  • Elisp:如果你已经熟悉一门编程语言。

通过内置'info'阅读器,你可以从GNU.org将其作为PDF查看或直接从Emacs本身访问:C-h i。按m选择相应章节。

有些用户更喜欢使用'info'来阅读章节,因为它具有方便的快捷方式,其段落会适应窗口宽度,字体会适应当前屏幕分辨率。有些人觉得这样不那么刺激眼睛。最后,你可以轻松地将章节中的内容复制到任何Emacs缓冲区,甚至可以直接从示例中执行Lisp代码片段。

你可能想要阅读信息手册以了解更多信息:C-h i m info <RET>。 按 ? 在info模式下可以快速查看快捷键列表。

提示和技巧

TRAMP

TRAMP (Transparent Remote Access, Multiple Protocols) ,顾名思义,是一个可以通过很多协议透明访问远程文件的一个扩展。当提示输入文件名时,输入特定的格式就可以使用TRAMPP。比如:

在打开/etc/hosts文件之前提示输入root的密码以获取root权限:

C-x C-f /su::/etc/hosts

要通过SSH使用'you'用户名登录'remotehost'主机打开文件~/example.txt

C-x C-f /ssh:you@remotehost:~/example.txt

TRAMP的路径一般是这种格式'/[protocol]:[[user@]host]:<file>'。

作为用户'you'连接至'myhost'并以sudo编辑/etc/hosts

/ssh:you@remotehost|sudo:remotehost:/etc/hosts

TRAMP支持的不只上面的两个简单例子。请查看Emacs里面的TRAMPP info手册了解更多的信息。

使用Emacs作为git mergetool

默认情况下,Git支持使用Emacs的Emerge模式作为合并工具。但是你可能更喜欢Ediff模式。不幸的是,由于技术原因,这种模式不被git支持。通过在emacs调用时对一些elisp代码赋值,仍然有一种方法可以使用Ediff。

.gitconfig
[mergetool.ediff]
    cmd = emacs --eval \" (progn (defun ediff-write-merge-buffer () (let ((file ediff-merge-store-file)) (set-buffer ediff-buffer-C) (write-region (point-min) (point-max) file) (message \\\"Merge buffer saved in: %s\\\" file) (set-buffer-modified-p nil) (sit-for 1))) (setq ediff-quit-hook 'kill-emacs ediff-quit-merge-hook 'ediff-write-merge-buffer) (ediff-merge-files-with-ancestor \\\"$LOCAL\\\" \\\"$REMOTE\\\" \\\"$BASE\\\" nil \\\"$MERGED\\\"))\" 

[merge]
	tool = ediff

请注意,该命令必须在同一行上。在上面的例子中,我们启动了一个Emacs的新实例。你可能想要使用emacsclient更快地启动; 不建议这样做,因为Ediff调用不是很干净:它可能会打断当前的Emacs会话。

如果你想要一个即时启动,可以使用-q参数。如果想在保留至少一部分配置的情况下快速启动Emacs,则可以这样使用Emacs:

emacs -q -l ~/.emacs-light

light配置文件仅加载Ediff所需的内容。

关于这个技巧的细节和Ediff问题,参见kerneltrap.org[dead link 2017-06-02]stackoverflow

使用大写锁定作为控制键

一些用户喜欢这种个修改,以避免所谓的'emacs pinky'。如果你想在X上试用它,运行

$ setxkbmap -option 'ctrl:nocaps'

或者,交换键值,运行

$ setxkbmap -option 'ctrl:swapcaps'

要永久更改它,请考虑将其添加到.xinitrc文件中。

如果要将一个区域变为大写,只需使用默认的C-x C-u键绑定,调用upcase-region函数。

参见[1]了解另一种方法。

如果缺少Caps Lock功能,请同时将其映射为“Shift”。

$ setxkbmap -option "shift:both_capslock"

某些桌面环境包含图形工具以简化键盘重新映射。 例如,在Plasma 5中打开系统设置并点击输入设备。选择键盘,然后在高级选项卡中会看到Caps Lock设置,可以在其中选择Caps Lock也是一个Ctrl。

键盘宏和寄存器

这一部分会提供一个实用的指南来使用一些更强大的编辑特性。也就是“键盘宏”和“寄存器”。

我们的目标是产生一个字符列表和它们在这个列表中对应的位置。虽然这可以通过手工格式化来完成,但是这样会很慢而且容易出错。如果我们采用一些Emacs更高级的编辑功能却可以起到四两拨千斤的功效。在介绍这个方法之前,需要先了解一些技术背后的细节。

要介绍的第一个特性就是寄存器。寄存器的功能是用来保存和获取各种各样的数据。每个寄存器用一个字母来命名,这个字母就是用来调用这个寄存器的。

另一个要介绍的就是键盘宏。一个键盘宏存储了一个命令序列以便以后可以重复使用。下面就一步一步地讲解这个方法。

首先我们从一个包含如下字符的缓冲区开始:

ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz

通过`number-to-register' 命令 (C-x r n)我们来准备一个寄存器,把数字'0'存储在寄存器'k'中:

C-x r n k

当光标在缓冲区开头的时候,开始录制键盘宏 (C-x () 然后开始对字符串进行格式化:

C-x ( C-f M-4 .

插入 (C-x r i) 然后将寄存器'k'加1 (C-x r +) 。开头的 (C-u) 命令是用来在插入文字之后让光标移到插入的文字后面:

C-u C-x r i k C-x r + k

最后我们来插入一个回车来结束格式化。Emacs可以重复以上过程,从我们定义键盘宏的位置开始,直到最后一个字符。C-x e命令停止宏的录制并开始执行这段宏。开头的 M-0 命令是用来让宏在出错的时候停下来,这样在它走到这行的结尾就会停下来。

<RET> M-0 C-x e

下面是结果:

 A....0
 B....1
 C....2
 [...]
 x....49
 y....50
 z....51

正则表达式

From the Emacs Manual: "A regular expression, or regexp for short, is a pattern that denotes a (possibly infinite) set of strings." This section will not go into any detail regarding regular expressions themselves (as there is simply too much to cover). It will however provide a quick demonstration of their power. See Regular Expressions section in the Emacs Manual for further reading.

Given the same scenario presented above: A list of characters which are to be formatted to represent their respective position in the list. (see Keyboard macros and registers[broken link: invalid section]). Again, starting with a buffer containing.

ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz

At the beginning of the buffer, use C-M-% (if the key-sequence is difficult to perform, it may be more comfortable to use M-x query-replace-regexp). At the prompt:

\(.\)

which simply matches one character. Then, when prompted for the replacement:

\1....\#^J
Note: '^J' represents where a newline should be placed, it should not be entered into the prompt. The newline must instead be inserted literally using C-q C-j.

The replacement expression reads: "Insert the matched text between the first set of parentheses (in this case, a single character), followed by 4 periods then insert an automatically incremented number followed by a newline.

Finally, press ! to apply this across the entire buffer. All of the formatting that was performed in the previous section was performed with a single regexp replacement.

定制

Emacs能通过~/.emacs或者M-x customize来定制。本段落将着眼于手动定制 ~/.emacs,并且提供了一些常用配置的样例。配置命令提供了一个适应的途径,通过它你能够渐渐熟悉Emacs。

这里的所有例子都能在Emacs中奏效。比如,在Emacs中计算表达式: C-M-x 同时指到任何需要求值的地方。

或者

C-x C-e 指到最后的“)”。

用'y'和'n'来代替频繁地输入'yes’和'no‘是一个好的方法:

(defalias 'yes-or-no-p 'y-or-n-p)

取消光标闪烁:

(blink-cursor-mode -1)

类似地,开启上一节提到的列号模式:

(column-number-mode 1)

它们两者之间的相似不是偶然:光标闪烁模式和列号模式都是'副参模式',按照规则,'副参模式’能通过正负值来设置。如果参数省略,'副参模式'将被开/关。

这里有其他一些'副参模式'的例子,下面的参数将会关闭滚动栏、菜单栏、工具栏。

(scroll-bar-mode -1)
(menu-bar-mode -1)
(tool-bar-mode -1)

变量'auto-mode-alist'修改之后能够改变默认的“主参模式”。下面的例子把'.tut'和'.req'修改成了'.text-mode'。

(setq auto-mode-alist
  (append
    '(("\\.tut$" . text-mode)
      ("\\.req$" . text-mode))
    auto-mode-alist))

Settings can also be applied on a per-mode basis. A common method for this is to add a function to a hook. For example, to force indentation to use spaces instead of tabs, but only in text-mode:

(add-hook 'text-mode-hook (lambda () (setq indent-tabs-mode nil)))

Similarly, to only use spaces for indentation everywhere:

(setq-default indent-tabs-mode nil)

Keybindings can be adjusted in two ways. The first of which is 'define-key'. 'define-key' creates a keybinding for a command but only in one mode. The example below will make F8 delete any whitespace from the end of each line of a 'text-mode' buffer:

(define-key text-mode-map (kbd "<f8>") 'delete-trailing-whitespace)

The other method is 'global-set-key'. This is used to bind a key to a command everywhere. To bind 'query-replace-regexp' (C-M-%) to '<f7>'.

(global-set-key (kbd "<f7>") 'query-replace-regexp)

Binding a command to an alternate key does not replace any existing bindings. Which is to say, 'query-replace-regexp' would be bound to both F7 and C-M-% after the above example.

Almost anything within Emacs can be configured. Browsing through the Emacs Wiki should give a solid place to start.


多种配置

你可以使用少量配置然后告诉Emacs来加载其他配置。

例如,我们来定义两个配置文件。

.emacs
(load "~/.emacs.d/main" nil t)
(load "~/.emacs.d/functions" nil t)
(load "~/.emacs.d/modes" nil t)
(load "~/.emacs.d/plugins" nil t)
(load "~/.emacs.d/theme" nil t)

这是我们在后台载入的完整配置。但是plugins文件太大导致载入太慢,如果我们要打开一个新的Emacs窗口,可能就不会使用plugins配置,每次加载它实在是太笨重了。

.emacs-light
(load "~/.emacs.d/main" nil t)
(load "~/.emacs.d/functions" nil t)
(load "~/.emacs.d/modes" nil t)
(load "~/.emacs.d/theme" nil t)

现在我们这样来加载Emacs:

emacs -q -l ~/.emacs-light

你可以为这个命令创建一个别名。

加载扩展程序

你能用require来加载扩展程序,例如这样:

(require 'mediawiki)

如果你试着在一个买有安装mediawiki的机器上使用相同的配置,Emacs会提示错误。并且,所有制定的扩展代码都会失效。

一个小的技巧是测试require的返回值。

(if (require 'mediawiki nil t)
    (progn
      (setq mediawiki-site-alist '(
             ("ArchLinux" "https://wiki.archlinux.org/" "UserName" "" "Main Page")
             )
           )
      (setq mediawiki-mode-hook
            (lambda ()
              (visual-line-mode 1)
              (turn-off-auto-fill)
              ))
 ))

Local and custom variables

You can define variables in your configuration file that can be later one modified locally for a file.

(defcustom my-compiler "gcc" "Some documentation")

Now in any file you can define local variables in two ways:

  • On the very first line, write
// -*- my-compiler:g++; mode:c++ -*-
  • If you cannot (or do not want to) write this on the first line, you can put it at the end:
// Local Variables:
// my-compiler: g++
// mode: c++
// End:

Note that the beginning characters need to be comments for the current language, that's why here we used two backslashes for C++. For Elisp you would use

;; -*- mode:emacs-lisp -*-

There is two functions that may help you in defining the variables: add-file-local-variable and add-file-local-variable-prop-line.

Finally, custom variable are considered insecure by default. If you try to open a file that contains local variable redefining insecure custom variables, Emacs will ask you for confirmation.

If you know what you are doing, you can declare the variable as secure, thus removing the Emacs prompt for confirmation. You need to specify a predicate that any new value has to verify so that it can be considered safe.

(defcustom my-compiler "gcc" "Some documentation" :safe 'stringp)

In the previous example, if you attempt to set anything else than a string, Emacs will consider it insecure.

Custom colors and theme

Colors can be easily customized using the face facility.

(set-face-background  'region                 "color-17")
(set-face-foreground  'region                 "white")
(set-face-bold-p      'font-lock-builtin-face t ) 

You can have let Emacs tell you the name of the face where the point is. Use the customize-face function for that. The facility will show you how to set colors, bold, underline, etc.

Emacs in console can handle 256 colors, but you will have to use an appropriate terminal for that. For instance URxvt has support for 256 colors. You can use the list-colors-display for a comprehensive list of supported colors. This is highly terminal-dependent.

SyncTeX support

Emacs is definitely one of the most powerful LaTeX editor. This is mostly due to the fact you can adapt or create a LaTeX mode to fit your needs best.

Still, there might be some challenges, like SyncTeX support. First you need to make sure your TeX distribution has it. If you installed TeX Live manually, you may need to install the synctex package.

# umask 022 && tlmgr install synctex

SyncTeX support is viewer-dependent. Here we will use Zathura as an example, so the code needs to be adapted if you want to use another PDF viewer.

(defcustom tex-my-viewer "zathura --fork -s -x \"emacsclient --eval '(progn (switch-to-buffer  (file-name-nondirectory \"'\"'\"%{input}\"'\"'\")) (goto-line %{line}))'\"" 
  "PDF Viewer for TeX documents. You may want to fork the viewer
so that it detects when the same document is launched twice, and
persists when Emacs gets closed.

Simple command:

  zathura --fork

We can use

  emacsclient --eval '(progn (switch-to-buffer  (file-name-nondirectory \"%{input}\")) (goto-line %{line}))'

to reverse-search a pdf using SyncTeX. Note that the quotes and double-quotes matter and must be escaped appropriately."
:safe 'stringp)

Here we define our custom variable. If you are using AucTeX or Emacs default LaTeX-mode, you will have to set the viewer accordingly.

Now open a LaTeX source file with Emacs, compile the document, and launch the viewer. Zathura will spawn. If you press Ctrl+Left click Emacs should place the point at the corresponding position.

Documentation

You may find yourself overwhelmed by the amount of Emacs features. You may find it difficult to know how to use Emacs Lisp to customize your favorite modes, or even to create your own modes / packages. Thankfully Emacs takes a strong point to auto-documenting everything: its internals, current configuration, bindings, etc. Almost everything is documented.

Contextual help

Emacs is self-documenting by design. As such, a great deal of information is available to determine the name of a specific command or its keybinding, for example. The following is a listing of some of the most helpful of these:

C-h a        Find a command matching a description.
C-h b        List all active keybindings.
C-h f        Describe the given function.
C-h k        Find which command a key is bound to.
C-h m        Display information regarding the currently active modes.
C-h t        Start the Emacs tutorial.
C-h v        Describe the given variable.
C-h w        Find which key(s) a command is bound to.

拓展模块

虽然Emacs包含了成百上千种模式(mode),库和其它扩展,还有更多的扩展来增强Emacs。大多数扩展会详细说明安装它的时候要对~/.emacs作什么改动。这些说明一般会在一个elisp源文件开头的注释中,或者在一个README中(如果这个扩展包含了多个源文件)。

在'community'仓库中有很多流行的扩展,更多的扩展还放在了AUR。这些软件包的名字有一个'emacs-'前缀(比如emacs-lua-mode)。在很多情况下,在安装的过程会显示怎样修改~/.emacs以安装该扩展到Emacs中。

想知道怎样激活一个不在上面提到的地方的扩展,查看Emacs Wiki中的相应页面,一般会提供一个配置的例子。Emacs Wiki也是一个寻找扩展的优秀资源。

你也可以使用Emacs Lisp Package Archive (ELPA) 来自动安装软件包。打开那个网站看说明。ELPA已经包括在了Emacs24中;它已经作为Emacs生态系统中的一部分了。

疑难杂症

彩色输出的问题

Emacs默认使用原生的转义串来输出颜色。也就是说,它会在要显示颜色的地方显示奇怪的字符。

~/.emacs中加入下面的代码解决这个问题:

(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)

菜单显示为空

一些菜单显示为空,这是GNU Emacs 23.1的一个bug(使用GTK toolkit的时候)。好像在Emacs的CVS trunk中已经修复了。对应的Debian bug report 有一个应对措施。

X 窗口下的字符显示问题

当你使用X窗口启动emacs时,如果发现主窗口中的所有字符都是黑框白块(就像你没有安装正确的字体看到的字符一样),那么你需要安装 xorg-fonts-75dpi 或者 xorg-fonts-100dpi 并且重启X窗口。

启动速度慢

启动速度慢经常是由下面两种情况引起的。

要确定是哪种情况,这样打开Emacs:

$ emacs -q

如果Emacs还是启动很慢,则是错误的网络配置[broken link: invalid section]。如果不是,则可以确定是.emacs的问题[broken link: invalid section]

错误的网络配置

当启动Emacs的时候,一些错误,特别是在/etc/hosts中的,经常会导致5秒以上的延迟。在网络配置指南中查看'set the hostname' 了解更多内容。

初始化文件加载慢

一个很简单的方法查找原因是注释掉(比如在行开头使用';')你的~/.emacs(或者~/.emacs.d/init.el)里面可疑的地方,然后再启动Emacs,看速度是否有改善。记住,使用"require"和"load"会减慢启动速度,特别是用在很大的插件上。一般来说,他们应该用在当目标是Emacs启动的时候就需要或者提供仅仅是一个扩展的"autoloads"。否则,直接使用'autoload'函数。比如,不是这样:

(require 'anything)

你应该这样:

(autoload 'anything "anything" "Select anything" t)

不能打开配置文件: ...

这个错误最常见的原因是'load-path'变量没有包含某些插件的目录。要解决这个问题,在加载插件前,把需要加载的插件目录加入到要搜索的list中:

 (add-to-list 'load-path "/path/to/directory/")

当尝试使用一个插件的包,而这个包又被Emacs加上了非'/usr'的前缀时,load-path需要更新。把下面的代码放到使用这个插件的包的代码的前面:

 (add-to-list 'load-path "/usr/share/emacs/site-lisp")

如果手动编译Emacs,记住默认的前缀是'/usr/local'。

Dead-accent keys problem: '<dead-acute> is undefined'

Searching about this bug on Google, we find this link: http://lists.gnu.org/archive/html/help-gnu-emacs/2009-05/msg00167.html

Explaining the problem: in recent versions of b72

Emacs, the normal way to use accent keys doesn't work as expected. Trying to accent a word like 'fiancé' will produce the message above.

A way to solve it is just put the line above on your startup file, ~/.emacs:

  (require 'iso-transl)

And no, it isn't a bug, but a feature of new Emacs versions. Reading the subsequent messages about it on the mail list, we found it (http://lists.gnu.org/archive/html/help-gnu-emacs/2009-05/msg00179.html):

It seems that nothing is loaded automatically because there is a choice betwee iso-transl and iso-acc. Both seem to provide an input method with C-x 8 or Alt-<accent> prefix, but what you and I are doing is just pressing a dead key (^, ´, `, ~, ¨) for the accent and then another key to "compose" the accented character. And there is no Alt key used in this! And according to documentation it seems be appropriate for 8-bit encodings, so it should be pretty useless in UTF-8. I reported this bug when it was introduced, but the bug seems to be

a3b

classified as a feature ... Maybe it's just because the file is auto-loaded though pretty useless. 

C-M-% and some other bindings do not work in emacs nox

This is because terminals are more limited than Xorg. Some terminals may handle more bindings than other, though. Two solutions:

  • either use the graphical version,
  • or change the binding to a supported one.

Example:

.emacs
(global-set-key (kbd "C-M-y") 'query-replace-regexp)

Emacs client gets stuck when switching back to it

If you are using Emacs daemon, then you should know that input is blocking. If one Emacs instance is in the minibuffer (after an M-x for instance), then all other instance will wait for it to finish. Press C-g to cancel any input to make sure this Emacs session is not blocking.

Emacs-nox output gets messy

When working in a terminal, the color, indentation, or anything related to the output might become crazy. This is (probably?) because Emacs was sent a special character at some point which may conflict with the current terminal. There is not much to be done but restarting emacs. If someone has a workaround or a more detailed explanation on the issue, feel free to contribute.

Graphical Emacs does not suffer from this issue.

Shift + Arrow keys not working in emacs within tmux

First you must enable xterm-keys in your tmux config.

.tmux.conf
setw -g xterm-keys on

But, this will break other key combinations. To fix them, put the following in your emacs config.

.emacs
;; handle tmux's xterm-keys
;; put the following line in your ~/.tmux.conf:
;;   setw -g xterm-keys on
(if (getenv "TMUX")
    (progn
      (let ((x 2) (tkey ""))
	(while (<= x 8)
	  ;; shift
	  (if (= x 2)
	      (setq tkey "S-"))
	  ;; alt
	  (if (= x 3)
	      (setq tkey "M-"))
	  ;; alt + shift
	  (if (= x 4)
	      (setq tkey "M-S-"))
	  ;; ctrl
	  (if (= x 5)
	      (setq tkey "C-"))
	  ;; ctrl + shift
	  (if (= x 6)
	      (setq tkey "C-S-"))
	  ;; ctrl + alt
	  (if (= x 7)
	      (setq tkey "C-M-"))
	  ;; ctrl + alt + shift
	  (if (= x 8)
	      (setq tkey "C-M-S-"))

	  ;; arrows
	  (define-key key-translation-map (kbd (format "M-[ 1 ; %d A" x)) (kbd (format "%s<up>" tkey)))
	  (define-key key-translation-map (kbd (format "M-[ 1 ; %d B" x)) (kbd (format "%s<down>" tkey)))
	  (define-key key-translation-map (kbd (format "M-[ 1 ; %d C" x)) (kbd (format "%s<right>" tkey)))
	  (define-key key-translation-map (kbd (format "M-[ 1 ; %d D" x)) (kbd (format "%s<left>" tkey)))
	  ;; home
	  (define-key key-translation-map (kbd (format "M-[ 1 ; %d H" x)) (kbd (format "%s<home>" tkey)))
	  ;; end
	  (define-key key-translation-map (kbd (format "M-[ 1 ; %d F" x)) (kbd (format "%s<end>" tkey)))
	  ;; page up
	  (define-key key-translation-map (kbd (format "M-[ 5 ; %d ~" x)) (kbd (format "%s<prior>" tkey)))
	  ;; page down
	  (define-key key-translation-map (kbd (format "M-[ 6 ; %d ~" x)) (kbd (format "%s<next>" tkey)))
	  ;; insert
	  (define-key key-translation-map (kbd (format "M-[ 2 ; %d ~" x)) (kbd (format "%s<delete>" tkey)))
	  ;; delete
	  (define-key key-translation-map (kbd (format "M-[ 3 ; %d ~" x)) (kbd (format "%s<delete>" tkey)))
	  ;; f1
	  (define-key key-translation-map (kbd (format "M-[ 1 ; %d P" x)) (kbd (format "%s<f1>" tkey)))
	  ;; f2
	  (define-key key-translation-map (kbd (format "M-[ 1 ; %d Q" x)) (kbd (format "%s<f2>" tkey)))
	  ;; f3
	  (define-key key-translation-map (kbd (format "M-[ 1 ; %d R" x)) (kbd (format "%s<f3>" tkey)))
	  ;; f4
	  (define-key key-translation-map (kbd (format "M-[ 1 ; %d S" x)) (kbd (format "%s<f4>" tkey)))
	  ;; f5
	  (define-key key-translation-map (kbd (format "M-[ 15 ; %d ~" x)) (kbd (format "%s<f5>" tkey)))
	  ;; f6
	  (define-key key-translation-map (kbd (format "M-[ 17 ; %d ~" x)) (kbd (format "%s<f6>" tkey)))
	  ;; f7
	  (define-key key-translation-map (kbd (format "M-[ 18 ; %d ~" x)) (kbd (format "%s<f7>" tkey)))
	  ;; f8
	  (define-key key-translation-map (kbd (format "M-[ 19 ; %d ~" x)) (kbd (format "%s<f8>" tkey)))
	  ;; f9
	  (define-key key-translation-map (kbd (format "M-[ 20 ; %d ~" x)) (kbd (format "%s<f9>" tkey)))
	  ;; f10
	  (define-key key-translation-map (kbd (format "M-[ 21 ; %d ~" x)) (kbd (format "%s<f10>" tkey)))
	  ;; f11
	  (define-key key-translation-map (kbd (format "M-[ 23 ; %d ~" x)) (kbd (format "%s<f11>" tkey)))
	  ;; f12
	  (define-key key-translation-map (kbd (format "M-[ 24 ; %d ~" x)) (kbd (format "%s<f12>" tkey)))
	  ;; f13
	  (define-key key-translation-map (kbd (format "M-[ 25 ; %d ~" x)) (kbd (format "%s<f13>" tkey)))
	  ;; f14
	  (define-key key-translation-map (kbd (format "M-[ 26 ; %d ~" x)) (kbd (format "%s<f14>" tkey)))
	  ;; f15
	  (define-key key-translation-map (kbd (format "M-[ 28 ; %d ~" x)) (kbd (format "%s<f15>" tkey)))
	  ;; f16
	  (define-key key-translation-map (kbd (format "M-[ 29 ; %d ~" x)) (kbd (format "%s<f16>" tkey)))
	  ;; f17
	  (define-key key-translation-map (kbd (format "M-[ 31 ; %d ~" x)) (kbd (format "%s<f17>" tkey)))
	  ;; f18
	  (define-key key-translation-map (kbd (format "M-[ 32 ; %d ~" x)) (kbd (format "%s<f18>" tkey)))
	  ;; f19
	  (define-key key-translation-map (kbd (format "M-[ 33 ; %d ~" x)) (kbd (format "%s<f19>" tkey)))
	  ;; f20
	  (define-key key-translation-map (kbd (format "M-[ 34 ; %d ~" x)) (kbd (format "%s<f20>" tkey)))

	  (setq x (+ x 1))
	  ))
      )
  )

替代方案

有很多Emacs的实现。GNU/Emacs 可能是最受欢迎的了。
更轻量的兼容性较好的Emacs可以在Arch仓库或在AUR中找到。

mg

mg(原来叫MicroGnuEmacs),是用C语言实现的轻量级Emacs。

mgofficial repositories 中,也可以从上游下载源码page。注意,mg 没有UTF-8支持。

zile

引用官方网站page的描述,"GNU Zile is a lightweight Emacs clone. Zile is short for Zile Is Lossy Emacs. Zile has been written to be as similar as possible to Emacs; every Emacs user should feel at home.",意思是'GNU Zile'是一个轻量级的Emacs的克隆。Zile是'Zile Is Lossy Emacs'的缩写。 Zile的实现与Emacs如此相似以至于每个Emacs用户使用Zile一定会有一种宾至如归的感觉。

zile 可以在官方仓库中找到。

最新的tarball可以在GNU的官方源mirrors中找到。

uemacs

uemacs 是由Linus Torvalds定制的微型Emacs版本。在 AUR 中名为uemacs-gitAUR

remacs

remacs 是一个用Rust写成的社区驱动的Emacs移植版。在 AUR 中名为 remacs-gitAUR

资源