Next: , Previous: , Up: Files, Buffers, and Windows   [Contents][Index]


3.3 Files

These commands either read a file into the current buffer or write it out to some file. Various other bookkeeping operations are performed as well.

Command: Find File (bound to C-x C-f)

This is the command normally used to get a file into Hemlock. It prompts for the name of a file, and if that file has already been read in, selects that buffer; otherwise, it reads file into a new buffer whose name is derived from the name of the file. If the file does not exist, then the buffer is left empty, and "(New File)" is displayed in the echo area; the file may then be created by saving the buffer.

The buffer name created is in the form "name type directory". This means that the filename "/sys/emacs/teco.mid" has "Teco Mid /Sys/Emacs/" as its the corresponding buffer name. The reason for rearranging the fields in this fashion is that it facilitates recognition since the components most likely to differ are placed first. If the buffer cannot be created because it already exists, but has another file in it (an unlikely occurrence), then the user is prompted for the buffer to use, as by Create Buffer.

Find File takes special action if the file has been modified on disk since it was read into Hemlock. This usually happens when several people are simultaneously editing a file, an unhealthy circumstance. If the buffer is unmodified, Find File just asks for confirmation before reading in the new version. If the buffer is modified, then Find File beeps and prompts for a single key-event to indicate what action to take. It recognizes the following key-events:

Return, Space, y

Prompt for a file in which to save the current buffer and then read in the file found to be modified on disk.

Delete, Backspace, n

Forego reading the file.

r

Read the file found to be modified on disk into the buffer containing the earlier version with modifications. This loses all changes you had in the buffer.

Command: Save File (bound to C-x C-s)

This command writes the current buffer out to its associated file and resets the buffer modification flag. If there is no associated file, then the user is prompted for a file, which is made the associated file. If the buffer is not modified, then the user is asked whether to actually write it or not.

If the file has been modified on disk since the last time it was read, Save File prompts for confirmation before overwriting the file.

Command: Save All Files (bound to C-x C-m)
Command: Save All Files and Exit (bound to C-x M-z)
Hemlock Variable: Save All Files Confirm (initial value t)

Save All Files does a Save File on all buffers which have an associated file. Save All Files and Exit does the same thing and then exits Hemlock.

When Save All Files Confirm is true, these commands will ask for confirmation before saving a file.

Command: Visit File (bound to C-x C-v)

This command prompts for a file and reads it into the current buffer, setting the associated filename. Since the old contents of the buffer are destroyed, the user is given a chance to save the buffer if it is modified. As for Find File, the file need not actually exist. This command warns if some other buffer also contains the file.

Command: Write File (bound to C-x C-w) This command prompts for a file

and writes the current buffer out to it, changing the associated filename and resetting the modification flag. When the buffer’s associated file is specified this command does the same thing as Save File.

Command: Backup File

This command is similar to Write File, but it neither sets the associated filename nor clears the modification flag. This is useful for saving the current state somewhere else, perhaps on a reliable machine.

Since Backup File doesn’t update the write date for the buffer, Find File and Save File will get all upset if you back up a buffer on any file that has been read into Hemlock.

Command: Revert File
Hemlock Variable: Revert File Confirm (initial value t)

This command replaces the text in the current buffer with the contents of the associated file or the checkpoint file for that file, whichever is more recent. The point is put in approximately the same place that it was before the file was read. If the original file is reverted to, then clear the modified flag, otherwise leave it set. If a prefix argument is specified, then always revert to the original file, ignoring any checkpoint file.

If the buffer is modified and Revert File Confirm is true, then the user is asked for confirmation.

Command: Insert File (bound to C-x C-r)

This command prompts for a file and inserts it at the point, pushing a buffer mark before inserting.

Command: Write Region

This command prompts for a file and writes the text in the region out to it.

Hemlock Variable: Add Newline at EOF on Writing File (initial value :ask-user)

This variable controls whether some file writing commands add a newline at the end of the file if the last line is non-empty.

:ask-user

Ask the user whether to add a newline.

t

Automatically add a newline and inform the user.

nil

Never add a newline and do not ask.

Some programs will lose the text on the last line or get an error when the last line does not have a newline at the end.

Hemlock Variable: Keep Backup Files (initial value nil)

Whenever a file is written by Save File and similar commands, the old file is renamed by appending ".BAK" to the name, ensuring that some version of the file will survive a system crash during the write. If set to true, this backup file will not deleted even when the write successfully completes.


Next: Windows, Previous: Buffers, Up: Files, Buffers, and Windows   [Contents][Index]