Emacs缓冲区撤销限制

7
当我向标准输出打印大量内容时,在我的matlab-shell缓冲区中出现了此警告:
Warning (undo): Buffer `*MATLAB*' undo info was 12268000 bytes long.
The undo info was discarded because it exceeded `undo-outer-limit'.

This is normal if you executed a command that made a huge change
to the buffer.  In that case, to prevent similar problems in the
future, set `undo-outer-limit' to a value that is large enough to
cover the maximum size of normal changes you expect a single
command to make, but not so large that it might exceed the
maximum memory allotted to Emacs.

我的Emacs长这样: enter image description here

我真的不需要在右边的 matlab-shell 缓冲区中使用撤销。有没有办法禁用这个警告?请注意,左侧的缓冲区是一个 MATLAB 脚本,这意味着其主模式是 MATLAB,当然不应该禁用撤销功能。


MATLAB” 的缓冲区处于哪种模式下?我可以看到较浅的文本是 “M-Shell”。我猜它是一个 matlab-shell-mode,但如果你使用 C-h m 那么你就能告诉我们了。 - phils
@phils,你的猜测是正确的。这是 matlab-shell 模式。左边和右边的模式不同吗? - rowman
它们是不同的吗?嗯,一个是模式,以帮助编辑特定语言的源代码,另一个是与外部正在运行的进程进行交互的模式。尽管两者都与MATLAB有关,但这两种活动几乎没有共同点。 - phils
@phils,谢谢。我不明白右侧缓冲区中的star_MATLAB_star是什么意思。它与MATLAB模式有关吗? - rowman
不,那是缓冲区的名称,就像“frequency_response.m”是左窗口中缓冲区的名称一样。访问文件的缓冲区以它们正在访问的文件命名(但如果您打开多个具有相同文件名的文件,则会进行唯一化处理)。像*MATLAB*这样的非文件缓冲区通常具有以星号开头和结尾的名称(我实际上不确定这是否是一项记录在案的惯例,但显然旨在防止与实际文件的命名冲突)。 - phils
2个回答

13

如同那个警告信息所说(或者曾经说过?):

您可以通过将条目(undo discard-info)添加到warning-suppress-types用户选项中以禁用此缓冲区的弹出, 该选项在warnings库中定义。

也就是说:

(add-to-list 'warning-suppress-types '(undo discard-info))

(当然,这只会禁用警告,而不是撤消数据收集本身。)


7

您的问题不太明确,但是假设您想表达的是在此缓冲区中没有需要撤消的内容,那么您可以按缓冲区禁用撤消系统:

buffer-disable-undo is an interactive compiled Lisp function in `simple.el'.

(buffer-disable-undo &optional BUFFER)

Make BUFFER stop keeping undo information.
No argument or nil as argument means do this for the current buffer.

所以,您可以交互式地调用M-x buffer-disable-undo RET,或者如果您确信,您可以将其添加到涉及的模式的挂钩函数中。 编辑: 考虑到问题评论中的额外信息,我建议如下操作:
(add-hook 'matlab-shell-mode-hook 'buffer-disable-undo)

我更新了问题。buffer-disable-undo 部分回答了这个问题。 - rowman

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接