即使在更改.emacs之后,Emacs也会自动添加换行符

时间:2012-11-26 22:54:01

标签: emacs text-editor

我目前正在使用Mac,并且我正在尝试将Emacs设置为默认情况下不在文件末尾添加换行符,但我搜索的几乎所有内容都表示只是添加(setq require-final-newline nil)到主目录中的.emacs文件...这不起作用。我接下来要改变什么呢?

这就是.emacs文件现在的样子

(custom-set-variables
  ;; custom-set-variables was added by Custom.
  ;; If you edit it by hand, you could mess it up, so be careful.
  ;; Your init file should contain only one such instance.
  ;; If there is more than one, they won't work right.
 '(gud-gdb-command-name "gdb --annotate=1")
 '(large-file-warning-threshold nil)
 '(require-final-newline nil))
(custom-set-faces
  ;; custom-set-faces was added by Custom.
  ;; If you edit it by hand, you could mess it up, so be careful.
  ;; Your init file should contain only one such instance.
  ;; If there is more than one, they won't work right.
 )

1 个答案:

答案 0 :(得分:15)

你试过了吗?

(setq mode-require-final-newline nil)

文件的主要模式可能是使用此变量的值而不是......

如何找出使用此模式而不是您尝试的变量并不是很明显,但可能是该模式的作者更了解...

因此,您可能希望更改该文件的主要模式,这可以通过此SQ问题的答案来完成:How to tell emacs to open .h file in C++ mode?(显然可以根据您的需要定制答案)。