暂时禁用在Emacs中添加换行符 [英] Temporarly disable adding of newlines in Emacs
问题描述
我启用了 require-final-newline
,因为我通常希望Emacs在我的文件中添加换行符。但是在某些情况下,我希望Emacs 删除换行符(如编辑不应该生成换行符的yasnippet时,请参阅emacs + latex + yasnippet:为什么插入片段后的换行符)。
I've enabled require-final-newline
, because I usually want Emacs to add newlines to my files where it's missing. But there are some cases, where I want Emacs to remove the newline (like when editing a yasnippet that should not produce a newline, see emacs + latex + yasnippet: Why are newlines inserted after a snippet?).
有没有办法暂时实现这一点(如启用某种模式或某种东西),而无需更改 .emacs
并重新启动Emacs?
Is there a way to achieve this temporarly (like enabling a mode or something), without having to change .emacs
and restarting Emacs?
推荐答案
除了@eldrich所提及的内容之外,您可以在给定的缓冲区中本地设置其值。将这样的东西放在模式挂钩上,以给定模式关闭它:
In addition to what @eldrich mentioned, you can set its value locally in a given buffer. Put something like this on a mode hook, to turn it off for a given mode:
(defun foo () (set (make-local-variable 'require-final-newline) nil))
(add-hook 'some-mode-hook 'foo)
这篇关于暂时禁用在Emacs中添加换行符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!