unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* The last character of a file
@ 2003-11-06 23:34 Matthew Walker
  2003-11-06 23:41 ` Dan Anderson
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Matthew Walker @ 2003-11-06 23:34 UTC (permalink / raw)


Emacs is adding a newline to the end of my file.  I'd like it not to :o)

I have a large file (~200Mb) that I wish to edit.  Emacs tells me that 
it's too large to open.  I only want to alter a few bytes in the first 
1000, so I extract them using head:

head --bytes=1000 source.file > source.file.head

I then extract the end of the file:

tail --bytes=<filesize-1000> source.file > source.file.tail

Next on the list is to edit source.file.head, and then put the two files 
back together:

cat source.file.head source.file.tail > source.file.updated

My problem is that emacs seems not to like the fact that 
source.file.head doesn't end with a newline.  It seems to feel compelled 
to add a newline to the end of the file.  The file is now 1001 bytes in 
size, and they just don't append nicely like that.

I could cut off the last byte by

head --bytes=1000 source.file.head | cat - source.file.tail > 
source.file.updated

But I'd like more to know either:
* how to edit the file with emacs, or
* how to stop emacs from adding the newline.

Thank you for your thoughts,

Matthew.

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

* Re: The last character of a file
  2003-11-06 23:34 The last character of a file Matthew Walker
@ 2003-11-06 23:41 ` Dan Anderson
  2003-11-07 17:44 ` Stefan Monnier
  2003-11-08  0:48 ` Thien-Thi Nguyen
  2 siblings, 0 replies; 4+ messages in thread
From: Dan Anderson @ 2003-11-06 23:41 UTC (permalink / raw)
  Cc: help-gnu-emacs

Try putting:

(setq require-final-newline nil)

in your .emacs

Documentation:
*Value of t says silently ensure a file ends in a newline when it is
saved.  Non-nil but not t says ask user whether to add a newline when
there isn't one. nil means don't add newlines.

-Dan

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

* Re: The last character of a file
  2003-11-06 23:34 The last character of a file Matthew Walker
  2003-11-06 23:41 ` Dan Anderson
@ 2003-11-07 17:44 ` Stefan Monnier
  2003-11-08  0:48 ` Thien-Thi Nguyen
  2 siblings, 0 replies; 4+ messages in thread
From: Stefan Monnier @ 2003-11-07 17:44 UTC (permalink / raw)


> Emacs is adding a newline to the end of my file.  I'd like it not to :o)

By default Emacs normally does not add a newline.
It is controlled by the variable require-final-newline.
If that variable is t set it to nil or `ask'.
And also try to find out why it is set to t.  It might be due
to the major mode you're using to edit the file, or to some change
in your .emacs or in the system global site-start.el or default.el.
(try passing -q and/or --no-site-file as args to Emacs when starting
to prevent loading those config files).


        Stefan

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

* Re: The last character of a file
  2003-11-06 23:34 The last character of a file Matthew Walker
  2003-11-06 23:41 ` Dan Anderson
  2003-11-07 17:44 ` Stefan Monnier
@ 2003-11-08  0:48 ` Thien-Thi Nguyen
  2 siblings, 0 replies; 4+ messages in thread
From: Thien-Thi Nguyen @ 2003-11-08  0:48 UTC (permalink / raw)


Matthew Walker <m.g.walker@NOmassey.SPac.AMnz> writes:

> Emacs is adding a newline to the end of my file.  I'd like it not to :o)

if you're on vms this is basically required (but you would have probably
killed yourself by now out of sheer misery so that can't be the case).

> * how to stop emacs from adding the newline.

see var `require-final-newline'.

thi

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

end of thread, other threads:[~2003-11-08  0:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-11-06 23:34 The last character of a file Matthew Walker
2003-11-06 23:41 ` Dan Anderson
2003-11-07 17:44 ` Stefan Monnier
2003-11-08  0:48 ` Thien-Thi Nguyen

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