PREV UP NEXT GNU Emacs Lisp Reference Manual

Chapter 22: Files

In Emacs, you can find, create, view, save, and otherwise work with files and file directories. This chapter describes most of the file-related functions of Emacs Lisp, but a few others are described in Buffers, and those related to backups and auto-saving are described in Backups and Auto-Saving.

Many of the file functions take one or more arguments that are file names. A file name is actually a string. Most of these functions expand file name arguments using expand-file-name, so that ~ is handled correctly, as are relative file names (including ../). These functions don't recognize environment variable substitutions such as $HOME. See File Name Expansion.

  • Visiting Files Reading files into Emacs buffers for editing.
  • Saving Buffers Writing changed buffers back into files.
  • Reading from Files Reading files into buffers without visiting.
  • Writing to Files Writing new files from parts of buffers.
  • File Locks Locking and unlocking files, to prevent simultaneous editing by two people.
  • Information about Files Testing existence, accessibility, size of files.
  • Changing File Attributes Renaming files, changing protection, etc.
  • File Names Decomposing and expanding file names.
  • Contents of Directories Getting a list of the files in a directory.
  • Create/Delete Dirs Creating and Deleting Directories.
  • Magic File Names Defining "magic" special handling for certain file names.
  • Format Conversion Conversion to and from various file formats.
  • Files and MS-DOS Distinguishing text and binary files on MS-DOS.