Tue
26 Oct 2004
2:41 pm
Emacs require-final-newline on fedora: How to kill it!
Posted by shimon under computers/Unix/emacs , kind of writing/tipsI have been annoyed that emacs21 on a fedora core 2 machine keeps asking me:
(This file) does not end in newline. Add one?
Of course I don't want to add one. If I wanted to add a new line I'd just hit Alt-Shift-. Enter like every sane person. Right? Shut up, emacs.
OK, simple enough. Just set require-final-newline to nil. Just put that setting into my .emacs file.
This didn't work: (setq require-final-newline nil)
This also didn't work: (setq-default require-final-newline nil)
Using emacs' own customization system, it still didn't work. I could set the variable in a session, but after quitting and starting again the setting didn't stick.
I started to worry. Then I tracked it down.
The non-nil setting comes from /usr/share/emacs/site-lisp/default.el. This apparently runs after your .emacs and, on FC2, sets require-final-newline to 'query. So to stop this atrocity, you have two options:
-
Become root, and edit /usr/share/emacs/site-lisp/default.el.
-
Avoid running this silly default.el file by putting into your .emacs:
(setq inhibit-default-init t)
I chose the latter option. Perhaps this post will help future Google searchers do the right thing even faster.
Full Entries RSS
August 28th, 2006 at 5:05 pm
Hi,
Thanks!
Drove me nuts!
Raanan
September 29th, 2006 at 1:20 pm
Just wanted to say thanks for this — it’s solved exactly the same annoyance for me
November 2nd, 2006 at 4:09 pm
Yep. Thanks.
December 26th, 2006 at 6:22 pm
Thanks alot!
I can’t belive they had it run after my .emacs, how rude!
January 17th, 2007 at 11:44 am
Thanks, I ran into the same problem with RHEL.
June 13th, 2007 at 8:40 pm
Thank you. This newline query was driving me crazy.
July 18th, 2007 at 12:43 pm
Thank you. Who ever made this decision should have their ass kicked.
July 27th, 2007 at 8:40 pm
Thank you!
September 18th, 2007 at 12:02 pm
Thank you sooo much! -Pinaki
September 21st, 2007 at 9:16 am
“Me Too”.
Cheers,
Aas (this comment does not end with a newline)
September 28th, 2007 at 3:06 pm
thanks++
October 18th, 2007 at 3:45 pm
Many thanks!
November 16th, 2007 at 3:35 pm
A reader emailed the following alternative:
(I’m leaving his name off, because it’s unclear whether he wanted to remain anonymous… but if you’re the author and want credit, let me know and I’ll edit this comment. Either way, thanks very much!)
Hi,
Just saw the post below and thought you might like to know that there
is a third way (without the drawbacks) - in your .emacs, add this:
;; ensure we do this *after* default.el is loaded!
(add-hook ‘after-init-hook
‘(lambda ()
(setq require-final-newline nil)))