Hour 5: Recovering from Errors
"Undo commands of Emacs are commands that later can be undone themselves."
一个undo的例子
插入1,2,3,4,每行一个

undo两次

插入5

然后undo一次,你会看到5被撤销掉了,当你插入5时,undo序列被打断,继续undo会添加3,4

自动备份
关于备份:备份只会发生在eamcs打开文件时的第一次保存
There are two different ways Emacs can do these backups:
- Single backup--In this mode only one backup is kept of the file. When you edit the file for the second time in Emacs, the first backup is overwritten. The filename used for the backup is the original filename with a tilde (~) appended to the end of the file. (This is the default.)
- Numbered backup--In this mode, each new backup is numbered consecutively; thus, you might have several backups of the same file. The filename used for the backups is the original with .~42~ appended (for the 42nd backup of the file).
(setq make-backup-files t)
(setq version-control 'never)
Finally, if you want Emacs to make numbered backups, you must insert the following lines into your .emacs file:
(setq make-backup-files t)
(setq version-control t)
Configuring Numbered Backups
为了避免磁盘空间充斥着备份文件,emacs提供了两个变量用于配置
kept-old-versions 缺省值为2 Emacs在创建一个新的编号备份时将为文件保留的最老版本的个数
kept-new-versions 缺省值为2 Emacs在创建一个新的编号备份时将为文件保留的最新版本的个数
示例配置:
(setq kept-old-versions 1)
(setq kept-new-versions 5)
Keeping All the Backup Files in One Directory
从sams的cd里把backup-dir拷出来,在.emacs里加入
(require 'backup-dir)
(setq bkup-backup-directory-info
'((t "/home/blackie/.backups" ok-create full-path)))
Recovering from a Crash
Recovering an Autosave File
使用M-x 然后键入recover-file


写yes即可
Recovering Sessions
如果在事故前编辑了许多文件,这就需要用recover-session来帮助整个的恢复工作了,能够减轻负担
Press M-x and
type recover-session. Emacs now shows you a list of all the session files, sorted by date

In this buffer, you can
press Enter on top of a session to see which files it contains

To get back to the session buffer, simply kill
the buffer with the information about the session. You do this by pressing C-x
k (kill-buffer) and pressing the Enter key.


yes即可

本文介绍了Emacs编辑器中的错误恢复机制,包括撤销命令的使用及特点;详细讲解了两种备份模式:单一备份和编号备份,以及如何配置备份设置;还介绍了如何从崩溃中恢复未保存的工作,包括自动保存文件的恢复方法。
931

被折叠的 条评论
为什么被折叠?



