# write-buffer(2)

[Home] [Commands] [Variables] [Macro-Dev] [Glossary]

## NAME

write-buffer - Write contents of buffer to named (new) file

## SYNOPSIS

n write-buffer "file-name" (C-x C-w)

## DESCRIPTION

write-buffer is used to write the contents of the buffer to a NEW file, use save-buffer(2) if the buffer is to be written to the existing file already associated with the buffer.

write-buffer writes the contents of the current buffer to the named file file-name. The action of the write also changes the file name associated with the current buffer to the new file name.

Unlike append-buffer(2), write-buffer always replaces an existing file and the new file inherits the buffers file characteristics instead of the old file's.

On writing the file, if time(2m) mode is enabled then the time stamp string is searched for in the file and modified if located, to reflect the modification date and time.

If the buffer contains a narrow(2m) it will automatically be removed before saving so that the whole buffer is saved and restored when saving is complete

If backup(2m) mode is enabled and the buffer is associated with a different file (compared with file-name) then any automatic save copies of the file associated with the buffer are deleted.

The argument n may be used to change the default behavior of write-buffer described above, n is a bit based flag where:-

0x01

Enables validity checks (default). These include a check that the proposed file does not already exist, if so confirmation of writing is requested from the user. Also MicroEmacs 2009 checks all other current buffers for one with the proposed file name, if found, again confirmation is requested. Without this flag the command will always succeed wherever possible.

0x02

Disables the expansion of any narrows (see narrow-buffer(2)) before saving the buffer.

## NOTES

undo(2) information may be discarded when the file is written.

## SEE ALSO

$auto-time(5), append-buffer(2), backup(2m), buffer-mode(2), change-file-name(2), file-attrib(3), save-buffer(2), time(2m), write-region(3).

(c) Copyright JASSPA 2009
Last Modified: 2009/08/29
Generated On: 2009/10/12

</HMTL>