Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emacs automatically adding a newline even after changing .emacs

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.
 )
like image 446
Jayson Avatar asked Nov 26 '12 22:11

Jayson


1 Answers

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).

like image 172
Trey Jackson Avatar answered Oct 22 '22 04:10

Trey Jackson