Emacs - require-final-newline local value overrides global value

nha*_*nha 3 emacs emacs24 emacs-prelude

I want to set the require-final-newline for every buffer to nil. In my config file, I have :

(setq require-final-newline nil)
(setq-default require-final-newline nil)
Run Code Online (Sandbox Code Playgroud)

It appears to set the global value correctly. However in every buffer that I open, the local value is still t. Using describe-variable, I get :

require-final-newline is a variable defined in `files.el'.
Its value is t
Original value was nil
Local in buffer myfile.js; global value is nil
Run Code Online (Sandbox Code Playgroud)

files.el is in /usr/local/Cellar/emacs/24.5/share/emacs/24.5/lisp/, so I guess I should not modify it. How do I set this local value to nil ?

phi*_*ils 6

首先,有一些模式require-final-newline基于这些类型的文件需要最后的换行符而强制设置。js-mode然而,我不相信是其中之一。

大概您有一些导致此问题的自定义配置,可能是通过js-mode-hook或设置的prog-mode-hook

确认有emacs -Q这不是默认行为,然后你就可以着手追查元凶(我只想M-x rgreprequire-final-newline你的elisp的文件)。