annotate lisp/packages/crypt.el @ 191:ecf6ba7b0a10 r20-3b22

Import from CVS: tag r20-3b22
author cvs
date Mon, 13 Aug 2007 09:57:38 +0200
parents 2d532a89d707
children
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
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 120
diff changeset
703 (progn
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 120
diff changeset
704 (defgroup crypt nil
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 120
diff changeset
705 "Handling compressed and encrypted files."
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 120
diff changeset
706 :group 'compression)
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 120
diff changeset
707 )
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
708
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
709 (defcustom crypt-encryption-type 'crypt
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 "*Method of encryption. Must be an element of `crypt-encryption-alist.'
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
711 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
712 :type 'symbol
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
713 :group 'crypt)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
715 (defcustom crypt-encryption-file-extension nil
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 "*Regexp for extension of files encrypted with `crypt-encryption-type.'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 Should be of the form \"\\\\(\\\\.foo\\\\)$\". nil says use default values in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 `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
719 \\[crypt-rebuild-tables]."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
720 :type 'regexp
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
721 :group 'crypt)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
723 (defcustom crypt-never-ever-decrypt nil
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
724 "*t says never attempt to decrypt a buffer."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
725 :type 'boolean
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
726 :group 'crypt)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
728 (defcustom crypt-auto-write-buffer-encrypted nil
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 "*t says files with `crypt-encryption-alist' file extension auto-encrypted.
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
730 nil says query. See `crypt-auto-write-buffer.'"
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
731 :type 'boolean
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
732 :group 'crypt)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
734 (defcustom crypt-confirm-password nil
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
735 "*t says confirm new passwords and when writing a newly encrypted buffer."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
736 :type 'boolean
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
737 :group 'crypt)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
739 (defcustom crypt-encoded-disable-auto-save t
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 "*If t, turn off auto-save-mode for buffers which are encoded.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 If non-nil but not t, then no message is displayed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 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
744 autosave file, so the autosave would be in a different format from the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 original. The disadvantage of turning off autosaves is that any work you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 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
747 saved.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 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
750 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
751 Unencoded recovery data is better than none at all."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
752 :type '(choice (const :tag "on" t)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
753 (const :tag "off" nil)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
754 (const :tag "no message" other))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
755 :group 'crypt)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
757 (defcustom crypt-encrypted-disable-auto-save t
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 "*If t, turn off auto-save-mode for buffers which are encrypted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 If non-nil but not t, then no message is displayed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 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
762 the autosave file, so the autosave would be in cleartext form. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 disadvantage of turning off autosaves is that any work you do in that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 buffer will be completely lost if the changes are not explicitly saved.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 You might consider setting this variable to nil and use buffer-local
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 variables in files for which security is more important than data
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
768 recovery."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
769 :type '(choice (const :tag "on" t)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
770 (const :tag "off" nil)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
771 (const :tag "no message" other))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
772 :group 'crypt)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 ;;; ENCRYPTION
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 ;;; 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
777 ;;; determining when a buffer should be decrypted. we do this only buffers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 ;;; 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
779 ;;; _NOT_ match a MAGIC-REGEXP-INVERSE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 ;;; Currently MAGIC-REGEXP matches non-ASCII characters and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 ;;; MAGIC-REGEXP-INVERSE will match Sun OS, 4.x BSD, and Ultrix executable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 ;;; magic numbers, so binaries can still be edited (heh) without headaches.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 (defconst crypt-encryption-magic-regexp "[\000\200-\237]"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 "Regexp that must be found very close to beginning of encrypted buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 This is intended to be an internal variable \(not user-visible\). If you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 change this after crypt++ is loaded then do \\[crypt-rebuild-tables].")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 (defconst crypt-encryption-magic-regexp-inverse
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 "\\`\201\001\\|^\\(..\\)?\\([\007\010\013]\001\\|\001[\007\010\013]\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 "Regexp that must *not* be found very close to beginning of encrypted buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 This is intended to be an internal variable \(not user-visible\). If you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 change this after crypt++ is loaded then do \\[crypt-rebuild-tables].")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 (defconst crypt-magic-search-limit 100
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 "Limit of regular expression search used to recognize encrypted files.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 Maximum position in file for presence of `crypt-encryption-magic-regexp' and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 absence of `crypt-encryption-magic-regexp-inverse'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 (defun crypt-build-encryption-alist ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 ;; Returns the encryption alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 ;; crypt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 (list 'crypt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 crypt-encryption-magic-regexp crypt-encryption-magic-regexp-inverse
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 (or crypt-encryption-file-extension "\\(\\.e\\)$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 "crypt" "crypt"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 nil
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 "Crypt"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 ;; DES (Cipher Block Chaining - CBC) [DES' default]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 (list 'des
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 crypt-encryption-magic-regexp crypt-encryption-magic-regexp-inverse
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 (or crypt-encryption-file-extension "\\(\\.des\\)$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 "des" "des"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 '("-e" "-k")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 '("-d" "-k")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 "DES-CBC"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 ;; DES (Electronic Code Book - ECB)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 (list 'des-ecb
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 crypt-encryption-magic-regexp crypt-encryption-magic-regexp-inverse
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 (or crypt-encryption-file-extension "\\(\\.des\\)$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 "des" "des"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 '("-e" "-b" "-k")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 '("-d" "-b" "-k")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 "DES-ECB"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 ;; PGP
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 (list 'pgp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 crypt-encryption-magic-regexp crypt-encryption-magic-regexp-inverse
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 (or crypt-encryption-file-extension "\\(\\.pgp\\)$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 "pgp" "pgp"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 '("+batchmode" "+verbose=0" "-c" "-f" "-z")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 '("+batchmode" "+verbose=0" "-f" "-z")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 "PGP"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 ;; Add new elements here ...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 (defconst crypt-encryption-alist (crypt-build-encryption-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 "List of elements describing the encryption methods available.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 each element looks like
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 \(ENCRYPTION-TYPE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 MAGIC-REGEXP MAGIC-REGEXP-INVERSE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 FILE-EXTENSION
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 ENCRYPT-PROGRAM DECRYPT-PROGRAM
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 ENCRYPT-ARGS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 DECRYPT-ARGS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 MINOR-MODE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 GARBAGE-REGEXP-OR-LISPEXP
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 FILE-EXTENSION-TRICKS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 \)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 ENCRYPTION-TYPE is a symbol denoting the encryption type.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 MAGIC-REGEXP regexp that must match very close to the beginning of an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 encrypted buffer. This may also be some elisp expression to be evaluated at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 \(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
871 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
872 internal variable `crypt-encryption-magic-regexp' which will match non-ASCII
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 characters.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 MAGIC-REGEXP-INVERSE regexp that must _NOT_ match very close to the beginning
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 of an encrypted buffer. This may also be some elisp expression to be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 evaluated at \(point-min\) that will return t for a NON-encrypted buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 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
879 Currently set to the internal variable `crypt-encryption-magic-regexp-inverse'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 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
881 binaries can still be edited (heh) without headaches.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 FILE-EXTENSION regexp denoting the file extension usually appended the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 filename of files encrypted with ENCRYPT-PROGRAM. The variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 `crypt-encryption-file-extension' will over ride the default.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 ENCRYPT-PROGRAM name of executable file to be used for encryption.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 DECRYPT-PROGRAM name of executable file to be used for decryption.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 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
892 list of strings or nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 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
895 list of strings or nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 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
898 appear in the mode line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 GARBAGE-REGEXP-OR-LISPEXP dummy variable for compatibility with encoding.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902 FILE-EXTENSION-TRICKS is t or nil depending on whether or not tricks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903 converting between different encryption types can be done based on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904 FILE-EXTENSION; typically t.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905 ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908 ;;; ENCODING
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
910 (defcustom crypt-auto-decode-buffer t
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911 "*t says buffers visiting encoded files will be decoded automatically.
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
912 nil means to ask before doing the decoding."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
913 :type 'boolean
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
914 :group 'crypt)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
916 (defcustom crypt-auto-write-buffer nil
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917 "*t says save files with `crypt-encoding-alist' file extensions as encoded.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918 nil says to ask before doing this encoding. Similarly, buffers originating
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919 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
920 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
921 ask before doing this decoding."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
922 :type 'boolean
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
923 :group 'crypt)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925 ;; This is an internal variable documented here and not in a DOCSTRING in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926 ;; 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
927 ;; default, then it contains the answer to the question "Write out buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928 ;; foobar using `compression-type'?". This question is asked only if *plain*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929 ;; buffer foobar is being written to disk *and* it has a provocative
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 ;; `compression-type' file-name extension (see DOCSTRING for variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 ;; crypt-auto-write-buffer). The variable is local to all buffers with a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932 ;; default value of 'ask so if the situation described above arises, then the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933 ;; question is asked at least once, unless the user-defined variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934 ;; crypt-auto-write-buffer is non-nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935 (defvar crypt-auto-write-answer-local 'ask)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936 (make-variable-buffer-local 'crypt-auto-write-answer-local)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937 (setq-default crypt-auto-write-answer-local 'ask)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938 (put 'crypt-auto-write-answer-local 'permanent-local t) ; for v19 Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939 (put 'crypt-auto-write-answer-local 'preserved t) ; for kill-fix.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
941 (defcustom crypt-query-if-interactive t
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942 "*t says ask when saving buffers where `crypt-encoded-mode' was toggled.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943 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
944 `crypt-encoding-alist') buffer will be written in an encoded format without
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945 asking.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 This variable is designed for users that edit a plain file (with plain
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948 extension) and then toggle `(crypt-encoded-mode)' and do not wish to be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 queried every time that they save the buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951 NOTE: if `(crypt-encoded-mode)' was not called interactively (the usual
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952 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
953 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
954 the relevant variable."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
955 :type 'boolean
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
956 :group 'crypt)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
958 (defcustom crypt-no-extension-implies-plain t
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959 "*t says file extensions not in `crypt-encoding-alist' may be written plain.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960 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
961 extension is written in plain format automatically, otherwise query user.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963 nil says user works with encoded (compressed) files without file extensions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964 and will not be queried each time they save these files.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966 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
967 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
968 save-buffer so nil will mean that neither will query."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
969 :type 'boolean
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
970 :group 'crypt)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
972 (defcustom crypt-freeze-vs-fortran t
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973 "*t says `.F' file extension denotes a frozen file not a Fortran file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974 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
975 \\[crypt-rebuild-tables]."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
976 :type 'boolean
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
977 :group 'crypt)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
979 (defcustom crypt-compact-vs-C++ nil
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980 "*t says `.C' file extension denotes a compacted file not a C++ file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981 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
982 \\[crypt-rebuild-tables]."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
983 :type 'boolean
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
984 :group 'crypt)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
985
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
986 (defcustom crypt-ignored-filenames nil
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
987 "*List of regexp filenames for which encoded to plain conversion is not done.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
988 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
989 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
990 plain format.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
991
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
992 This variable is provided for users that want to compress their incoming mail
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
993 for RMAIL and VM which look for files `RMAIL' and `INBOX,' respectively, to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
994 store incoming mail. For example, the gzip extensions on `RMAIL.gz' and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
995 `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
996 no query about conversion to plain format will be made."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
997 :type '(repeat regexp)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
998 :group 'crypt)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
1000 (defcustom crypt-default-encoding "gzip"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1001 "*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
1002 Must match one of the elements of `crypt-encoding-alist'."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
1003 :type 'string
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
1004 :group 'crypt)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1005
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
1006 (defcustom crypt-dos-has-ctrl-z nil
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1007 "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
1008 Buffer local and set by `crypt-dos-to-unix-region'"
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
1009 :type 'boolean
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
1010 :group 'crypt)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1011 (make-variable-buffer-local 'crypt-dos-has-ctrl-z)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1012 (setq-default crypt-dos-has-ctrl-z nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1013 (put 'crypt-dos-has-ctrl-z 'permanent-local t) ; for v19 Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1014 (put 'crypt-dos-has-ctrl-z 'preserved t) ; for kill-fix.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1015
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1016 (defun crypt-build-encoding-alist ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017 ;; Returns the encoding alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1018 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1019 ;; compress
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1020 (list 'compress
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1021 "\037\235" nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022 "\\(\\.Z\\)$"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1023 "compress" "uncompress"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1024 nil nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1025 "Compress"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1026 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1027 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1028 ;; gzip (GNU zip)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1029 (list 'gzip
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1030 "\037\213" nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031 "\\(\\.g?z\\)$"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1032 "gzip" "gzip"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1033 "--quiet" "--decompress --quiet"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1034 "Zip"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1035 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1036 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1037 ;; freeze
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1038 (list 'freeze
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1039 "\037\236\\|\037\237" nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1040 "\\(\\.F\\)$"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1041 "freeze" "freeze"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1042 "" "-d"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1043 "Freeze"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1044 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1045 crypt-freeze-vs-fortran)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1046 ;; compact
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1047 (list 'compact
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1048 "\377\037" nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1049 "\\(\\.C\\)$"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1050 "compact" "uncompact"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1051 nil nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1052 "Compact"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1053 "^Compression *:.*\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1054 crypt-compact-vs-C++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1055 ;; DOS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1056 (list 'dos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1057 "[^\n\r]*\r$" nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1058 "\\(\\.DOS\\)$"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1059 'crypt-unix-to-dos-region 'crypt-dos-to-unix-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1060 nil nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1061 "Dos"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1062 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1063 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1064 ;; Add new elements here ...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1065 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1066
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1067 (defconst crypt-encoding-alist (crypt-build-encoding-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1068 "List of elements describing the encoding methods available.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1069 each element looks like
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1070
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1071 \(ENCODING-TYPE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1072 MAGIC-REGEXP MAGIC-REGEXP-INVERSE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1073 FILE-EXTENSION
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1074 ENCODE-PROGRAM DECODE-PROGRAM
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1075 ENCODE-ARGS DECODE-ARGS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1076 MINOR-MODE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1077 GARBAGE-REGEXP-OR-LISPEXP
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1078 FILE-EXTENSION-TRICKS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1079 \)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1080
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1081 ENCODING-TYPE is a symbol denoting the encoding type. Currently known
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1082 encodings are (compress compact freeze gzip).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1083
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1084 MAGIC-REGEXP is a regexp that matches the magic number at the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1085 beginning of files encoded with ENCODING-TYPE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1086
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1087 MAGIC-REGEXP-INVERSE dummy variable for compatibility with encryption.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1088
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1089 FILE-EXTENSION is a string denoting the file extension usually
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1090 appended the filename of files encoded with ENCODING-TYPE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1091
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1092 ENCODE-PROGRAM is a string denoting the name of the executable used to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1093 encode files.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1094
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1095 DECODE-PROGRAM is a string denoting the name of the executable used to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1096 decode files.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1097
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1098 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
1099 list of strings or nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1100
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1101 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
1102 list of strings or nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1103
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1104 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
1105 it will appear in the mode line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1106
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1107 GARBAGE-REGEXP-OR-LISPEXP is (1) a regexp that matches any extraneous text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1108 that is produced by the ENCODE-COMMAND including any newlines and will be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1109 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
1110 clean up extraneous material in the buffer or nil. This is normally not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1111 needed but can be derived for any ENCODE-COMMAND by checking the standard
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1112 error that results from `sh -c \"cat foo | ENCODE-COMMAND > bar\"'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1113
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1114 FILE-EXTENSION-TRICKS is t or nil depending on whether or not tricks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1115 converting between different encoding types can be done based on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1116 FILE-EXTENSION; typically t.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1117 ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1118
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 142
diff changeset
1119 (defvar crypt-inhibit-formats (when (featurep 'mule) '(dos))
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 142
diff changeset
1120 "*A list of crypt abilities to turn off. In particular, setting this
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 142
diff changeset
1121 variable to be '(dos) will stop the dos-mode CRLF <-> LF damage.")
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 142
diff changeset
1122
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1123
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1124 ;;; This allows the user to alter contents of the encoding and encryption
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1125 ;;; table variables without having to reload all of crypt++.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1126 (defun crypt-rebuild-tables ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1127 "Rebuilds the encryption and encoding tables and `minor-mode-alist'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1128 Allows user to alter variables used in building these tables. May be called
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1129 interactively or in an initialization file. Part of `after-init-hook'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1130 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1131 (setq crypt-encryption-alist (crypt-build-encryption-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1132 crypt-encoding-alist (crypt-build-encoding-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1133 (crypt-rebuild-minor-modes-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1134
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1135
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1136 ;;; Buffer locals.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1137
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1138 (defvar crypt-buffer-save-encrypted nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1139 "*non-nil says save buffer encrypted with `crypt-encryption-type.'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1140 local to all buffers.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1141 (make-variable-buffer-local 'crypt-buffer-save-encrypted)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1142 (put 'crypt-buffer-save-encrypted 'permanent-local t) ; for v19 Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1143 (put 'crypt-buffer-save-encrypted '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-encryption-key nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1146 "*Key used for encryption of current buffer. Local to all buffers.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1147 (make-variable-buffer-local 'crypt-buffer-encryption-key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1148 (put 'crypt-buffer-encryption-key 'permanent-local t) ; for v19 Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1149 (put 'crypt-buffer-encryption-key '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-save-encoded nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1152 "*non-nil says buffer will be saved encoded. Local to all buffers.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1153 (make-variable-buffer-local 'crypt-buffer-save-encoded)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1154 (put 'crypt-buffer-save-encoded 'permanent-local t) ; for v19 Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1155 (put 'crypt-buffer-save-encoded '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-encoding-type nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1158 "*non-nil says buffer is encoded with ENCODING-TYPE. Local to all buffers.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1159 (make-variable-buffer-local 'crypt-buffer-encoding-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1160 (put 'crypt-buffer-encoding-type 'permanent-local t) ; for v19 Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1161 (put 'crypt-buffer-encoding-type 'preserved t) ; for kill-fix.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1162
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1163 (defvar crypt-buffer-interactive-encoded-mode nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1164 "t says `crypt-encoded-mode' was toggled interactively, almost always nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1165 Local to all buffers.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1166 (make-variable-buffer-local 'crypt-buffer-interactive-encoded-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1167 (put 'crypt-buffer-interactive-encoded-mode 'permanent-local t) ; v19 Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1168 (put 'crypt-buffer-interactive-encoded-mode 'preserved t) ; kill-fix.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1169
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1170
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1171 ;;; Functions and macros that search `crypt-encryption-alist' and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1172 ;;; `crypt-encoding-alist'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1173
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1174 (defun crypt-get-alist-member (type n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1175 ;; Returns TYPE's Nth element
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1176 (nth n (or (assoc type crypt-encryption-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1177 (assoc type crypt-encoding-alist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1178
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1179 (defmacro crypt-get-magic-regexp (type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1180 ;; Returns regexp found at top of files encoded/encrypted with TYPE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1181 (list 'crypt-get-alist-member type 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1182
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1183 (defmacro crypt-get-magic-regexp-inverse (type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1184 ;; Returns regexp *not* found at top of files encoded/encrypted with TYPE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1185 (list 'crypt-get-alist-member type 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1186
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1187 (defmacro crypt-get-file-extension (type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1188 ;; Returns regexp matching extension of files encoded/encrypted with TYPE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1189 (list 'crypt-get-alist-member type 3))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1190
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1191 (defmacro crypt-get-encoding-program (type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1192 ;; Returns name of program, as string, used to encode/encrypt with TYPE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1193 (list 'crypt-get-alist-member type 4))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1194
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1195 (defmacro crypt-get-decoding-program (type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1196 ;; Returns name of program, as string, used to decode/decrypt with TYPE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1197 (list 'crypt-get-alist-member type 5))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1198
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1199 (defmacro crypt-get-encoding-args (type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1200 ;; Returns arguments passed to program used to encode/encrypt with TYPE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1201 (list 'crypt-get-alist-member type 6))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1202
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1203 (defmacro crypt-get-decoding-args (type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1204 ;; Returns arguments passed to program used to decode/decrypt with TYPE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1205 (list 'crypt-get-alist-member type 7))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1206
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1207 (defmacro crypt-get-minor-mode-name (type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1208 ;; Returns minor mode name, as string, for encoding/encrypting with TYPE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1209 (list 'crypt-get-alist-member type 8))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1210
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1211 (defmacro crypt-get-cleanup-regexp (type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1212 ;; Returns regexp or lisp-exp for cleaning up encoding/encrypting with TYPE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1213 (list 'crypt-get-alist-member type 9))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1214
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1215 (defmacro crypt-get-extension-tricks (type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1216 ;; Returns t if file extension tricks doable for encoding/encrypting with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1217 ;; TYPE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1218 (list 'crypt-get-alist-member type 10))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1219
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1220 (defun crypt-buffer-save-name (type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1221 ;; Returns variable `crypt-buffer-save-TYPE', set to t if encoding with TYPE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1222 ;; local to all buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1223 (intern (concat "crypt-buffer-save-" (symbol-name type))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1224
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1225
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1226 ;;; Create a buffer-local variable for each type of encoding.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1227 ;;; These variables are used to trigger the minor mode names.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1228
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1229 (defun crypt-build-minor-mode-alist ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1230 ;; Returns minor mode alist entries for encoded and encrypted buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1231 (append
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1232 ;; First the encrypted minor mode -- only one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1233 (list (list 'crypt-buffer-save-encrypted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1234 (concat " " (crypt-get-minor-mode-name crypt-encryption-type))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1235 ;; Now the encoding minor modes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1236 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1237 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1238 (lambda (element)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1239 (let ((variable (crypt-buffer-save-name (car element))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1240 (make-variable-buffer-local variable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1241 (put variable 'permanent-local t) ; for v19 Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1242 (put variable 'preserved t) ; for kill-fix.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1243 (list variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1244 (concat " " (crypt-get-minor-mode-name (car element)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1245 crypt-encoding-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1246
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1247 (defconst crypt-minor-mode-alist (crypt-build-minor-mode-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1248 "Alist containing encoded and encrypted minor modes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1249 Derived from variable `crypt-encoding-alist' and function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1250 `crypt-build-minor-mode-encrypted'")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1251
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1252 (defun crypt-rebuild-minor-modes-alist ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1253 ;; Rebuilds the encryption and encoding minor modes and `minor-mode-alist.'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1254 ;; Allows user to alter variables used in building this alist. Called by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1255 ;; `crypt-rebuild-tables' and so part of `after-init-hook'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1256
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1257 ;; First remove old crypt minor mode entries from `minor-mode-alist'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1258 (if (memq (car crypt-minor-mode-alist) minor-mode-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1259 (let ((alist crypt-minor-mode-alist) elt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1260 (while (and alist (setq elt (car alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1261 (setq minor-mode-alist (delq elt minor-mode-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1262 alist (cdr alist)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1263
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1264 ;; Get new crypt minor mode entries and add to minor-mode-alist.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1265 (setq crypt-minor-mode-alist (crypt-build-minor-mode-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1266 minor-mode-alist (append crypt-minor-mode-alist minor-mode-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1267
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1268
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1269 (defmacro crypt-save-point (&rest body)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1270 ;; Save value of point, evaluate FORMS, and restore value of point. If the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1271 ;; 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
1272 ;; exists because, save-excursion loses track of point during some types of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1273 ;; deletions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1274 (let ((var (make-symbol "saved-point")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1275 (list 'let (list (list var '(point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1276 (list 'unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1277 (cons 'progn body)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1278 (list 'goto-char var)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1279
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1280
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1281 (defun crypt-find-file-hook ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1282
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1283 ;; Hook run for decoding and/or decrypting the contents of a buffer. Meant
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1284 ;; to be called as part of `find-file-hooks'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1285
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1286 (let ((buffer-file-name buffer-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1287 (old-buffer-file-name buffer-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1288 (old-buffer-modified-p (buffer-modified-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1289 (case-fold-search nil) ; case-sensitive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1290 encrypted encoded buffer-read-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1291
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1292 ;; DECODE AND/OR DECRYPT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1293 (crypt-save-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1294
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1295 ;; Do we have to DECODE? If not, then move on.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1296 (if (and (crypt-encoded-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1297 (or crypt-auto-decode-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1298 (y-or-n-p (format "Decode %s? " (buffer-name)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1299
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1300 ;; Decode, uncompress, the buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1301 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1302
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1303 (if (and (not (null buffer-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1304 (string-match "\\.Z$" buffer-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1305 (set-visited-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1306 (substring buffer-file-name 0 (match-beginning 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1307 (if (and (not (null buffer-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1308 (string-match "\\.gz$" buffer-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1309 (set-visited-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1310 (substring buffer-file-name 0 (match-beginning 0)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1311 (message "Decoding %s..." (buffer-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1312 (crypt-encode-buffer t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1313
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1314 ;; Store the encoding mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1315
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1316 ;; We can not yet go into the minor modes because the major mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1317 ;; may change later on and blow away all local variables (and thus
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1318 ;; the minor modes). Only needed for vanilla v18. Our
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1319 ;; buffer-locals defined 'permanent-local for v19 Emacs and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1320 ;; 'preserved for kill-fix.el.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1321
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1322 (setq encoded crypt-buffer-encoding-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1323
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1324 ;; Strip encoded file's extension so later we can set buffer's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1325 ;; major mode based on its file-name sans encoding extension.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1326 (if (string-match (crypt-get-file-extension
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1327 crypt-buffer-encoding-type) buffer-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1328 (setq buffer-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1329 (substring buffer-file-name 0 (match-beginning 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1330
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1331 ;; Decoding ends.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1332 (if (not (input-pending-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1333 (message "Decoding %s... done" (buffer-name)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1334
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1335 ;; Do we have to DECRYPT? If not, then move on.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1336 (if (crypt-encrypted-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1337
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1338 ;; Decrypt buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1339 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1340
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1341 (message "Decrypting %s..." (buffer-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1342 (crypt-encrypt-buffer crypt-buffer-encryption-key t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1343
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1344 ;; Save key in case major mode blows all buffer-locals.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1345
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1346 ;; Only needed for vanilla v18. Our buffer-locals defined
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1347 ;; 'permanent-local for v19 Emacs and 'preserved for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1348 ;; kill-fix.el.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1349
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1350 (setq encrypted crypt-buffer-encryption-key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1351
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1352 ;; Strip encrypted file's extension so later we can set buffer's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1353 ;; major mode based on its file-name sans encrypting extension.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1354 (if (and (crypt-get-extension-tricks crypt-encryption-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1355 (string-match (crypt-get-file-extension
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1356 crypt-encryption-type) buffer-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1357 (setq buffer-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1358 (substring buffer-file-name 0 (match-beginning 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1359
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1360 (if (not (input-pending-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1361 (message "Decrypting %s... done" (buffer-name))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1362
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1363 ;; MAJOR AND MINOR MODES
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1364
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1365 ;; 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
1366 ;; code the does automatic selection of major mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1367
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1368 (if (or encoded encrypted)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1369
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1370 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1371
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1372 ;; Set the major mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1373 (set-auto-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1374 (hack-local-variables)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1375
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1376 ;; Now set our own minor mode(s).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1377 (if encoded
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1378 ;; Recover encoding type, may have been smashed by major mode,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1379 ;; and toggle encoded mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1380 (progn (setq crypt-buffer-encoding-type encoded)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1381 (crypt-encoded-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 (if encrypted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1384 ;; Recover encryption key, may have been smashed by major mode,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1385 ;; and toggle encrypted mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1386 (progn (setq crypt-buffer-encryption-key encrypted)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1387 (crypt-encrypted-mode 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1388
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1389 ;; Restore buffer file name now, so that lock file entry is removed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1390 ;; properly.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1391 (setq buffer-file-name old-buffer-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1392
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1393 ;; Restore buffer modified flag to its previous value. Will also
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1394 ;; remove lock file entry for buffer if previous value was nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1395 ;; This is why buffer-file-name had to be restored manually above.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1396 (set-buffer-modified-p old-buffer-modified-p)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1397
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1398 (defun crypt-encoded-p (&optional buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1399 ;; Returns t if current buffer, or optionally BUFFER, is encoded.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1400 ;; Sets `crypt-buffer-encoding-type' to encoding method.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1401 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1402 (and buffer (set-buffer buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1403 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1404 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1405 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1406 (let ((alist crypt-encoding-alist) elt found)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1407 (while (and alist (setq elt (car alist)) (not found))
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 142
diff changeset
1408 (if (and (looking-at (nth 1 elt))
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 142
diff changeset
1409 (not (memq (nth 0 elt) crypt-inhibit-formats)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1410 (setq crypt-buffer-encoding-type (nth 0 elt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1411 found t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1412 ;; Decrement
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1413 (setq alist (cdr alist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1414 found))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1415
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1416 (defun crypt-encrypted-p (&optional buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1417 ;; Returns t if current buffer, or optionally BUFFER, is encrypted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1418 ;; Look for MAGIC-REGEXP and absence of MAGIC-REGEXP-INVERSE. If so, then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1419 ;; assume it is an encrypted buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1420 ;; Sets `crypt-buffer-encryption-key' to password if not set already.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1421
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1422 ;; Do not try to decrypt buffer if not wanted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1423 (if (not crypt-never-ever-decrypt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1424
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1425 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1426 (and buffer (set-buffer buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1427
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1428 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1429 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1430 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1431
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1432 (let ((magic-regexp (crypt-get-magic-regexp crypt-encryption-type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1433 (magic-regexp-inverse (crypt-get-magic-regexp-inverse
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1434 crypt-encryption-type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1435 (limit (min (point-max) crypt-magic-search-limit)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1436
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1437 ;; Check all encryption conditions. If any fail, then return nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1438 ;; value of this if-form, else check for password.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1439 (if (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1440
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1441 ;; Check for existence of MAGIC-REGEXP.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1442 (if (stringp magic-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1443 ;; regular expression
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1444 (re-search-forward magic-regexp limit t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1445 ;; lisp expression
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1446 (eval magic-regexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1447
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1448 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1449
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1450 ;; Check for absence of MAGIC-REGEXP-INVERSE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1451 (not (if (stringp magic-regexp-inverse)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1452 ;; regular expression
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1453 (re-search-forward magic-regexp-inverse limit t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1454 ;; lisp expression
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1455 (eval magic-regexp-inverse))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1456
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1457 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1458
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1459 ;; Get key, i.e., the password?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1460 (or crypt-buffer-encryption-key
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1461 ;; Do not confirm on reading an encrypted file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1462 (let ((crypt-confirm-password nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1463 (call-interactively 'crypt-set-encryption-key)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1464
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1465 ;; Do not turn on encryption mode if no key: may be a binary
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1466 ;; file. Thanks to Paul Dworkin (paul@media-lab.media.mit.edu).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1467 (if (equal crypt-buffer-encryption-key "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1468 ;; Return nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1469 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1470 (message "No key given. Assumed normal.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1471 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1472 ;; Return t.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1473 t))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1474
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1475
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1476 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1477
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1478 (defun crypt-check-extension-for-encoding ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1479
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1480 ;; Checks file extensions for possible toggling of encoding modes. Used for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1481 ;; buffers to be written to disk and called by `crypt-write-file-hook'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1482
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1483 ;; 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
1484 ;; ends in one of the file-extensions in `crypt-encoding-alist' even if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1485 ;; `crypt-buffer-save-encoded' is nil. Conversely, we try to write out a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1486 ;; 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
1487 ;; file-extensions even if `crypt-buffer-save-encoded' is non-nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1488
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1489 (let ((alist crypt-encoding-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1490 (case-fold-search nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1491 found elt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1492
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1493 ;; Search through the file name extensions for a match.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1494 (while (and alist (setq elt (car alist)) (not found))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1495 (if (string-match (nth 3 elt) buffer-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1496 (setq found t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1497 ;; Decrement.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1498 (setq alist (cdr alist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1499
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1500 ;; Did we find a match?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1501 (if found
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1502
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1503 ;; File name ends in a very provocative extension.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1504
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1505 ;; Check to see if already an encoded file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1506 (if crypt-buffer-save-encoded
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1507
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1508 ;; Already encoded - do the methods of encoding match?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1509 (if (not (eq (nth 0 elt) crypt-buffer-encoding-type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1510
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1511 ;; A new encoding method is desired.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1512
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1513 ;; Can we play some filename extension tricks with the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1514 ;; destination extension?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1515 (if (crypt-get-extension-tricks (nth 0 elt))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1516
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1517 ;; Can play tricks.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1518 ;; Change the method of encoding?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1519 (if (crypt-y-or-n-p (format "Write %s using %s? "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1520 (buffer-name) (nth 4 elt)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1521
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1522 ;; Case one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1523 ;; Turn off original encoding and turn on new encoding.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1524 (progn (crypt-encoded-mode -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1525 (setq crypt-buffer-encoding-type (nth 0 elt))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1526 (crypt-encoded-mode 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1527
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1528 ;; Can not play tricks - maybe wants a plain file?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1529 (if (crypt-y-or-n-p (format "Write %s a plain file? "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1530 (buffer-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1531
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1532 ;; Case three.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1533 ;; Turn off the minor mode and _then_ the flags.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1534 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1535 (crypt-encoded-mode -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1536 (setq crypt-buffer-save-encoded nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1537 crypt-buffer-encoding-type nil)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1538
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1539 ;; Was a plain file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1540 (if (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1541 ;; Can we play some filename extension tricks?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1542 ;; If not then we must abort.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1543 (crypt-get-extension-tricks (nth 0 elt))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1544
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1545 (crypt-y-or-n-p (format "Write %s using %s? "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1546 (buffer-name) (nth 4 elt))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1547
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1548 ;; Case two.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1549 ;; Turn on encoding flags and _then_ the minor mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1550 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1551 (setq crypt-buffer-save-encoded t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1552 crypt-buffer-encoding-type (nth 0 elt))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1553 (crypt-encoded-mode 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1554
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1555 ;; No match - a plain-jane file extension - but if the encoded flag is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1556 ;; non-nil then the user may really want it written out in plain
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1557 ;; format so we must override this flag.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1558 (if (and crypt-buffer-save-encoded
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 the list of files to be ignored.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1561 ;; If `crypt-ignored-filenames' is nil then this let form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1562 ;; will return t. If a match is found this form will return
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1563 ;; nil. Otherwise it will return t.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1564 (let ((tlist crypt-ignored-filenames)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1565 case-fold-search found elt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1566
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1567 ;; Search through the list of filenames for a match.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1568 (while (and tlist (setq elt (car tlist)) (not found))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1569 (if (string-match elt buffer-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1570 (setq found t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1571 ;; Decrement.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1572 (setq tlist (cdr tlist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1573
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1574 ;; Return t if we can _not_ find a match.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1575 (not found))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1576
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1577 ;; If `(crypt-encoded-mode)' was called interactively, then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1578 ;; there is a high probability that no matter what the file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1579 ;; name extension the user wishes to write the file out in some
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1580 ;; encoded format. Thanks to Kimball Collins
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1581 ;; <kpc@ptolemy.arc.nasa.gov> for pointing out the need for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1582 ;; this. Unfortunately, still can not distinguish between
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1583 ;; write-file and save-buffer. In the former the user may want
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1584 ;; to write in plain format (or indeed some other format).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1585
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1586 (if crypt-buffer-interactive-encoded-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1587 ;; Interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1588 crypt-query-if-interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1589 ;; Non-interactive but still may want encoded format.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1590 crypt-no-extension-implies-plain)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1591
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1592 (crypt-y-or-n-p (format "Write %s as a plain file? "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1593 (buffer-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1594
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1595 ;; Case three.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1596 ;; Turn off the minor mode and _then_ the flags.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1597 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1598 (crypt-encoded-mode -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1599 (setq crypt-buffer-save-encoded nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1600 crypt-buffer-encoding-type nil))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1601
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1602
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1603 (defun crypt-y-or-n-p (prompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1604 ;; Queries user based on `crypt-auto-write-buffer' and internal buffer-local
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1605 ;; variable `crypt-auto-write-answer-local'. Returns value of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1606 ;; `crypt-auto-write-answer-local', which is t or nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1607
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1608 ;; Check if we need to ask user. Should be 'ask, nil, or t.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1609 (if (eq crypt-auto-write-answer-local 'ask) ; Default value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1610 ;; We may need to ask.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1611 (or crypt-auto-write-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1612 ;; Ask and store the answer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1613 ;; Note: we only store if we asked.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1614 (setq crypt-auto-write-answer-local (y-or-n-p prompt)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1615 ;; Use previous answer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1616 crypt-auto-write-answer-local)) ; Will be nil or t.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1617
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1618
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1619 ;;; This function should be called ONLY as a write-file hook.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1620 ;;; Odd things will happen if it is called elsewhere.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1621
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1622 (defun crypt-write-file-hook ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1623
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1624 ;; Hook for possibly writing out file, and backup file, in a non-plain
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1625 ;; format. Terminates calls in `write-file-hooks' and should be at end of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1626 ;; list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1627
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1628 ;; Check file-extension for possible toggling of encoding modes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1629 (crypt-check-extension-for-encoding)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1630
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1631 ;; Check extension for encryption.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1632 (if (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1633
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1634 ;; Maybe file ends with provocative extension w.r.t. encryption?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1635 (stringp (crypt-get-file-extension crypt-encryption-type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1636 (let ((case-fold-search nil)) ; Make case-sensitive.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1637 (string-match (crypt-get-file-extension crypt-encryption-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1638 buffer-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1639
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1640 ;; Can we play tricks?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1641 (crypt-get-extension-tricks crypt-encryption-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1642
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1643 ;; Match of filename extension - is file in plain format?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1644 (not crypt-buffer-save-encrypted)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1645
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1646 ;; Query?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1647 (or crypt-auto-write-buffer-encrypted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1648 (y-or-n-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1649 (format "Write %s as an encrypted file? " (buffer-name)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1650
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1651 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1652 ;; Set password and toggle `crypt-encrypted-mode'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1653 (call-interactively 'crypt-set-encryption-key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1654 (crypt-encrypted-mode 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1655
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1656 ;; 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
1657 ;; 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
1658 ;; done here but later in the write-file-hooks - probably at the end.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1659
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1660 (if (or crypt-buffer-save-encoded crypt-buffer-save-encrypted)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1661
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1662 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1663 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1664
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1665 (let
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1666
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1667 ;; BINDINGS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1668 ((copy-buffer (get-buffer-create " *crypt copy buffer*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1669 (selective-display selective-display)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1670 (buffer-read-only))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1671
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1672 ;; FORMS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1673 (copy-to-buffer copy-buffer 1 (1+ (buffer-size)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1674 (narrow-to-region (point) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1675
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1676 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1677
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1678 ;; BODYFORM
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1679 (let (setmodes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1680
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1681 ;; As of v19, if one of functions of the `write-file-hooks'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1682 ;; returns a non-nil value, then `basic-save-buffer' no
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1683 ;; longer creates a backup file. We must do it ourselves.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1684 ;; this should be a no-op in v18.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1685 (or buffer-backed-up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1686 (setq setmodes (backup-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1687
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1688 (insert-buffer-substring copy-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1689 (kill-buffer copy-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1690
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1691 ;; "Who would cross the Bridge of Death
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1692 ;; Must answer me
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1693 ;; These questions three
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1694 ;; Ere the other side he see."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1695 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1696 ;; Bridgekeeper from Monty Python and the Holy Grail
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1697
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1698 ;; [1] selective-display non-nil means we must convert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1699 ;; carriage returns to newlines now, and set the variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1700 ;; selective-display temporarily to nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1701 (if selective-display
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 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1704 (subst-char-in-region (point-min) (point-max) ?\r ?\n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1705 (setq selective-display nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1706
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1707 ;; [2] encryption
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1708 (if crypt-buffer-save-encrypted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1709 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1710 ;; check for password
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1711 (if (not crypt-buffer-encryption-key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1712 (call-interactively 'crypt-set-encryption-key))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1713 (if (null crypt-buffer-encryption-key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1714 (error "No encryption key set for buffer %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1715 (buffer-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1716 (if (not (stringp crypt-buffer-encryption-key))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1717 (error "Encryption key is not a string"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1718 (message "Encrypting %s..." (buffer-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1719 (crypt-encrypt-buffer crypt-buffer-encryption-key)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1720
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1721 ;; [3] encoding
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1722 (if crypt-buffer-save-encoded
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1723 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1724 (message "Encoding %s..." (buffer-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1725 (crypt-encode-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1726
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1727 ;; Now write buffer/region to disk.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1728 (write-region (point-min) (point-max) buffer-file-name nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1729 (delete-region (point-min) (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1730 (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1731
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1732 ;; Now that the file is written, set its modes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1733 (if setmodes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1734 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1735 (set-file-modes buffer-file-name setmodes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1736 (error nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1737
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1738 ;; Return t so that `basic-save-buffer' will know that the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1739 ;; save has already been done.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1740
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1741 ;; NOTE: this TERMINATES write-file-hooks so any hooks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1742 ;; following this one will not be executed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1743
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1744 t )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1745
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1746 ;; UNWINDFORMS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1747 ;; unwind...sit back...take a load off...have a beer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1748
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1749 ;; If the encoded and encrypted stuff has already been removed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1750 ;; then this is a no-op. This form is executed if BODYFORM
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1751 ;; completes normally but the value of BODYFORM is returned -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1752 ;; i.e., t is returned.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1753
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1754 (delete-region (point-min) (point-max))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1755
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1756
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1757 ;;;; ENCRYPTION
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1758
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1759 (defun crypt-encrypt-region (start end key &optional decrypt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1760 "Encrypt region START to END using KEY and `crypt-encryption-type'. When
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1761 called interactively START and END default to point and mark \(START being the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1762 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
1763 decryption is done."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1764
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1765 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1766 (let (decrypt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1767 (barf-if-buffer-read-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1768 (list (region-beginning)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1769 (region-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1770 (crypt-read-string-no-echo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1771 (concat (if (setq decrypt (y-or-n-p "Decrypt region? ")) "De" "En")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1772 "crypt buffer using key: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1773 ;; Do not confirm on decrypting region.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1774 (if (not decrypt) crypt-confirm-password))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1775 decrypt)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1776
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1777 (crypt-save-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1778
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1779 ;; We define the PROGRAM as the encryption program or decryption program
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1780 ;; listed for `crypt-encryption-type' of `crypt-encryption-alist.' These
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1781 ;; should be just the name of the executable and should _not_ contain any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1782 ;; arguments. `(call-process-region)' would be confused if we tried to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1783 ;; pass the arguments as part of the PROGRAM. The arguments are passed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1784 ;; through the encryption args or decryption args listed for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1785 ;; `crypt-encryption-type' of `crypt-encryption-alist.'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1786
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1787 ;; Thanks to Joe Ilacqua <spike@world.std.com> and others for pointing out
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1788 ;; an error that occurs with some encryption programs (e.g., the crypt from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1789 ;; Sun Microsystems, HPUX-8, and BSD) if `args' is `"".' This will allow
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1790 ;; nil values and lists of strings for argument.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1791
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1792 (let (prog args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1793
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1794 ;; Get the proper program and arguments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1795 (if decrypt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1796 (setq prog (crypt-get-decoding-program crypt-encryption-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1797 args (crypt-get-decoding-args crypt-encryption-type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1798 (setq prog (crypt-get-encoding-program crypt-encryption-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1799 args (crypt-get-encoding-args crypt-encryption-type)))
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 arguments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1802 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1803
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1804 ;; nil or "" args - don't pass.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1805 ((or (not args) (equal "" args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1806 (call-process-region start end prog t t nil key))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1807
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1808 ;; 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
1809 ((listp args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1810 (apply 'call-process-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1811 (append (list start end prog t t nil) args (list key))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1812
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1813 ;; Default - just a non-null string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1814 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1815 (call-process-region start end prog t t nil args key))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1816
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1817
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1818 (defun crypt-encrypt-buffer (key &optional decrypt buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1819
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1820 ;; Use KEY to encrypt current buffer and with optional DECRYPT decrypt.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1821 ;; With optional BUFFER, encrypt or decrypt that buffer. Not meant to be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1822 ;; called interactively, toggle `crypt-encrypted-mode' to encrypt an entire
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1823 ;; buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1824
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1825 (or buffer (setq buffer (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1826 (save-excursion (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1827 (crypt-encrypt-region (point-min) (point-max) key decrypt)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1828
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1829
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1830 ;;;; ENCODING
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1831
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1832 (defun crypt-encode-region (start end &optional decode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1833
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1834 "Encode region START to END. When called interactively START and END
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1835 default to point and mark \(START being the lesser of the two\). With
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1836 optional DECODE non-nil, decoding is done.
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 encoding is attempted, then checks for correct magic number at start of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1839 newly-encoded region. If not found, then searches and deletes a user-defined
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1840 regexp, or executes a user-defined lisp expression, as defined in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1841 `crypt-encoding-alist,' and checks again for magic number."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1842
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1843 (interactive "*r\nP")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1844
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1845 ;; If called interactively then we may need to determine the encoding type.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1846 (if (and (interactive-p) (not crypt-buffer-encoding-type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1847 (crypt-read-encoding-type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1848
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1849 (crypt-save-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1850
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1851 ;; 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
1852 ;; or decoding program with the arguments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1853
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1854 (let (prog args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1855
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1856 ;; Get the proper program and arguments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1857 (if decode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1858 (setq prog (crypt-get-decoding-program crypt-buffer-encoding-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1859 args (crypt-get-decoding-args crypt-buffer-encoding-type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1860 (setq prog (crypt-get-encoding-program crypt-buffer-encoding-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1861 args (crypt-get-encoding-args crypt-buffer-encoding-type)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1862
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1863 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1864
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1865 ;; prog is a string?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1866 ((stringp prog)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1867
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1868 ;; Check arguments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1869 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1870
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1871 ;; 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
1872 ((listp args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1873
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1874 ;; Cat all the strings together.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1875 (while args
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1876 (setq prog (concat prog " " (car args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1877 args (cdr args))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1878
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1879 ;; Check if a non-null string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1880 ((and (not (string= "" args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1881 (not (eq args t))) ; just in case...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1882 (setq prog (concat prog " " args))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1883
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1884 (call-process-region start end shell-file-name t t nil "-c" prog))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1885
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1886 ;; Otherwise try and eval it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1887 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1888 (eval (if args
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1889 (list prog start end args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1890 (list prog start end))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1891
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1892 ;; Encoding or decoding region?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1893 (if (not decode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1894
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1895 ;; Check if encoded region starts with magic number.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1896 (let ((magic (crypt-get-magic-regexp crypt-buffer-encoding-type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1897 (clean (crypt-get-cleanup-regexp crypt-buffer-encoding-type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1898 (case-fold-search nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1899
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1900 ;; Top of region.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1901 (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1902
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1903 ;; Check for magic number.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1904 (if (not (looking-at magic))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1905
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1906 ;; Magic number not there.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1907
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1908 ;; Some compression programs produce an (inane) standard error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1909 ;; message that gets piped into the buffer. For example, some
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1910 ;; versions of compact output "Compression : 35.50%." There may
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1911 ;; be some way to clean up buffer and check again.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1912
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1913 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1914
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1915 ;; No mechanism to clean up - failed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1916 ((eq clean nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1917 (error "Encoding failed!"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1918
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1919 ;; Cleanup a regexp string?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1920 ((stringp clean)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1921
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1922 ;; Is regexp there?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1923 (if (looking-at clean)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1924
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1925 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1926 ;; Delete the match.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1927 (delete-region (match-beginning 0) (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1928
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1929 ;; Check for magic again.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1930 (if (not (looking-at magic))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1931 (error "Encoding failed!")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1932
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1933 ;; Default: evaluate a lisp expression and check again.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1934 (t (eval clean)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1935 (if (not (looking-at magic))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1936 (error "Encoding failed!")))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1937
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1938 (defun crypt-encode-buffer (&optional decode buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1939
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1940 ;; Encode current buffer. With optional DECODE non-nil decode and optional
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1941 ;; BUFFER, encode or decode that buffer. Not meant to be called
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1942 ;; interactively, toggle `crypt-encoded-mode' to encode an entire buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1943
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1944 (or buffer (setq buffer (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1945 (save-excursion (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1946 (crypt-encode-region (point-min) (point-max) decode)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1947
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1948
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1949 ;;;; DOS <--> UNIX
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1950 (defun crypt-dos-to-unix-region (start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1951 "Converts region from START to END, from dos to unix format.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1952 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
1953 Sets `crypt-dos-has-ctrl-z'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1954 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1955 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1956 (let ((remove-ctrl-z (equal end (point-max))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1957 (narrow-to-region start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1958 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1959 (while (search-forward "\r\n" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1960 (replace-match "\n" nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1961 (if remove-ctrl-z
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1962 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1963 (goto-char (1- (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1964 (setq crypt-dos-has-ctrl-z (looking-at "\C-z"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1965 (if crypt-dos-has-ctrl-z (replace-match ""))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1966
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1967 (defun crypt-unix-to-dos-region (start end)
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
1968 "Converts region from START to END, from unix to dos format.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1969 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
1970 `crypt-dos-has-ctrl-z' is non-nil."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1971 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1972 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1973 (let ((add-ctrl-z (and crypt-dos-has-ctrl-z
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1974 (equal end (point-max)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1975 (narrow-to-region start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1976 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1977 (while (search-forward "\n" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1978 (replace-match "\r\n" nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1979 (if add-ctrl-z
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1980 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1981 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1982 (insert "\C-z")))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1983
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1984
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1985 ;;;; MODES
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1986
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1987 (defun crypt-encrypted-mode (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1988
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1989 "Toggle encrypted mode. With ARG, turn on iff positive, otherwise turn off.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1990 minor mode in which buffers are automatically encrypted before being written.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1991 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
1992 buffer is marked modified, since it needs to be rewritten with or without
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1993 encryption.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1994
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1995 Entering encrypted mode causes auto-saving to be turned off in the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1996 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
1997 encrypted."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1998
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1999 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2000 (let ((oldval crypt-buffer-save-encrypted))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2001 (setq crypt-buffer-save-encrypted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2002 (if arg (> arg 0) (not crypt-buffer-save-encrypted)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2003
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2004 (if crypt-buffer-save-encrypted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2005 ;; We are going to save as encrypted, we will turn off auto-saving.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2006 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2007 ;; 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
2008 ;; already an autosave for some other reason, what business does this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2009 ;; package have tampering with it?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2010 ; ;; If an auto-save file already exists, then delete it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2011 ; (if (and (stringp buffer-auto-save-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2012 ; (file-exists-p buffer-auto-save-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2013 ; (delete-file buffer-auto-save-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2014 ;; If the key is not set then ask for it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2015 (if (not crypt-buffer-encryption-key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2016 (call-interactively 'crypt-set-encryption-key))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2017 ;; Turn-off auto-saving if crypt-encrypted-disable-auto-save non-nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2018 (and crypt-encrypted-disable-auto-save
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2019 auto-save-default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2020 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2021 (auto-save-mode 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2022 (if (eq crypt-encrypted-disable-auto-save t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2023 (message "Auto-save off (in this buffer)")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2024
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2025 ;; 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
2026 ;; 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
2027 (auto-save-mode (if (and auto-save-default buffer-file-name) 1 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2028
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2029 (if crypt-buffer-encryption-key
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2030 ;; Set buffer-modified flag to t only if the mode has been changed,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2031 ;; old code set unconditionally to nil if mode was not changed .
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2032 ;; Modification suggested by: Gerd Hillebrand <ggh@cs.brown.edu>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2033 (if (not (eq oldval crypt-buffer-save-encrypted))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2034 (set-buffer-modified-p t)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2035
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2036
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2037 ;;; Forgetting encryption keys (by jwz)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2038 ;;; This is really kind of bogus. Good behavior would be:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2039 ;;; - If a crypted buffer has not been "accessed" (edited? selected?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2040 ;;; viewed?) in N minutes, kill the buffer (since the plaintext is valuable.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2041 ;;; - If a crypted buffer is modified, but "idle", just forget the password
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2042 ;;; instead of killing the buffer (though the plaintext is valuable, it's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2043 ;;; also unsaved...)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2044 ;;; - The "idleness" of a modified buffer should be reset with every mod, so
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2045 ;;; that an unsaved buffer that you have been constantly typing at for an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2046 ;;; hour doesn't lose its password.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2047 ;;; - 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
2048 ;;; is made to save that buffer, then we should confirm that the newly-
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2049 ;;; 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
2050 ;;; with PGP, we could check that by attempting to decrypt the file on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2051 ;;; disk into a scratch buffer and seeing if it contains the PGP error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2052 ;;; message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2053 ;;; - BUG: if a password has been forgotten, and you save, and are prompted,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2054 ;;; 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
2055 ;;; real file name no longer exists on disk - only as a ~ file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2056
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2057 (defun crypt-forget-encryption-key ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2058 (cond (crypt-buffer-encryption-key
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2059 (let ((inhibit-quit t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2060 (fillarray crypt-buffer-encryption-key 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2061 (setq crypt-buffer-encryption-key nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2062 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2063 (t nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2064
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2065 (add-hook 'kill-buffer-hook 'crypt-forget-encryption-key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2066
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
2067 (defcustom crypt-forget-passwd-timeout (* 60 60)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2068 "*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
2069 If nil, keep them indefinitely."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
2070 :type '(choice integer (const :tag "indefinite" nil))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
2071 :group 'crypt)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2072
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2073 (defun crypt-reset-passwd-timer ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2074 (if (fboundp 'get-itimer) ; XEmacs, or anything with itimer.el loaded.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2075 (let ((name "crypt-forget-passwds"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2076 (if (get-itimer name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2077 (delete-itimer name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2078 (if crypt-forget-passwd-timeout
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2079 (start-itimer name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2080 'crypt-reset-passwds-timeout
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2081 crypt-forget-passwd-timeout)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2082
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2083 (defun crypt-reset-passwds-timeout ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2084 ;; run by the timer code to forget all passwords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2085 (let ((buffers (buffer-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2086 (inhibit-quit t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2087 (keep-going nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2088 (while buffers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2089 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2090 (set-buffer (car buffers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2091 (cond ((and crypt-buffer-encryption-key
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2092 (buffer-modified-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2093 ;; don't forget the password in modified buffers, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2094 ;; do check again later (maybe it will be unmodified.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2095 (setq keep-going t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2096 (crypt-buffer-encryption-key
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2097 ;; forget the password in unmodified buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2098 (crypt-forget-encryption-key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2099 ;; Mark the buffer read only so that it's not accidentally
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2100 ;; edited; the smart thing to do is revert it, type the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2101 ;; encryption key (to make sure they same key is used)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2102 ;; and then edit it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2103 (setq buffer-read-only t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2104 (message "Password discarded in buffer %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2105 (buffer-name (car buffers))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2106 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2107 (setq buffers (cdr buffers)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2108 (if keep-going
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2109 (crypt-reset-passwd-timer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2110 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2111
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2112
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2113 ;;; Originally `tek-symbol-alist-to-table' from tek-highlight.el.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2114 (defun crypt-symbol-alist-to-table (list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2115 ;; Converts an alist of symbols to a table suitable for `completing-read.'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2116 ;; Called by `crypt-read-encoding-type'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2117 (mapcar (function (lambda (x) (list (symbol-name (car x)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2118 list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2119
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2120 (defun crypt-read-encoding-type ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2121
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2122 ;; Function called to query user for `crypt-buffer-encoding-type' uses
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2123 ;; contents of `crypt-encoding-alist' and `crypt-default-encoding.'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2124
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2125 ;; Use poor man's gmhist (i.e., we could have used gmhist's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2126 ;; `completing-read-with-history-in' instead).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2127 (let (
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2128 ;; Find the encoding type desired by user.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2129 (type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2130 (completing-read
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2131 (concat "encoding type (? for list): [" crypt-default-encoding "] ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2132 (crypt-symbol-alist-to-table crypt-encoding-alist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2133
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2134 ;; Test length of object returned by `completing-read'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2135 (if (zerop (length 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 ;; Nothing there, i.e., user hit return -- use default.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2138 (setq crypt-buffer-encoding-type (intern crypt-default-encoding))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2139
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2140 ;; Use the value from mini-buffer and update the default value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2141 (setq crypt-buffer-encoding-type (intern type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2142 crypt-default-encoding type))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2143
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2144 (defun crypt-encoded-mode (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2145
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2146 "Toggle encoded mode. With ARG, turn on iff positive, otherwise turn off.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2147 minor mode in which buffers are automatically encoded before being written. if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2148 toggled then current buffer is marked modified, since it needs to be written
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2149 with or without encoding.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2150
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2151 Entering encoded mode causes auto-saving to be turned off in the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2152 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
2153 encoded."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2154
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2155 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2156
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2157 ;; Set flag indicating whether or not `(crypt-encoded-mode)' was called
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2158 ;; interactively.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2159 (setq crypt-buffer-interactive-encoded-mode (interactive-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2160
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2161 ;; If called interactively then need to determine encoding type.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2162 (if (and crypt-buffer-interactive-encoded-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2163 (not crypt-buffer-encoding-type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2164 (crypt-read-encoding-type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2165
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2166 ;; Save old value of `crypt-buffer-save-encoded'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2167 (let ((oldval crypt-buffer-save-encoded))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2168
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2169 ;; Set the variable `crypt-buffer-save-encoded' to t if the argument is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2170 ;; positive, otherwise toggle its current value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2171 (setq crypt-buffer-save-encoded
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2172 (if arg (> arg 0) (not crypt-buffer-save-encoded)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2173
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2174 ;; Set the variable generated by `(crypt-buffer-save-name)' to the value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2175 ;; stored in `crypt-buffer-save-encoded.'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2176 (set-variable (crypt-buffer-save-name crypt-buffer-encoding-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2177 crypt-buffer-save-encoded)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2178
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2179 (if crypt-buffer-save-encoded
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2180 ;; We are going to save as encoded, we might turn off auto-saving.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2181 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2182 ;; 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
2183 ;; already an autosave for some other reason, what business does this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2184 ;; package have tampering with it?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2185 ; ;; If an auto-save file already exists, then delete it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2186 ; (if (and (stringp buffer-auto-save-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2187 ; (file-exists-p buffer-auto-save-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2188 ; (delete-file buffer-auto-save-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2189 ;; Turn-off auto-saving if crypt-encoded-disable-auto-save non-nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2190 (and crypt-encoded-disable-auto-save
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2191 auto-save-default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2192 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2193 (auto-save-mode 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2194 (if (eq crypt-encoded-disable-auto-save t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2195 (message "Auto-save off (in this buffer)")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2196
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2197 ;; 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
2198 ;; only if we are editing a file and the default says we should.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2199 (auto-save-mode (if (and auto-save-default buffer-file-name) 1 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2200
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2201 ;; Have we toggled the mode?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2202
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2203 ;; If yes, then mark buffer as modified. If not, then leave
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2204 ;; buffer-modified flag alone.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2205
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2206 ;; The old code previously set the variable `set-buffer-modified-p' to a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2207 ;; value of t if there was a mode change and (unconditionally) to nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2208 ;; if there was not a mode change.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2209
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2210 ;; Modification suggested by: Gerd Hillebrand <ggh@cs.brown.edu>.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2211
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2212 (if (not (eq oldval crypt-buffer-save-encoded))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2213 (set-buffer-modified-p t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2214
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2215
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2216 ;;;; Additional encryption functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2217
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2218 ;; For Emacs V18 compatibility
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2219 (and (not (fboundp 'buffer-disable-undo))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2220 (fboundp 'buffer-flush-undo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2221 (fset 'buffer-disable-undo 'buffer-flush-undo))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2222
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2223 (fset 'crypt-read-string-no-echo 'read-passwd)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2224
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2225 ;(defun crypt-read-string-no-echo (prompt &optional confirm)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2226 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2227 ; ;; Read a string from minibuffer, prompting with PROMPT, echoing periods.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2228 ; ;; Optional second argument CONFIRM non-nil means that the user will be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2229 ; ;; 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
2230 ; ;; mismatch, the whole process is repeated.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2231 ; ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2232 ; ;; Line editing keys are --
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2233 ; ;; C-h, DEL rubout
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2234 ; ;; C-u, C-x line kill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2235 ; ;; C-q, C-v literal next
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2236 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2237 ; (catch 'return-value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2238 ; (save-excursion
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 ((input-buffer (get-buffer-create (make-temp-name " *password*")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2241 ; char hold-password help-form kill-ring)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2242 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2243 ; (set-buffer input-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2244 ; ;; Don't add to undo ring.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2245 ; (buffer-disable-undo input-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2246 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2247 ; (let ((cursor-in-echo-area t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2248 ; (echo-keystrokes 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2249 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2250 ; (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2251 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2252 ; ;; BODYFORM
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2253 ; ;; Repeat until we get a `throw'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2254 ; (while t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2255 ; (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2256 ; (message prompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2257 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2258 ; ;; Read string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2259 ; (while (not (memq (setq char (read-char)) '(?\C-m ?\C-j)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2260 ; (if (setq help-form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2261 ; (cdr
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2262 ; (assq char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2263 ; '((?\C-h . (delete-char -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2264 ; (?\C-? . (delete-char -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2265 ; (?\C-u . (delete-region 1 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2266 ; (?\C-x . (delete-region 1 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2267 ; (?\C-q . (quoted-insert 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2268 ; (?\C-v . (quoted-insert 1))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2269 ; (condition-case error-data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2270 ; (eval help-form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2271 ; (error t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2272 ; ;; Just a plain character - insert into password buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2273 ; (insert char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2274 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2275 ; ;; I think crypt-read-string-no-echo should echo asterisks.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2276 ; ;; -- Jamie. How about periods like in ange-ftp? -- lrd
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2277 ; ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2278 ; (message "%s%s" prompt (make-string (buffer-size) ?.)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2279 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2280 ; ;; Do we have to confirm password?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2281 ; (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2282 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2283 ; ;; No confirmation requested - terminate.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2284 ; ((not confirm)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2285 ; (throw 'return-value (buffer-string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2286 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2287 ; ;; Can we compare (confirm) password values yet?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2288 ; (hold-password
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2289 ; (if (string= hold-password (buffer-string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2290 ; ;; The two passwords match - terminate.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2291 ; (throw 'return-value hold-password)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2292 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2293 ; ;; Mismatch - start over.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2294 ; (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2295 ; (message (concat prompt "[Mismatch. Start over]"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2296 ; (beep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2297 ; (sit-for 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2298 ; (fillarray hold-password 0) ; destroy extra copy now
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2299 ; (setq hold-password nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2300 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2301 ; ;; Store password and read again.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2302 ; (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2303 ; (setq hold-password (buffer-string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2304 ; (message (concat prompt "[Retype to confirm]"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2305 ; (sit-for 2))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2306 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2307 ; ;; UNWINDFORMS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2308 ; ;; Clean up.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2309 ; (set-buffer input-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2310 ; (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2311 ; (buffer-disable-undo input-buffer) ; redundant, but why not be safe.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2312 ; (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2313 ; (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2314 ; (while (not (eobp)) (delete-char 1) (insert "*")) ; destroy now
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2315 ; (kill-buffer input-buffer)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2316
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2317 (defun crypt-set-encryption-key (key &optional buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2318
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2319 "Set the encryption KEY, a string, for current buffer or optionally BUFFER.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2320 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
2321 needs to be saved with the new key."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2322
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2323 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2324 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2325 (barf-if-buffer-read-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2326 (list (crypt-read-string-no-echo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2327 (format "Encryption key for %s? [RET to ignore]: " (buffer-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2328 crypt-confirm-password))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2329
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2330 ;; For security reasons we remove `(crypt-set-encryption-key "password")'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2331 ;; from the `command-history' list if called interactively.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2332 (if (interactive-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2333 (setq command-history (cdr command-history)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2334
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2335 (or buffer (setq buffer (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2336
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2337 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2338 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2339 (if (equal key crypt-buffer-encryption-key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2340 (message "Key is identical to original, no change.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2341
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2342 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2343 ;; jwz: destroy old string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2344 (if (and crypt-buffer-encryption-key
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2345 (not (eq crypt-buffer-encryption-key key)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2346 (fillarray crypt-buffer-encryption-key 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2347 (setq crypt-buffer-encryption-key key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2348
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2349 ;; Don't touch the modify flag unless we're in `(crypt-encrypted-mode)'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2350 (if crypt-buffer-save-encrypted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2351 (set-buffer-modified-p t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2352
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2353 (crypt-reset-passwd-timer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2354 ))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2355
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2356
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2357 ;;;; Install hooks and mode indicators.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2358
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2359 ;;; Check if mode indicators are not already installed and then prepend them.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2360 (and (not (assq 'crypt-buffer-save-encrypted minor-mode-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2361 (setq minor-mode-alist (append crypt-minor-mode-alist minor-mode-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2362
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2363 ;;; Install the hooks.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2364
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2365 ;;; If add-hook isn't already defined overwrite it with our own.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2366 ;;; Note the `add-hook' function must take the optional APPEND argument.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2367 (if (not (fboundp 'add-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2368 ;; No add-hook found.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2369 ;; Use `add-hook' from GNU Emacs v19.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2370 (defun add-hook (hook function &optional append)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2371 "Add to the value of HOOK the function FUNCTION.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2372 FUNCTION is not added if already present.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2373 FUNCTION is added (if necessary) at the beginning of the hook list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2374 unless the optional argument APPEND is non-nil, in which case
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2375 FUNCTION is added at the end.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2376
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2377 HOOK should be a symbol, and FUNCTION may be any valid function. If
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2378 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
2379 function, it is changed to a list of functions."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2380 (or (boundp hook) (set hook nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2381 ;; If the hook value is a single function, turn it into a list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2382 (let ((old (symbol-value hook)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2383 (if (or (not (listp old)) (eq (car old) 'lambda))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2384 (set hook (list old))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2385 (or (if (consp function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2386 ;; Clever way to tell whether a given lambda-expression
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2387 ;; is equal to anything in the hook.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2388 (let ((tail (assoc (cdr function) (symbol-value hook))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2389 (equal function tail))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2390 (memq function (symbol-value hook)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2391 (set hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2392 (if append
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2393 (nconc (symbol-value hook) (list function))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2394 (cons function (symbol-value hook)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2395
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2396 ;;; Attach ourselves to the find-file-hooks and find-file-not-found-hooks.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2397 (add-hook 'find-file-hooks 'crypt-find-file-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2398 (add-hook 'find-file-not-found-hooks 'crypt-find-file-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2399
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2400 ;; 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
2401 ;; 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
2402 ;; everyone would upgrade - lrd 8/31/93.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2403 (condition-case err
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2404 (add-hook 'write-file-hooks 'crypt-write-file-hook t) ; *must* append this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2405 (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2406 ;; Do it by hand. Not as robust as `add-hook'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2407
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2408 ;; Contributed by Ken Laprade <laprade@trantor.harris-atd.com>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2409 ;; Really should use some sort of add-hook - 16 Feb 93 - KCL
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2410 (or (and (listp write-file-hooks) (not (eq (car write-file-hooks) 'lambda)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2411 (setq write-file-hooks (list write-file-hooks)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2412
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2413 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2414 ((not (memq 'crypt-write-file-hook write-file-hooks))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2415 ;; make this hook last on purpose
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2416 (setq write-file-hooks (append write-file-hooks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2417 (list 'crypt-write-file-hook)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2418
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2419 ;; In order that the tables and key-binding correctly reflect user's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2420 ;; preferences we add ourselves to the `after-init-hook' GNU Emacs v19 and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2421 ;; 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
2422 ;; (or earlier). These are run *after* ~/.emacs and ../lisp/default.el are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2423 ;; loaded. Unfortunately, v18 does not have `after-init-hook' and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2424 ;; `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
2425 ;; to work our functions in properly without overwriting the user's value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2426 ;; Therefore, we do nothing and hope they upgrade to v19 soon.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2427
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2428 (cond ((boundp 'after-init-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2429 ;; Must be running GNU Emacs v19 :->
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2430 (add-hook 'after-init-hook 'crypt-rebuild-tables)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2431 (add-hook 'after-init-hook 'crypt-rebuild-minor-modes-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2432 (add-hook 'after-init-hook 'crypt-bind-insert-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2433
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2434 ((and (string-match "^19" emacs-version) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2435 ;; Probably running Lucid Emacs v19.7 (or earlier) since it,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2436 ;; unfortunately, does not have `after-init-hook'. Use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2437 ;; `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
2438 ;; Emacs 19.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2439 (add-hook 'term-setup-hook 'crypt-rebuild-tables)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2440 (add-hook 'term-setup-hook 'crypt-rebuild-minor-modes-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2441 (add-hook 'term-setup-hook 'crypt-bind-insert-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2442
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2443
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2444 ;;; Code for conditionally decoding/decrypting an inserted file
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-bind-insert-file t
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2447 "*t value means bind `crypt-insert-file' over `insert-file'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2448 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
2449 \\[crypt-bind-insert-file]."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
2450 :type 'boolean
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
2451 :group 'crypt)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2452
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
2453 (defcustom crypt-auto-decode-insert nil
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2454 "*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
2455 nil says to ask before doing this."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
2456 :type 'boolean
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
2457 :group 'crypt)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2458
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2459 ;;; Bind `crypt-insert-file' over wherever `insert-file' is bound?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2460 (defun crypt-bind-insert-file ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2461
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2462 "Bind `crypt-insert-file' in place of `insert-file' or reverse based on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2463 `crypt-bind-insert-file'. Part of `after-init-hook'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2464
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2465 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2466
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2467 (if (interactive-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2468 (setq crypt-bind-insert-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2469 (y-or-n-p "Bind crypt-insert-file over insert-file? ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2470
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2471 (if crypt-bind-insert-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2472 (substitute-key-definition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2473 'insert-file 'crypt-insert-file (current-global-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2474 (substitute-key-definition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2475 'crypt-insert-file 'insert-file (current-global-map))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2476
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2477 ;;; Now call it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2478 (crypt-bind-insert-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2479
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2480 ;;; crypt++ replacement for `insert-file'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2481 (defun crypt-insert-file (filename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2482 "Insert decoded/decrypted contents of file FILENAME into buffer after point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2483 Set mark after the inserted text.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2484
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2485 This function is meant for the user to run interactively.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2486 Don't call it from programs! Use `insert-file-contents' instead.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2487 \(Its calling sequence is different; see its documentation\).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2488
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2489 This version will attempt to decrypt and/or decode file before inserting.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2490 see variable `crypt-auto-decode-insert'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2491 (interactive "fInsert file: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2492 (if (file-directory-p filename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2493 (signal 'file-error (list "Opening input file" "file is a directory"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2494 filename)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2495 (let ((tem (crypt-insert-file-contents filename))) ; use crypt++ to insert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2496 (push-mark (+ (point) (car (cdr tem))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2497
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2498 (defun crypt-insert-file-contents (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2499
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2500 ;; Similar to `insert-file-contents' except decoding/decrypting of FILE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2501 ;; attempted. See `crypt-insert-file' and `crypt-auto-decode-insert'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2502
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2503 (let (temp-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2504 temp-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2505 (crypt-auto-decode-buffer crypt-auto-decode-insert)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2506 (orig-buffer (current-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 ;; Create a temporary buffer and decode and decrypt it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2509 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2510
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2511 ;; Temporary buffer, use the same name as the file to be inserted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2512 (setq temp-buffer (generate-new-buffer (file-name-nondirectory file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2513 (set-buffer temp-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2514
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2515 ;; Original insert-file-contents - save list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2516 (setq temp-list (insert-file-contents file nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2517
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2518 ;; Make temp-buffer unmodified.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2519 (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2520
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2521 ;; Need to set buffer name to file name for crypt++.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2522 (setq buffer-file-name file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2523
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2524 ;; Decode and decrypt, if necessary.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2525 (crypt-find-file-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2526
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2527 ;; Find the length of the file to be inserted. `insert-file-contents'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2528 ;; returns it for the original encoded/encrypted file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2529 (setcdr temp-list (cons (buffer-size) ()))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2530
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2531 ;; Now insert temp-buffer into original buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2532 (set-buffer orig-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2533 (insert-buffer temp-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2534
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2535 ;; Kill the temporary buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2536 (kill-buffer temp-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2537
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2538 ;; Return modified list from `insert-file-contents'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2539 temp-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2540
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2541
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2542 ;;;; BUG REPORTS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2543
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2544 ;;; This section is provided for reports.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2545 ;;; Using Barry A. Warsaw's reporter.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2546
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2547 (defconst crypt-version "2.82"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2548 "Revision number of crypt++.el -- handles compressed and encrypted files.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2549 Type \\[crypt-submit-report] to send a bug report. Available via anonymous
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2550 ftp in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2551
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2552 /roebling.poly.edu:/pub/lisp/crypt++.el.gz
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2553 /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
2554
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2555 (defconst crypt-help-address
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2556 "dodd@roebling.poly.edu"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2557 "Address(es) accepting submission of reports on crypt++.el.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2558
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2559 (defconst crypt-maintainer "Larry"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2560 "First name(s) of people accepting submission of reports on crypt++.el.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2561
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2562 (defconst crypt-file "crypt++.el"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2563 "Name of file containing emacs lisp code.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2564
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2565 (defconst crypt-variable-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2566 (list 'shell-file-name ; These
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2567 'load-path ; are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2568 'exec-path ; useful.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2569 'crypt-encryption-type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2570 'crypt-encryption-file-extension
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2571 'crypt-never-ever-decrypt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2572 'crypt-auto-write-buffer-encrypted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2573 'crypt-confirm-password
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2574 'crypt-encrypted-disable-auto-save
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2575 'crypt-auto-decode-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2576 'crypt-auto-write-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2577 'crypt-query-if-interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2578 'crypt-no-extension-implies-plain
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2579 'crypt-freeze-vs-fortran
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2580 'crypt-compact-vs-C++
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2581 'crypt-ignored-filenames
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2582 'crypt-default-encoding
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2583 'crypt-encoded-disable-auto-save
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2584 'crypt-bind-insert-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2585 'crypt-auto-decode-insert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2586 'crypt-encoding-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2587 'crypt-encryption-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2588 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2589 "List of variables to be appended to reports sent by `crypt-submit-report.'")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2590
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2591 (defun crypt-submit-report ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2592 "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
2593 version `crypt-version,' to `crypt-maintainer' at address `crypt-help-address'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2594 listing variables `crypt-variable-list' in the message."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2595 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2596
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2597 ;; In case we can't find reporter...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2598 (condition-case err
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2599 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2600 ;; Get it if we can.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2601 (require 'reporter)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2602
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2603 (reporter-submit-bug-report
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2604 crypt-help-address ; address
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2605 (concat crypt-file " " crypt-version) ; pkgname
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2606 crypt-variable-list ; varlist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2607 nil nil ; pre-hooks and post-hooks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2608 (concat "Yo! " crypt-maintainer ","))) ; salutation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2609
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2610 ;; ...fail gracefully.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2611 (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2612 (beep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2613
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2614 ;; Do they have ange-ftp?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2615 (if (and (featurep 'ange-ftp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2616 (y-or-n-p (concat "Sorry, reporter.el not found. "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2617 "Can I ange-ftp it for you? ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2618
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2619 ;; Yes. Then Ange-ftp a copy from roebling.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2620 (let ((ange-ftp-generate-anonymous-password t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2621 ;; Might want to use the elisp archive official site? But
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2622 ;; then it would have to be uncompressed, etc. Ick!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2623 (find-file-other-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2624 "/anonymous@roebling.poly.edu:/pub/reporter.el")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2625 (eval-current-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2626 (message (concat "Save reporter.el somewhere in `load-path' "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2627 "and try again.")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2628
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2629 ;; No ange-ftp.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2630 (message "Sorry, reporter.el not found.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2631 (sit-for 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2632 (message (concat "Get it from archive.cis.ohio-state.edu "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2633 "or roebling.poly.edu"))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2634
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2635 ;;; Provide this package as crypt++ as well as crypt.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2636 (provide 'crypt++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2637 (provide 'crypt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2638
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2639 ;;; crypt++.el ends here.