Saving Files

To save the file you are editing, type C-x C-s or select Save Buffer from the Files menu. Emacs writes the file. To let you know that the file was saved correctly, it puts the message Wrote filename in the minibuffer. If you haven’t made any changes to the file, Emacs puts the message (No changes need to be saved) in the minibuffer.

If you decide to save something you’ve typed in the *scratch* buffer by typing C-x C-s, Emacs asks you for a filename. After you give it a filename, Emacs changes the mode line to reflect the filename, replacing *scratch* with the new name.

If you type C-x C-s and your session freezes (nothing you type is accepted), probably C-s and C-q are being used as flow control characters. In this case, C-s means “stop receiving input.” Type C-q to restart the session. A command called enable-flow-control (added in Emacs 19) can quickly solve this problem. Type ESC x enable-flow-control RETURN. You can then type C-\ in place of C-s, and C-^ in place of C-q. This command solves the problem for the current session only. See “Making Emacs Work the Way You Want” at the end of Chapter 2 for a permanent solution. To understand more about flow control problems, see Chapter 11.

If you have problems with C-s (or even if you don’t), you may want to use the write-file command (C-x C-w) to save your files. The write-file command is slightly different from save-buffer. The save-buffer command assumes you don’t want to change the file’s name. The write-file ...

Get Learning GNU Emacs, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.