;;; crypt++.el -- code for handling all sorts of compressed and encrypted files
;;; (also installed as crypt.el)

;; Authors: Lawrence R. Dodd <dodd@roebling.poly.edu>
;;	Rod Whitby <rwhitby@research.canon.oz.au>
;;	Kyle E. Jones <kyle@uunet.uu.net>
;; Maintainer: <kb@cs.umb.edu>
;; Created: crypt.el in 1988, crypt++.el on 18 Jan 1993.
;; Version: 2.84
;; Keywords: extensions
;; $Id: crypt++.el,v 1.11 1998/03/20 21:20:04 karl Exp $

;;; Copyright (C) 1998 Free Software Foundation, Inc.
;;; Copyright (C) 1994 Lawrence R. Dodd
;;; Copyright (C) 1993 Lawrence R. Dodd and Rod Whitby
;;; Copyright (C) 1988, 1989, 1990 Kyle E. Jones
;;;
;;; This program is free software; you can redistribute it and/or modify
;;; it under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 2 of the License, or
;;; (at your option) any later version.
;;;
;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with this program; if not, write to the Free Software
;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

;;; Commentary:

;;; Please see notes on INSTALLATION and USAGE on the pages below.

;;; LCD Archive Entry:
;;; crypt++|Rod Whitby and Lawrence R. Dodd|kb@cs.umb.edu|
;;; Handle compressed and encrypted files.|
;;; 1998-03-20|2.84|~/misc/crypt++.el.Z|

;;; AVAILABLE:
;;; ftp://ftp.cs.umb.edu/pub/misc/crypt++.el
;;; news:gnu.emacs.sources

;;; BUG REPORTS:
;;;
;;; Type M-x crypt-submit-report to generate a bug report template or put your
;;; cursor at the end of this line and type C-x C-e: (crypt-submit-report)
;;;
;;; Please note that this bug-report facility (crypt-submit-report) uses
;;; Barry Warsaw's reporter.el which is part of GNU Emacs v19 and
;;; bundled with many other packages.  If needed, you can obtain a copy
;;; of reporter.el at the elisp-archive.  In fact, crypt-submit-report
;;; will attempt to ange-ftp a copy for you if you do not
;;; have one accessible.
;;;
;;; Main author:
;;; Lawrence R. Dodd <dodd@roebling.poly.edu>
;;; Polytechnic University
;;; Brooklyn, New York USA


