annotate lisp/packages/crypt.el @ 129:e292c9648bb9 xemacs-20-1p3

Import from CVS: tag xemacs-20-1p3
author cvs
date Mon, 13 Aug 2007 09:28:38 +0200
parents cca96a509cfe
children 1856695b1fa9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; crypt.el --- code for handling all sorts of compressed and encrypted files
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;; Author: Lawrence R. Dodd <dodd@roebling.poly.edu>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; Rod Whitby <rwhitby@research.canon.oz.au>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Kyle E. Jones <kyle@uunet.uu.net>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; Maintainer: Lawrence R. Dodd <dodd@roebling.poly.edu>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; Created: crypt.el in 1988, crypt++.el on 18 Jan 1993
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
8 ;; Version: 2.83
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; Date: 1994/03/31 12:30:17
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; Keywords: extensions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;;; Copyright (C) 1994 Lawrence R. Dodd
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;;; Copyright (C) 1993 Lawrence R. Dodd and Rod Whitby
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;;; Copyright (C) 1988, 1989, 1990 Kyle E. Jones
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;;; This program is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;;; it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;;; the Free Software Foundation; either version 2 of the License, or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;;; (at your option) any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;;; This program is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;;; along with this program; if not, write to the Free Software
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;;; Synched up with: Not in FSF.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;;; NOTE: Apparently not being maintained by the author, who now
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;;; uses jka-compr.el. --ben (1/26/96)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;;; Included patch (1/26/96)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ;;; Please see notes on INSTALLATION and USAGE on the pages below.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ;;; LCD Archive Entry:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 ;;; crypt++|Rod Whitby and Lawrence R. Dodd|dodd@roebling.poly.edu|
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ;;; Code for handling all sorts of compressed and encrypted files.|
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
43 ;;; 1994/03/31 12:30:17|2.83|~/misc/crypt++.el.Z|
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ;;; AVAILABLE:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 ;;; via anonymous ftp to roebling.poly.edu [128.238.5.31] in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 ;;; /pub/lisp/crypt++.el.gz
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 ;;; via anonymous ftp to archive.cis.ohio-state.edu [128.146.8.52] in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 ;;; /pub/gnu/emacs/elisp-archive/misc/crypt++.el.Z
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 ;;; BUG REPORTS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 ;;; Type M-x crypt-submit-report to generate a bug report template or put your
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 ;;; cursor at the end of this line and type C-x C-e: (crypt-submit-report)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 ;;; Please note that this bug-report facility (crypt-submit-report) uses Barry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 ;;; Warsaw's reporter.el which is part of GNU Emacs v19 and bundled with many
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 ;;; other packages. If needed, you can obtain a copy of reporter.el at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 ;;; /roebling.poly.edu:/pub/reporter.el or the elisp-archive. In fact,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 ;;; crypt-submit-report will attempt to ange-ftp a copy for you from roebling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 ;;; if you do not have one accessible.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 ;;; Lawrence R. Dodd <dodd@roebling.poly.edu>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 ;;; Polytechnic University
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 ;;; Brooklyn, New York USA
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 ;;; VERSION:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 ;;;
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
71 ;;; Version: 2.83
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 ;;; Ident: crypt++.el,v 2.82 1994/03/31 12:30:17 dodd Exp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 ;;; Date: 1994/03/31 12:30:17
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 ;;; INSTALLATION:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 ;;; To use this package, simply put it in a file called "crypt.el" in a Lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 ;;; directory known to Emacs (see `load-path'), byte-compile it (you may get a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 ;;; warning saying that the function reporter-submit-bug-report is not known
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 ;;; to be defined -- ignore it), and put the line:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 ;;; (require 'crypt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 ;;; in your ~/.emacs file or in the file default.el in the ../lisp directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 ;;; of the Emacs distribution. Do not bother trying to autoload this file;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 ;;; this package uses find-file and write-file hooks and thus should be loaded
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 ;;; the first time you visit any sort of file. Any package loaded after this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 ;;; one that appends something to `write-file-hooks' will not be executed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 ;;; because this package writes out the file. Other packages that append to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 ;;; `write-file-hooks' should either be modified to prepend to that hook or be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 ;;; loaded before this one (preferably the former).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 ;;; NOTE: encryption users should set `crypt-encryption-type' to one of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 ;;; values in `crypt-encryption-alist' (see USAGE below).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 ;;; SEE ALSO: /roebling.poly.edu:/pub/crypt++-fnf.el for file-not-found
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 ;;; support for GNU Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 ;;; SPECIAL NOTES:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 ;;; If crypt is dumped with the emacs executable, or if it has already been
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 ;;; loaded in an emacs session, then modifying the variables used in building
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 ;;; the encryption and encoding tables will have no effect until these tables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 ;;; are rebuilt. This may be done with `M-x crypt-rebuild-tables'. See USAGE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 ;;; below to determine variables for which this is needed. For example,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 ;;; post-load changes to `crypt-encryption-file-extension' or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 ;;; `crypt-freeze-vs-fortran' can be incorporated into the encryption table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 ;;; via `M-x crypt-rebuild-tables'. Similarly, post-load changes to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 ;;; `crypt-bind-insert-file' are handled with `M-x crypt-bind-insert-file'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 ;;; USAGE:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 ;;; By default, intended to be transparent. User-defined variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 ;;; controlling ENCRYPTION are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 ;;; crypt-encryption-type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 ;;; crypt-encryption-file-extension
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 ;;; crypt-never-ever-decrypt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 ;;; crypt-auto-write-buffer-encrypted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 ;;; crypt-confirm-password
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 ;;; crypt-encrypted-disable-auto-save
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 ;;; crypt-encryption-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 ;;; controlling ENCODING are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 ;;; crypt-auto-decode-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 ;;; crypt-auto-write-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 ;;; crypt-query-if-interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 ;;; crypt-no-extension-implies-plain
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 ;;; crypt-freeze-vs-fortran
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 ;;; crypt-compact-vs-C++
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 ;;; crypt-ignored-filenames
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 ;;; crypt-default-encoding
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 ;;; crypt-encoded-disable-auto-save
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 ;;; crypt-encoding-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 ;;; controlling file insertion are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 ;;; crypt-bind-insert-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 ;;; crypt-auto-decode-insert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 ;;; To find out more about these variables, load this file, put your cursor at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 ;;; the end of any of the variable names, and hit C-h v [RET].
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 ;;; NOTE: encryption users should set `crypt-encryption-type' to one of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 ;;; values in `crypt-encryption-alist'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 ;;; Although rarely needed, the following functions may be called interactively
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 ;;; (crypt-encoded-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 ;;; (crypt-encode-region)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 ;;; (crypt-encrypted-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 ;;; (crypt-encrypt-region)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 ;;; (crypt-set-encryption-key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 ;;; (crypt-rebuild-tables)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 ;;; (crypt-insert-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 ;;; (crypt-bind-insert-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 ;;; (crypt-submit-report)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 ;;; To find out more about these functions, load this file, put your cursor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 ;;; inside any of the `()' of the above lines, and hit C-h f [RET].
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 ;;; NOTES ON INTERFACES WITH OTHER PROGRAMS AND PACKAGES:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 ;;; GZIP: the environment variable GZIP of gzip can cause an error if it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 ;;; contains `--verbose' because standard output messages will be appended to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 ;;; gzip'ed files. This corrupts the files. The cleanest solution is to pass
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 ;;; the `--quiet' switch in `crypt-encoding-alist' to override this. use gzip
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 ;;; version 1.0.4 or higher from prep.ai.mit.edu:/pub/gnu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 ;;; TAR-MODE: works properly with version 1.28 (or higher) with v19 emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 ;;; DESCRIPTION:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 ;;; The basic purpose of this package of Lisp functions is to recognize
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 ;;; automatically encrypted and encoded (i.e., compressed) files when they are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 ;;; first visited or written. The BUFFER corresponding to the file is decoded
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 ;;; and/or decrypted before it is presented to the user. The file itself is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 ;;; unchanged on the disk. When the buffer is subsequently saved to disk, a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 ;;; hook function re-encodes the buffer before the actual disk write takes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 ;;; place.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 ;;; This package recognizes all sorts of compressed files by a magic number at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 ;;; the beginning of these files but uses a heuristic to detect encrypted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 ;;; files. If you are asked for an encryption key for a file that is in fact
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 ;;; not encrypted, just hit RET and the file will be accepted as is, and the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 ;;; crypt minor mode will not be entered.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 ;;; Other types of encoding programs may be added to this package by using the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 ;;; variable `crypt-encoding-alist' which contains a table of encoding
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 ;;; programs such as compress, gzip (GNU zip), freeze, and compact.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 ;;; This new extended version of crypt now monitors the filename extensions of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 ;;; buffers that are written out using write-file (C-x C-w). If the filename
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 ;;; extension matches one of the extensions listed in `crypt-encoding-alist,'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 ;;; then this package will write the file out using the corresponding encoding
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 ;;; (compression) method. This is done whether or not the buffer originated
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 ;;; from a previously encoded (compressed) file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 ;;; Thus, if the user is editing a file that may or may not have been encoded
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 ;;; originally (e.g., foobar.Z or foobar) and decides to write it to a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 ;;; different file (e.g., barfoo or barfoo.z or barfoo.C). This package will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 ;;; examine the filename extension and write the buffer in plain format or an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 ;;; alternate encoding (compression) format by searching through the entries
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 ;;; in the table of encoding methods `crypt-encoding-alist.' This change in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 ;;; encoding state is done automatically if the variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 ;;; `crypt-auto-write-buffer' is t otherwise the user is asked.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 ;;; TO DO/KNOWN BUGS/HELP WANTED/APPLY WITHIN:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 ;;; All Users/hackers out there are strongly encouraged to pursue any of these
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 ;;; matters further (especially those that concern encryption and decryption!).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 ;;; It is important to future programmers and modifiers of crypt++.el to know
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 ;;; about its perceived limitations. Since necessity drives invention, users
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 ;;; who find any of the following features of crypt++.el annoying are asked to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 ;;; make suggestions and send patches (again, especially those that concern
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 ;;; encryption and decryption!).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 ;;; * currently crypt++ assumes that if a file is both encrypted and encoded
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 ;;; (i.e., compressed) that the order in which it was done was encryption
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 ;;; first _then_ compression. As has been pointed by many people compression
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 ;;; following encryption is useless since the encrypted file is basically
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 ;;; random. On the other hand, many agree that doing encryption _following_
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 ;;; compression is better since it makes it harder to crack the encryption.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 ;;; We would like to make the ordering of these two user-configurable or if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 ;;; nothing else change the order.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 ;;; Having read the above however, Francois Pinard <pinard@iro.umontreal.ca>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 ;;; writes that encryption following compression may not be harder to crack
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 ;;; since "the fact that the first few uncrypted bytes are expected (the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 ;;; compress signature) facilitates a serious attempt at uncrypting."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 ;;; jwz agrees with Francois.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 ;;; * get write-region and append-to-file to handle encoded and encrypted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 ;;; files. There is an interesting low-level encoding package by Jay Adams
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 ;;; <jka@ece.cmu.edu> called jka-compr.el that might address some of these
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 ;;; issues. We encourage hackers out there to come up with crypt++ versions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 ;;; of write-region and append-to-file. The difficulty is creating versions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 ;;; that mimic the originals as closely as possible.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 ;;; * instead of using call-process-region (which can fail badly if the region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 ;;; is large and there's not much room in /tmp), write the region to a temp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 ;;; file (with a customisable location) and use call-process directly.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 ;;; * users have mentioned trouble using crypt++ and hilit simultaneously since
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 ;;; the functions in write-file-hook for both write the file to disk and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 ;;; return t. A possible solution is to have one of them write to a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 ;;; scratch buffer instead of to disk and return nil and then allow the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 ;;; other to do its work on the scratch buffer and write it to disk. Thanks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 ;;; to Wayne Folta <folta@cs.UMD.EDU> and Amir J Katz <amir@matis.ingr.com>.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 ;;; It would be nice to have another way in emacs to have an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 ;;; after-write-file-hook and a before-write-file-hook of some sort.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 ;;; Lucid Emacs has an after-write-file-hook. Recent versions of hilit19.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 ;;; do not automatically attach to `write-file-hooks' and return t.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 ;;; However, the general problem of multiple packages returning t still
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 ;;; remains. dos-mode.el and crypt.el also conflict.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 ;;; * another possible source of trouble is with encryption (and encoding)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 ;;; programs sticking verbose output into buffers prior to being written to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 ;;; disk. This was definitely occurring with gzip because of --verbose in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 ;;; the GZIP environment variable and is solved/hidden with the --quiet
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 ;;; switch. However, I suspect that some encryption problems out there are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 ;;; capable of similar things so the user should be careful.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 ;;; * integrating crypt++ with a backgrounding package such as Olin Shivers'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 ;;; `background.el' might be useful too. thanks to Mark Borges
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 ;;; <mdb@noaacrd.Colorado.EDU> for suggesting this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 ;;; * Performing M-x crypt-encode-buffer or M-x crypt-encrypt-buffer and then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 ;;; saving the file would possibly cause errors. It is better to toggle
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 ;;; `crypt-encoded-mode' (or `crypt-encrypted-mode') and simply save the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 ;;; file. It is for this reason that `crypt-encode-buffer' and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 ;;; `crypt-encrypt-buffer' are not interactive.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 ;;; * use plists instead of alists replacing calls to `nth' with `get'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 ;;; * merge encryption code completely into encoding code making encryption
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 ;;; just a special case of encoding.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 ;;; Change log:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 ;;; 1.1 - original version of crypt.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 ;;; 1.2 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 ;;; jwz: works with tar-mode.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 ;;; jwz: applied patch from piet, merged with Lawrence Dodd's gzip version
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 ;;; 1.3 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 ;;; lrd: fixed compress-magic-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 ;;; 1.4, 1.5, 1.6 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 ;;; lrd: write-file compresses or gzips based on file extension
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 ;;; 2.1 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 ;;; lrd: merged with Rod Whitby's table-driven version (major upgrade)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 ;;; 2.2 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 ;;; rjw: Changed file name to crypt++.el, so archie and lispdir can find it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 ;;; 2.3 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 ;;; rjw: Separated the hook additions and minor mode alist additions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 ;;; 2.4 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 ;;; rjw: Fixed the interactive form for crypt-buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 ;;; 2.5 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 ;;; lrd: doc mods, changed GNU free software notice (was out of date), added
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 ;;; anonymous ftp information
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 ;;; 2.6 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 ;;; lrd: added back in definition of `buffer' in defun crypt-buffer caused
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 ;;; an error when trying to read encrypted file; modified check for minor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 ;;; mode alist addition; added gzip magic number warning
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 ;;; 2.7 - [posted to gnu.emacs.sources]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 ;;; lrd: added `TO DO' and `KNOW BUGS' section to header
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 ;;; 2.8 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 ;;; lrd: added note about updating to v 1.24 of tar-mode.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 ;;; Thanks to Mark Borges <mdb@noaacrd.Colorado.EDU>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 ;;; 2.9 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 ;;; lrd: moved query about `crypt-freeze-vs-fortran' out of defvar for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 ;;; `crypt-encoding-alist,' an erroneous value of nil was being stuck into
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 ;;; alist when user set `crypt-freeze-vs-fortran' was nil, doc mod.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 ;;; Thanks to Mark Borges <mdb@noaacrd.Colorado.EDU>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 ;;; 2.10 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 ;;; rjw: moved query about `crypt-freeze-vs-fortran' back into defvar for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 ;;; `crypt-encoding-alist,' - used append to ignore the erroneous nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 ;;; 2.11 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 ;;; rjw: fixed a bug in my fix :-(
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 ;;; 2.12 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 ;;; rjw: Defvar crypt-magic-regexp and crypt-magic-regexp-inverse and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 ;;; allow either a regexp or an elisp expression.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 ;;; Suggested by Franc,ois Pinard <pinard@iro.umontreal.ca>.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 ;;; 2.13 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 ;;; lrd: added in info on lispdir.el, doc mods and some puttering while
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 ;;; looking over rjw's v 2.12 mods.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 ;;; 2.14 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 ;;; lrd: doc mod - trivial huh? switched `compact' and `gzip' in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 ;;; `crypt-encoding-alist' - want gzip near top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 ;;; 2.15 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 ;;; lrd: added in LCD Archive Entry and modified comments on tar-mode.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 ;;; since the version at the elisp-archive now works with crypt++.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 ;;; 2.16 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 ;;; lrd: provide `crypt' as well as `crypt++' allowing something like `ln -s
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 ;;; crypt++.el crypt.el' to be meaningful
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 ;;; Suggested (by|as) Per Abrahamsen <amanda@iesd.auc.dk>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 ;;; 2.17 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 ;;; lrd: clarified bug report procedure, added fancy pseudo-graphics, added
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 ;;; to the `TO DO' list, put RCS tags in LCD Archive entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 ;;; 2.18 - [posted to gnu.emacs.sources]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 ;;; lrd: included pointer to elisp archive in crypt-version description,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 ;;; changed "Decode buffer %s? " to "Decode %s? " in crypt-find-file-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 ;;; to be more general (mainly for crypt-insert-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 ;;; 2.19 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 ;;; rjw: Added the crypt-compact-vs-C++ switch to distinguish compacted and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 ;;; C++ files.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 ;;; 2.20 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 ;;; lrd: (1) modified interactive form of crypt-buffer. (2) made search
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 ;;; case-insensitive in crypt-submit-report. (3) modified encoded-mode and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 ;;; crypt-mode so that buffer-modified is not unconditionally set to nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 ;;; when the mode is not changed. Thanks to Gerd Hillebrand
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 ;;; <ggh@cs.brown.edu> for suggesting (2) and (3).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 ;;; 2.21 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 ;;; rjw: Added an entry to the TODO list about the hazards of using
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 ;;; call-process-region on a large region and not much room in /tmp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 ;;; (David Carlisle <carlisle@computer-science.manchester.ac.uk>).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 ;;; 2.22 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 ;;; lrd: allow write-file-hooks to contain functions as well as lists.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 ;;; Contributed by Ken Laprade <laprade@trantor.harris-atd.com>.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 ;;; 2.23 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 ;;; lrd: made crypt-submit-report list values of more user-defined variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 ;;; 2.24 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 ;;; lrd: pass the -q switch to gzip to thwart the possibility of a --verbose
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 ;;; in the GZIP environment variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 ;;; 2.25 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 ;;; lrd: added some more to the TO DO list, clarified some things, also
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 ;;; untabified the entire file (I got tired of the control I's)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 ;;; 2.26 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 ;;; lrd: use the long-named options for GNU zip (self-documenting)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 ;;; 2.27 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 ;;; lrd: included observation by Francois Pinard <pinard@iro.umontreal.ca>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 ;;; and worked on text in TO DO/KNOWN BUGS list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 ;;; 2.28 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 ;;; lrd: added two new variables in (crypt-submit-report) to the list stuck
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 ;;; at the bottom of the mail message; changed the comments regarding the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 ;;; user-defined variables. added in default values in user defined
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 ;;; variables. added to and removed stuff to the `TO DO' list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 ;;; (encoded-mode):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 ;;; added in code to remove any auto-save-files that may have been formed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 ;;; before becoming an encoded buffer (for example a plain file saved to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 ;;; disk encoded had orphan auto-save-files left behind). turning off
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 ;;; auto-save-mode disables the creation of auto-save-files, but it also
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 ;;; disables the possibility of these being removed when the buffer is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 ;;; saved.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 ;;; (crypt-region):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 ;;; now call the encryption and decryption program directly instead of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 ;;; through the shell. this is more secure since the shell will expose the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 ;;; password (key). thanks to Jon Cargille <jcargill@cs.wisc.edu>. defined
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 ;;; two new variables `crypt-decryption-args' and `crypt-encryption-args' to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 ;;; take the arguments separately. removed (let ((opoint)...)) construct
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 ;;; this was a throw back to some old dead code and was not being used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 ;;; 2.29 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 ;;; lrd: added three new variables in (crypt-submit-report); added to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 ;;; `TO DO' list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 ;;; (encode-region,encode-buffer,encoded-mode): fixed interactive forms -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 ;;; the conversion to table version had eliminated some of the interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 ;;; features of these. thanks to Kimball Collins <kpc@ptolemy.arc.nasa.gov>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 ;;; for point this out. new interactive form uses functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 ;;; `crypt-get-encoding-type' and `crypt-symbol-alist-to-table' and variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 ;;; `crypt-default-encoding' to generate completion list of encoding types.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 ;;; (crypt-write-file-hook): two new user-defined variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 ;;; `crypt-query-if-interactive' and `crypt-no-extension-implies-plain' and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 ;;; the buffer-local variable `buffer-interactive-mode' are used to help
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 ;;; determined whether or not plain output is really desired for files
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 ;;; without a compression file-name extension. the default behavior is the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 ;;; same as before.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 ;;; 2.30 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 ;;; lrd: added test for user-defined variable `crypt-never-ever-decrypt'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 ;;; when finding a file. some users may never wish to decrypt files
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 ;;; and like to edit binary files. thanks to Nelson Minar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 ;;; <nelson@reed.edu>. added to doc-strings of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 ;;; `crypt-magic-regexp[-inverse]' -- these can be set to nil[t] and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 ;;; accomplish the same thing as setting `crypt-never-ever-decrypt' to t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 ;;; 2.31 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 ;;; rjw: Updated the comments in the encryption check section.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 ;;; 2.32 - [posted to gnu.emacs.sources]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 ;;; lrd: added warning about `crypt-(de|en)cryption-program'; doc mod.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 ;;; 2.33 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 ;;; lrd: if `crypt-(de|en)cryption-args' are nil then don't pass any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 ;;; arguments to (de|en)cryption program, nil is the default instead of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 ;;; "". Thanks to Joe Ilacqua <spike@world.std.com>, David J. Schur
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 ;;; <djs@idm.com>, Peter Nuth <nuth@ai.mit.edu>, and Greg Larson
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 ;;; <glarson@bnr.ca>. `-q' exists in gzip 1.0.3 but not `--quiet' changed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 ;;; GZIP NOTE. Thanks to Chris Moore <moore@src.bae.co.uk>.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 ;;; 2.34 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 ;;; lrd: allow `crypt-(de|en)cryption-args' to be a list of strings -- more
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 ;;; robust. query for password (key), if none is set, when writing out file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 ;;; for which `buffer-save-encrypted' is t. Thanks to John Interrante
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 ;;; <interran@uluru.Stanford.EDU>. (crypt-write-file-hook): check filename
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 ;;; extension against regexp `crypt-encryption-file-extension' and query for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 ;;; encryption, unless `crypt-auto-write-buffer-encrypted' is t (don't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 ;;; bother doing reverse check, encrypted to plain, not a common request).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 ;;; (crypt-mode): delete auto-save files (cf., encoded-mode), may exist now.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 ;;; (read-string-no-echo): applied patch from Piet van Oostrum
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 ;;; <piet@cs.ruu.nl> -- set `cursor-in-echo-area' _after_ setting buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 ;;; (this was screwing up gnews).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 ;;; 2.35 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 ;;; lrd: doc mod
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 ;;; 2.36 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 ;;; lrd: fixed typo, added RMAIL note.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 ;;; 2.37 - [posted to gnu.emacs.sources]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 ;;; lrd:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 ;;; (crypt-write-file-hook): search user-defined list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 ;;; `crypt-ignored-filenames' for possible match with `buffer-filename'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 ;;; before attempting conversion from compressed to plain format; useful for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 ;;; compressed incoming mail files (e.g., RMAIL, INBOX).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 ;;; (crypt-mode): query for key if not set already; need to switch order of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 ;;; recovering key and toggling crypt-mode in crypt-find-file-hook (thanks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 ;;; to Piet van Oostrum <piet@cs.ruu.nl>).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 ;;; (crypt-buffer) and (encode-buffer): remove interactive form; use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 ;;; (crypt-mode) and (encoded-mode) instead so encryption and compression
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 ;;; are done at the very end; leave interactive form in (crypt-region) and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 ;;; (encode-region) may still be used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 ;;; (set-encryption-key): remove from `command-history' if called
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 ;;; interactively - thanks to George M. Georgiou
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 ;;; <georgiou@silicon.csci.csusb.edu>.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 ;;; 2.38 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 ;;; lrd: added `crypt-' prefix to `(read-string-no-echo)' and `(save-point)'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 ;;; changed file extension for gzip files to `.z' _or_ `.gz' (future release
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 ;;; of gzip with use later extension by default and so this should be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 ;;; changed to just `.gz' someday).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 ;;; 2.39 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 ;;; lrd: doc mod. added in patch from jwz - `(crypt-read-string-no-echo)' is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 ;;; more secure, put property 'permanent-local on buffer-locals works for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 ;;; Lucid Emacs and doesn't harm v18 emacs, change `buffer-interactive-mode'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 ;;; to `buffer-interactive-encoded-mode.'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 ;;; 2.40 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 ;;; lrd: put property 'preserved in case kill-fix.el is being used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 ;;; 2.41 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 ;;; lrd: all functions and variables now start with `crypt-', moved REVISION
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 ;;; HISTORY to bottom of header, interactive version of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 ;;; `(crypt-encrypt-region)' clearer, `(crypt-read-string-no-echo)' now
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 ;;; echos `.'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 ;;; 2.42 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 ;;; lrd: (crypt-check-extension-for-encoding): broke out of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 ;;; `(crypt-write-file-hook)'. setting user variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 ;;; `crypt-compact-vs-C++' and `crypt-freeze-vs-fortran' to nil no longer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 ;;; completely disables the reading compact'ed and frozen files but just
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 ;;; disables the use of the file-extension tricks of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 ;;; `(crypt-check-extension-for-encoding).' (crypt-encode-region): allow
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 ;;; for a single line message from encoding program at top of region; if it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 ;;; is there, then remove it; kludge for `compact' program.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 ;;; 2.43 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 ;;; lrd: (crypt-encode-region): generalize the clean up procedure; add
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 ;;; element to `crypt-encoding-alist' and introduce new function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 ;;; `(crypt-encoding-cleanup-regexp)' to extract a compression specific
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 ;;; regexp for erroneous message or lisp expression for cleanup.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 ;;; 2.44 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 ;;; lrd: new element for `crypt-encoding-alist' handles whether or not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 ;;; file-name extension tricks may be play with encoding method; compact and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 ;;; freeze values default to `crypt-compact-vs-C++' and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 ;;; `crypt-freeze-vs-fortran' (thanks to rjw);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 ;;; (crypt-encoding-extension-tricks): new defun to handle this;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 ;;; (crypt-check-extension-for-encoding): monitors "tricks" entry of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 ;;; `crypt-encoding-alist' and adjust the bag of tricks it can apply.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 ;;; 2.45 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 ;;; lrd: (crypt-encode-region): delete entire match of cleanup regexp by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 ;;; requiring newlines in GARBAGE-REGEXP-OR-LISPEXP. (crypt-submit-report):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 ;;; use Warsaw's reporter.el.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 ;;; 2.46 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 ;;; lrd: (crypt-find-file-hook, crypt-write-file-hook): cleaned, documented,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 ;;; and replaced occurrences of `(cond (C BODY))' with `(if C BODY)';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 ;;; changed `crypt-magic-regexp' to `crypt-encryption-magic-regexp' and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 ;;; `crypt-magic-regexp-inverse' to `crypt-encryption-magic-regexp-inverse'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 ;;; for consistency with other variable names. new user-defined variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 ;;; `crypt-encryption-minor-mode-name' instead of always "Crypt". grouped
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 ;;; all encryption variables together.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 ;;; 2.47 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 ;;; lrd: somewhat major change - put program-specific encryption variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 ;;; into a single table `crypt-encryption-alist' and let the variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 ;;; `crypt-encryption-type' define the appropriate entry to use; new
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 ;;; user-defined variable `crypt-confirm-password,' thanks to Jeff Clark
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 ;;; <jclark@src.honeywell.com>. (crypt-submit-report): improved error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 ;;; handling, thanks to baw. (crypt-write-file-hook): fixed bug with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 ;;; `crypt-encoding-extension-tricks'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 ;;; 2.48 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 ;;; lrd: added dummy argument to `crypt-encoding-alist' and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 ;;; `crypt-encryption-alist' and merged all defuns that work on their
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 ;;; elements into defuns that all start with `crypt-get-' and look through
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 ;;; both lists. simplifies some of code and closer to treating encryption
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 ;;; as a special case of encoding; crypt-minor-mode-alist: replaced (nth *)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 ;;; with `(crypt-get-minor-mode)' call; (crypt-encode-region): allow
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 ;;; arguments to be list of strings; renamed (crypt-get-encoding-type) to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 ;;; (crypt-read-encoding-type) for clarity.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 ;;; 2.49 - [posted to gnu.emacs.sources]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 ;;; lrd: (crypt-encode-region): ignore `args' if set to t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 ;;; 2.50 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 ;;; lrd: (crypt-write-file-hook): in v19 we need to call `backup-buffer'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 ;;; ourselves -- we write out the file and return t so `basic-save-buffer'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 ;;; does not do it; also call `set-file-modes'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 ;;; 2.51 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 ;;; lrd: some `defvar's are now `defconst's and tar-mode note was changed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 ;;; 2.52 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 ;;; lrd: make doc strings conform to GNU standards.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 ;;; 2.53 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 ;;; lrd: made header conform to GNU Conventional Headers standard.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 ;;; 2.54 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 ;;; lrd: `crypt-encryption-file-extension', `crypt-freeze-vs-fortran',
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 ;;; `crypt-compact-vs-C++', `crypt-encryption-magic-regexp', and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 ;;; `crypt-encryption-magic-regexp-inverse' are used in defining the tables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 ;;; `crypt-encoding-alist' and `crypt-encryption-alist' and so need to be set
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 ;;; _before_ loading crypt++. use `add-hook' if it is available.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 ;;; 2.55 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 ;;; lrd: new interactive function `crypt-insert-file' mimics `insert-file'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 ;;; but attempts to decode or decrypt before insertion; bound `C-x i' if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 ;;; `crypt-bind-insert-file' is non-nil. comment out doc-strings from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 ;;; internal subroutines, saves space.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 ;;; 2.56 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 ;;; tfb: change the definitions of crypt-{encoding,encryption}-alist, to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 ;;; call the functions crypt-make-{encoding,encryption}-alist resp.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 ;;; Added crypt-reinit which regenerates these variables from their
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 ;;; functions, thus allowing this stuff to be preloaded even if people
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 ;;; set things in their init files.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 ;;; Tim Bradshaw <tim.bradshaw@mid-heidelberg.de>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 ;;; 2.57 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 ;;; lrd: untabify; remove duplicate entry in `crypt-make-encoding-alist';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 ;;; change name of `crypt-make-*-alist' to `crypt-build-*-alist' and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 ;;; `crypt-reinit' to `crypt-rebuild-tables'; (crypt-read-string-no-echo):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 ;;; change local variable `form' to `help-form' so it is defined;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 ;;; `crypt-encryption-alist' and `crypt-encoding-alist' must be defined with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 ;;; `defconst' since we wish crypt++ to initialize these variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 ;;; unconditionally; modify INSTALLATION section to reflect these changes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 ;;; 2.58 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 ;;; lrd: doc mod.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 ;;; 2.59 - [posted to gnu.emacs.sources]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 ;;; lrd: (crypt-bind-insert-file): new function for changing "C-x i" in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 ;;; initialization file or interactively.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 ;;; 2.60 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 ;;; lrd: add `crypt-rebuild-tables' and `crypt-bind-insert-file' to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 ;;; `after-init-hook' in GNU emacs v19 and to `term-setup-hook' in Lucid
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 ;;; emacs. Change INSTALLATION notes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 ;;; 2.61 - [posted to gnu.emacs.sources]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 ;;; lrd: Doc mod. Clean up the installation of minor mode indicators.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 ;;; 2.62 - [posted to gnu.emacs.sources]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 ;;; lrd: installed patch from stig@hackvan.com to simplify crypt-get-* defuns
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 ;;; (now defmacros). Don't add to `term-setup-hook' unless no
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 ;;; `after-init-hook' _and_ definitely running v19, otherwise Rod gets an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 ;;; error at home :-<. Don't assume C-x i had `insert-file' bound to it:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 ;;; store old binding in `crypt-old-binding' before overwriting and use in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 ;;; function `crypt-bind-insert-file.'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 ;;; 2.63 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 ;;; lrd: (crypt-encode-buffer, crypt-encode-region, crypt-encrypt-buffer,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 ;;; crypt-encrypt-region): changed argument list putting optional buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 ;;; last and making default action to encode or encrypt. (crypt-encoded-p,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 ;;; crypt-encrypted-p): new functions that do the actual testing of file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 ;;; contents. (crypt-find-file): uses these new functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 ;;; (crypt-rebuild-minor-modes-alist): new function to rebuild
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 ;;; `minor-mode-alist' called by function crypt-rebuild-tables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 ;;; (crypt-build-minor-mode-alist): new function called by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 ;;; `crypt-minor-mode-alist' to create itself. `crypt-minor-mode-encrypted'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 ;;; removed because defined in function crypt-build-minor-mode-alist.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 ;;; 2.64 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 ;;; lrd: (crypt-find-file-hook): temporarily remove the encrytion file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 ;;; extension to help determine the major mode, just like is done with the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 ;;; encoding file extension. In order for this to work properly the file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 ;;; extension in `crypt-encryption-file-extension' and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 ;;; `crypt-encryption-alist' needs to be inside a pair of \\( \\).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 ;;; 2.65 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 ;;; lrd: (crypt-find-file-hook): move determination of key, password, into
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 ;;; (crypt-encrypted-p).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 ;;; 2.66 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 ;;; lrd: (crypt-set-encryption-key): improve prompt string for encryption
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 ;;; key.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 ;;; 2.67 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 ;;; lrd: (crypt-write-file-hook): make check for encryption file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 ;;; extension case-sensitive.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 ;;; 2.68 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 ;;; lrd: fixed check for previous addition to `minor-mode-alist' -- was not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 ;;; working. Check for an `add-hook' function; if one does not exist then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 ;;; use a copy of one from GNU Emacs 19. When using `add-hook' to append to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 ;;; the `write-file-hooks' make sure that the version accepts the optional
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 ;;; APPEND argument -- v19's does but the one in the elisp archive by Dan
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 ;;; LaLiberte <liberte@cs.uiuc.edu> does not append. This causes problems.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 ;;; Thanks to Francesco Potorti` <pot@fly.CNUCE.CNR.IT> for pointing this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 ;;; out.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 ;;; 2.69 - [posted to gnu.emacs.sources]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 ;;; lrd: doc mod with regards `after-init-hook' and Lucid Emacs. Add
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 ;;; pointer to crypt++-fnf.el for people who might be interested.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 ;;; 2.70 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 ;;; lrd: narrow conditions under which crypt-encryption-magic-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 ;;; matches. Thanks to Philippe Michel <michel@thomson-lcr.fr> and Francois
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 ;;; Pinard <pinard@iro.umontreal.ca> for helping explain this with regards
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 ;;; to ISO/Latin-1.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 ;;; 2.71 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 ;;; lrd: applied patches from Darrin Jewell <jewell@bdi.com> for DOS to UNIX
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 ;;; support. DOS entry added to crypt-build-encoding-alist.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 ;;; (crypt-dos-to-unix-region, crypt-unix-to-dos-region): New
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 ;;; functions. (crypt-dos-has-ctrl-z): New buffer-local variable.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 ;;; (crypt-encode-region): allow for encoding and decoding programs to be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 ;;; elisp expressions. If they are then apply them directly to region.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 ;;; Point out that crypt++.el conflicts with dos-mode.el.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 ;;; 2.72 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 ;;; lrd: The limit for the regular expression search done by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 ;;; `crypt-encrypted-p' is extended to 100 by default. The enlargement of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 ;;; search field is needed because of previous reduction in size of regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 ;;; being searched for. (crypt-magic-search-limit): New variable defining
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 ;;; this new limit. (crypt-encrypted-p): Uses it and cleaned up. Doc mod.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 ;;; Thanks to Philippe Michel <michel@thomson-lcr.fr>, Francois Pinard
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 ;;; <pinard@iro.umontreal.ca>, and Dave Goldberg <dsg@blackbird.mitre.org>.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 ;;; 2.73 - [posted to gnu.emacs.sources]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 ;;; lrd: Apply patch from Kevin Rodgers <kevin@traffic.den.mmc.com> that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 ;;; uses more verbose messages and capitals. Doc mod.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 ;;; 2.74 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 ;;; lrd: Untabify. (crypt-encrypted-p): Check value of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 ;;; `crypt-never-ever-decrypt' before anything else.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 ;;; 2.75 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 ;;; lrd: (crypt-version): Remove call to `substring'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 ;;; 2.76 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 ;;; lrd: (crypt-encryption-magic-regexp-inverse): Add in regexp that will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 ;;; match ksh `.sh_history' files so that they are not interpreted as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 ;;; encrypted files. Thanks to Francesco Potorti` <pot@fly.CNUCE.CNR.IT>.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 ;;; 2.77 - [posted to gnu.emacs.sources]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 ;;; lrd: (crypt-bind-insert-file): Use substitute-key-definition to bind
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 ;;; crypt-insert-file to whatever key insert-file is bound to (not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 ;;; necessarily C-x i). Call crypt-bind-insert-file directly in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 ;;; file. Variable crypt-bind-insert-file: Doc mod. Remove
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 ;;; crypt-old-binding. Replace `M-x foobar' in doc strings with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 ;;; `\\[foobar]'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 ;;; 2.78 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 ;;; lrd: (crypt-auto-write-answer-local): New internal variable. Holds
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 ;;; answer to query about file-extension tricks question per buffer. Thanks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 ;;; to George Forman <forman@cs.washington.edu>. Remove Rod from list of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 ;;; maintainers...he's busy enough. Merge multiple setq forms into single
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 ;;; setq forms.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 ;;; 2.79 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 ;;; lrd: (crypt-y-or-n-p): New internal function for querying. Tests the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 ;;; internal variable crypt-auto-write-answer-local to ensure single query.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 ;;; (crypt-check-extension-for-encoding): Replace all occurrences of queries
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 ;;; involving y-or-no-p constructs with crypt-y-or-n-p.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 ;;; 2.80 - [posted to gnu.emacs.sources]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 ;;; lrd: (crypt-set-encryption-key): Shorten interactive prompt. Change
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 ;;; documentation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 ;;; 2.81 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 ;;; lrd: (crypt-variable-list): Add shell and path variables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 ;;; (crypt-confirm-password): Fix spelling error in doc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 ;;; 2.82 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 ;;; lrd: Applied patch from Noah Friedman <friedman@prep.ai.mit.edu>.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 ;;; (crypt-encoded-disable-auto-save, crypt-encrypted-disable-auto-save):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 ;;; New user-defined variables. (crypt-encoded-mode, crypt-encrypted-mode):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 ;;; Use them.
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
695 ;;; 2.83 -
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
696 ;;; hniksic: Added custom.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 ;;;; User definable variables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
703 (defgroup crypt nil
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
704 "Handling compressed and encrypted files."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
705 :group 'data)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
706
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
707 (defcustom crypt-encryption-type 'crypt
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 "*Method of encryption. Must be an element of `crypt-encryption-alist.'
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
709 If you change this after crypt++ is loaded then do \\[crypt-rebuild-tables]."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
710 :type 'symbol
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
711 :group 'crypt)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
713 (defcustom crypt-encryption-file-extension nil
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 "*Regexp for extension of files encrypted with `crypt-encryption-type.'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 Should be of the form \"\\\\(\\\\.foo\\\\)$\". nil says use default values in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 `crypt-encryption-alist.' If you change this after crypt++ is loaded then do
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
717 \\[crypt-rebuild-tables]."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
718 :type 'regexp
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
719 :group 'crypt)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
721 (defcustom crypt-never-ever-decrypt nil
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
722 "*t says never attempt to decrypt a buffer."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
723 :type 'boolean
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
724 :group 'crypt)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
726 (defcustom crypt-auto-write-buffer-encrypted nil
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 "*t says files with `crypt-encryption-alist' file extension auto-encrypted.
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
728 nil says query. See `crypt-auto-write-buffer.'"
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
729 :type 'boolean
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
730 :group 'crypt)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
732 (defcustom crypt-confirm-password nil
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
733 "*t says confirm new passwords and when writing a newly encrypted buffer."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
734 :type 'boolean
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
735 :group 'crypt)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
737 (defcustom crypt-encoded-disable-auto-save t
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 "*If t, turn off auto-save-mode for buffers which are encoded.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 If non-nil but not t, then no message is displayed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 The default is t is because there isn't any way to tell emacs to encode the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 autosave file, so the autosave would be in a different format from the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 original. The disadvantage of turning off autosaves is that any work you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 do in that buffer will be completely lost if the changes are not explicitly
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 saved.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 It is probably best to set this variable to nil and use buffer-local
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 variables in files for which you don't actually care about autosaves.
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
749 Unencoded recovery data is better than none at all."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
750 :type '(choice (const :tag "on" t)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
751 (const :tag "off" nil)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
752 (const :tag "no message" other))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
753 :group 'crypt)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
755 (defcustom crypt-encrypted-disable-auto-save t
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 "*If t, turn off auto-save-mode for buffers which are encrypted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 If non-nil but not t, then no message is displayed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 The default is t is because there isn't any way to tell emacs to encrypt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 the autosave file, so the autosave would be in cleartext form. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 disadvantage of turning off autosaves is that any work you do in that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 buffer will be completely lost if the changes are not explicitly saved.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 You might consider setting this variable to nil and use buffer-local
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 variables in files for which security is more important than data
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
766 recovery."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
767 :type '(choice (const :tag "on" t)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
768 (const :tag "off" nil)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
769 (const :tag "no message" other))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
770 :group 'crypt)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 ;;; ENCRYPTION
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 ;;; Encrypted files have no magic number, so we have to hack a way of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 ;;; determining when a buffer should be decrypted. we do this only buffers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 ;;; that match a MAGIC-REGEXP very close to beginning of buffer and that do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 ;;; _NOT_ match a MAGIC-REGEXP-INVERSE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 ;;; Currently MAGIC-REGEXP matches non-ASCII characters and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 ;;; MAGIC-REGEXP-INVERSE will match Sun OS, 4.x BSD, and Ultrix executable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 ;;; magic numbers, so binaries can still be edited (heh) without headaches.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 (defconst crypt-encryption-magic-regexp "[\000\200-\237]"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 "Regexp that must be found very close to beginning of encrypted buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 This is intended to be an internal variable \(not user-visible\). If you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 change this after crypt++ is loaded then do \\[crypt-rebuild-tables].")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 (defconst crypt-encryption-magic-regexp-inverse
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 "\\`\201\001\\|^\\(..\\)?\\([\007\010\013]\001\\|\001[\007\010\013]\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 "Regexp that must *not* be found very close to beginning of encrypted buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 This is intended to be an internal variable \(not user-visible\). If you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 change this after crypt++ is loaded then do \\[crypt-rebuild-tables].")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 (defconst crypt-magic-search-limit 100
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 "Limit of regular expression search used to recognize encrypted files.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 Maximum position in file for presence of `crypt-encryption-magic-regexp' and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 absence of `crypt-encryption-magic-regexp-inverse'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 (defun crypt-build-encryption-alist ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 ;; Returns the encryption alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 ;; crypt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 (list 'crypt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 crypt-encryption-magic-regexp crypt-encryption-magic-regexp-inverse
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 (or crypt-encryption-file-extension "\\(\\.e\\)$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 "crypt" "crypt"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 "Crypt"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 ;; DES (Cipher Block Chaining - CBC) [DES' default]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 (list 'des
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 crypt-encryption-magic-regexp crypt-encryption-magic-regexp-inverse
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 (or crypt-encryption-file-extension "\\(\\.des\\)$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 "des" "des"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 '("-e" "-k")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 '("-d" "-k")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 "DES-CBC"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 ;; DES (Electronic Code Book - ECB)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 (list 'des-ecb
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 crypt-encryption-magic-regexp crypt-encryption-magic-regexp-inverse
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 (or crypt-encryption-file-extension "\\(\\.des\\)$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 "des" "des"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 '("-e" "-b" "-k")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 '("-d" "-b" "-k")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 "DES-ECB"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 ;; PGP
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 (list 'pgp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 crypt-encryption-magic-regexp crypt-encryption-magic-regexp-inverse
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 (or crypt-encryption-file-extension "\\(\\.pgp\\)$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 "pgp" "pgp"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 '("+batchmode" "+verbose=0" "-c" "-f" "-z")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 '("+batchmode" "+verbose=0" "-f" "-z")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 "PGP"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 ;; Add new elements here ...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 (defconst crypt-encryption-alist (crypt-build-encryption-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 "List of elements describing the encryption methods available.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 each element looks like
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 \(ENCRYPTION-TYPE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 MAGIC-REGEXP MAGIC-REGEXP-INVERSE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 FILE-EXTENSION
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 ENCRYPT-PROGRAM DECRYPT-PROGRAM
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 ENCRYPT-ARGS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 DECRYPT-ARGS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 MINOR-MODE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 GARBAGE-REGEXP-OR-LISPEXP
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 FILE-EXTENSION-TRICKS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 \)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 ENCRYPTION-TYPE is a symbol denoting the encryption type.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 MAGIC-REGEXP regexp that must match very close to the beginning of an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 encrypted buffer. This may also be some elisp expression to be evaluated at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 \(point-min\) that will return t for an encrypted buffer. If this is set to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 nil then crypt++ will never try to decrypt a buffer. Currently set to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 internal variable `crypt-encryption-magic-regexp' which will match non-ASCII
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 characters.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 MAGIC-REGEXP-INVERSE regexp that must _NOT_ match very close to the beginning
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 of an encrypted buffer. This may also be some elisp expression to be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 evaluated at \(point-min\) that will return t for a NON-encrypted buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 If this is set to t then crypt++ will never try to decrypt a buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 Currently set to the internal variable `crypt-encryption-magic-regexp-inverse'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 which will match Sun OS, 4.x BSD, and Ultrix executable magic numbers, so
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 binaries can still be edited (heh) without headaches.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 FILE-EXTENSION regexp denoting the file extension usually appended the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 filename of files encrypted with ENCRYPT-PROGRAM. The variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 `crypt-encryption-file-extension' will over ride the default.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 ENCRYPT-PROGRAM name of executable file to be used for encryption.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 DECRYPT-PROGRAM name of executable file to be used for decryption.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 ENCRYPT-ARGS arguments to be passed to ENCRYPT-PROGRAM may be a string or a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 list of strings or nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 DECRYPT-ARGS arguments to be passed to DECRYPT-PROGRAM may be a string or a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 list of strings or nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 MINOR-MODE string denoting the name for the encrypted minor mode as it will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 appear in the mode line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 GARBAGE-REGEXP-OR-LISPEXP dummy variable for compatibility with encoding.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 FILE-EXTENSION-TRICKS is t or nil depending on whether or not tricks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 converting between different encryption types can be done based on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902 FILE-EXTENSION; typically t.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903 ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 ;;; ENCODING
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
908 (defcustom crypt-auto-decode-buffer t
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909 "*t says buffers visiting encoded files will be decoded automatically.
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
910 nil means to ask before doing the decoding."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
911 :type 'boolean
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
912 :group 'crypt)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
914 (defcustom crypt-auto-write-buffer nil
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 "*t says save files with `crypt-encoding-alist' file extensions as encoded.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916 nil says to ask before doing this encoding. Similarly, buffers originating
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917 from encoded files to be written to files not ending in `crypt-encoding-alist'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918 file extensions will be written in plain format automatically. nil says to
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
919 ask before doing this decoding."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
920 :type 'boolean
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
921 :group 'crypt)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923 ;; This is an internal variable documented here and not in a DOCSTRING in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924 ;; order to save memory. If this variable's value has been changed from its
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925 ;; default, then it contains the answer to the question "Write out buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926 ;; foobar using `compression-type'?". This question is asked only if *plain*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 ;; buffer foobar is being written to disk *and* it has a provocative
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928 ;; `compression-type' file-name extension (see DOCSTRING for variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929 ;; crypt-auto-write-buffer). The variable is local to all buffers with a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 ;; default value of 'ask so if the situation described above arises, then the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 ;; question is asked at least once, unless the user-defined variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932 ;; crypt-auto-write-buffer is non-nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933 (defvar crypt-auto-write-answer-local 'ask)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934 (make-variable-buffer-local 'crypt-auto-write-answer-local)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935 (setq-default crypt-auto-write-answer-local 'ask)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936 (put 'crypt-auto-write-answer-local 'permanent-local t) ; for v19 Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937 (put 'crypt-auto-write-answer-local 'preserved t) ; for kill-fix.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
939 (defcustom crypt-query-if-interactive t
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940 "*t says ask when saving buffers where `crypt-encoded-mode' was toggled.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941 nil says that even if filename extension is plain (i.e., not listed in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942 `crypt-encoding-alist') buffer will be written in an encoded format without
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943 asking.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945 This variable is designed for users that edit a plain file (with plain
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946 extension) and then toggle `(crypt-encoded-mode)' and do not wish to be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 queried every time that they save the buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 NOTE: if `(crypt-encoded-mode)' was not called interactively (the usual
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950 scenario) then the value of this variable has no effect on how the buffer is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951 written to disk. In such a case `crypt-no-extension-implies-plain' is then
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
952 the relevant variable."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
953 :type 'boolean
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
954 :group 'crypt)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
956 (defcustom crypt-no-extension-implies-plain t
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957 "*t says file extensions not in `crypt-encoding-alist' may be written plain.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958 if `crypt-auto-write-buffer' is also t then any file ending in a plain
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959 extension is written in plain format automatically, otherwise query user.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961 nil says user works with encoded (compressed) files without file extensions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962 and will not be queried each time they save these files.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964 NOTE: (1) this does not effect find-file (C-x C-f) since that works with a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965 magic regexp. (2) there is no way to distinguish between write-file and
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
966 save-buffer so nil will mean that neither will query."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
967 :type 'boolean
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
968 :group 'crypt)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
970 (defcustom crypt-freeze-vs-fortran t
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971 "*t says `.F' file extension denotes a frozen file not a Fortran file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972 If you change this variable after crypt++ has been loaded then do
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
973 \\[crypt-rebuild-tables]."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
974 :type 'boolean
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
975 :group 'crypt)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
977 (defcustom crypt-compact-vs-C++ nil
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978 "*t says `.C' file extension denotes a compacted file not a C++ file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979 If you change this variable after crypt++ has been loaded then do
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
980 \\[crypt-rebuild-tables]."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
981 :type 'boolean
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
982 :group 'crypt)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
983
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
984 (defcustom crypt-ignored-filenames nil
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
985 "*List of regexp filenames for which encoded to plain conversion is not done.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
986 A filename with a plain extension, in encoded format, that is matched by one of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
987 these elements will be saved in encoded format without a query for conversion to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
988 plain format.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
989
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
990 This variable is provided for users that want to compress their incoming mail
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
991 for RMAIL and VM which look for files `RMAIL' and `INBOX,' respectively, to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
992 store incoming mail. For example, the gzip extensions on `RMAIL.gz' and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
993 `INBOX.gz' can be removed, this variable set to '\(\"INBOX$\" \"RMAIL$\"\) and
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
994 no query about conversion to plain format will be made."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
995 :type '(repeat regexp)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
996 :group 'crypt)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
997
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
998 (defcustom crypt-default-encoding "gzip"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999 "*Default encoding type as string used when `crypt-encoded-mode' is toggled.
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
1000 Must match one of the elements of `crypt-encoding-alist'."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
1001 :type 'string
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
1002 :group 'crypt)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1003
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
1004 (defcustom crypt-dos-has-ctrl-z nil
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1005 "t if this buffer had a ctrl-z stripped from end, otherwise, nil.
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
1006 Buffer local and set by `crypt-dos-to-unix-region'"
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
1007 :type 'boolean
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
1008 :group 'crypt)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1009 (make-variable-buffer-local 'crypt-dos-has-ctrl-z)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1010 (setq-default crypt-dos-has-ctrl-z nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1011 (put 'crypt-dos-has-ctrl-z 'permanent-local t) ; for v19 Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1012 (put 'crypt-dos-has-ctrl-z 'preserved t) ; for kill-fix.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1013
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1014 (defun crypt-build-encoding-alist ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1015 ;; Returns the encoding alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1016 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017 ;; compress
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1018 (list 'compress
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1019 "\037\235" nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1020 "\\(\\.Z\\)$"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1021 "compress" "uncompress"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022 nil nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1023 "Compress"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1024 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1025 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1026 ;; gzip (GNU zip)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1027 (list 'gzip
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1028 "\037\213" nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1029 "\\(\\.g?z\\)$"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1030 "gzip" "gzip"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031 "--quiet" "--decompress --quiet"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1032 "Zip"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1033 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1034 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1035 ;; freeze
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1036 (list 'freeze
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1037 "\037\236\\|\037\237" nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1038 "\\(\\.F\\)$"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1039 "freeze" "freeze"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1040 "" "-d"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1041 "Freeze"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1042 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1043 crypt-freeze-vs-fortran)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1044 ;; compact
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1045 (list 'compact
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1046 "\377\037" nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1047 "\\(\\.C\\)$"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1048 "compact" "uncompact"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1049 nil nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1050 "Compact"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1051 "^Compression *:.*\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1052 crypt-compact-vs-C++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1053 ;; DOS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1054 (list 'dos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1055 "[^\n\r]*\r$" nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1056 "\\(\\.DOS\\)$"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1057 'crypt-unix-to-dos-region 'crypt-dos-to-unix-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1058 nil nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1059 "Dos"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1060 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1061 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1062 ;; Add new elements here ...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1063 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1064
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1065 (defconst crypt-encoding-alist (crypt-build-encoding-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1066 "List of elements describing the encoding methods available.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1067 each element looks like
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1068
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1069 \(ENCODING-TYPE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1070 MAGIC-REGEXP MAGIC-REGEXP-INVERSE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1071 FILE-EXTENSION
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1072 ENCODE-PROGRAM DECODE-PROGRAM
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1073 ENCODE-ARGS DECODE-ARGS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1074 MINOR-MODE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1075 GARBAGE-REGEXP-OR-LISPEXP
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1076 FILE-EXTENSION-TRICKS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1077 \)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1078
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1079 ENCODING-TYPE is a symbol denoting the encoding type. Currently known
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1080 encodings are (compress compact freeze gzip).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1081
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1082 MAGIC-REGEXP is a regexp that matches the magic number at the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1083 beginning of files encoded with ENCODING-TYPE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1084
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1085 MAGIC-REGEXP-INVERSE dummy variable for compatibility with encryption.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1086
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1087 FILE-EXTENSION is a string denoting the file extension usually
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1088 appended the filename of files encoded with ENCODING-TYPE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1089
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1090 ENCODE-PROGRAM is a string denoting the name of the executable used to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1091 encode files.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1092
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1093 DECODE-PROGRAM is a string denoting the name of the executable used to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1094 decode files.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1095
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1096 ENCODE-ARGS arguments to be passed to ENCODE-PROGRAM may be a string or a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1097 list of strings or nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1098
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1099 DECODE-ARGS arguments to be passed to DECODE-PROGRAM may be a string or a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1100 list of strings or nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1101
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1102 MINOR-MODE is a string denoting the name for the encoded minor mode as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1103 it will appear in the mode line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1104
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1105 GARBAGE-REGEXP-OR-LISPEXP is (1) a regexp that matches any extraneous text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1106 that is produced by the ENCODE-COMMAND including any newlines and will be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1107 removed from the buffer before saving to disk; (2) a lisp expression that will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1108 clean up extraneous material in the buffer or nil. This is normally not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1109 needed but can be derived for any ENCODE-COMMAND by checking the standard
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1110 error that results from `sh -c \"cat foo | ENCODE-COMMAND > bar\"'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1111
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1112 FILE-EXTENSION-TRICKS is t or nil depending on whether or not tricks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1113 converting between different encoding types can be done based on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1114 FILE-EXTENSION; typically t.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1115 ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1116
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1117
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1118 ;;; This allows the user to alter contents of the encoding and encryption
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1119 ;;; table variables without having to reload all of crypt++.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1120 (defun crypt-rebuild-tables ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1121 "Rebuilds the encryption and encoding tables and `minor-mode-alist'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1122 Allows user to alter variables used in building these tables. May be called
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1123 interactively or in an initialization file. Part of `after-init-hook'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1124 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1125 (setq crypt-encryption-alist (crypt-build-encryption-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1126 crypt-encoding-alist (crypt-build-encoding-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1127 (crypt-rebuild-minor-modes-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1128
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1129
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1130 ;;; Buffer locals.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1131
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1132 (defvar crypt-buffer-save-encrypted nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1133 "*non-nil says save buffer encrypted with `crypt-encryption-type.'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1134 local to all buffers.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1135 (make-variable-buffer-local 'crypt-buffer-save-encrypted)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1136 (put 'crypt-buffer-save-encrypted 'permanent-local t) ; for v19 Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1137 (put 'crypt-buffer-save-encrypted 'preserved t) ; for kill-fix.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1138
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1139 (defvar crypt-buffer-encryption-key nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1140 "*Key used for encryption of current buffer. Local to all buffers.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1141 (make-variable-buffer-local 'crypt-buffer-encryption-key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1142 (put 'crypt-buffer-encryption-key 'permanent-local t) ; for v19 Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1143 (put 'crypt-buffer-encryption-key 'preserved t) ; for kill-fix.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1144
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1145 (defvar crypt-buffer-save-encoded nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1146 "*non-nil says buffer will be saved encoded. Local to all buffers.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1147 (make-variable-buffer-local 'crypt-buffer-save-encoded)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1148 (put 'crypt-buffer-save-encoded 'permanent-local t) ; for v19 Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1149 (put 'crypt-buffer-save-encoded 'preserved t) ; for kill-fix.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1150
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1151 (defvar crypt-buffer-encoding-type nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1152 "*non-nil says buffer is encoded with ENCODING-TYPE. Local to all buffers.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1153 (make-variable-buffer-local 'crypt-buffer-encoding-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1154 (put 'crypt-buffer-encoding-type 'permanent-local t) ; for v19 Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1155 (put 'crypt-buffer-encoding-type 'preserved t) ; for kill-fix.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1156
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1157 (defvar crypt-buffer-interactive-encoded-mode nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1158 "t says `crypt-encoded-mode' was toggled interactively, almost always nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1159 Local to all buffers.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1160 (make-variable-buffer-local 'crypt-buffer-interactive-encoded-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1161 (put 'crypt-buffer-interactive-encoded-mode 'permanent-local t) ; v19 Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1162 (put 'crypt-buffer-interactive-encoded-mode 'preserved t) ; kill-fix.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1163
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1164
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1165 ;;; Functions and macros that search `crypt-encryption-alist' and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1166 ;;; `crypt-encoding-alist'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1167
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1168 (defun crypt-get-alist-member (type n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1169 ;; Returns TYPE's Nth element
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1170 (nth n (or (assoc type crypt-encryption-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1171 (assoc type crypt-encoding-alist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1172
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1173 (defmacro crypt-get-magic-regexp (type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1174 ;; Returns regexp found at top of files encoded/encrypted with TYPE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1175 (list 'crypt-get-alist-member type 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1176
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1177 (defmacro crypt-get-magic-regexp-inverse (type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1178 ;; Returns regexp *not* found at top of files encoded/encrypted with TYPE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1179 (list 'crypt-get-alist-member type 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1180
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1181 (defmacro crypt-get-file-extension (type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1182 ;; Returns regexp matching extension of files encoded/encrypted with TYPE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1183 (list 'crypt-get-alist-member type 3))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1184
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1185 (defmacro crypt-get-encoding-program (type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1186 ;; Returns name of program, as string, used to encode/encrypt with TYPE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1187 (list 'crypt-get-alist-member type 4))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1188
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1189 (defmacro crypt-get-decoding-program (type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1190 ;; Returns name of program, as string, used to decode/decrypt with TYPE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1191 (list 'crypt-get-alist-member type 5))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1192
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1193 (defmacro crypt-get-encoding-args (type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1194 ;; Returns arguments passed to program used to encode/encrypt with TYPE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1195 (list 'crypt-get-alist-member type 6))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1196
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1197 (defmacro crypt-get-decoding-args (type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1198 ;; Returns arguments passed to program used to decode/decrypt with TYPE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1199 (list 'crypt-get-alist-member type 7))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1200
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1201 (defmacro crypt-get-minor-mode-name (type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1202 ;; Returns minor mode name, as string, for encoding/encrypting with TYPE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1203 (list 'crypt-get-alist-member type 8))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1204
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1205 (defmacro crypt-get-cleanup-regexp (type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1206 ;; Returns regexp or lisp-exp for cleaning up encoding/encrypting with TYPE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1207 (list 'crypt-get-alist-member type 9))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1208
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1209 (defmacro crypt-get-extension-tricks (type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1210 ;; Returns t if file extension tricks doable for encoding/encrypting with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1211 ;; TYPE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1212 (list 'crypt-get-alist-member type 10))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1213
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1214 (defun crypt-buffer-save-name (type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1215 ;; Returns variable `crypt-buffer-save-TYPE', set to t if encoding with TYPE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1216 ;; local to all buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1217 (intern (concat "crypt-buffer-save-" (symbol-name type))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1218
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1219
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1220 ;;; Create a buffer-local variable for each type of encoding.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1221 ;;; These variables are used to trigger the minor mode names.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1222
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1223 (defun crypt-build-minor-mode-alist ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1224 ;; Returns minor mode alist entries for encoded and encrypted buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1225 (append
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1226 ;; First the encrypted minor mode -- only one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1227 (list (list 'crypt-buffer-save-encrypted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1228 (concat " " (crypt-get-minor-mode-name crypt-encryption-type))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1229 ;; Now the encoding minor modes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1230 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1231 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1232 (lambda (element)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1233 (let ((variable (crypt-buffer-save-name (car element))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1234 (make-variable-buffer-local variable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1235 (put variable 'permanent-local t) ; for v19 Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1236 (put variable 'preserved t) ; for kill-fix.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1237 (list variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1238 (concat " " (crypt-get-minor-mode-name (car element)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1239 crypt-encoding-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1240
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1241 (defconst crypt-minor-mode-alist (crypt-build-minor-mode-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1242 "Alist containing encoded and encrypted minor modes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1243 Derived from variable `crypt-encoding-alist' and function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1244 `crypt-build-minor-mode-encrypted'")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1245
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1246 (defun crypt-rebuild-minor-modes-alist ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1247 ;; Rebuilds the encryption and encoding minor modes and `minor-mode-alist.'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1248 ;; Allows user to alter variables used in building this alist. Called by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1249 ;; `crypt-rebuild-tables' and so part of `after-init-hook'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1250
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1251 ;; First remove old crypt minor mode entries from `minor-mode-alist'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1252 (if (memq (car crypt-minor-mode-alist) minor-mode-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1253 (let ((alist crypt-minor-mode-alist) elt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1254 (while (and alist (setq elt (car alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1255 (setq minor-mode-alist (delq elt minor-mode-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1256 alist (cdr alist)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1257
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1258 ;; Get new crypt minor mode entries and add to minor-mode-alist.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1259 (setq crypt-minor-mode-alist (crypt-build-minor-mode-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1260 minor-mode-alist (append crypt-minor-mode-alist minor-mode-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1261
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1262
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1263 (defmacro crypt-save-point (&rest body)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1264 ;; Save value of point, evaluate FORMS, and restore value of point. If the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1265 ;; saved value of point is no longer valid go to (point-max). This macro
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1266 ;; exists because, save-excursion loses track of point during some types of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1267 ;; deletions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1268 (let ((var (make-symbol "saved-point")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1269 (list 'let (list (list var '(point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1270 (list 'unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1271 (cons 'progn body)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1272 (list 'goto-char var)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1273
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1274
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1275 (defun crypt-find-file-hook ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1276
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1277 ;; Hook run for decoding and/or decrypting the contents of a buffer. Meant
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1278 ;; to be called as part of `find-file-hooks'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1279
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1280 (let ((buffer-file-name buffer-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1281 (old-buffer-file-name buffer-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1282 (old-buffer-modified-p (buffer-modified-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1283 (case-fold-search nil) ; case-sensitive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1284 encrypted encoded buffer-read-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1285
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1286 ;; DECODE AND/OR DECRYPT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1287 (crypt-save-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1288
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1289 ;; Do we have to DECODE? If not, then move on.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1290 (if (and (crypt-encoded-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1291 (or crypt-auto-decode-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1292 (y-or-n-p (format "Decode %s? " (buffer-name)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1293
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1294 ;; Decode, uncompress, the buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1295 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1296
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1297 (if (and (not (null buffer-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1298 (string-match "\\.Z$" buffer-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1299 (set-visited-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1300 (substring buffer-file-name 0 (match-beginning 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1301 (if (and (not (null buffer-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1302 (string-match "\\.gz$" buffer-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1303 (set-visited-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1304 (substring buffer-file-name 0 (match-beginning 0)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1305 (message "Decoding %s..." (buffer-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1306 (crypt-encode-buffer t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1307
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1308 ;; Store the encoding mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1309
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1310 ;; We can not yet go into the minor modes because the major mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1311 ;; may change later on and blow away all local variables (and thus
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1312 ;; the minor modes). Only needed for vanilla v18. Our
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1313 ;; buffer-locals defined 'permanent-local for v19 Emacs and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1314 ;; 'preserved for kill-fix.el.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1315
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1316 (setq encoded crypt-buffer-encoding-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1317
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1318 ;; Strip encoded file's extension so later we can set buffer's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1319 ;; major mode based on its file-name sans encoding extension.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1320 (if (string-match (crypt-get-file-extension
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1321 crypt-buffer-encoding-type) buffer-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1322 (setq buffer-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1323 (substring buffer-file-name 0 (match-beginning 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1324
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1325 ;; Decoding ends.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1326 (if (not (input-pending-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1327 (message "Decoding %s... done" (buffer-name)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1328
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1329 ;; Do we have to DECRYPT? If not, then move on.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1330 (if (crypt-encrypted-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1331
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1332 ;; Decrypt buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1333 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1334
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1335 (message "Decrypting %s..." (buffer-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1336 (crypt-encrypt-buffer crypt-buffer-encryption-key t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1337
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1338 ;; Save key in case major mode blows all buffer-locals.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1339
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1340 ;; Only needed for vanilla v18. Our buffer-locals defined
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1341 ;; 'permanent-local for v19 Emacs and 'preserved for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1342 ;; kill-fix.el.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1343
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1344 (setq encrypted crypt-buffer-encryption-key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1345
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1346 ;; Strip encrypted file's extension so later we can set buffer's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1347 ;; major mode based on its file-name sans encrypting extension.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1348 (if (and (crypt-get-extension-tricks crypt-encryption-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1349 (string-match (crypt-get-file-extension
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1350 crypt-encryption-type) buffer-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1351 (setq buffer-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1352 (substring buffer-file-name 0 (match-beginning 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1353
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1354 (if (not (input-pending-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1355 (message "Decrypting %s... done" (buffer-name))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1356
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1357 ;; MAJOR AND MINOR MODES
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1358
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1359 ;; OK, if any changes have been made to the buffer we need to rerun the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1360 ;; code the does automatic selection of major mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1361
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1362 (if (or encoded encrypted)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1363
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1364 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1365
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1366 ;; Set the major mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1367 (set-auto-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1368 (hack-local-variables)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1369
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1370 ;; Now set our own minor mode(s).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1371 (if encoded
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1372 ;; Recover encoding type, may have been smashed by major mode,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1373 ;; and toggle encoded mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1374 (progn (setq crypt-buffer-encoding-type encoded)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1375 (crypt-encoded-mode 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1376
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1377 (if encrypted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1378 ;; Recover encryption key, may have been smashed by major mode,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1379 ;; and toggle encrypted mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1380 (progn (setq crypt-buffer-encryption-key encrypted)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1381 (crypt-encrypted-mode 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1382
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1383 ;; Restore buffer file name now, so that lock file entry is removed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1384 ;; properly.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1385 (setq buffer-file-name old-buffer-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1386
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1387 ;; Restore buffer modified flag to its previous value. Will also
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1388 ;; remove lock file entry for buffer if previous value was nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1389 ;; This is why buffer-file-name had to be restored manually above.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1390 (set-buffer-modified-p old-buffer-modified-p)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1391
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1392 (defun crypt-encoded-p (&optional buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1393 ;; Returns t if current buffer, or optionally BUFFER, is encoded.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1394 ;; Sets `crypt-buffer-encoding-type' to encoding method.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1395 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1396 (and buffer (set-buffer buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1397 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1398 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1399 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1400 (let ((alist crypt-encoding-alist) elt found)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1401 (while (and alist (setq elt (car alist)) (not found))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1402 (if (looking-at (nth 1 elt))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1403 (setq crypt-buffer-encoding-type (nth 0 elt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1404 found t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1405 ;; Decrement
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1406 (setq alist (cdr alist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1407 found))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1408
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1409 (defun crypt-encrypted-p (&optional buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1410 ;; Returns t if current buffer, or optionally BUFFER, is encrypted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1411 ;; Look for MAGIC-REGEXP and absence of MAGIC-REGEXP-INVERSE. If so, then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1412 ;; assume it is an encrypted buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1413 ;; Sets `crypt-buffer-encryption-key' to password if not set already.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1414
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1415 ;; Do not try to decrypt buffer if not wanted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1416 (if (not crypt-never-ever-decrypt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1417
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1418 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1419 (and buffer (set-buffer buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1420
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1421 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1422 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1423 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1424
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1425 (let ((magic-regexp (crypt-get-magic-regexp crypt-encryption-type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1426 (magic-regexp-inverse (crypt-get-magic-regexp-inverse
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1427 crypt-encryption-type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1428 (limit (min (point-max) crypt-magic-search-limit)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1429
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1430 ;; Check all encryption conditions. If any fail, then return nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1431 ;; value of this if-form, else check for password.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1432 (if (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1433
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1434 ;; Check for existence of MAGIC-REGEXP.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1435 (if (stringp magic-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1436 ;; regular expression
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1437 (re-search-forward magic-regexp limit t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1438 ;; lisp expression
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1439 (eval magic-regexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1440
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1441 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1442
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1443 ;; Check for absence of MAGIC-REGEXP-INVERSE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1444 (not (if (stringp magic-regexp-inverse)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1445 ;; regular expression
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1446 (re-search-forward magic-regexp-inverse limit t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1447 ;; lisp expression
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1448 (eval magic-regexp-inverse))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1449
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1450 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1451
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1452 ;; Get key, i.e., the password?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1453 (or crypt-buffer-encryption-key
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1454 ;; Do not confirm on reading an encrypted file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1455 (let ((crypt-confirm-password nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1456 (call-interactively 'crypt-set-encryption-key)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1457
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1458 ;; Do not turn on encryption mode if no key: may be a binary
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1459 ;; file. Thanks to Paul Dworkin (paul@media-lab.media.mit.edu).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1460 (if (equal crypt-buffer-encryption-key "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1461 ;; Return nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1462 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1463 (message "No key given. Assumed normal.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1464 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1465 ;; Return t.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1466 t))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1467
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1468
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1469 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1470
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1471 (defun crypt-check-extension-for-encoding ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1472
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1473 ;; Checks file extensions for possible toggling of encoding modes. Used for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1474 ;; buffers to be written to disk and called by `crypt-write-file-hook'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1475
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1476 ;; We try to flag a buffer to be written out in encoded form if the file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1477 ;; ends in one of the file-extensions in `crypt-encoding-alist' even if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1478 ;; `crypt-buffer-save-encoded' is nil. Conversely, we try to write out a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1479 ;; buffer as a plain file if it does _not_ end in one of these
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1480 ;; file-extensions even if `crypt-buffer-save-encoded' is non-nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1481
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1482 (let ((alist crypt-encoding-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1483 (case-fold-search nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1484 found elt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1485
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1486 ;; Search through the file name extensions for a match.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1487 (while (and alist (setq elt (car alist)) (not found))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1488 (if (string-match (nth 3 elt) buffer-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1489 (setq found t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1490 ;; Decrement.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1491 (setq alist (cdr alist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1492
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1493 ;; Did we find a match?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1494 (if found
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1495
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1496 ;; File name ends in a very provocative extension.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1497
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1498 ;; Check to see if already an encoded file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1499 (if crypt-buffer-save-encoded
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1500
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1501 ;; Already encoded - do the methods of encoding match?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1502 (if (not (eq (nth 0 elt) crypt-buffer-encoding-type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1503
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1504 ;; A new encoding method is desired.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1505
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1506 ;; Can we play some filename extension tricks with the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1507 ;; destination extension?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1508 (if (crypt-get-extension-tricks (nth 0 elt))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1509
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1510 ;; Can play tricks.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1511 ;; Change the method of encoding?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1512 (if (crypt-y-or-n-p (format "Write %s using %s? "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1513 (buffer-name) (nth 4 elt)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1514
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1515 ;; Case one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1516 ;; Turn off original encoding and turn on new encoding.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1517 (progn (crypt-encoded-mode -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1518 (setq crypt-buffer-encoding-type (nth 0 elt))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1519 (crypt-encoded-mode 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1520
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1521 ;; Can not play tricks - maybe wants a plain file?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1522 (if (crypt-y-or-n-p (format "Write %s a plain file? "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1523 (buffer-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1524
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1525 ;; Case three.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1526 ;; Turn off the minor mode and _then_ the flags.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1527 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1528 (crypt-encoded-mode -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1529 (setq crypt-buffer-save-encoded nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1530 crypt-buffer-encoding-type nil)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1531
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1532 ;; Was a plain file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1533 (if (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1534 ;; Can we play some filename extension tricks?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1535 ;; If not then we must abort.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1536 (crypt-get-extension-tricks (nth 0 elt))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1537
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1538 (crypt-y-or-n-p (format "Write %s using %s? "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1539 (buffer-name) (nth 4 elt))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1540
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1541 ;; Case two.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1542 ;; Turn on encoding flags and _then_ the minor mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1543 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1544 (setq crypt-buffer-save-encoded t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1545 crypt-buffer-encoding-type (nth 0 elt))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1546 (crypt-encoded-mode 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1547
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1548 ;; No match - a plain-jane file extension - but if the encoded flag is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1549 ;; non-nil then the user may really want it written out in plain
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1550 ;; format so we must override this flag.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1551 (if (and crypt-buffer-save-encoded
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1552
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1553 ;; Search the list of files to be ignored.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1554 ;; If `crypt-ignored-filenames' is nil then this let form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1555 ;; will return t. If a match is found this form will return
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1556 ;; nil. Otherwise it will return t.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1557 (let ((tlist crypt-ignored-filenames)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1558 case-fold-search found elt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1559
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1560 ;; Search through the list of filenames for a match.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1561 (while (and tlist (setq elt (car tlist)) (not found))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1562 (if (string-match elt buffer-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1563 (setq found t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1564 ;; Decrement.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1565 (setq tlist (cdr tlist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1566
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1567 ;; Return t if we can _not_ find a match.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1568 (not found))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1569
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1570 ;; If `(crypt-encoded-mode)' was called interactively, then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1571 ;; there is a high probability that no matter what the file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1572 ;; name extension the user wishes to write the file out in some
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1573 ;; encoded format. Thanks to Kimball Collins
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1574 ;; <kpc@ptolemy.arc.nasa.gov> for pointing out the need for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1575 ;; this. Unfortunately, still can not distinguish between
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1576 ;; write-file and save-buffer. In the former the user may want
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1577 ;; to write in plain format (or indeed some other format).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1578
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1579 (if crypt-buffer-interactive-encoded-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1580 ;; Interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1581 crypt-query-if-interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1582 ;; Non-interactive but still may want encoded format.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1583 crypt-no-extension-implies-plain)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1584
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1585 (crypt-y-or-n-p (format "Write %s as a plain file? "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1586 (buffer-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1587
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1588 ;; Case three.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1589 ;; Turn off the minor mode and _then_ the flags.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1590 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1591 (crypt-encoded-mode -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1592 (setq crypt-buffer-save-encoded nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1593 crypt-buffer-encoding-type nil))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1594
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1595
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1596 (defun crypt-y-or-n-p (prompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1597 ;; Queries user based on `crypt-auto-write-buffer' and internal buffer-local
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1598 ;; variable `crypt-auto-write-answer-local'. Returns value of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1599 ;; `crypt-auto-write-answer-local', which is t or nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1600
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1601 ;; Check if we need to ask user. Should be 'ask, nil, or t.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1602 (if (eq crypt-auto-write-answer-local 'ask) ; Default value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1603 ;; We may need to ask.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1604 (or crypt-auto-write-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1605 ;; Ask and store the answer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1606 ;; Note: we only store if we asked.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1607 (setq crypt-auto-write-answer-local (y-or-n-p prompt)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1608 ;; Use previous answer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1609 crypt-auto-write-answer-local)) ; Will be nil or t.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1610
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1611
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1612 ;;; This function should be called ONLY as a write-file hook.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1613 ;;; Odd things will happen if it is called elsewhere.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1614
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1615 (defun crypt-write-file-hook ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1616
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1617 ;; Hook for possibly writing out file, and backup file, in a non-plain
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1618 ;; format. Terminates calls in `write-file-hooks' and should be at end of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1619 ;; list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1620
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1621 ;; Check file-extension for possible toggling of encoding modes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1622 (crypt-check-extension-for-encoding)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1623
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1624 ;; Check extension for encryption.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1625 (if (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1626
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1627 ;; Maybe file ends with provocative extension w.r.t. encryption?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1628 (stringp (crypt-get-file-extension crypt-encryption-type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1629 (let ((case-fold-search nil)) ; Make case-sensitive.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1630 (string-match (crypt-get-file-extension crypt-encryption-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1631 buffer-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1632
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1633 ;; Can we play tricks?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1634 (crypt-get-extension-tricks crypt-encryption-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1635
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1636 ;; Match of filename extension - is file in plain format?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1637 (not crypt-buffer-save-encrypted)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1638
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1639 ;; Query?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1640 (or crypt-auto-write-buffer-encrypted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1641 (y-or-n-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1642 (format "Write %s as an encrypted file? " (buffer-name)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1643
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1644 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1645 ;; Set password and toggle `crypt-encrypted-mode'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1646 (call-interactively 'crypt-set-encryption-key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1647 (crypt-encrypted-mode 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1648
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1649 ;; Now decide whether or not we need to continue with this defun. Does the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1650 ;; buffer need to be saved in a non-plain form? If not then writing is not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1651 ;; done here but later in the write-file-hooks - probably at the end.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1652
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1653 (if (or crypt-buffer-save-encoded crypt-buffer-save-encrypted)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1654
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1655 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1656 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1657
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1658 (let
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1659
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1660 ;; BINDINGS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1661 ((copy-buffer (get-buffer-create " *crypt copy buffer*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1662 (selective-display selective-display)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1663 (buffer-read-only))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1664
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1665 ;; FORMS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1666 (copy-to-buffer copy-buffer 1 (1+ (buffer-size)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1667 (narrow-to-region (point) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1668
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1669 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1670
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1671 ;; BODYFORM
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1672 (let (setmodes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1673
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1674 ;; As of v19, if one of functions of the `write-file-hooks'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1675 ;; returns a non-nil value, then `basic-save-buffer' no
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1676 ;; longer creates a backup file. We must do it ourselves.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1677 ;; this should be a no-op in v18.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1678 (or buffer-backed-up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1679 (setq setmodes (backup-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1680
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1681 (insert-buffer-substring copy-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1682 (kill-buffer copy-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1683
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1684 ;; "Who would cross the Bridge of Death
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1685 ;; Must answer me
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1686 ;; These questions three
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1687 ;; Ere the other side he see."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1688 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1689 ;; Bridgekeeper from Monty Python and the Holy Grail
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1690
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1691 ;; [1] selective-display non-nil means we must convert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1692 ;; carriage returns to newlines now, and set the variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1693 ;; selective-display temporarily to nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1694 (if selective-display
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1695 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1696 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1697 (subst-char-in-region (point-min) (point-max) ?\r ?\n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1698 (setq selective-display nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1699
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1700 ;; [2] encryption
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1701 (if crypt-buffer-save-encrypted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1702 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1703 ;; check for password
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1704 (if (not crypt-buffer-encryption-key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1705 (call-interactively 'crypt-set-encryption-key))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1706 (if (null crypt-buffer-encryption-key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1707 (error "No encryption key set for buffer %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1708 (buffer-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1709 (if (not (stringp crypt-buffer-encryption-key))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1710 (error "Encryption key is not a string"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1711 (message "Encrypting %s..." (buffer-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1712 (crypt-encrypt-buffer crypt-buffer-encryption-key)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1713
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1714 ;; [3] encoding
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1715 (if crypt-buffer-save-encoded
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1716 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1717 (message "Encoding %s..." (buffer-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1718 (crypt-encode-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1719
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1720 ;; Now write buffer/region to disk.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1721 (write-region (point-min) (point-max) buffer-file-name nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1722 (delete-region (point-min) (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1723 (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1724
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1725 ;; Now that the file is written, set its modes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1726 (if setmodes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1727 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1728 (set-file-modes buffer-file-name setmodes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1729 (error nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1730
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1731 ;; Return t so that `basic-save-buffer' will know that the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1732 ;; save has already been done.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1733
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1734 ;; NOTE: this TERMINATES write-file-hooks so any hooks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1735 ;; following this one will not be executed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1736
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1737 t )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1738
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1739 ;; UNWINDFORMS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1740 ;; unwind...sit back...take a load off...have a beer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1741
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1742 ;; If the encoded and encrypted stuff has already been removed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1743 ;; then this is a no-op. This form is executed if BODYFORM
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1744 ;; completes normally but the value of BODYFORM is returned -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1745 ;; i.e., t is returned.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1746
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1747 (delete-region (point-min) (point-max))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1748
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1749
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1750 ;;;; ENCRYPTION
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1751
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1752 (defun crypt-encrypt-region (start end key &optional decrypt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1753 "Encrypt region START to END using KEY and `crypt-encryption-type'. When
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1754 called interactively START and END default to point and mark \(START being the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1755 lesser of the two\), and KEY is prompted for. With optional DECRYPT non-nil,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1756 decryption is done."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1757
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1758 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1759 (let (decrypt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1760 (barf-if-buffer-read-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1761 (list (region-beginning)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1762 (region-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1763 (crypt-read-string-no-echo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1764 (concat (if (setq decrypt (y-or-n-p "Decrypt region? ")) "De" "En")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1765 "crypt buffer using key: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1766 ;; Do not confirm on decrypting region.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1767 (if (not decrypt) crypt-confirm-password))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1768 decrypt)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1769
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1770 (crypt-save-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1771
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1772 ;; We define the PROGRAM as the encryption program or decryption program
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1773 ;; listed for `crypt-encryption-type' of `crypt-encryption-alist.' These
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1774 ;; should be just the name of the executable and should _not_ contain any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1775 ;; arguments. `(call-process-region)' would be confused if we tried to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1776 ;; pass the arguments as part of the PROGRAM. The arguments are passed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1777 ;; through the encryption args or decryption args listed for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1778 ;; `crypt-encryption-type' of `crypt-encryption-alist.'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1779
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1780 ;; Thanks to Joe Ilacqua <spike@world.std.com> and others for pointing out
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1781 ;; an error that occurs with some encryption programs (e.g., the crypt from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1782 ;; Sun Microsystems, HPUX-8, and BSD) if `args' is `"".' This will allow
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1783 ;; nil values and lists of strings for argument.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1784
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1785 (let (prog args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1786
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1787 ;; Get the proper program and arguments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1788 (if decrypt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1789 (setq prog (crypt-get-decoding-program crypt-encryption-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1790 args (crypt-get-decoding-args crypt-encryption-type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1791 (setq prog (crypt-get-encoding-program crypt-encryption-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1792 args (crypt-get-encoding-args crypt-encryption-type)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1793
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1794 ;; Check arguments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1795 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1796
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1797 ;; nil or "" args - don't pass.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1798 ((or (not args) (equal "" args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1799 (call-process-region start end prog t t nil key))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1800
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1801 ;; Check if the args are in the form of a list - must use apply.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1802 ((listp args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1803 (apply 'call-process-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1804 (append (list start end prog t t nil) args (list key))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1805
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1806 ;; Default - just a non-null string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1807 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1808 (call-process-region start end prog t t nil args key))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1809
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1810
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1811 (defun crypt-encrypt-buffer (key &optional decrypt buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1812
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1813 ;; Use KEY to encrypt current buffer and with optional DECRYPT decrypt.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1814 ;; With optional BUFFER, encrypt or decrypt that buffer. Not meant to be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1815 ;; called interactively, toggle `crypt-encrypted-mode' to encrypt an entire
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1816 ;; buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1817
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1818 (or buffer (setq buffer (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1819 (save-excursion (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1820 (crypt-encrypt-region (point-min) (point-max) key decrypt)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1821
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1822
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1823 ;;;; ENCODING
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1824
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1825 (defun crypt-encode-region (start end &optional decode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1826
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1827 "Encode region START to END. When called interactively START and END
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1828 default to point and mark \(START being the lesser of the two\). With
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1829 optional DECODE non-nil, decoding is done.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1830
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1831 If encoding is attempted, then checks for correct magic number at start of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1832 newly-encoded region. If not found, then searches and deletes a user-defined
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1833 regexp, or executes a user-defined lisp expression, as defined in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1834 `crypt-encoding-alist,' and checks again for magic number."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1835
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1836 (interactive "*r\nP")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1837
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1838 ;; If called interactively then we may need to determine the encoding type.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1839 (if (and (interactive-p) (not crypt-buffer-encoding-type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1840 (crypt-read-encoding-type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1841
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1842 (crypt-save-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1843
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1844 ;; We define the PROGRAM as `shell-file-name' and have it call the encoding
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1845 ;; or decoding program with the arguments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1846
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1847 (let (prog args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1848
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1849 ;; Get the proper program and arguments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1850 (if decode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1851 (setq prog (crypt-get-decoding-program crypt-buffer-encoding-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1852 args (crypt-get-decoding-args crypt-buffer-encoding-type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1853 (setq prog (crypt-get-encoding-program crypt-buffer-encoding-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1854 args (crypt-get-encoding-args crypt-buffer-encoding-type)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1855
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1856 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1857
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1858 ;; prog is a string?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1859 ((stringp prog)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1860
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1861 ;; Check arguments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1862 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1863
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1864 ;; Check if the args are in the form of a list, will catch 'nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1865 ((listp args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1866
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1867 ;; Cat all the strings together.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1868 (while args
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1869 (setq prog (concat prog " " (car args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1870 args (cdr args))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1871
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1872 ;; Check if a non-null string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1873 ((and (not (string= "" args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1874 (not (eq args t))) ; just in case...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1875 (setq prog (concat prog " " args))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1876
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1877 (call-process-region start end shell-file-name t t nil "-c" prog))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1878
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1879 ;; Otherwise try and eval it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1880 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1881 (eval (if args
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1882 (list prog start end args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1883 (list prog start end))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1884
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1885 ;; Encoding or decoding region?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1886 (if (not decode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1887
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1888 ;; Check if encoded region starts with magic number.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1889 (let ((magic (crypt-get-magic-regexp crypt-buffer-encoding-type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1890 (clean (crypt-get-cleanup-regexp crypt-buffer-encoding-type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1891 (case-fold-search nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1892
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1893 ;; Top of region.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1894 (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1895
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1896 ;; Check for magic number.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1897 (if (not (looking-at magic))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1898
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1899 ;; Magic number not there.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1900
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1901 ;; Some compression programs produce an (inane) standard error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1902 ;; message that gets piped into the buffer. For example, some
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1903 ;; versions of compact output "Compression : 35.50%." There may
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1904 ;; be some way to clean up buffer and check again.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1905
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1906 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1907
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1908 ;; No mechanism to clean up - failed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1909 ((eq clean nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1910 (error "Encoding failed!"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1911
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1912 ;; Cleanup a regexp string?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1913 ((stringp clean)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1914
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1915 ;; Is regexp there?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1916 (if (looking-at clean)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1917
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1918 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1919 ;; Delete the match.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1920 (delete-region (match-beginning 0) (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1921
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1922 ;; Check for magic again.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1923 (if (not (looking-at magic))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1924 (error "Encoding failed!")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1925
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1926 ;; Default: evaluate a lisp expression and check again.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1927 (t (eval clean)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1928 (if (not (looking-at magic))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1929 (error "Encoding failed!")))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1930
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1931 (defun crypt-encode-buffer (&optional decode buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1932
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1933 ;; Encode current buffer. With optional DECODE non-nil decode and optional
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1934 ;; BUFFER, encode or decode that buffer. Not meant to be called
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1935 ;; interactively, toggle `crypt-encoded-mode' to encode an entire buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1936
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1937 (or buffer (setq buffer (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1938 (save-excursion (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1939 (crypt-encode-region (point-min) (point-max) decode)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1940
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1941
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1942 ;;;; DOS <--> UNIX
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1943 (defun crypt-dos-to-unix-region (start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1944 "Converts region from START to END, from dos to unix format.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1945 Replaces \"\\r\\n\" with \"\\n\" and, if exists, removes ^Z at end of file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1946 Sets `crypt-dos-has-ctrl-z'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1947 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1948 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1949 (let ((remove-ctrl-z (equal end (point-max))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1950 (narrow-to-region start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1951 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1952 (while (search-forward "\r\n" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1953 (replace-match "\n" nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1954 (if remove-ctrl-z
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1955 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1956 (goto-char (1- (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1957 (setq crypt-dos-has-ctrl-z (looking-at "\C-z"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1958 (if crypt-dos-has-ctrl-z (replace-match ""))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1959
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1960 (defun crypt-unix-to-dos-region (start end)
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
1961 "Converts region from START to END, from unix to dos format.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1962 Replaces \"\\n\" with \"\\r\\n\" and adds a ^Z at end of file if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1963 `crypt-dos-has-ctrl-z' is non-nil."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1964 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1965 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1966 (let ((add-ctrl-z (and crypt-dos-has-ctrl-z
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1967 (equal end (point-max)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1968 (narrow-to-region start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1969 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1970 (while (search-forward "\n" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1971 (replace-match "\r\n" nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1972 (if add-ctrl-z
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1973 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1974 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1975 (insert "\C-z")))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1976
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1977
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1978 ;;;; MODES
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1979
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1980 (defun crypt-encrypted-mode (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1981
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1982 "Toggle encrypted mode. With ARG, turn on iff positive, otherwise turn off.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1983 minor mode in which buffers are automatically encrypted before being written.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1984 if toggled and a key has been set for the current buffer, then the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1985 buffer is marked modified, since it needs to be rewritten with or without
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1986 encryption.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1987
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1988 Entering encrypted mode causes auto-saving to be turned off in the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1989 buffer, as there is no way in Emacs Lisp to force auto save files to be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1990 encrypted."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1991
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1992 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1993 (let ((oldval crypt-buffer-save-encrypted))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1994 (setq crypt-buffer-save-encrypted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1995 (if arg (> arg 0) (not crypt-buffer-save-encrypted)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1996
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1997 (if crypt-buffer-save-encrypted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1998 ;; We are going to save as encrypted, we will turn off auto-saving.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1999 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2000 ;; NEVER do this. Turning off auto-saving is one thing. But if there's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2001 ;; already an autosave for some other reason, what business does this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2002 ;; package have tampering with it?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2003 ; ;; If an auto-save file already exists, then delete it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2004 ; (if (and (stringp buffer-auto-save-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2005 ; (file-exists-p buffer-auto-save-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2006 ; (delete-file buffer-auto-save-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2007 ;; If the key is not set then ask for it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2008 (if (not crypt-buffer-encryption-key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2009 (call-interactively 'crypt-set-encryption-key))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2010 ;; Turn-off auto-saving if crypt-encrypted-disable-auto-save non-nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2011 (and crypt-encrypted-disable-auto-save
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2012 auto-save-default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2013 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2014 (auto-save-mode 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2015 (if (eq crypt-encrypted-disable-auto-save t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2016 (message "Auto-save off (in this buffer)")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2017
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2018 ;; We are not going to save as encrypted, we will turn on auto-saving
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2019 ;; but only if we are editing a file and the default says we should.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2020 (auto-save-mode (if (and auto-save-default buffer-file-name) 1 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2021
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2022 (if crypt-buffer-encryption-key
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2023 ;; Set buffer-modified flag to t only if the mode has been changed,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2024 ;; old code set unconditionally to nil if mode was not changed .
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2025 ;; Modification suggested by: Gerd Hillebrand <ggh@cs.brown.edu>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2026 (if (not (eq oldval crypt-buffer-save-encrypted))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2027 (set-buffer-modified-p t)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2028
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2029
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2030 ;;; Forgetting encryption keys (by jwz)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2031 ;;; This is really kind of bogus. Good behavior would be:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2032 ;;; - If a crypted buffer has not been "accessed" (edited? selected?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2033 ;;; viewed?) in N minutes, kill the buffer (since the plaintext is valuable.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2034 ;;; - If a crypted buffer is modified, but "idle", just forget the password
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2035 ;;; instead of killing the buffer (though the plaintext is valuable, it's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2036 ;;; also unsaved...)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2037 ;;; - The "idleness" of a modified buffer should be reset with every mod, so
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2038 ;;; that an unsaved buffer that you have been constantly typing at for an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2039 ;;; hour doesn't lose its password.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2040 ;;; - But, if a password for a buffer has been discarded, and then an attempt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2041 ;;; is made to save that buffer, then we should confirm that the newly-
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2042 ;;; typed password is the same as the password used in the file on disk.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2043 ;;; with PGP, we could check that by attempting to decrypt the file on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2044 ;;; disk into a scratch buffer and seeing if it contains the PGP error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2045 ;;; message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2046 ;;; - BUG: if a password has been forgotten, and you save, and are prompted,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2047 ;;; the old file has already been renamed to a backup!! so if you ^G, the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2048 ;;; real file name no longer exists on disk - only as a ~ file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2049
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2050 (defun crypt-forget-encryption-key ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2051 (cond (crypt-buffer-encryption-key
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2052 (let ((inhibit-quit t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2053 (fillarray crypt-buffer-encryption-key 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2054 (setq crypt-buffer-encryption-key nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2055 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2056 (t nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2057
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2058 (add-hook 'kill-buffer-hook 'crypt-forget-encryption-key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2059
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
2060 (defcustom crypt-forget-passwd-timeout (* 60 60)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2061 "*Do not retain passwords for encrypted buffers more than this many seconds.
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
2062 If nil, keep them indefinitely."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
2063 :type '(choice integer (const :tag "indefinite" nil))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
2064 :group 'crypt)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2065
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2066 (defun crypt-reset-passwd-timer ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2067 (if (fboundp 'get-itimer) ; XEmacs, or anything with itimer.el loaded.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2068 (let ((name "crypt-forget-passwds"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2069 (if (get-itimer name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2070 (delete-itimer name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2071 (if crypt-forget-passwd-timeout
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2072 (start-itimer name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2073 'crypt-reset-passwds-timeout
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2074 crypt-forget-passwd-timeout)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2075
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2076 (defun crypt-reset-passwds-timeout ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2077 ;; run by the timer code to forget all passwords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2078 (let ((buffers (buffer-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2079 (inhibit-quit t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2080 (keep-going nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2081 (while buffers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2082 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2083 (set-buffer (car buffers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2084 (cond ((and crypt-buffer-encryption-key
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2085 (buffer-modified-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2086 ;; don't forget the password in modified buffers, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2087 ;; do check again later (maybe it will be unmodified.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2088 (setq keep-going t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2089 (crypt-buffer-encryption-key
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2090 ;; forget the password in unmodified buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2091 (crypt-forget-encryption-key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2092 ;; Mark the buffer read only so that it's not accidentally
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2093 ;; edited; the smart thing to do is revert it, type the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2094 ;; encryption key (to make sure they same key is used)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2095 ;; and then edit it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2096 (setq buffer-read-only t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2097 (message "Password discarded in buffer %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2098 (buffer-name (car buffers))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2099 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2100 (setq buffers (cdr buffers)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2101 (if keep-going
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2102 (crypt-reset-passwd-timer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2103 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2104
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2105
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2106 ;;; Originally `tek-symbol-alist-to-table' from tek-highlight.el.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2107 (defun crypt-symbol-alist-to-table (list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2108 ;; Converts an alist of symbols to a table suitable for `completing-read.'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2109 ;; Called by `crypt-read-encoding-type'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2110 (mapcar (function (lambda (x) (list (symbol-name (car x)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2111 list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2112
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2113 (defun crypt-read-encoding-type ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2114
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2115 ;; Function called to query user for `crypt-buffer-encoding-type' uses
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2116 ;; contents of `crypt-encoding-alist' and `crypt-default-encoding.'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2117
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2118 ;; Use poor man's gmhist (i.e., we could have used gmhist's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2119 ;; `completing-read-with-history-in' instead).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2120 (let (
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2121 ;; Find the encoding type desired by user.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2122 (type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2123 (completing-read
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2124 (concat "encoding type (? for list): [" crypt-default-encoding "] ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2125 (crypt-symbol-alist-to-table crypt-encoding-alist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2126
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2127 ;; Test length of object returned by `completing-read'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2128 (if (zerop (length type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2129
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2130 ;; Nothing there, i.e., user hit return -- use default.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2131 (setq crypt-buffer-encoding-type (intern crypt-default-encoding))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2132
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2133 ;; Use the value from mini-buffer and update the default value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2134 (setq crypt-buffer-encoding-type (intern type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2135 crypt-default-encoding type))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2136
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2137 (defun crypt-encoded-mode (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2138
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2139 "Toggle encoded mode. With ARG, turn on iff positive, otherwise turn off.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2140 minor mode in which buffers are automatically encoded before being written. if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2141 toggled then current buffer is marked modified, since it needs to be written
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2142 with or without encoding.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2143
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2144 Entering encoded mode causes auto-saving to be turned off in the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2145 buffer, as there is no way in Emacs Lisp to force auto save files to be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2146 encoded."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2147
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2148 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2149
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2150 ;; Set flag indicating whether or not `(crypt-encoded-mode)' was called
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2151 ;; interactively.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2152 (setq crypt-buffer-interactive-encoded-mode (interactive-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2153
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2154 ;; If called interactively then need to determine encoding type.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2155 (if (and crypt-buffer-interactive-encoded-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2156 (not crypt-buffer-encoding-type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2157 (crypt-read-encoding-type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2158
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2159 ;; Save old value of `crypt-buffer-save-encoded'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2160 (let ((oldval crypt-buffer-save-encoded))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2161
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2162 ;; Set the variable `crypt-buffer-save-encoded' to t if the argument is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2163 ;; positive, otherwise toggle its current value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2164 (setq crypt-buffer-save-encoded
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2165 (if arg (> arg 0) (not crypt-buffer-save-encoded)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2166
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2167 ;; Set the variable generated by `(crypt-buffer-save-name)' to the value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2168 ;; stored in `crypt-buffer-save-encoded.'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2169 (set-variable (crypt-buffer-save-name crypt-buffer-encoding-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2170 crypt-buffer-save-encoded)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2171
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2172 (if crypt-buffer-save-encoded
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2173 ;; We are going to save as encoded, we might turn off auto-saving.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2174 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2175 ;; NEVER do this. Turning off auto-saving is one thing. But if there's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2176 ;; already an autosave for some other reason, what business does this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2177 ;; package have tampering with it?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2178 ; ;; If an auto-save file already exists, then delete it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2179 ; (if (and (stringp buffer-auto-save-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2180 ; (file-exists-p buffer-auto-save-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2181 ; (delete-file buffer-auto-save-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2182 ;; Turn-off auto-saving if crypt-encoded-disable-auto-save non-nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2183 (and crypt-encoded-disable-auto-save
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2184 auto-save-default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2185 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2186 (auto-save-mode 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2187 (if (eq crypt-encoded-disable-auto-save t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2188 (message "Auto-save off (in this buffer)")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2189
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2190 ;; We are not going to save as encoded, we will turn on auto-saving but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2191 ;; only if we are editing a file and the default says we should.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2192 (auto-save-mode (if (and auto-save-default buffer-file-name) 1 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2193
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2194 ;; Have we toggled the mode?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2195
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2196 ;; If yes, then mark buffer as modified. If not, then leave
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2197 ;; buffer-modified flag alone.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2198
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2199 ;; The old code previously set the variable `set-buffer-modified-p' to a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2200 ;; value of t if there was a mode change and (unconditionally) to nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2201 ;; if there was not a mode change.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2202
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2203 ;; Modification suggested by: Gerd Hillebrand <ggh@cs.brown.edu>.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2204
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2205 (if (not (eq oldval crypt-buffer-save-encoded))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2206 (set-buffer-modified-p t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2207
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2208
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2209 ;;;; Additional encryption functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2210
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2211 ;; For Emacs V18 compatibility
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2212 (and (not (fboundp 'buffer-disable-undo))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2213 (fboundp 'buffer-flush-undo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2214 (fset 'buffer-disable-undo 'buffer-flush-undo))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2215
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2216 (fset 'crypt-read-string-no-echo 'read-passwd)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2217
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2218 ;(defun crypt-read-string-no-echo (prompt &optional confirm)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2219 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2220 ; ;; Read a string from minibuffer, prompting with PROMPT, echoing periods.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2221 ; ;; Optional second argument CONFIRM non-nil means that the user will be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2222 ; ;; asked to type the string a second time for confirmation and if there is a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2223 ; ;; mismatch, the whole process is repeated.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2224 ; ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2225 ; ;; Line editing keys are --
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2226 ; ;; C-h, DEL rubout
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2227 ; ;; C-u, C-x line kill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2228 ; ;; C-q, C-v literal next
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2229 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2230 ; (catch 'return-value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2231 ; (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2232 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2233 ; (let ((input-buffer (get-buffer-create (make-temp-name " *password*")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2234 ; char hold-password help-form kill-ring)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2235 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2236 ; (set-buffer input-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2237 ; ;; Don't add to undo ring.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2238 ; (buffer-disable-undo input-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2239 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2240 ; (let ((cursor-in-echo-area t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2241 ; (echo-keystrokes 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2242 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2243 ; (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2244 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2245 ; ;; BODYFORM
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2246 ; ;; Repeat until we get a `throw'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2247 ; (while t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2248 ; (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2249 ; (message prompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2250 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2251 ; ;; Read string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2252 ; (while (not (memq (setq char (read-char)) '(?\C-m ?\C-j)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2253 ; (if (setq help-form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2254 ; (cdr
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2255 ; (assq char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2256 ; '((?\C-h . (delete-char -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2257 ; (?\C-? . (delete-char -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2258 ; (?\C-u . (delete-region 1 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2259 ; (?\C-x . (delete-region 1 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2260 ; (?\C-q . (quoted-insert 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2261 ; (?\C-v . (quoted-insert 1))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2262 ; (condition-case error-data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2263 ; (eval help-form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2264 ; (error t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2265 ; ;; Just a plain character - insert into password buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2266 ; (insert char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2267 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2268 ; ;; I think crypt-read-string-no-echo should echo asterisks.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2269 ; ;; -- Jamie. How about periods like in ange-ftp? -- lrd
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2270 ; ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2271 ; (message "%s%s" prompt (make-string (buffer-size) ?.)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2272 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2273 ; ;; Do we have to confirm password?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2274 ; (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2275 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2276 ; ;; No confirmation requested - terminate.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2277 ; ((not confirm)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2278 ; (throw 'return-value (buffer-string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2279 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2280 ; ;; Can we compare (confirm) password values yet?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2281 ; (hold-password
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2282 ; (if (string= hold-password (buffer-string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2283 ; ;; The two passwords match - terminate.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2284 ; (throw 'return-value hold-password)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2285 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2286 ; ;; Mismatch - start over.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2287 ; (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2288 ; (message (concat prompt "[Mismatch. Start over]"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2289 ; (beep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2290 ; (sit-for 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2291 ; (fillarray hold-password 0) ; destroy extra copy now
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2292 ; (setq hold-password nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2293 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2294 ; ;; Store password and read again.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2295 ; (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2296 ; (setq hold-password (buffer-string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2297 ; (message (concat prompt "[Retype to confirm]"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2298 ; (sit-for 2))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2299 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2300 ; ;; UNWINDFORMS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2301 ; ;; Clean up.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2302 ; (set-buffer input-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2303 ; (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2304 ; (buffer-disable-undo input-buffer) ; redundant, but why not be safe.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2305 ; (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2306 ; (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2307 ; (while (not (eobp)) (delete-char 1) (insert "*")) ; destroy now
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2308 ; (kill-buffer input-buffer)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2309
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2310 (defun crypt-set-encryption-key (key &optional buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2311
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2312 "Set the encryption KEY, a string, for current buffer or optionally BUFFER.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2313 If buffer is in encrypted mode, then it is also marked as modified, since it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2314 needs to be saved with the new key."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2315
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2316 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2317 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2318 (barf-if-buffer-read-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2319 (list (crypt-read-string-no-echo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2320 (format "Encryption key for %s? [RET to ignore]: " (buffer-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2321 crypt-confirm-password))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2322
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2323 ;; For security reasons we remove `(crypt-set-encryption-key "password")'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2324 ;; from the `command-history' list if called interactively.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2325 (if (interactive-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2326 (setq command-history (cdr command-history)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2327
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2328 (or buffer (setq buffer (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2329
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2330 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2331 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2332 (if (equal key crypt-buffer-encryption-key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2333 (message "Key is identical to original, no change.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2334
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2335 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2336 ;; jwz: destroy old string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2337 (if (and crypt-buffer-encryption-key
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2338 (not (eq crypt-buffer-encryption-key key)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2339 (fillarray crypt-buffer-encryption-key 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2340 (setq crypt-buffer-encryption-key key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2341
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2342 ;; Don't touch the modify flag unless we're in `(crypt-encrypted-mode)'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2343 (if crypt-buffer-save-encrypted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2344 (set-buffer-modified-p t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2345
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2346 (crypt-reset-passwd-timer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2347 ))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2348
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2349
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2350 ;;;; Install hooks and mode indicators.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2351
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2352 ;;; Check if mode indicators are not already installed and then prepend them.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2353 (and (not (assq 'crypt-buffer-save-encrypted minor-mode-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2354 (setq minor-mode-alist (append crypt-minor-mode-alist minor-mode-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2355
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2356 ;;; Install the hooks.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2357
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2358 ;;; If add-hook isn't already defined overwrite it with our own.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2359 ;;; Note the `add-hook' function must take the optional APPEND argument.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2360 (if (not (fboundp 'add-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2361 ;; No add-hook found.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2362 ;; Use `add-hook' from GNU Emacs v19.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2363 (defun add-hook (hook function &optional append)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2364 "Add to the value of HOOK the function FUNCTION.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2365 FUNCTION is not added if already present.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2366 FUNCTION is added (if necessary) at the beginning of the hook list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2367 unless the optional argument APPEND is non-nil, in which case
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2368 FUNCTION is added at the end.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2369
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2370 HOOK should be a symbol, and FUNCTION may be any valid function. If
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2371 HOOK is void, it is first set to nil. If HOOK's value is a single
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2372 function, it is changed to a list of functions."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2373 (or (boundp hook) (set hook nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2374 ;; If the hook value is a single function, turn it into a list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2375 (let ((old (symbol-value hook)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2376 (if (or (not (listp old)) (eq (car old) 'lambda))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2377 (set hook (list old))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2378 (or (if (consp function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2379 ;; Clever way to tell whether a given lambda-expression
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2380 ;; is equal to anything in the hook.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2381 (let ((tail (assoc (cdr function) (symbol-value hook))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2382 (equal function tail))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2383 (memq function (symbol-value hook)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2384 (set hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2385 (if append
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2386 (nconc (symbol-value hook) (list function))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2387 (cons function (symbol-value hook)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2388
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2389 ;;; Attach ourselves to the find-file-hooks and find-file-not-found-hooks.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2390 (add-hook 'find-file-hooks 'crypt-find-file-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2391 (add-hook 'find-file-not-found-hooks 'crypt-find-file-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2392
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2393 ;; Take care when appending to write-file-hook. User's version of add-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2394 ;; may not have APPEND option. If it fails then do it by hand. I wish
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2395 ;; everyone would upgrade - lrd 8/31/93.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2396 (condition-case err
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2397 (add-hook 'write-file-hooks 'crypt-write-file-hook t) ; *must* append this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2398 (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2399 ;; Do it by hand. Not as robust as `add-hook'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2400
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2401 ;; Contributed by Ken Laprade <laprade@trantor.harris-atd.com>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2402 ;; Really should use some sort of add-hook - 16 Feb 93 - KCL
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2403 (or (and (listp write-file-hooks) (not (eq (car write-file-hooks) 'lambda)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2404 (setq write-file-hooks (list write-file-hooks)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2405
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2406 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2407 ((not (memq 'crypt-write-file-hook write-file-hooks))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2408 ;; make this hook last on purpose
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2409 (setq write-file-hooks (append write-file-hooks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2410 (list 'crypt-write-file-hook)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2411
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2412 ;; In order that the tables and key-binding correctly reflect user's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2413 ;; preferences we add ourselves to the `after-init-hook' GNU Emacs v19 and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2414 ;; Lucid Emacs v 19.8 (or later) or `term-setup-hook' in Lucid Emacs v 19.7
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2415 ;; (or earlier). These are run *after* ~/.emacs and ../lisp/default.el are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2416 ;; loaded. Unfortunately, v18 does not have `after-init-hook' and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2417 ;; `term-setup-hook' is just a single function. It is a bit of a pain trying
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2418 ;; to work our functions in properly without overwriting the user's value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2419 ;; Therefore, we do nothing and hope they upgrade to v19 soon.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2420
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2421 (cond ((boundp 'after-init-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2422 ;; Must be running GNU Emacs v19 :->
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2423 (add-hook 'after-init-hook 'crypt-rebuild-tables)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2424 (add-hook 'after-init-hook 'crypt-rebuild-minor-modes-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2425 (add-hook 'after-init-hook 'crypt-bind-insert-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2426
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2427 ((and (string-match "^19" emacs-version) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2428 ;; Probably running Lucid Emacs v19.7 (or earlier) since it,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2429 ;; unfortunately, does not have `after-init-hook'. Use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2430 ;; `term-setup-hook' instead and hope they upgrade to Lucid 19.8 or GNU
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2431 ;; Emacs 19.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2432 (add-hook 'term-setup-hook 'crypt-rebuild-tables)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2433 (add-hook 'term-setup-hook 'crypt-rebuild-minor-modes-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2434 (add-hook 'term-setup-hook 'crypt-bind-insert-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2435
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2436
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2437 ;;; Code for conditionally decoding/decrypting an inserted file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2438
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
2439 (defcustom crypt-bind-insert-file t
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2440 "*t value means bind `crypt-insert-file' over `insert-file'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2441 If you wish to change this variable after crypt++ has been loaded then do
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
2442 \\[crypt-bind-insert-file]."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
2443 :type 'boolean
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
2444 :group 'crypt)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2445
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
2446 (defcustom crypt-auto-decode-insert nil
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2447 "*t says decode/decrypt files that are inserted with `crypt-insert-file'.
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
2448 nil says to ask before doing this."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
2449 :type 'boolean
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
2450 :group 'crypt)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2451
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2452 ;;; Bind `crypt-insert-file' over wherever `insert-file' is bound?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2453 (defun crypt-bind-insert-file ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2454
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2455 "Bind `crypt-insert-file' in place of `insert-file' or reverse based on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2456 `crypt-bind-insert-file'. Part of `after-init-hook'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2457
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2458 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2459
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2460 (if (interactive-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2461 (setq crypt-bind-insert-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2462 (y-or-n-p "Bind crypt-insert-file over insert-file? ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2463
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2464 (if crypt-bind-insert-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2465 (substitute-key-definition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2466 'insert-file 'crypt-insert-file (current-global-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2467 (substitute-key-definition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2468 'crypt-insert-file 'insert-file (current-global-map))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2469
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2470 ;;; Now call it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2471 (crypt-bind-insert-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2472
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2473 ;;; crypt++ replacement for `insert-file'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2474 (defun crypt-insert-file (filename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2475 "Insert decoded/decrypted contents of file FILENAME into buffer after point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2476 Set mark after the inserted text.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2477
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2478 This function is meant for the user to run interactively.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2479 Don't call it from programs! Use `insert-file-contents' instead.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2480 \(Its calling sequence is different; see its documentation\).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2481
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2482 This version will attempt to decrypt and/or decode file before inserting.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2483 see variable `crypt-auto-decode-insert'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2484 (interactive "fInsert file: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2485 (if (file-directory-p filename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2486 (signal 'file-error (list "Opening input file" "file is a directory"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2487 filename)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2488 (let ((tem (crypt-insert-file-contents filename))) ; use crypt++ to insert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2489 (push-mark (+ (point) (car (cdr tem))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2490
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2491 (defun crypt-insert-file-contents (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2492
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2493 ;; Similar to `insert-file-contents' except decoding/decrypting of FILE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2494 ;; attempted. See `crypt-insert-file' and `crypt-auto-decode-insert'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2495
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2496 (let (temp-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2497 temp-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2498 (crypt-auto-decode-buffer crypt-auto-decode-insert)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2499 (orig-buffer (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2500
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2501 ;; Create a temporary buffer and decode and decrypt it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2502 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2503
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2504 ;; Temporary buffer, use the same name as the file to be inserted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2505 (setq temp-buffer (generate-new-buffer (file-name-nondirectory file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2506 (set-buffer temp-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2507
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2508 ;; Original insert-file-contents - save list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2509 (setq temp-list (insert-file-contents file nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2510
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2511 ;; Make temp-buffer unmodified.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2512 (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2513
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2514 ;; Need to set buffer name to file name for crypt++.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2515 (setq buffer-file-name file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2516
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2517 ;; Decode and decrypt, if necessary.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2518 (crypt-find-file-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2519
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2520 ;; Find the length of the file to be inserted. `insert-file-contents'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2521 ;; returns it for the original encoded/encrypted file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2522 (setcdr temp-list (cons (buffer-size) ()))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2523
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2524 ;; Now insert temp-buffer into original buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2525 (set-buffer orig-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2526 (insert-buffer temp-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2527
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2528 ;; Kill the temporary buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2529 (kill-buffer temp-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2530
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2531 ;; Return modified list from `insert-file-contents'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2532 temp-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2533
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2534
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2535 ;;;; BUG REPORTS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2536
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2537 ;;; This section is provided for reports.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2538 ;;; Using Barry A. Warsaw's reporter.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2539
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2540 (defconst crypt-version "2.82"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2541 "Revision number of crypt++.el -- handles compressed and encrypted files.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2542 Type \\[crypt-submit-report] to send a bug report. Available via anonymous
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2543 ftp in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2544
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2545 /roebling.poly.edu:/pub/lisp/crypt++.el.gz
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2546 /archive.cis.ohio-state.edu:/pub/gnu/emacs/elisp-archive/misc/crypt++.el.Z")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2547
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2548 (defconst crypt-help-address
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2549 "dodd@roebling.poly.edu"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2550 "Address(es) accepting submission of reports on crypt++.el.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2551
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2552 (defconst crypt-maintainer "Larry"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2553 "First name(s) of people accepting submission of reports on crypt++.el.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2554
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2555 (defconst crypt-file "crypt++.el"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2556 "Name of file containing emacs lisp code.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2557
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2558 (defconst crypt-variable-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2559 (list 'shell-file-name ; These
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2560 'load-path ; are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2561 'exec-path ; useful.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2562 'crypt-encryption-type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2563 'crypt-encryption-file-extension
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2564 'crypt-never-ever-decrypt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2565 'crypt-auto-write-buffer-encrypted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2566 'crypt-confirm-password
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2567 'crypt-encrypted-disable-auto-save
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2568 'crypt-auto-decode-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2569 'crypt-auto-write-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2570 'crypt-query-if-interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2571 'crypt-no-extension-implies-plain
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2572 'crypt-freeze-vs-fortran
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2573 'crypt-compact-vs-C++
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2574 'crypt-ignored-filenames
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2575 'crypt-default-encoding
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2576 'crypt-encoded-disable-auto-save
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2577 'crypt-bind-insert-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2578 'crypt-auto-decode-insert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2579 'crypt-encoding-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2580 'crypt-encryption-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2581 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2582 "List of variables to be appended to reports sent by `crypt-submit-report.'")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2583
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2584 (defun crypt-submit-report ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2585 "Submit via reporter.el a bug report on program. Send report on `crypt-file'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2586 version `crypt-version,' to `crypt-maintainer' at address `crypt-help-address'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2587 listing variables `crypt-variable-list' in the message."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2588 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2589
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2590 ;; In case we can't find reporter...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2591 (condition-case err
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2592 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2593 ;; Get it if we can.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2594 (require 'reporter)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2595
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2596 (reporter-submit-bug-report
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2597 crypt-help-address ; address
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2598 (concat crypt-file " " crypt-version) ; pkgname
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2599 crypt-variable-list ; varlist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2600 nil nil ; pre-hooks and post-hooks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2601 (concat "Yo! " crypt-maintainer ","))) ; salutation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2602
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2603 ;; ...fail gracefully.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2604 (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2605 (beep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2606
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2607 ;; Do they have ange-ftp?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2608 (if (and (featurep 'ange-ftp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2609 (y-or-n-p (concat "Sorry, reporter.el not found. "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2610 "Can I ange-ftp it for you? ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2611
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2612 ;; Yes. Then Ange-ftp a copy from roebling.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2613 (let ((ange-ftp-generate-anonymous-password t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2614 ;; Might want to use the elisp archive official site? But
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2615 ;; then it would have to be uncompressed, etc. Ick!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2616 (find-file-other-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2617 "/anonymous@roebling.poly.edu:/pub/reporter.el")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2618 (eval-current-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2619 (message (concat "Save reporter.el somewhere in `load-path' "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2620 "and try again.")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2621
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2622 ;; No ange-ftp.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2623 (message "Sorry, reporter.el not found.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2624 (sit-for 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2625 (message (concat "Get it from archive.cis.ohio-state.edu "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2626 "or roebling.poly.edu"))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2627
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2628 ;;; Provide this package as crypt++ as well as crypt.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2629 (provide 'crypt++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2630 (provide 'crypt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2631
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2632 ;;; crypt++.el ends here.