# find-file(2)

[Home] [Commands] [Variables] [Macro-Dev] [Glossary]

## NAME

find-file - Load a file

## SYNOPSIS

n find-file "file-name" (C-x C-f)

## DESCRIPTION

find-file finds the named file file-name. If it is already in a buffer, make that buffer active in the current window, otherwise attempt to create a new buffer and read the file into it.

The numeric argument n is used to modify the default behavior of the command, where the bits are defined as follows:

0x01

If the file does not exist and this bit is not set the command fails at this point. If the file does not exist and this bit is set (or no argument is specified as the default argument is `1`) then a new empty buffer is created with the given file name, saving the buffer subsequently creates a new file.

0x02

If this bit is set the file will be loaded with binary(2m) mode enabled. See help on binary mode for more information on editing binary data files.

0x04

If this bit is set the file will be loaded with crypt(2m) mode enabled. See help on crypt mode for more information on editing encrypted files.

0x08

If this bit is set the file will be loaded with rbin(2m) mode enabled. See help on rbin mode for more information on efficient editing of binary data files.

0x10

If this bit is set then the file hook evaluation is not performed when the file is loaded (i.e. the buffer's file hook is not executed).

Text files are usually thought of as named collections of text residing on disk (or some other storage medium). In MicroEmacs 2009 the disk based versions of files come into play only when reading into or writing out buffers. The link between the physical file and the buffer is through the associated file name.

MicroEmacs 2009 permits full file names, i.e. you can specify:

    disk:\directories\filename.extension

or (UNIX)

    /directories/filename.extension

If the disk and directories are not specified, the current buffers disk/ directory is used. Several points should be noted in respect to the methods that MicroEmacs utilizes in the handling of files:-

- Without explicitly saving the buffer(s) to file, all edits would be lost upon leaving MicroEmacs - you are asked to confirm whenever you are about to lose edits.

- MicroEmacs has a mechanism for "protecting" your disk-based files from overwriting when it saves files. When instructed to save a file, it proceeds to dump the file to disk, making a backup of the existing file when backup(2m) mode is enabled.

- Auto-saving files can be performed on edited buffers by setting the $auto-time(5) variable. The file is saved in the same place with a '`#`' appended to the file name. This can be used directly by the user or in the unlikely event of MicroEmacs crashing (or system crash), the files are automatically recovered next time it is edited.

If you do not wish to perform any edits but merely browse the file(s), add the view(2m) mode to the buffer or ask for the file to be read in for viewing only.

## RCS Support

If the file does not exist and the variable $rcs-file(5) is set then the existence of the RCS file is tested. If the rcs file exists then it will be checked out using a command-line created from the variable $rcs-co-com(5). If the check-out is successful then this file is loaded.

This raw interface for supporting file revision control systems has been adapted to support SCCS and Visual Source Safe see help on variable $rcs-file for more information and examples.

## HTTP Support

MicroEmacs supports http file loading, this is available by default on UNIX systems but must be compiled in on win32 platforms (socket libraries not available on all win95 machines so cannot be compiled in by default). When available a http file can be loaded by simply executing find-file and giving the http file name, i.e. "`http://user:password@address:port/file`". Only the `http://`, `address` and `/file` components are mandatory, the rest can usually be omitted. e.g.:

    find-file "http://www.jasspa.com/index.html"

See help page on %http-proxy-addr(5) for information on HTTP proxy server support.

## FTP support

MicroEmacs supports ftp file loading, this is identical to http except the prefix `ftp://` is used as opposed to `http://`. The user name and password defaults to guest in the absence of both these fields. If the user name is supplied but not the password the password will be prompted for; this can be useful as the password will not be stored or written to the history file. Connection is by default on port 21.

    find-file "ftp://<me>:<password>@members.xoom.com/jasspa/index.html"

See also ftp(3).

The progress of the FTP transfer, and the FTP commands issued, may be viewed in the `*ftp-console*` buffer. This is popped up depending on the setting of the %ftp-flags(5) variable.

## NOTES

The base name part (i.e. not the path) of `file-name` can contain wild-card characters compatible with most file systems, namely:-

?

Match any character.

[abc]

Match character only if it is a, b or c.

[a-d]

Match character only if it is a, b, c or d.

[^abc]

Match character only if it is not a, b or c.

*

Match any number of characters.

If the name matches more than one file, a buffer will be created for each matching file. Note that these are not the same wild-card characters used by regex.

For ftp and http then a ftp console window is opened up to show the progress of the transfer (when configured), this is described in ftp(3).

## SEE ALSO

auto(2m), binary(2m), crypt(2m), rbin(2m), time(2m), view(2m), buffer-mode(2), file-attrib(3), file-op(2), find-bfile(3), ftp(3), next-window-find-file(2), page-bfile(3), page-file(3), read-file(2), save-buffer(2), view-file(2), write-buffer(2), $rcs-file(5), %ftp-flags(5), %http-flags(5), %http-proxy-addr(5).

(c) Copyright JASSPA 2009
Last Modified: 2009/08/29
Generated On: 2009/10/12

</HMTL>