The changes that you make after visiting a file will not be saved unless you save the buffer. When you save the buffer, Emacs writes the current contents of the buffer into the visited file. Some commands to save buffers are:
This command will permanently save the current buffer in its visited
file (save-buffer
). You will see the following message in the
echo area if you save a file called "myfile.texinfo" :
Wrote /usr/workspace/myfile.texinfo
Try using this command twice. You will get the above message the first time you use this command, the second time you will get the following message:
(No changes need to be saved)
This message indicates that you haven’t made any changes since the last time you saved the file.
This command will save all the buffers in their visited files
(save-some-buffers
). It will prompt you for typing yes or no:
Save file /usr/workspace/myfile.texinfo? (y or n)
You will get the above message for all the buffers. Type "y" if you want to save the buffer.
This command will prompt you for a file name and save the current buffer
in that file. (write-file
). You will see the following message in
the echo area:
Write file: /usr/workspace/
After you type in a file name, press RET. The buffer will be saved in a new file. You can make copies of a particular file using this command.
You can also undo all the changes made since the file was visited or saved by reading the text from the file again (called reverting). For more information on this option, See Reverting in SXEmacs User’s Manual.
When you save a file in Emacs, it destroys its old contents. However,
if you set the variable make-backup-files
to non-nil
i.e. ‘t’, Emacs will create a backup file. Select the
Describe variable option from the Help menu and look at the
documentation for this variable. Its default value should be
‘t’. However, if its not then use M-x set-variable to set it
to ‘t’ (see Setting Variables). The backup file will contain
the contents from the last time you visited the file. Emacs also
provides options for creating numbered backups. For more information on
backups, See Backup in SXEmacs User’s Manual.
Emacs also saves all the files from time to time so that in case of a system crash you don’t lose lot of your work. You will see the message ‘Auto-saving...’ displayed in the echo area when the buffer is being saved automatically. The auto saved files are named by putting the character ‘#’ in front and back. For example a file called "myfile.texinfo" would be named as #myfile.texinfo#. For information on controlling auto-saving and recovering data from auto-saving, See Auto Save Files in SXEmacs User’s Manual.
Emacs provides protection from simultaneous editing which occurs if two users are visiting the same file and trying to save their changes. It will put a lock on a file which is being visited and modified. If any other user tries to modify that file, it will inform the user about the lock and provide some options. For more information on protection against simultaneous editing, See Interlocking in SXEmacs User’s Manual.