[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5. Handling for Compressed and Encrypted Files

The basic purpose of this package of Lisp functions is to recognize automatically encrypted and encoded (i.e., compressed) files when they are first visited or written. The BUFFER corresponding to the file is decoded and/or decrypted before it is presented to the user. The file itself is unchanged on the disk. When the buffer is subsequently saved to disk, a hook function re-encodes the buffer before the actual disk write takes place.

This package recognizes all sorts of compressed files by a magic number at the beginning of these files but uses a heuristic to detect encrypted files. If you are asked for an encryption key for a file that is in fact not encrypted, just hit RET and the file will be accepted as is, and the crypt minor mode will not be entered.

Other types of encoding programs may be added to this package by using the variable crypt-encoding-alist which contains a table of encoding programs such as compress, gzip (GNU zip), freeze, and compact.

This new extended version of crypt now monitors the filename extensions of buffers that are written out using write-file (C-x C-w). If the filename extension matches one of the extensions listed in crypt-encoding-alist, then this package will write the file out using the corresponding encoding (compression) method. This is done whether or not the buffer originated from a previously encoded (compressed) file.

Thus, if the user is editing a file that may or may not have been encoded originally (e.g., `foobar.Z' or `foobar') and decides to write it to a different file (e.g., `barfoo' or `barfoo.z' or `barfoo.C'). This package will examine the filename extension and write the buffer in plain format or an alternate encoding (compression) format by searching through the entries in the table of encoding methods crypt-encoding-alist. This change in encoding state is done automatically if the variable crypt-auto-write-buffer is t otherwise the user is asked.

To use this package, put the line (require 'crypt) in your initialization file. Do not bother trying to autoload this file; this package uses find-file and write-file hooks and thus should be loaded the first time you visit any sort of file. Any package loaded after this one that appends something to write-file-hooks will not be executed because this package writes out the file. Other packages that append to write-file-hooks should either be modified to prepend to that hook or be loaded before this one (preferably the former).

NOTE: encryption users should set crypt-encryption-type to one of the values in crypt-encryption-alist.

To configure this package, type:

  M-x customize-group RET compression RET

[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated by XEmacs Webmaster on October, 2 2007 using texi2html