unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* problem with require-final-newline
@ 2004-05-13 17:43 Charles Jamieson
  2004-05-13 23:07 ` Kevin Rodgers
  2004-05-14  7:20 ` Alan Mackenzie
  0 siblings, 2 replies; 3+ messages in thread
From: Charles Jamieson @ 2004-05-13 17:43 UTC (permalink / raw)


   I have the line

	(setq-default require-final-newline t)

in my .emacs file.  When I save a .txt file without a final newline, I 
am asked whether to add a newline.  When I enter C-h v 
require-final-newline, I am informed this variable is set to query.

    However, when I save a .cpp or.h file without a terminating new 
line, the newline is silently added.  In fact when I enter C-h v 
require-final-newline, I am informed its value is set to t.

     Why is this variable not being set consistently across file types?

-charles

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: problem with require-final-newline
  2004-05-13 17:43 problem with require-final-newline Charles Jamieson
@ 2004-05-13 23:07 ` Kevin Rodgers
  2004-05-14  7:20 ` Alan Mackenzie
  1 sibling, 0 replies; 3+ messages in thread
From: Kevin Rodgers @ 2004-05-13 23:07 UTC (permalink / raw)


Charles Jamieson wrote:
 >   I have the line
 >
 >     (setq-default require-final-newline t)
 >
 > in my .emacs file.  When I save a .txt file without a final newline, I
 > am asked whether to add a newline.  When I enter C-h v
 > require-final-newline, I am informed this variable is set to query.
 >
 >    However, when I save a .cpp or.h file without a terminating new line,
 > the newline is silently added.  In fact when I enter C-h v
 > require-final-newline, I am informed its value is set to t.
 >
 >     Why is this variable not being set consistently across file types?

My guess is that something like this is lurking somewhere (either in
~/.emacs, default.el, or site-start.el):

(add-hook 'text-mode-hook
	  (lambda ()
	    (set (make-local-variable 'require-final-newline) 'query)))

-- 
Kevin Rodgers

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: problem with require-final-newline
  2004-05-13 17:43 problem with require-final-newline Charles Jamieson
  2004-05-13 23:07 ` Kevin Rodgers
@ 2004-05-14  7:20 ` Alan Mackenzie
  1 sibling, 0 replies; 3+ messages in thread
From: Alan Mackenzie @ 2004-05-14  7:20 UTC (permalink / raw)


Charles Jamieson <cjamieson@no.junk> wrote on Thu, 13 May 2004 17:43:48
GMT:
>    I have the line

> 	(setq-default require-final-newline t)

> in my .emacs file.  When I save a .txt file without a final newline, I 
> am asked whether to add a newline.  When I enter C-h v 
> require-final-newline, I am informed this variable is set to query.

>     However, when I save a .cpp or.h file without a terminating new 
> line, the newline is silently added.  In fact when I enter C-h v 
> require-final-newline, I am informed its value is set to t.

CC Mode does this to help you.  A C++ (etc) source file absolutely
requires a final newline to be syntactically correct, I think.  If for
any reason you don't want this, you can set the (buffer local) value to
nil or 'query in a hook function.

>      Why is this variable not being set consistently across file types?

Different file types have different requirements, or lack thereof.

> -charles

-- 
Alan Mackenzie (Munich, Germany)
Email: aacm@muuc.dee; to decode, wherever there is a repeated letter
(like "aa"), remove half of them (leaving, say, "a").

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-05-14  7:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-05-13 17:43 problem with require-final-newline Charles Jamieson
2004-05-13 23:07 ` Kevin Rodgers
2004-05-14  7:20 ` Alan Mackenzie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).