[ < ] [ > ]   [ << ] [Plus haut] [ >> ]         [Top] [Table des matières] [Index] [ ? ]

8.5 Files

Text that you insert in an Emacs buffer lasts only as long as the Emacs session. To keep any text permanently you must put it in a file. Files are named units of text which are stored by the operating system for you to retrieve later by name. To use the contents of a file in any way, you must specify the file name. That includes editing the file with Emacs.

Suppose there is a file named ‘test.emacs’ in your home directory. To begin editing this file in Emacs, type

 
C-x C-f test.emacs <RET>

Here the file name is given as an argument to the command C-x C-f (find-file). That command uses the minibuffer to read the argument, and you type <RET> to terminate the argument (voir la section The Minibuffer).

Emacs obeys this command by visiting the file: it creates a buffer, it copies the contents of the file into the buffer, and then displays the buffer for editing. If you alter the text, you can save the new text in the file by typing C-x C-s (save-buffer). This copies the altered buffer contents back into the file ‘test.emacs’, making them permanent. Until you save, the changed text exists only inside Emacs, and the file ‘test.emacs’ is unaltered.

To create a file, just visit it with C-x C-f as if it already existed. This creates an empty buffer, in which you can insert the text you want to put in the file. Emacs actually creates the file the first time you save this buffer with C-x C-s.

To learn more about using files in Emacs, see File Handling.


Ce document a été généré par Eric Reinbold le 23 Février 2009 en utilisant texi2html 1.78.