I'm currently on a mac and am trying to set Emacs to not add a newline at the end of a file by default, but pretty much everything I search for says to just add (setq require-final-newline nil) to the .emacs file in the home directory... This does not work. What should I be looking at next to change?
This is what the .emacs file looks like right now
(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.
)
Have you tried:
(setq mode-require-final-newline nil)
It is possible the major mode for the file is using the value of this variable instead...
It's not immediately obvious how to find out what modes use this instead of the variable you tried, but presumably the writer of that mode knows better...
So, it's possible you might want to change the major mode for that file, which can be accomplished by the answer to this SQ question: How to tell emacs to open .h file in C++ mode? (obviously customzinging the answer to suit your need).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With