# save-buffer(2)

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

## NAME

save-buffer - Save contents of changed buffer to file

## SYNOPSIS

n save-buffer (C-x C-s)

## DESCRIPTION

save-buffer saves the contents of the current buffer if the contents have been changed, writing the buffer back to the file it was read from.

On saving 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 backup(2m) mode is enabled then a backup copy of the file existing is created and the contents of the buffer are written to the file. Any automatic save copies of the file are deleted.

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 auto(2m) mode is enabled the the file is written out in the style indicated by modes cr(2m), lf(2m) and ctrlz(2m). Otherwise the file is written out in the style on the current platform.

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

0x01

Enables validity checks (default). These include check that the buffer has been modified, if not an error occurs. Also the time stamp of the file to be written is checked, if the file systems file exists and is newer the confirmation of writing is requested from the user. If this flag is not supplied then the buffer is written whenever possible and without any prompts to the user.

0x02

Disables the expansion of any narrows (see narrow-buffer(2)) before saving the buffer. That is, the buffer is saved as it appears on the screen and the content of any narrow regions is discarded.

## NOTES

- undo(2) information is discarded when the file is saved.
- Refer to $auto-time(5) for a description of the file extensions used by MicroEmacs 2009 for backup and temporary files.
- Buffers may also be saved via the list-buffers(2) command.

## SEE ALSO

$auto-time(5), $timestamp(5), buffer-mode(2), find-file(2), narrow-buffer(2), save-some-buffers(2), undo(2), backup(2m), time(2m), undo(2m), narrow(2m), auto(2m), cr(2m), ctrlz(2m), lf(2m), write-buffer(2), append-buffer(2).

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

</HMTL>