1. Computing & Technology

Discuss in my forum

Saving

By , About.com Guide

reverting. See Reverting. You could also undo all the changes by repeating the undo command C-x u until you have undone all the changes; but reverting is easier.

M-x set-visited-file-name alters the name of the file that the current buffer is visiting. It reads the new file name using the minibuffer. Then it marks the buffer as visiting that file name, and changes the buffer name correspondingly. set-visited-file-name does not save the buffer in the newly visited file; it just alters the records inside Emacs in case you do save later. It also marks the buffer as "modified" so that C-x C-s in that buffer will save.

If you wish to mark the buffer as visiting a different file and save it right away, use C-x C-w (write-file). It is precisely equivalent to set-visited-file-name followed by C-x C-s. C-x C-s used on a buffer that is not visiting a file has the same effect as C-x C-w; that is, it reads a file name, marks the buffer as visiting that file, and saves it there. The default file name in a buffer that is not visiting a file is made by combining the buffer name with the buffer's default directory (see File Names).

If the new file name implies a major mode, then C-x C-w switches to that major mode, in most cases. The command set-visited-file-name also does this. See Choosing Modes.

If Emacs is about to save a file and sees that the date of the latest version on disk does not match what Emacs last read or wrote, Emacs notifies you of this fact, because it probably indicates a problem caused by simultaneous editing and requires your immediate attention. See Simultaneous Editing.

If the value of the variable require-final-newline is t, Emacs silently puts a newline at the end of any file that doesn't already end in one, every time a file is saved or written. If the value is nil, Emacs leaves the end of the file unchanged; if it's neither nil nor t, Emacs asks you whether to add a newline. The default is nil.

  • Backup: How Emacs saves the old version of your file.
  • Interlocking: How Emacs protects against simultaneous editing of one file by two users.
  • Shadowing: Copying files to "shadows" automatically.
  • Time Stamps: Emacs can update time stamps on saved files.

©2012 About.com. All rights reserved.

A part of The New York Times Company.