在使用emacs编辑文件时,经常会出现文件缓冲区被修改的情况(当然啦!)。在退出前,emacs会询问是否保存更改。现在很有趣的是想知道实际上发生了什么变化。有没有办法找出来呢?
在使用emacs编辑文件时,经常会出现文件缓冲区被修改的情况(当然啦!)。在退出前,emacs会询问是否保存更改。现在很有趣的是想知道实际上发生了什么变化。有没有办法找出来呢?
从Emacs 22.1版本开始(至少如此),'save-buffers-kill-emacs
(默认绑定为C-x C-c)会提示您保存每个未保存的带有文件的缓冲区。当提示时,键入d以保存并查看差异。
来自帮助文档:
Save some modified file-visiting buffers. Asks user about each one.
You can answer `y' to save, `n' not to save, `C-r' to look at the
buffer in question with `view-buffer' before deciding or `d' to
view the differences using `diff-buffer-with-file'.
如果您查看提示,它应该会显示类似于:
Save file /path/to/file.txt? (y, n, !, ., q, C-r, d, or C-h)
输入 C-h 将会给你提供更详细的描述(但是你所要的是 d):
Type SPC or `y' to save the current buffer;
DEL or `n' to skip the current buffer;
RET or `q' to give up on the save (skip all remaining buffers);
C-g to quit (cancel the whole command);
! to save all remaining buffers;
C-r to view this buffer;
d to view changes in this buffer;
or . (period) to save the current buffer and exit.
我使用 diff-buffer-with-file 命令,并选择与缓冲区对应的文件(这是此命令的默认设置...只需按回车键即可)。
您也可以使用 highlight-changes-mode,但是除非您启用它,否则它不会跟踪更改,因此如果您想要在关闭未处于此模式的文件时查看更改内容,则不太有用 :-)
您可以启用 highlight-changes-mode
。它会将所有更改以红色显示。但它不会显示空格的更改,只会用红色的 _
标记删除。另请参见http://www.emacswiki.org/emacs/TrackChanges。
;; higlight changes in documents
(global-highlight-changes-mode t)
(setq highlight-changes-visibility-initial-state nil); initially hide
当您想查看更改内容时,请切换 highlight-changes-visible-mode。