;;; INSTALLATION:
;;;
;;; To use this package, simply put it in a file called "crypt++.el" in a Lisp
;;; directory known to Emacs (see `load-path'), byte-compile it (ignore
;;; warnings about undefined functions), and put the line:
;;;
;;;                      (require 'crypt++)
;;;
;;; in your ~/.emacs file or in the file default.el in the ../lisp directory
;;; of the Emacs distribution.  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).
;;;
;;; An alternative is to stick (require 'crypt) in your ~/.emacs, if it is not
;;; already there, and then make a symbolic link from crypt++.el to crypt.el
;;; with "ln -s crypt++.el crypt.el".  This will make crypt++ act like a
;;; drop-in replacement for the original crypt since any package requiring
;;; crypt will find crypt++ instead.

;;; NOTE: encryption users should set `crypt-encryption-type' to one of the
;;; values in `crypt-encryption-alist' (see USAGE below).

;;; SPECIAL NOTES:
;;;
;;; If crypt++ is dumped with the emacs executable, or if it has already been
;;; loaded in an emacs session, then modifying the variables used in building
;;; the encryption and encoding tables will have no effect until these tables
;;; are rebuilt.  This may be done with `M-x crypt-rebuild-tables'.  See USAGE
;;; below to determine variables for which this is needed.  For example,
;;; post-load changes to `crypt-encryption-file-extension' or
;;; `crypt-freeze-vs-fortran' can be incorporated into the encryption table
;;; via `M-x crypt-rebuild-tables'.  Similarly, post-load changes to
;;; `crypt-bind-insert-file' are handled with `M-x crypt-bind-insert-file'.

;;; DUMPING CRYPT++ WITH GNU EMACS 18:
;;;
;;; If crypt++ has been dumped with emacs then calls to `crypt-rebuild-tables'
;;; and `crypt-bind-insert-file' will be needed in the user's ~/.emacs or
;;; ../lisp/default.el file in order to assure the changes take effect.  For
;;; example,
;;;
;;;           ;; Set my own preferences...
;;;           (setq crypt-encryption-type 'des
;;;                 crypt-encryption-file-extension "\\(\\.e\\)$"
;;;                 crypt-bind-insert-file nil
;;;                 crypt-freeze-vs-fortran nil)
;;;
;;;           ;; Has crypt++ been loaded already?
;;;           (if (featurep 'crypt++)
;;;
;;;               ;; Yes.  Just rebuild the encryption and encoding tables
;;;               ;; and key binding.
;;;               (progn
;;;                 (crypt-rebuild-tables)
;;;                 (crypt-bind-insert-file))
;;;
;;;             ;; No.  Load the whole thing.
;;;             (require 'crypt++))
;;;
;;; This guarantees that the users preferences will be incorporated into
;;; crypt++ without having to reload all of crypt++.el to do it.
;;;
;;; In GNU Emacs 19 and Lucid Emacs 19.8 the execution of
;;; `crypt-rebuild-tables' and `crypt-bind-insert-file' is done automatically
;;; through `after-init-hook'.  So, for the above example, all that is needed
;;; is
;;;
;;;           ;; Set my own preferences...
;;;           (setq crypt-encryption-type 'des
;;;                 crypt-encryption-file-extension "\\(\\.e\\)$"
;;;                 crypt-bind-insert-file nil
;;;                 crypt-freeze-vs-fortran nil)
;;;
;;;           (require 'crypt++)
;;;
;;; There is an `after-init-hook' in Lucid Emacs v 19.8 but in early versions
;;; of Lucid Emacs it will use `term-setup-hook' instead.


;;; USAGE:
;;;
;;; By default, intended to be transparent.  User-defined variables
;;;
;;;     controlling ENCRYPTION are:
;;;        crypt-encryption-type
;;;        crypt-encryption-file-extension
;;;        crypt-never-ever-decrypt
;;;        crypt-auto-write-buffer-encrypted
;;;        crypt-confirm-password
;;;        crypt-encrypted-disable-auto-save
;;;        crypt-encryption-alist
;;;
;;;     controlling ENCODING are:
;;;        crypt-auto-decode-buffer
;;;        crypt-auto-write-buffer
;;;        crypt-query-if-interactive
;;;        crypt-no-extension-implies-plain
;;;        crypt-freeze-vs-fortran
;;;        crypt-compact-vs-C++
;;;        crypt-ignored-filenames
;;;        crypt-default-encoding
;;;        crypt-encoded-disable-auto-save
;;;        crypt-encoding-alist
;;;
;;;     controlling file insertion are:
;;;        crypt-bind-insert-file
;;;        crypt-auto-decode-insert
;;;
;;; To find out more about these variables, load this file, put your cursor at
;;; the end of any of the variable names, and hit C-h v [RET].
;;;
;;; NOTE: encryption users should set `crypt-encryption-type' to one of the
;;; values in `crypt-encryption-alist'.
;;;
;;; Although rarely needed, the following may be called interactively:
;;;        (crypt-encoded-mode)
;;;        (crypt-encode-region)
;;;        (crypt-encrypted-mode)
;;;        (crypt-encrypt-region)
;;;        (crypt-set-encryption-key)
;;;        (crypt-rebuild-tables)
;;;        (crypt-insert-file)
;;;        (crypt-bind-insert-file)
;;;        (crypt-submit-report)
;;;
;;; To find out more about these functions, load this file, put your cursor
;;; inside any of the `()' of the above lines, and hit C-h f [RET].


;;; NOTES ON INTERFACES WITH OTHER PROGRAMS AND PACKAGES:
;;;
;;; GZIP: the environment variable GZIP of gzip can cause an error if it
;;; contains `--verbose' because standard output messages will be appended to
;;; gzip'ed files.  This corrupts the files.  The cleanest solution is to pass
;;; the `--quiet' switch in `crypt-encoding-alist' to override this.  Use gzip
;;; version 1.0.4 or higher from ftp://ftp.gnu.org/pub/gnu/gzip-*.tar.gz.
;;;
;;; TAR-MODE: works properly with version 1.28 (or higher) with v19 emacs.
;;;
;;; RMAIL and CHANGING MAJOR MODE (for v18 ONLY): in v18 emacs
;;; crypt++.el's buffer local variables are smashed whenever the major
;;; mode is changed of a buffer or whenever RMAIL is run on an encrypted
;;; and/or compressed file.  This screws things up.  No smashing occurs
;;; with v19 Emacs.  for v18 emacs Joe Wells' "kill-fix.el" is needed to
;;; prevent this.  Get a copy of kill-fix.el from
;;; archive.cis.ohio-state.edu, store it where emacs can find it, stick
;;; a "(require 'kill-fix)" anywhere in your ~/.emacs, and the problem
;;; will be fixed.
;;;
;;; LISPDIR: if you save this file as crypt++.el then the "(require 'crypt)"
;;; in lispdir.el needs to be replaced with "(require 'crypt++)"
;;; or the symbolic link suggested above can be used.


;;; DESCRIPTION:
;;;
;;; 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 DO/KNOWN BUGS/HELP WANTED/APPLY WITHIN:
;;;
;;; All users/hackers out there are strongly encouraged to pursue any of these
;;; matters further (especially those that concern encryption and decryption!).
;;; It is important to future programmers and modifiers of crypt++.el to know
;;; about its perceived limitations.  Since necessity drives invention, users
;;; who find any of the following features of crypt++.el annoying are asked to
;;; make suggestions and send patches (again, especially those that concern
;;; encryption and decryption!).
;;;
;;; * currently crypt++ assumes that if a file is both encrypted and encoded
;;;   (i.e., compressed) that the order in which it was done was encryption
;;;   first _then_ compression.  As has been pointed by many people compression
;;;   following encryption is useless since the encrypted file is basically
;;;   random.  On the other hand, many agree that doing encryption _following_
;;;   compression is better since it makes it harder to crack the encryption.
;;;   We would like to make the ordering of these two user-configurable or if
;;;   nothing else change the order.
;;;
;;;   Having read the above however, Francois Pinard <pinard@iro.umontreal.ca>
;;;   writes that encryption following compression may not be harder to crack
;;;   since "the fact that the first few uncrypted bytes are expected (the
;;;   compress signature) facilitates a serious attempt at uncrypting."
;;;   jwz agrees with Francois.
;;;
;;; * get write-region and append-to-file to handle encoded and encrypted
;;;   files.  There is an interesting low-level encoding package by Jay Adams
;;;   <jka@ece.cmu.edu> called jka-compr.el that might address some of these
;;;   issues.  We encourage hackers out there to come up with crypt++ versions
;;;   of write-region and append-to-file.  The difficulty is creating versions
;;;   that mimic the originals as closely as possible.
;;;
;;; * instead of using call-process-region (which can fail badly if the region
;;;   is large and there's not much room in /tmp), write the region to a temp
;;;   file (with a customisable location) and use call-process directly.
;;;
;;; * users have mentioned trouble using crypt++ and hilit simultaneously since
;;;   the functions in write-file-hook for both write the file to disk and
;;;   return t.  A possible solution is to have one of them write to a
;;;   scratch buffer instead of to disk and return nil and then allow the
;;;   other to do its work on the scratch buffer and write it to disk.  Thanks
;;;   to Wayne Folta <folta@cs.UMD.EDU> and Amir J Katz <amir@matis.ingr.com>.
;;;   It would be nice to have another way in emacs to have an
;;;   after-write-file-hook and a before-write-file-hook of some sort.
;;;   Lucid Emacs has an after-write-file-hook.  Recent versions of hilit19.el
;;;   do not automatically attach to `write-file-hooks' and return t.
;;;   However, the general problem of multiple packages returning t still
;;;   remains.  dos-mode.el and crypt++.el also conflict.
;;;
;;; * another possible source of trouble is with encryption (and encoding)
;;;   programs sticking verbose output into buffers prior to being written to
;;;   disk.  This was definitely occurring with gzip because of --verbose in
;;;   the GZIP environment variable and is solved/hidden with the --quiet
;;;   switch.  However, I suspect that some encryption problems out there are
;;;   capable of similar things so the user should be careful.
;;;
;;; * integrating crypt++ with a backgrounding package such as Olin Shivers'
;;;   `background.el' might be useful too.  thanks to Mark Borges
;;;   <mdb@noaacrd.Colorado.EDU> for suggesting this.
;;;
;;; * Performing M-x crypt-encode-buffer or M-x crypt-encrypt-buffer and then
;;;   saving the file would possibly cause errors.  It is better to toggle
;;;   `crypt-encoded-mode' (or `crypt-encrypted-mode') and simply save the
;;;   file.  It is for this reason that `crypt-encode-buffer' and
;;;   `crypt-encrypt-buffer' are not interactive.
;;;
;;; * use plists instead of alists replacing calls to `nth' with `get'
;;;
;;; * merge encryption code completely into encoding code making encryption
;;;   just a special case of encoding.


;;; Change log:
;;;
;;; 1.1 - original version of crypt.el
;;; 1.2 -
;;;   jwz: works with tar-mode.el
;;;   jwz: applied patch from piet, merged with Lawrence Dodd's gzip version
;;; 1.3 -
;;;   lrd: fixed compress-magic-regexp
;;; 1.4, 1.5, 1.6 -
;;;   lrd: write-file compresses or gzips based on file extension
;;; 2.1 -
;;;   lrd: merged with Rod Whitby's table-driven version (major upgrade)
;;; 2.2 -
;;;   rjw: Changed file name to crypt++.el, so archie and lispdir can find it.
;;; 2.3 -
;;;   rjw: Separated the hook additions and minor mode alist additions.
;;; 2.4 -
;;;   rjw: Fixed the interactive form for crypt-buffer.
;;; 2.5 -
;;;   lrd: doc mods, changed GNU free software notice (was out of date), added
;;;   anonymous ftp information
;;; 2.6 -
;;;   lrd: added back in definition of `buffer' in defun crypt-buffer caused
;;;   an error when trying to read encrypted file; modified check for minor
;;;   mode alist addition; added gzip magic number warning
;;; 2.7 - [posted to gnu.emacs.sources]
;;;   lrd: added `TO DO' and `KNOW BUGS' section to header
;;; 2.8 -
;;;   lrd: added note about updating to v 1.24 of tar-mode.el
;;;   Thanks to Mark Borges <mdb@noaacrd.Colorado.EDU>
;;; 2.9 -
;;;   lrd: moved query about `crypt-freeze-vs-fortran' out of defvar for
;;;   `crypt-encoding-alist,' an erroneous value of nil was being stuck into
;;;   alist when user set `crypt-freeze-vs-fortran' was nil, doc mod.
;;;   Thanks to Mark Borges <mdb@noaacrd.Colorado.EDU>
;;; 2.10 -
;;;   rjw: moved query about `crypt-freeze-vs-fortran' back into defvar for
;;;   `crypt-encoding-alist,' - used append to ignore the erroneous nil.
;;; 2.11 -
;;;   rjw: fixed a bug in my fix :-(
;;; 2.12 -
;;;   rjw: Defvar crypt-magic-regexp and crypt-magic-regexp-inverse and
;;;   allow either a regexp or an elisp expression.
;;;   Suggested by Franc,ois Pinard <pinard@iro.umontreal.ca>.
;;; 2.13 -
;;;   lrd: added in info on lispdir.el, doc mods and some puttering while
;;;   looking over rjw's v 2.12 mods.
;;; 2.14 -
;;;   lrd: doc mod - trivial huh? switched `compact' and  `gzip' in
;;;   `crypt-encoding-alist' - want gzip near top
;;; 2.15 -
;;;   lrd: added in LCD Archive Entry and modified comments on tar-mode.el
;;;   since the version at the elisp-archive now works with crypt++.el
;;; 2.16 -
;;;   lrd: provide `crypt' as well as `crypt++' allowing something like `ln -s
;;;   crypt++.el crypt.el' to be meaningful
;;;   Suggested (by|as) Per Abrahamsen <amanda@iesd.auc.dk>
;;; 2.17 -
;;;   lrd: clarified bug report procedure, added fancy pseudo-graphics, added
;;;   to the `TO DO' list, put RCS tags in LCD Archive entry
;;; 2.18 - [posted to gnu.emacs.sources]
;;;   lrd: included pointer to elisp archive in crypt-version description,
;;;   changed "Decode buffer %s? " to "Decode %s? " in crypt-find-file-hook
;;;   to be more general (mainly for crypt-insert-file)
;;; 2.19 -
;;;   rjw: Added the crypt-compact-vs-C++ switch to distinguish compacted and
;;;   C++ files.
;;; 2.20 -
;;;   lrd: (1) modified interactive form of crypt-buffer. (2) made search
;;;   case-insensitive in crypt-submit-report. (3) modified encoded-mode and
;;;   crypt-mode so that buffer-modified is not unconditionally set to nil
;;;   when the mode is not changed. Thanks to Gerd Hillebrand
;;;   <ggh@cs.brown.edu> for suggesting (2) and (3).
;;; 2.21 -
;;;   rjw: Added an entry to the TODO list about the hazards of using
;;;   call-process-region on a large region and not much room in /tmp
;;;   (David Carlisle <carlisle@computer-science.manchester.ac.uk>).
;;; 2.22 -
;;;   lrd: allow write-file-hooks to contain functions as well as lists.
;;;   Contributed by Ken Laprade <laprade@trantor.harris-atd.com>.
;;; 2.23 -
;;;   lrd: made crypt-submit-report list values of more user-defined variables
;;; 2.24 -
;;;   lrd: pass the -q switch to gzip to thwart the possibility of a --verbose
;;;   in the GZIP environment variable
;;; 2.25 -
;;;   lrd: added some more to the TO DO list, clarified some things, also
;;;   untabified the entire file (I got tired of the control I's)
;;; 2.26 -
;;;   lrd: use the long-named options for GNU zip (self-documenting)
;;; 2.27 -
;;;   lrd: included observation by Francois Pinard <pinard@iro.umontreal.ca>
;;;   and worked on text in TO DO/KNOWN BUGS list
;;; 2.28 -
;;;   lrd: added two new variables in (crypt-submit-report) to the list stuck
;;;   at the bottom of the mail message; changed the comments regarding the
;;;   user-defined variables.  added in default values in user defined
;;;   variables.  added to and removed stuff to the `TO DO' list.
;;;
;;;   (encoded-mode):
;;;   added in code to remove any auto-save-files that may have been formed
;;;   before becoming an encoded buffer (for example a plain file saved to
;;;   disk encoded had orphan auto-save-files left behind).  turning off
;;;   auto-save-mode disables the creation of auto-save-files, but it also
;;;   disables the possibility of these being removed when the buffer is
;;;   saved.
;;;
;;;   (crypt-region):
;;;   now call the encryption and decryption program directly instead of
;;;   through the shell.  this is more secure since the shell will expose the
;;;   password (key).  thanks to Jon Cargille <jcargill@cs.wisc.edu>.  defined
;;;   two new variables `crypt-decryption-args' and `crypt-encryption-args' to
;;;   take the arguments separately.  removed (let ((opoint)...)) construct
;;;   this was a throw back to some old dead code and was not being used.
;;; 2.29 -
;;;   lrd: added three new variables in (crypt-submit-report); added to the
;;;   `TO DO' list.
;;;
;;;   (encode-region,encode-buffer,encoded-mode): fixed interactive forms -
;;;   the conversion to table version had eliminated some of the interactive
;;;   features of these.  thanks to Kimball Collins <kpc@ptolemy.arc.nasa.gov>
;;;   for point this out.  new interactive form uses functions
;;;   `crypt-get-encoding-type' and `crypt-symbol-alist-to-table' and variable
;;;   `crypt-default-encoding' to generate completion list of encoding types.
;;;
;;;   (crypt-write-file-hook): two new user-defined variables
;;;   `crypt-query-if-interactive' and `crypt-no-extension-implies-plain' and
;;;   the buffer-local variable `buffer-interactive-mode' are used to help
;;;   determined whether or not plain output is really desired for files
;;;   without a compression file-name extension.  the default behavior is the
;;;   same as before.
;;; 2.30 -
;;;   lrd: added test for user-defined variable `crypt-never-ever-decrypt'
;;;   when finding a file.  some users may never wish to decrypt files
;;;   and like to edit binary files.  thanks to Nelson Minar
;;;   <nelson@reed.edu>.  added to doc-strings of
;;;   `crypt-magic-regexp[-inverse]' -- these can be set to nil[t] and
;;;   accomplish the same thing as setting `crypt-never-ever-decrypt' to t
;;; 2.31 -
;;;   rjw: Updated the comments in the encryption check section.
;;; 2.32 - [posted to gnu.emacs.sources]
;;;   lrd: added warning about `crypt-(de|en)cryption-program'; doc mod.
;;; 2.33 -
;;;   lrd: if `crypt-(de|en)cryption-args' are nil then don't pass any
;;;   arguments to (de|en)cryption program, nil is the default instead of
;;;   "".  Thanks to Joe Ilacqua <spike@world.std.com>, David J. Schur
;;;   <djs@idm.com>, Peter Nuth <nuth@ai.mit.edu>, and Greg Larson
;;;   <glarson@bnr.ca>.  `-q' exists in gzip 1.0.3 but not `--quiet' changed
;;;   GZIP NOTE.  Thanks to Chris Moore <moore@src.bae.co.uk>.
;;; 2.34 -
;;;   lrd: allow `crypt-(de|en)cryption-args' to be a list of strings -- more
;;;   robust.  query for password (key), if none is set, when writing out file
;;;   for which `buffer-save-encrypted' is t.  Thanks to John Interrante
;;;   <interran@uluru.Stanford.EDU>.  (crypt-write-file-hook): check filename
;;;   extension against regexp `crypt-encryption-file-extension' and query for
;;;   encryption, unless `crypt-auto-write-buffer-encrypted' is t (don't
;;;   bother doing reverse check, encrypted to plain, not a common request).
;;;   (crypt-mode): delete auto-save files (cf., encoded-mode), may exist now.
;;;   (read-string-no-echo): applied patch from Piet van Oostrum
;;;   <piet@cs.ruu.nl> -- set `cursor-in-echo-area' _after_ setting buffer
;;;   (this was screwing up gnews).
;;; 2.35 -
;;;   lrd: doc mod
;;; 2.36 -
;;;   lrd: fixed typo, added RMAIL note.
;;; 2.37 - [posted to gnu.emacs.sources]
;;;   lrd:
;;;   (crypt-write-file-hook): search user-defined list
;;;   `crypt-ignored-filenames' for possible match with `buffer-filename'
;;;   before attempting conversion from compressed to plain format; useful for
;;;   compressed incoming mail files (e.g., RMAIL, INBOX).
;;;
;;;   (crypt-mode): query for key if not set already; need to switch order of
;;;   recovering key and toggling crypt-mode in crypt-find-file-hook (thanks
;;;   to Piet van Oostrum <piet@cs.ruu.nl>).
;;;
;;;   (crypt-buffer) and (encode-buffer): remove interactive form; use
;;;   (crypt-mode) and (encoded-mode) instead so encryption and compression
;;;   are done at the very end; leave interactive form in (crypt-region) and
;;;   (encode-region) may still be used.
;;;
;;;   (set-encryption-key): remove from `command-history' if called
;;;   interactively - thanks to George M. Georgiou
;;;   <georgiou@silicon.csci.csusb.edu>.
;;; 2.38 -
;;;   lrd: added `crypt-' prefix to `(read-string-no-echo)' and `(save-point)'
;;;   changed file extension for gzip files to `.z' _or_ `.gz' (future release
;;;   of gzip with use later extension by default and so this should be
;;;   changed to just `.gz' someday).
;;; 2.39 -
;;;   lrd: doc mod. added in patch from jwz - `(crypt-read-string-no-echo)' is
;;;   more secure, put property 'permanent-local on buffer-locals works for
;;;   Lucid Emacs and doesn't harm v18 emacs, change `buffer-interactive-mode'
;;;   to `buffer-interactive-encoded-mode.'
;;; 2.40 -
;;;   lrd: put property 'preserved in case kill-fix.el is being used.
;;; 2.41 -
;;;   lrd: all functions and variables now start with `crypt-', moved REVISION
;;;   HISTORY to bottom of header, interactive version of
;;;   `(crypt-encrypt-region)' clearer, `(crypt-read-string-no-echo)' now
;;;   echos `.'
;;; 2.42 -
;;;   lrd: (crypt-check-extension-for-encoding): broke out of
;;;   `(crypt-write-file-hook)'.  setting user variables
;;;   `crypt-compact-vs-C++' and `crypt-freeze-vs-fortran' to nil no longer
;;;   completely disables the reading compact'ed and frozen files but just
;;;   disables the use of the file-extension tricks of
;;;   `(crypt-check-extension-for-encoding).'  (crypt-encode-region): allow
;;;   for a single line message from encoding program at top of region; if it
;;;   is there, then remove it; kludge for `compact' program.
;;; 2.43 -
;;;   lrd: (crypt-encode-region): generalize the clean up procedure; add
;;;   element to `crypt-encoding-alist' and introduce new function
;;;   `(crypt-encoding-cleanup-regexp)' to extract a compression specific
;;;   regexp for erroneous message or lisp expression for cleanup.
;;; 2.44 -
;;;   lrd: new element for `crypt-encoding-alist' handles whether or not
;;;   file-name extension tricks may be play with encoding method; compact and
;;;   freeze values default to `crypt-compact-vs-C++' and
;;;   `crypt-freeze-vs-fortran' (thanks to rjw);
;;;   (crypt-encoding-extension-tricks): new defun to handle this;
;;;   (crypt-check-extension-for-encoding): monitors "tricks" entry of
;;;   `crypt-encoding-alist' and adjust the bag of tricks it can apply.
;;; 2.45 -
;;;   lrd: (crypt-encode-region): delete entire match of cleanup regexp by
;;;   requiring newlines in GARBAGE-REGEXP-OR-LISPEXP.  (crypt-submit-report):
;;;   use Warsaw's reporter.el.
;;; 2.46 -
;;;   lrd: (crypt-find-file-hook, crypt-write-file-hook): cleaned, documented,
;;;   and replaced occurrences of `(cond (C BODY))' with `(if C BODY)';
;;;   changed `crypt-magic-regexp' to `crypt-encryption-magic-regexp' and
;;;   `crypt-magic-regexp-inverse' to `crypt-encryption-magic-regexp-inverse'
;;;   for consistency with other variable names. new user-defined variable
;;;   `crypt-encryption-minor-mode-name' instead of always "Crypt".  grouped
;;;   all encryption variables together.
;;; 2.47 -
;;;   lrd: somewhat major change - put program-specific encryption variables
;;;   into a single table `crypt-encryption-alist' and let the variable
;;;   `crypt-encryption-type' define the appropriate entry to use; new
;;;   user-defined variable `crypt-confirm-password,' thanks to Jeff Clark
;;;   <jclark@src.honeywell.com>. (crypt-submit-report): improved error
;;;   handling, thanks to baw. (crypt-write-file-hook): fixed bug with
;;;   `crypt-encoding-extension-tricks'
;;; 2.48 -
;;;   lrd: added dummy argument to `crypt-encoding-alist' and
;;;   `crypt-encryption-alist' and merged all defuns that work on their
;;;   elements into defuns that all start with `crypt-get-' and look through
;;;   both lists.  simplifies some of code and closer to treating encryption
;;;   as a special case of encoding; crypt-minor-mode-alist: replaced (nth *)
;;;   with `(crypt-get-minor-mode)' call; (crypt-encode-region): allow
;;;   arguments to be list of strings; renamed (crypt-get-encoding-type) to
;;;   (crypt-read-encoding-type) for clarity.
;;; 2.49 - [posted to gnu.emacs.sources]
;;;   lrd: (crypt-encode-region): ignore `args' if set to t
;;; 2.50 -
;;;   lrd: (crypt-write-file-hook): in v19 we need to call `backup-buffer'
;;;   ourselves -- we write out the file and return t so `basic-save-buffer'
;;;   does not do it; also call `set-file-modes'
;;; 2.51 -
;;;   lrd: some `defvar's are now `defconst's and tar-mode note was changed.
;;; 2.52 -
;;;   lrd: make doc strings conform to GNU standards.
;;; 2.53 -
;;;   lrd: made header conform to GNU Conventional Headers standard.
;;; 2.54 -
;;;   lrd: `crypt-encryption-file-extension', `crypt-freeze-vs-fortran',
;;;   `crypt-compact-vs-C++', `crypt-encryption-magic-regexp', and
;;;   `crypt-encryption-magic-regexp-inverse' are used in defining the tables
;;;   `crypt-encoding-alist' and `crypt-encryption-alist' and so need to be set
;;;   _before_ loading crypt++.  use `add-hook' if it is available.
;;; 2.55 -
;;;   lrd: new interactive function `crypt-insert-file' mimics `insert-file'
;;;   but attempts to decode or decrypt before insertion; bound `C-x i' if
;;;   `crypt-bind-insert-file' is non-nil.  comment out doc-strings from
;;;   internal subroutines, saves space.
;;; 2.56 -
;;;   tfb: change the definitions of crypt-{encoding,encryption}-alist, to
;;;   call the functions crypt-make-{encoding,encryption}-alist resp.
;;;   Added crypt-reinit which regenerates these variables from their
;;;   functions, thus allowing this stuff to be preloaded even if people
;;;   set things in their init files.
;;;   Tim Bradshaw <tim.bradshaw@mid-heidelberg.de>
;;; 2.57 -
;;;   lrd: untabify; remove duplicate entry in `crypt-make-encoding-alist';
;;;   change name of `crypt-make-*-alist' to `crypt-build-*-alist' and
;;;   `crypt-reinit' to `crypt-rebuild-tables'; (crypt-read-string-no-echo):
;;;   change local variable `form' to `help-form' so it is defined;
;;;   `crypt-encryption-alist' and `crypt-encoding-alist' must be defined with
;;;   `defconst' since we wish crypt++ to initialize these variables
;;;   unconditionally; modify INSTALLATION section to reflect these changes.
;;; 2.58 -
;;;   lrd: doc mod.
;;; 2.59 - [posted to gnu.emacs.sources]
;;;   lrd: (crypt-bind-insert-file): new function for changing "C-x i" in
;;;   initialization file or interactively.
;;; 2.60 -
;;;   lrd: add `crypt-rebuild-tables' and `crypt-bind-insert-file' to
;;;   `after-init-hook' in GNU emacs v19 and to `term-setup-hook' in Lucid
;;;   emacs.  Change INSTALLATION notes.
;;; 2.61 - [posted to gnu.emacs.sources]
;;;   lrd: Doc mod.  Clean up the installation of minor mode indicators.
;;; 2.62 - [posted to gnu.emacs.sources]
;;;   lrd: installed patch from stig@hackvan.com to simplify crypt-get-* defuns
;;;   (now defmacros).  Don't add to `term-setup-hook' unless no
;;;   `after-init-hook' _and_ definitely running v19, otherwise Rod gets an
;;;   error at home :-<.  Don't assume C-x i had `insert-file' bound to it:
;;;   store old binding in `crypt-old-binding' before overwriting and use in
;;;   function `crypt-bind-insert-file.'
;;; 2.63 -
;;;   lrd: (crypt-encode-buffer, crypt-encode-region, crypt-encrypt-buffer,
;;;   crypt-encrypt-region): changed argument list putting optional buffer
;;;   last and making default action to encode or encrypt. (crypt-encoded-p,
;;;   crypt-encrypted-p): new functions that do the actual testing of file
;;;   contents.  (crypt-find-file): uses these new functions.
;;;   (crypt-rebuild-minor-modes-alist): new function to rebuild
;;;   `minor-mode-alist' called by function crypt-rebuild-tables.
;;;   (crypt-build-minor-mode-alist): new function called by
;;;   `crypt-minor-mode-alist' to create itself.  `crypt-minor-mode-encrypted'
;;;   removed because defined in function crypt-build-minor-mode-alist.
;;; 2.64 -
;;;   lrd: (crypt-find-file-hook): temporarily remove the encrytion file
;;;   extension to help determine the major mode, just like is done with the
;;;   encoding file extension.  In order for this to work properly the file
;;;   extension in `crypt-encryption-file-extension' and
;;;   `crypt-encryption-alist' needs to be inside a pair of \\( \\).
;;; 2.65 -
;;;   lrd: (crypt-find-file-hook): move determination of key, password, into
;;;   (crypt-encrypted-p).
;;; 2.66 -
;;;   lrd: (crypt-set-encryption-key): improve prompt string for encryption
;;;   key.
;;; 2.67 -
;;;   lrd: (crypt-write-file-hook): make check for encryption file-name
;;;   extension case-sensitive.
;;; 2.68 -
;;;   lrd: fixed check for previous addition to `minor-mode-alist' -- was not
;;;   working. Check for an `add-hook' function; if one does not exist then
;;;   use a copy of one from GNU Emacs 19.  When using `add-hook' to append to
;;;   the `write-file-hooks' make sure that the version accepts the optional
;;;   APPEND argument -- v19's does but the one in the elisp archive by Dan
;;;   LaLiberte <liberte@cs.uiuc.edu> does not append.  This causes problems.
;;;   Thanks to Francesco Potorti` <pot@fly.CNUCE.CNR.IT> for pointing this
;;;   out.
;;; 2.69 - [posted to gnu.emacs.sources]
;;;   lrd: doc mod with regards `after-init-hook' and Lucid Emacs.  Add
;;;   pointer to crypt++-fnf.el for people who might be interested.
;;; 2.70 -
;;;   lrd: narrow conditions under which crypt-encryption-magic-regexp
;;;   matches.  Thanks to Philippe Michel <michel@thomson-lcr.fr> and Francois
;;;   Pinard <pinard@iro.umontreal.ca> for helping explain this with regards
;;;   to ISO/Latin-1.
;;; 2.71 -
;;;   lrd: applied patches from Darrin Jewell <jewell@bdi.com> for DOS to UNIX
;;;   support.  DOS entry added to crypt-build-encoding-alist.
;;;   (crypt-dos-to-unix-region, crypt-unix-to-dos-region): New
;;;   functions. (crypt-dos-has-ctrl-z): New buffer-local variable.
;;;   (crypt-encode-region): allow for encoding and decoding programs to be
;;;   elisp expressions.  If they are then apply them directly to region.
;;;   Point out that crypt++.el conflicts with dos-mode.el.
;;; 2.72 -
;;;   lrd: The limit for the regular expression search done by
;;;   `crypt-encrypted-p' is extended to 100 by default.  The enlargement of
;;;   search field is needed because of previous reduction in size of regexp
;;;   being searched for.  (crypt-magic-search-limit): New variable defining
;;;   this new limit.  (crypt-encrypted-p): Uses it and cleaned up.  Doc mod.
;;;   Thanks to Philippe Michel <michel@thomson-lcr.fr>, Francois Pinard
;;;   <pinard@iro.umontreal.ca>, and Dave Goldberg <dsg@blackbird.mitre.org>.
;;; 2.73 - [posted to gnu.emacs.sources]
;;;   lrd: Apply patch from Kevin Rodgers <kevin@traffic.den.mmc.com> that
;;;   uses more verbose messages and capitals.  Doc mod.
;;; 2.74 -
;;;   lrd: Untabify.  (crypt-encrypted-p): Check value of
;;;   `crypt-never-ever-decrypt' before anything else.
;;; 2.75 -
;;;   lrd: (crypt-version): Remove call to `substring'.
;;; 2.76 -
;;;   lrd: (crypt-encryption-magic-regexp-inverse): Add in regexp that will
;;;   match ksh `.sh_history' files so that they are not interpreted as
;;;   encrypted files.  Thanks to Francesco Potorti` <pot@fly.CNUCE.CNR.IT>.
;;; 2.77 - [posted to gnu.emacs.sources]
;;;   lrd: (crypt-bind-insert-file): Use substitute-key-definition to bind
;;;   crypt-insert-file to whatever key insert-file is bound to (not
;;;   necessarily C-x i).  Call crypt-bind-insert-file directly in
;;;   file. Variable crypt-bind-insert-file: Doc mod.  Remove
;;;   crypt-old-binding.  Replace `M-x foobar' in doc strings with
;;;   `\\[foobar]'.
;;; 2.78 -
;;;   lrd: (crypt-auto-write-answer-local): New internal variable.  Holds
;;;   answer to query about file-extension tricks question per buffer.  Thanks
;;;   to George Forman <forman@cs.washington.edu>.  Remove Rod from list of
;;;   maintainers...he's busy enough.  Merge multiple setq forms into single
;;;   setq forms.
;;; 2.79 -
;;;   lrd: (crypt-y-or-n-p): New internal function for querying.  Tests the
;;;   internal variable crypt-auto-write-answer-local to ensure single query.
;;;   (crypt-check-extension-for-encoding): Replace all occurrences of queries
;;;   involving y-or-no-p constructs with crypt-y-or-n-p.
;;; 2.80 - [posted to gnu.emacs.sources]
;;;   lrd: (crypt-set-encryption-key): Shorten interactive prompt.  Change
;;;   documentation.
;;; 2.81 -
;;;   lrd: (crypt-variable-list): Add shell and path variables.
;;;   (crypt-confirm-password): Fix spelling error in doc.
;;; 2.82 -
;;;   lrd: Applied patch from Noah Friedman <friedman@prep.ai.mit.edu>.
;;;   (crypt-encoded-disable-auto-save, crypt-encrypted-disable-auto-save):
;;;   New user-defined variables. (crypt-encoded-mode, crypt-encrypted-mode):
;;;   Use them.
;;; 2.83 - 2feb98
;;;   kb: Changed occurrences of roebling.  Do (set-visited-file-name).
;;;   Incorporate patches from David Rosinger <dsrosing@ingr.com> for win32.
;;; 2.84 - 20mar98
;;;   kb: Applied XEmacs 2.83 patch by hniksic to add custom support.
;;;   Support .tgz as .tar.gz.
;;;   Add bzip support.
;;;   Merge pgp support from John Heidemann <johnh@isi.edu>,
;;;    http://www.isi.edu/~johnh/SOFTWARE/index.html.
;;;    Requires either mailcrypt or "PEM - PGP Enhanced Messaging for
;;;    GNU Emacs" from Roy Frederick Busdiecker, III (Rick).
;;;   Merge Mac support from Daniel M. German <dmg@csg.uwaterloo.ca>.


;;; Code:
