annotate lisp/packages/crypt.el @ 142:1856695b1fa9 r20-2b5

Import from CVS: tag r20-2b5
author cvs
date Mon, 13 Aug 2007 09:33:18 +0200
parents cca96a509cfe
children 2d532a89d707
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
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1119
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1120 ;;; This allows the user to alter contents of the encoding and encryption
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1121 ;;; table variables without having to reload all of crypt++.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1122 (defun crypt-rebuild-tables ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1123 "Rebuilds the encryption and encoding tables and `minor-mode-alist'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1124 Allows user to alter variables used in building these tables. May be called
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1125 interactively or in an initialization file. Part of `after-init-hook'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1126 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1127 (setq crypt-encryption-alist (crypt-build-encryption-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1128 crypt-encoding-alist (crypt-build-encoding-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1129 (crypt-rebuild-minor-modes-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1130
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1131
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1132 ;;; Buffer locals.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1133
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1134 (defvar crypt-buffer-save-encrypted nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1135 "*non-nil says save buffer encrypted with `crypt-encryption-type.'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1136 local to all buffers.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1137 (make-variable-buffer-local 'crypt-buffer-save-encrypted)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1138 (put 'crypt-buffer-save-encrypted 'permanent-local t) ; for v19 Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1139 (put 'crypt-buffer-save-encrypted 'preserved t) ; for kill-fix.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1140
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1141 (defvar crypt-buffer-encryption-key nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1142 "*Key used for encryption of current buffer. Local to all buffers.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1143 (make-variable-buffer-local 'crypt-buffer-encryption-key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1144 (put 'crypt-buffer-encryption-key 'permanent-local t) ; for v19 Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1145 (put 'crypt-buffer-encryption-key 'preserved t) ; for kill-fix.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1146
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1147 (defvar crypt-buffer-save-encoded nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1148 "*non-nil says buffer will be saved encoded. Local to all buffers.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1149 (make-variable-buffer-local 'crypt-buffer-save-encoded)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1150 (put 'crypt-buffer-save-encoded 'permanent-local t) ; for v19 Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1151 (put 'crypt-buffer-save-encoded 'preserved t) ; for kill-fix.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1152
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1153 (defvar crypt-buffer-encoding-type nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1154 "*non-nil says buffer is encoded with ENCODING-TYPE. Local to all buffers.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1155 (make-variable-buffer-local 'crypt-buffer-encoding-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1156 (put 'crypt-buffer-encoding-type 'permanent-local t) ; for v19 Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1157 (put 'crypt-buffer-encoding-type 'preserved t) ; for kill-fix.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1158
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1159 (defvar crypt-buffer-interactive-encoded-mode nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1160 "t says `crypt-encoded-mode' was toggled interactively, almost always nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1161 Local to all buffers.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1162 (make-variable-buffer-local 'crypt-buffer-interactive-encoded-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1163 (put 'crypt-buffer-interactive-encoded-mode 'permanent-local t) ; v19 Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1164 (put 'crypt-buffer-interactive-encoded-mode 'preserved t) ; kill-fix.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1165
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1166
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1167 ;;; Functions and macros that search `crypt-encryption-alist' and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1168 ;;; `crypt-encoding-alist'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1169
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1170 (defun crypt-get-alist-member (type n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1171 ;; Returns TYPE's Nth element
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1172 (nth n (or (assoc type crypt-encryption-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1173 (assoc type crypt-encoding-alist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1174
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1175 (defmacro crypt-get-magic-regexp (type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1176 ;; Returns regexp found at top of files encoded/encrypted with TYPE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1177 (list 'crypt-get-alist-member type 1))
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-inverse (type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1180 ;; Returns regexp *not* 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 2))
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-file-extension (type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1184 ;; Returns regexp matching extension of files encoded/encrypted with TYPE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1185 (list 'crypt-get-alist-member type 3))
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-encoding-program (type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1188 ;; Returns name of program, as string, used to encode/encrypt with TYPE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1189 (list 'crypt-get-alist-member type 4))
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-decoding-program (type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1192 ;; Returns name of program, as string, used to decode/decrypt with TYPE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1193 (list 'crypt-get-alist-member type 5))
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-encoding-args (type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1196 ;; Returns arguments passed to program used to encode/encrypt with TYPE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1197 (list 'crypt-get-alist-member type 6))
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-decoding-args (type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1200 ;; Returns arguments passed to program used to decode/decrypt with TYPE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1201 (list 'crypt-get-alist-member type 7))
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-minor-mode-name (type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1204 ;; Returns minor mode name, as string, for encoding/encrypting with TYPE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1205 (list 'crypt-get-alist-member type 8))
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-cleanup-regexp (type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1208 ;; Returns regexp or lisp-exp for cleaning up encoding/encrypting with TYPE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1209 (list 'crypt-get-alist-member type 9))
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-extension-tricks (type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1212 ;; Returns t if file extension tricks doable for encoding/encrypting with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1213 ;; TYPE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1214 (list 'crypt-get-alist-member type 10))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1215
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1216 (defun crypt-buffer-save-name (type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1217 ;; Returns variable `crypt-buffer-save-TYPE', set to t if encoding with TYPE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1218 ;; local to all buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1219 (intern (concat "crypt-buffer-save-" (symbol-name type))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1220
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1221
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1222 ;;; Create a buffer-local variable for each type of encoding.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1223 ;;; These variables are used to trigger the minor mode names.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1224
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1225 (defun crypt-build-minor-mode-alist ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1226 ;; Returns minor mode alist entries for encoded and encrypted buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1227 (append
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1228 ;; First the encrypted minor mode -- only one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1229 (list (list 'crypt-buffer-save-encrypted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1230 (concat " " (crypt-get-minor-mode-name crypt-encryption-type))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1231 ;; Now the encoding minor modes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1232 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1233 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1234 (lambda (element)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1235 (let ((variable (crypt-buffer-save-name (car element))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1236 (make-variable-buffer-local variable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1237 (put variable 'permanent-local t) ; for v19 Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1238 (put variable 'preserved t) ; for kill-fix.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1239 (list variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1240 (concat " " (crypt-get-minor-mode-name (car element)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1241 crypt-encoding-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1242
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1243 (defconst crypt-minor-mode-alist (crypt-build-minor-mode-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1244 "Alist containing encoded and encrypted minor modes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1245 Derived from variable `crypt-encoding-alist' and function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1246 `crypt-build-minor-mode-encrypted'")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1247
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1248 (defun crypt-rebuild-minor-modes-alist ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1249 ;; Rebuilds the encryption and encoding minor modes and `minor-mode-alist.'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1250 ;; Allows user to alter variables used in building this alist. Called by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1251 ;; `crypt-rebuild-tables' and so part of `after-init-hook'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1252
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1253 ;; First remove old crypt minor mode entries from `minor-mode-alist'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1254 (if (memq (car crypt-minor-mode-alist) minor-mode-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1255 (let ((alist crypt-minor-mode-alist) elt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1256 (while (and alist (setq elt (car alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1257 (setq minor-mode-alist (delq elt minor-mode-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1258 alist (cdr alist)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1259
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1260 ;; Get new crypt minor mode entries and add to minor-mode-alist.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1261 (setq crypt-minor-mode-alist (crypt-build-minor-mode-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1262 minor-mode-alist (append crypt-minor-mode-alist minor-mode-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
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1265 (defmacro crypt-save-point (&rest body)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1266 ;; Save value of point, evaluate FORMS, and restore value of point. If the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1267 ;; 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
1268 ;; exists because, save-excursion loses track of point during some types of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1269 ;; deletions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1270 (let ((var (make-symbol "saved-point")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1271 (list 'let (list (list var '(point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1272 (list 'unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1273 (cons 'progn body)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1274 (list 'goto-char var)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1275
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1276
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1277 (defun crypt-find-file-hook ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1278
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1279 ;; Hook run for decoding and/or decrypting the contents of a buffer. Meant
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1280 ;; to be called as part of `find-file-hooks'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1281
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1282 (let ((buffer-file-name buffer-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1283 (old-buffer-file-name buffer-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1284 (old-buffer-modified-p (buffer-modified-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1285 (case-fold-search nil) ; case-sensitive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1286 encrypted encoded buffer-read-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1287
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1288 ;; DECODE AND/OR DECRYPT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1289 (crypt-save-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1290
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1291 ;; Do we have to DECODE? If not, then move on.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1292 (if (and (crypt-encoded-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1293 (or crypt-auto-decode-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1294 (y-or-n-p (format "Decode %s? " (buffer-name)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1295
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1296 ;; Decode, uncompress, the buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1297 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1298
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1299 (if (and (not (null buffer-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1300 (string-match "\\.Z$" buffer-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1301 (set-visited-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1302 (substring buffer-file-name 0 (match-beginning 0)))
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 "\\.gz$" 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 (message "Decoding %s..." (buffer-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1308 (crypt-encode-buffer t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1309
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1310 ;; Store the encoding mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1311
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1312 ;; We can not yet go into the minor modes because the major mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1313 ;; may change later on and blow away all local variables (and thus
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1314 ;; the minor modes). Only needed for vanilla v18. Our
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1315 ;; buffer-locals defined 'permanent-local for v19 Emacs and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1316 ;; 'preserved for kill-fix.el.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1317
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1318 (setq encoded crypt-buffer-encoding-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1319
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1320 ;; Strip encoded file's extension so later we can set buffer's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1321 ;; major mode based on its file-name sans encoding extension.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1322 (if (string-match (crypt-get-file-extension
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1323 crypt-buffer-encoding-type) buffer-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1324 (setq buffer-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1325 (substring buffer-file-name 0 (match-beginning 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1326
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1327 ;; Decoding ends.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1328 (if (not (input-pending-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1329 (message "Decoding %s... done" (buffer-name)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1330
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1331 ;; Do we have to DECRYPT? If not, then move on.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1332 (if (crypt-encrypted-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1333
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1334 ;; Decrypt buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1335 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1336
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1337 (message "Decrypting %s..." (buffer-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1338 (crypt-encrypt-buffer crypt-buffer-encryption-key t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1339
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1340 ;; Save key in case major mode blows all buffer-locals.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1341
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1342 ;; Only needed for vanilla v18. Our buffer-locals defined
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1343 ;; 'permanent-local for v19 Emacs and 'preserved for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1344 ;; kill-fix.el.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1345
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1346 (setq encrypted crypt-buffer-encryption-key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1347
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1348 ;; Strip encrypted file's extension so later we can set buffer's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1349 ;; major mode based on its file-name sans encrypting extension.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1350 (if (and (crypt-get-extension-tricks crypt-encryption-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1351 (string-match (crypt-get-file-extension
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1352 crypt-encryption-type) buffer-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1353 (setq buffer-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1354 (substring buffer-file-name 0 (match-beginning 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1355
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1356 (if (not (input-pending-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1357 (message "Decrypting %s... done" (buffer-name))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1358
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1359 ;; MAJOR AND MINOR MODES
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1360
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1361 ;; 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
1362 ;; code the does automatic selection of major mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1363
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1364 (if (or encoded encrypted)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1365
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1366 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1367
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1368 ;; Set the major mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1369 (set-auto-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1370 (hack-local-variables)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1371
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1372 ;; Now set our own minor mode(s).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1373 (if encoded
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1374 ;; Recover encoding type, may have been smashed by major mode,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1375 ;; and toggle encoded mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1376 (progn (setq crypt-buffer-encoding-type encoded)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1377 (crypt-encoded-mode 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1378
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1379 (if encrypted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1380 ;; Recover encryption key, may have been smashed by major mode,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1381 ;; and toggle encrypted mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1382 (progn (setq crypt-buffer-encryption-key encrypted)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1383 (crypt-encrypted-mode 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1384
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1385 ;; Restore buffer file name now, so that lock file entry is removed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1386 ;; properly.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1387 (setq buffer-file-name old-buffer-file-name)
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 modified flag to its previous value. Will also
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1390 ;; remove lock file entry for buffer if previous value was nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1391 ;; This is why buffer-file-name had to be restored manually above.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1392 (set-buffer-modified-p old-buffer-modified-p)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1393
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1394 (defun crypt-encoded-p (&optional buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1395 ;; Returns t if current buffer, or optionally BUFFER, is encoded.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1396 ;; Sets `crypt-buffer-encoding-type' to encoding method.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1397 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1398 (and buffer (set-buffer buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1399 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1400 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1401 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1402 (let ((alist crypt-encoding-alist) elt found)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1403 (while (and alist (setq elt (car alist)) (not found))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1404 (if (looking-at (nth 1 elt))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1405 (setq crypt-buffer-encoding-type (nth 0 elt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1406 found t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1407 ;; Decrement
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1408 (setq alist (cdr alist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1409 found))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1410
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1411 (defun crypt-encrypted-p (&optional buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1412 ;; Returns t if current buffer, or optionally BUFFER, is encrypted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1413 ;; Look for MAGIC-REGEXP and absence of MAGIC-REGEXP-INVERSE. If so, then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1414 ;; assume it is an encrypted buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1415 ;; Sets `crypt-buffer-encryption-key' to password if not set already.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1416
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1417 ;; Do not try to decrypt buffer if not wanted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1418 (if (not crypt-never-ever-decrypt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1419
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1420 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1421 (and buffer (set-buffer buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1422
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1423 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1424 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1425 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1426
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1427 (let ((magic-regexp (crypt-get-magic-regexp crypt-encryption-type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1428 (magic-regexp-inverse (crypt-get-magic-regexp-inverse
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1429 crypt-encryption-type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1430 (limit (min (point-max) crypt-magic-search-limit)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1431
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1432 ;; Check all encryption conditions. If any fail, then return nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1433 ;; value of this if-form, else check for password.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1434 (if (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1435
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1436 ;; Check for existence of MAGIC-REGEXP.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1437 (if (stringp magic-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1438 ;; regular expression
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1439 (re-search-forward magic-regexp limit t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1440 ;; lisp expression
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1441 (eval magic-regexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1442
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1443 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1444
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1445 ;; Check for absence of MAGIC-REGEXP-INVERSE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1446 (not (if (stringp magic-regexp-inverse)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1447 ;; regular expression
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1448 (re-search-forward magic-regexp-inverse limit t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1449 ;; lisp expression
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1450 (eval magic-regexp-inverse))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1451
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1452 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1453
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1454 ;; Get key, i.e., the password?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1455 (or crypt-buffer-encryption-key
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1456 ;; Do not confirm on reading an encrypted file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1457 (let ((crypt-confirm-password nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1458 (call-interactively 'crypt-set-encryption-key)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1459
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1460 ;; Do not turn on encryption mode if no key: may be a binary
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1461 ;; file. Thanks to Paul Dworkin (paul@media-lab.media.mit.edu).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1462 (if (equal crypt-buffer-encryption-key "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1463 ;; Return nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1464 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1465 (message "No key given. Assumed normal.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1466 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1467 ;; Return t.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1468 t))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1469
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1470
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1471 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1472
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1473 (defun crypt-check-extension-for-encoding ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1474
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1475 ;; Checks file extensions for possible toggling of encoding modes. Used for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1476 ;; buffers to be written to disk and called by `crypt-write-file-hook'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1477
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1478 ;; 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
1479 ;; ends in one of the file-extensions in `crypt-encoding-alist' even if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1480 ;; `crypt-buffer-save-encoded' is nil. Conversely, we try to write out a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1481 ;; 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
1482 ;; file-extensions even if `crypt-buffer-save-encoded' is non-nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1483
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1484 (let ((alist crypt-encoding-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1485 (case-fold-search nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1486 found elt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1487
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1488 ;; Search through the file name extensions for a match.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1489 (while (and alist (setq elt (car alist)) (not found))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1490 (if (string-match (nth 3 elt) buffer-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1491 (setq found t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1492 ;; Decrement.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1493 (setq alist (cdr alist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1494
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1495 ;; Did we find a match?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1496 (if found
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1497
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1498 ;; File name ends in a very provocative extension.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1499
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1500 ;; Check to see if already an encoded file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1501 (if crypt-buffer-save-encoded
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1502
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1503 ;; Already encoded - do the methods of encoding match?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1504 (if (not (eq (nth 0 elt) crypt-buffer-encoding-type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1505
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1506 ;; A new encoding method is desired.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1507
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1508 ;; Can we play some filename extension tricks with the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1509 ;; destination extension?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1510 (if (crypt-get-extension-tricks (nth 0 elt))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1511
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1512 ;; Can play tricks.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1513 ;; Change the method of encoding?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1514 (if (crypt-y-or-n-p (format "Write %s using %s? "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1515 (buffer-name) (nth 4 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 ;; Case one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1518 ;; Turn off original encoding and turn on new encoding.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1519 (progn (crypt-encoded-mode -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1520 (setq crypt-buffer-encoding-type (nth 0 elt))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1521 (crypt-encoded-mode 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1522
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1523 ;; Can not play tricks - maybe wants a plain file?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1524 (if (crypt-y-or-n-p (format "Write %s a plain file? "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1525 (buffer-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1526
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1527 ;; Case three.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1528 ;; Turn off the minor mode and _then_ the flags.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1529 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1530 (crypt-encoded-mode -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1531 (setq crypt-buffer-save-encoded nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1532 crypt-buffer-encoding-type nil)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1533
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1534 ;; Was a plain file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1535 (if (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1536 ;; Can we play some filename extension tricks?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1537 ;; If not then we must abort.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1538 (crypt-get-extension-tricks (nth 0 elt))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1539
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1540 (crypt-y-or-n-p (format "Write %s using %s? "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1541 (buffer-name) (nth 4 elt))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1542
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1543 ;; Case two.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1544 ;; Turn on encoding flags and _then_ the minor mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1545 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1546 (setq crypt-buffer-save-encoded t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1547 crypt-buffer-encoding-type (nth 0 elt))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1548 (crypt-encoded-mode 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1549
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1550 ;; No match - a plain-jane file extension - but if the encoded flag is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1551 ;; non-nil then the user may really want it written out in plain
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1552 ;; format so we must override this flag.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1553 (if (and crypt-buffer-save-encoded
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1554
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1555 ;; Search the list of files to be ignored.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1556 ;; If `crypt-ignored-filenames' is nil then this let form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1557 ;; will return t. If a match is found this form will return
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1558 ;; nil. Otherwise it will return t.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1559 (let ((tlist crypt-ignored-filenames)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1560 case-fold-search found elt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1561
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1562 ;; Search through the list of filenames for a match.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1563 (while (and tlist (setq elt (car tlist)) (not found))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1564 (if (string-match elt buffer-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1565 (setq found t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1566 ;; Decrement.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1567 (setq tlist (cdr tlist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1568
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1569 ;; Return t if we can _not_ find a match.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1570 (not found))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1571
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1572 ;; If `(crypt-encoded-mode)' was called interactively, then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1573 ;; there is a high probability that no matter what the file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1574 ;; name extension the user wishes to write the file out in some
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1575 ;; encoded format. Thanks to Kimball Collins
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1576 ;; <kpc@ptolemy.arc.nasa.gov> for pointing out the need for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1577 ;; this. Unfortunately, still can not distinguish between
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1578 ;; write-file and save-buffer. In the former the user may want
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1579 ;; to write in plain format (or indeed some other format).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1580
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1581 (if crypt-buffer-interactive-encoded-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1582 ;; Interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1583 crypt-query-if-interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1584 ;; Non-interactive but still may want encoded format.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1585 crypt-no-extension-implies-plain)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1586
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1587 (crypt-y-or-n-p (format "Write %s as a plain file? "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1588 (buffer-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1589
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1590 ;; Case three.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1591 ;; Turn off the minor mode and _then_ the flags.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1592 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1593 (crypt-encoded-mode -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1594 (setq crypt-buffer-save-encoded nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1595 crypt-buffer-encoding-type nil))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1596
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1597
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1598 (defun crypt-y-or-n-p (prompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1599 ;; Queries user based on `crypt-auto-write-buffer' and internal buffer-local
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1600 ;; variable `crypt-auto-write-answer-local'. Returns value of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1601 ;; `crypt-auto-write-answer-local', which is t or nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1602
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1603 ;; Check if we need to ask user. Should be 'ask, nil, or t.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1604 (if (eq crypt-auto-write-answer-local 'ask) ; Default value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1605 ;; We may need to ask.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1606 (or crypt-auto-write-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1607 ;; Ask and store the answer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1608 ;; Note: we only store if we asked.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1609 (setq crypt-auto-write-answer-local (y-or-n-p prompt)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1610 ;; Use previous answer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1611 crypt-auto-write-answer-local)) ; Will be nil or t.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1612
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1613
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1614 ;;; This function should be called ONLY as a write-file hook.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1615 ;;; Odd things will happen if it is called elsewhere.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1616
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1617 (defun crypt-write-file-hook ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1618
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1619 ;; Hook for possibly writing out file, and backup file, in a non-plain
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1620 ;; format. Terminates calls in `write-file-hooks' and should be at end of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1621 ;; list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1622
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1623 ;; Check file-extension for possible toggling of encoding modes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1624 (crypt-check-extension-for-encoding)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1625
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1626 ;; Check extension for encryption.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1627 (if (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1628
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1629 ;; Maybe file ends with provocative extension w.r.t. encryption?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1630 (stringp (crypt-get-file-extension crypt-encryption-type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1631 (let ((case-fold-search nil)) ; Make case-sensitive.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1632 (string-match (crypt-get-file-extension crypt-encryption-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1633 buffer-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1634
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1635 ;; Can we play tricks?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1636 (crypt-get-extension-tricks crypt-encryption-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1637
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1638 ;; Match of filename extension - is file in plain format?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1639 (not crypt-buffer-save-encrypted)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1640
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1641 ;; Query?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1642 (or crypt-auto-write-buffer-encrypted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1643 (y-or-n-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1644 (format "Write %s as an encrypted file? " (buffer-name)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1645
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1646 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1647 ;; Set password and toggle `crypt-encrypted-mode'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1648 (call-interactively 'crypt-set-encryption-key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1649 (crypt-encrypted-mode 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1650
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1651 ;; 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
1652 ;; 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
1653 ;; done here but later in the write-file-hooks - probably at the end.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1654
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1655 (if (or crypt-buffer-save-encoded crypt-buffer-save-encrypted)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1656
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1657 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1658 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1659
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1660 (let
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1661
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1662 ;; BINDINGS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1663 ((copy-buffer (get-buffer-create " *crypt copy buffer*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1664 (selective-display selective-display)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1665 (buffer-read-only))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1666
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1667 ;; FORMS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1668 (copy-to-buffer copy-buffer 1 (1+ (buffer-size)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1669 (narrow-to-region (point) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1670
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1671 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1672
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1673 ;; BODYFORM
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1674 (let (setmodes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1675
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1676 ;; As of v19, if one of functions of the `write-file-hooks'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1677 ;; returns a non-nil value, then `basic-save-buffer' no
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1678 ;; longer creates a backup file. We must do it ourselves.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1679 ;; this should be a no-op in v18.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1680 (or buffer-backed-up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1681 (setq setmodes (backup-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1682
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1683 (insert-buffer-substring copy-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1684 (kill-buffer copy-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1685
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1686 ;; "Who would cross the Bridge of Death
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1687 ;; Must answer me
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1688 ;; These questions three
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1689 ;; Ere the other side he see."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1690 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1691 ;; Bridgekeeper from Monty Python and the Holy Grail
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1692
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1693 ;; [1] selective-display non-nil means we must convert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1694 ;; carriage returns to newlines now, and set the variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1695 ;; selective-display temporarily to nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1696 (if selective-display
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1697 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1698 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1699 (subst-char-in-region (point-min) (point-max) ?\r ?\n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1700 (setq selective-display nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1701
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1702 ;; [2] encryption
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1703 (if crypt-buffer-save-encrypted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1704 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1705 ;; check for password
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1706 (if (not crypt-buffer-encryption-key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1707 (call-interactively 'crypt-set-encryption-key))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1708 (if (null crypt-buffer-encryption-key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1709 (error "No encryption key set for buffer %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1710 (buffer-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1711 (if (not (stringp crypt-buffer-encryption-key))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1712 (error "Encryption key is not a string"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1713 (message "Encrypting %s..." (buffer-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1714 (crypt-encrypt-buffer crypt-buffer-encryption-key)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1715
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1716 ;; [3] encoding
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1717 (if crypt-buffer-save-encoded
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1718 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1719 (message "Encoding %s..." (buffer-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1720 (crypt-encode-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1721
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1722 ;; Now write buffer/region to disk.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1723 (write-region (point-min) (point-max) buffer-file-name nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1724 (delete-region (point-min) (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1725 (set-buffer-modified-p nil)
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 that the file is written, set its modes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1728 (if setmodes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1729 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1730 (set-file-modes buffer-file-name setmodes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1731 (error nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1732
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1733 ;; Return t so that `basic-save-buffer' will know that the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1734 ;; save has already been done.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1735
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1736 ;; NOTE: this TERMINATES write-file-hooks so any hooks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1737 ;; following this one will not be executed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1738
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1739 t )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1740
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1741 ;; UNWINDFORMS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1742 ;; unwind...sit back...take a load off...have a beer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1743
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1744 ;; If the encoded and encrypted stuff has already been removed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1745 ;; then this is a no-op. This form is executed if BODYFORM
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1746 ;; completes normally but the value of BODYFORM is returned -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1747 ;; i.e., t is returned.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1748
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1749 (delete-region (point-min) (point-max))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1750
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1751
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1752 ;;;; ENCRYPTION
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1753
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1754 (defun crypt-encrypt-region (start end key &optional decrypt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1755 "Encrypt region START to END using KEY and `crypt-encryption-type'. When
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1756 called interactively START and END default to point and mark \(START being the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1757 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
1758 decryption is done."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1759
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1760 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1761 (let (decrypt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1762 (barf-if-buffer-read-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1763 (list (region-beginning)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1764 (region-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1765 (crypt-read-string-no-echo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1766 (concat (if (setq decrypt (y-or-n-p "Decrypt region? ")) "De" "En")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1767 "crypt buffer using key: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1768 ;; Do not confirm on decrypting region.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1769 (if (not decrypt) crypt-confirm-password))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1770 decrypt)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1771
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1772 (crypt-save-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1773
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1774 ;; We define the PROGRAM as the encryption program or decryption program
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1775 ;; listed for `crypt-encryption-type' of `crypt-encryption-alist.' These
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1776 ;; should be just the name of the executable and should _not_ contain any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1777 ;; arguments. `(call-process-region)' would be confused if we tried to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1778 ;; pass the arguments as part of the PROGRAM. The arguments are passed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1779 ;; through the encryption args or decryption args listed for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1780 ;; `crypt-encryption-type' of `crypt-encryption-alist.'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1781
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1782 ;; Thanks to Joe Ilacqua <spike@world.std.com> and others for pointing out
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1783 ;; an error that occurs with some encryption programs (e.g., the crypt from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1784 ;; Sun Microsystems, HPUX-8, and BSD) if `args' is `"".' This will allow
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1785 ;; nil values and lists of strings for argument.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1786
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1787 (let (prog args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1788
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1789 ;; Get the proper program and arguments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1790 (if decrypt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1791 (setq prog (crypt-get-decoding-program crypt-encryption-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1792 args (crypt-get-decoding-args crypt-encryption-type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1793 (setq prog (crypt-get-encoding-program crypt-encryption-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1794 args (crypt-get-encoding-args crypt-encryption-type)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1795
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1796 ;; Check arguments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1797 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1798
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1799 ;; nil or "" args - don't pass.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1800 ((or (not args) (equal "" args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1801 (call-process-region start end prog t t nil key))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1802
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1803 ;; 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
1804 ((listp args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1805 (apply 'call-process-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1806 (append (list start end prog t t nil) args (list 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 ;; Default - just a non-null string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1809 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1810 (call-process-region start end prog t t nil args key))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1811
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1812
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1813 (defun crypt-encrypt-buffer (key &optional decrypt buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1814
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1815 ;; Use KEY to encrypt current buffer and with optional DECRYPT decrypt.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1816 ;; With optional BUFFER, encrypt or decrypt that buffer. Not meant to be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1817 ;; called interactively, toggle `crypt-encrypted-mode' to encrypt an entire
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1818 ;; 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 (or buffer (setq buffer (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1821 (save-excursion (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1822 (crypt-encrypt-region (point-min) (point-max) key decrypt)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1823
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1824
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1825 ;;;; ENCODING
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1826
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1827 (defun crypt-encode-region (start end &optional decode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1828
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1829 "Encode region START to END. When called interactively START and END
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1830 default to point and mark \(START being the lesser of the two\). With
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1831 optional DECODE non-nil, decoding is done.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1832
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1833 If encoding is attempted, then checks for correct magic number at start of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1834 newly-encoded region. If not found, then searches and deletes a user-defined
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1835 regexp, or executes a user-defined lisp expression, as defined in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1836 `crypt-encoding-alist,' and checks again for magic number."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1837
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1838 (interactive "*r\nP")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1839
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1840 ;; If called interactively then we may need to determine the encoding type.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1841 (if (and (interactive-p) (not crypt-buffer-encoding-type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1842 (crypt-read-encoding-type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1843
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1844 (crypt-save-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1845
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1846 ;; 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
1847 ;; or decoding program with the arguments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1848
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1849 (let (prog args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1850
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1851 ;; Get the proper program and arguments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1852 (if decode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1853 (setq prog (crypt-get-decoding-program crypt-buffer-encoding-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1854 args (crypt-get-decoding-args crypt-buffer-encoding-type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1855 (setq prog (crypt-get-encoding-program crypt-buffer-encoding-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1856 args (crypt-get-encoding-args crypt-buffer-encoding-type)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1857
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1858 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1859
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1860 ;; prog is a string?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1861 ((stringp prog)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1862
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1863 ;; Check arguments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1864 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1865
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1866 ;; 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
1867 ((listp args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1868
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1869 ;; Cat all the strings together.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1870 (while args
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1871 (setq prog (concat prog " " (car args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1872 args (cdr 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 ;; Check if a non-null string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1875 ((and (not (string= "" args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1876 (not (eq args t))) ; just in case...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1877 (setq prog (concat prog " " 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 (call-process-region start end shell-file-name t t nil "-c" prog))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1880
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1881 ;; Otherwise try and eval it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1882 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1883 (eval (if args
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1884 (list prog start end args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1885 (list prog start end))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1886
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1887 ;; Encoding or decoding region?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1888 (if (not decode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1889
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1890 ;; Check if encoded region starts with magic number.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1891 (let ((magic (crypt-get-magic-regexp crypt-buffer-encoding-type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1892 (clean (crypt-get-cleanup-regexp crypt-buffer-encoding-type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1893 (case-fold-search nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1894
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1895 ;; Top of region.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1896 (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1897
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1898 ;; Check for magic number.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1899 (if (not (looking-at magic))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1900
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1901 ;; Magic number not there.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1902
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1903 ;; Some compression programs produce an (inane) standard error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1904 ;; message that gets piped into the buffer. For example, some
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1905 ;; versions of compact output "Compression : 35.50%." There may
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1906 ;; be some way to clean up buffer and check again.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1907
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1908 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1909
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1910 ;; No mechanism to clean up - failed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1911 ((eq clean nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1912 (error "Encoding failed!"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1913
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1914 ;; Cleanup a regexp string?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1915 ((stringp clean)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1916
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1917 ;; Is regexp there?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1918 (if (looking-at clean)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1919
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1920 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1921 ;; Delete the match.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1922 (delete-region (match-beginning 0) (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1923
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1924 ;; Check for magic again.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1925 (if (not (looking-at magic))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1926 (error "Encoding failed!")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1927
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1928 ;; Default: evaluate a lisp expression and check again.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1929 (t (eval clean)
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 (defun crypt-encode-buffer (&optional decode buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1934
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1935 ;; Encode current buffer. With optional DECODE non-nil decode and optional
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1936 ;; BUFFER, encode or decode that buffer. Not meant to be called
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1937 ;; interactively, toggle `crypt-encoded-mode' to encode an entire buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1938
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1939 (or buffer (setq buffer (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1940 (save-excursion (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1941 (crypt-encode-region (point-min) (point-max) decode)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1942
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1943
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1944 ;;;; DOS <--> UNIX
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1945 (defun crypt-dos-to-unix-region (start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1946 "Converts region from START to END, from dos to unix format.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1947 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
1948 Sets `crypt-dos-has-ctrl-z'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1949 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1950 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1951 (let ((remove-ctrl-z (equal end (point-max))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1952 (narrow-to-region start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1953 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1954 (while (search-forward "\r\n" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1955 (replace-match "\n" nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1956 (if remove-ctrl-z
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1957 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1958 (goto-char (1- (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1959 (setq crypt-dos-has-ctrl-z (looking-at "\C-z"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1960 (if crypt-dos-has-ctrl-z (replace-match ""))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1961
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1962 (defun crypt-unix-to-dos-region (start end)
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
1963 "Converts region from START to END, from unix to dos format.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1964 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
1965 `crypt-dos-has-ctrl-z' is non-nil."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1966 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1967 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1968 (let ((add-ctrl-z (and crypt-dos-has-ctrl-z
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1969 (equal end (point-max)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1970 (narrow-to-region start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1971 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1972 (while (search-forward "\n" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1973 (replace-match "\r\n" nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1974 (if add-ctrl-z
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1975 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1976 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1977 (insert "\C-z")))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1978
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1979
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1980 ;;;; MODES
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1981
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1982 (defun crypt-encrypted-mode (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1983
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1984 "Toggle encrypted mode. With ARG, turn on iff positive, otherwise turn off.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1985 minor mode in which buffers are automatically encrypted before being written.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1986 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
1987 buffer is marked modified, since it needs to be rewritten with or without
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1988 encryption.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1989
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1990 Entering encrypted mode causes auto-saving to be turned off in the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1991 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
1992 encrypted."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1993
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1994 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1995 (let ((oldval crypt-buffer-save-encrypted))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1996 (setq crypt-buffer-save-encrypted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1997 (if arg (> arg 0) (not crypt-buffer-save-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 (if crypt-buffer-save-encrypted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2000 ;; We are going to save as encrypted, we will turn off auto-saving.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2001 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2002 ;; 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
2003 ;; already an autosave for some other reason, what business does this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2004 ;; package have tampering with it?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2005 ; ;; If an auto-save file already exists, then delete it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2006 ; (if (and (stringp buffer-auto-save-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2007 ; (file-exists-p buffer-auto-save-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2008 ; (delete-file buffer-auto-save-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2009 ;; If the key is not set then ask for it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2010 (if (not crypt-buffer-encryption-key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2011 (call-interactively 'crypt-set-encryption-key))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2012 ;; Turn-off auto-saving if crypt-encrypted-disable-auto-save non-nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2013 (and crypt-encrypted-disable-auto-save
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2014 auto-save-default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2015 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2016 (auto-save-mode 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2017 (if (eq crypt-encrypted-disable-auto-save t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2018 (message "Auto-save off (in this buffer)")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2019
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2020 ;; 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
2021 ;; 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
2022 (auto-save-mode (if (and auto-save-default buffer-file-name) 1 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2023
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2024 (if crypt-buffer-encryption-key
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2025 ;; Set buffer-modified flag to t only if the mode has been changed,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2026 ;; old code set unconditionally to nil if mode was not changed .
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2027 ;; Modification suggested by: Gerd Hillebrand <ggh@cs.brown.edu>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2028 (if (not (eq oldval crypt-buffer-save-encrypted))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2029 (set-buffer-modified-p t)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2030
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2031
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2032 ;;; Forgetting encryption keys (by jwz)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2033 ;;; This is really kind of bogus. Good behavior would be:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2034 ;;; - If a crypted buffer has not been "accessed" (edited? selected?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2035 ;;; viewed?) in N minutes, kill the buffer (since the plaintext is valuable.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2036 ;;; - If a crypted buffer is modified, but "idle", just forget the password
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2037 ;;; instead of killing the buffer (though the plaintext is valuable, it's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2038 ;;; also unsaved...)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2039 ;;; - The "idleness" of a modified buffer should be reset with every mod, so
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2040 ;;; that an unsaved buffer that you have been constantly typing at for an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2041 ;;; hour doesn't lose its password.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2042 ;;; - 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
2043 ;;; is made to save that buffer, then we should confirm that the newly-
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2044 ;;; 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
2045 ;;; with PGP, we could check that by attempting to decrypt the file on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2046 ;;; disk into a scratch buffer and seeing if it contains the PGP error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2047 ;;; message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2048 ;;; - BUG: if a password has been forgotten, and you save, and are prompted,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2049 ;;; 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
2050 ;;; real file name no longer exists on disk - only as a ~ file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2051
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2052 (defun crypt-forget-encryption-key ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2053 (cond (crypt-buffer-encryption-key
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2054 (let ((inhibit-quit t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2055 (fillarray crypt-buffer-encryption-key 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2056 (setq crypt-buffer-encryption-key nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2057 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2058 (t nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2059
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2060 (add-hook 'kill-buffer-hook 'crypt-forget-encryption-key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2061
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
2062 (defcustom crypt-forget-passwd-timeout (* 60 60)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2063 "*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
2064 If nil, keep them indefinitely."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
2065 :type '(choice integer (const :tag "indefinite" nil))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
2066 :group 'crypt)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2067
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2068 (defun crypt-reset-passwd-timer ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2069 (if (fboundp 'get-itimer) ; XEmacs, or anything with itimer.el loaded.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2070 (let ((name "crypt-forget-passwds"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2071 (if (get-itimer name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2072 (delete-itimer name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2073 (if crypt-forget-passwd-timeout
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2074 (start-itimer name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2075 'crypt-reset-passwds-timeout
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2076 crypt-forget-passwd-timeout)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2077
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2078 (defun crypt-reset-passwds-timeout ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2079 ;; run by the timer code to forget all passwords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2080 (let ((buffers (buffer-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2081 (inhibit-quit t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2082 (keep-going nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2083 (while buffers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2084 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2085 (set-buffer (car buffers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2086 (cond ((and crypt-buffer-encryption-key
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2087 (buffer-modified-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2088 ;; don't forget the password in modified buffers, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2089 ;; do check again later (maybe it will be unmodified.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2090 (setq keep-going t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2091 (crypt-buffer-encryption-key
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2092 ;; forget the password in unmodified buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2093 (crypt-forget-encryption-key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2094 ;; Mark the buffer read only so that it's not accidentally
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2095 ;; edited; the smart thing to do is revert it, type the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2096 ;; encryption key (to make sure they same key is used)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2097 ;; and then edit it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2098 (setq buffer-read-only t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2099 (message "Password discarded in buffer %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2100 (buffer-name (car buffers))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2101 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2102 (setq buffers (cdr buffers)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2103 (if keep-going
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2104 (crypt-reset-passwd-timer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2105 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2106
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2107
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2108 ;;; Originally `tek-symbol-alist-to-table' from tek-highlight.el.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2109 (defun crypt-symbol-alist-to-table (list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2110 ;; Converts an alist of symbols to a table suitable for `completing-read.'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2111 ;; Called by `crypt-read-encoding-type'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2112 (mapcar (function (lambda (x) (list (symbol-name (car x)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2113 list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2114
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2115 (defun crypt-read-encoding-type ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2116
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2117 ;; Function called to query user for `crypt-buffer-encoding-type' uses
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2118 ;; contents of `crypt-encoding-alist' and `crypt-default-encoding.'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2119
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2120 ;; Use poor man's gmhist (i.e., we could have used gmhist's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2121 ;; `completing-read-with-history-in' instead).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2122 (let (
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2123 ;; Find the encoding type desired by user.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2124 (type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2125 (completing-read
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2126 (concat "encoding type (? for list): [" crypt-default-encoding "] ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2127 (crypt-symbol-alist-to-table crypt-encoding-alist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2128
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2129 ;; Test length of object returned by `completing-read'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2130 (if (zerop (length type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2131
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2132 ;; Nothing there, i.e., user hit return -- use default.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2133 (setq crypt-buffer-encoding-type (intern crypt-default-encoding))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2134
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2135 ;; Use the value from mini-buffer and update the default value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2136 (setq crypt-buffer-encoding-type (intern type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2137 crypt-default-encoding type))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2138
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2139 (defun crypt-encoded-mode (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2140
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2141 "Toggle encoded mode. With ARG, turn on iff positive, otherwise turn off.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2142 minor mode in which buffers are automatically encoded before being written. if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2143 toggled then current buffer is marked modified, since it needs to be written
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2144 with or without encoding.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2145
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2146 Entering encoded mode causes auto-saving to be turned off in the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2147 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
2148 encoded."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2149
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2150 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2151
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2152 ;; Set flag indicating whether or not `(crypt-encoded-mode)' was called
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2153 ;; interactively.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2154 (setq crypt-buffer-interactive-encoded-mode (interactive-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2155
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2156 ;; If called interactively then need to determine encoding type.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2157 (if (and crypt-buffer-interactive-encoded-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2158 (not crypt-buffer-encoding-type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2159 (crypt-read-encoding-type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2160
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2161 ;; Save old value of `crypt-buffer-save-encoded'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2162 (let ((oldval crypt-buffer-save-encoded))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2163
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2164 ;; Set the variable `crypt-buffer-save-encoded' to t if the argument is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2165 ;; positive, otherwise toggle its current value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2166 (setq crypt-buffer-save-encoded
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2167 (if arg (> arg 0) (not 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 generated by `(crypt-buffer-save-name)' to the value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2170 ;; stored in `crypt-buffer-save-encoded.'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2171 (set-variable (crypt-buffer-save-name crypt-buffer-encoding-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2172 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 (if crypt-buffer-save-encoded
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2175 ;; We are going to save as encoded, we might turn off auto-saving.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2176 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2177 ;; 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
2178 ;; already an autosave for some other reason, what business does this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2179 ;; package have tampering with it?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2180 ; ;; If an auto-save file already exists, then delete it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2181 ; (if (and (stringp buffer-auto-save-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2182 ; (file-exists-p buffer-auto-save-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2183 ; (delete-file buffer-auto-save-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2184 ;; Turn-off auto-saving if crypt-encoded-disable-auto-save non-nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2185 (and crypt-encoded-disable-auto-save
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2186 auto-save-default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2187 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2188 (auto-save-mode 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2189 (if (eq crypt-encoded-disable-auto-save t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2190 (message "Auto-save off (in this buffer)")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2191
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2192 ;; 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
2193 ;; only if we are editing a file and the default says we should.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2194 (auto-save-mode (if (and auto-save-default buffer-file-name) 1 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2195
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2196 ;; Have we toggled the mode?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2197
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2198 ;; If yes, then mark buffer as modified. If not, then leave
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2199 ;; buffer-modified flag alone.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2200
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2201 ;; The old code previously set the variable `set-buffer-modified-p' to a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2202 ;; value of t if there was a mode change and (unconditionally) to nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2203 ;; if there was not a mode change.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2204
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2205 ;; Modification suggested by: Gerd Hillebrand <ggh@cs.brown.edu>.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2206
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2207 (if (not (eq oldval crypt-buffer-save-encoded))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2208 (set-buffer-modified-p t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2209
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2210
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2211 ;;;; Additional encryption functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2212
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2213 ;; For Emacs V18 compatibility
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2214 (and (not (fboundp 'buffer-disable-undo))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2215 (fboundp 'buffer-flush-undo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2216 (fset 'buffer-disable-undo 'buffer-flush-undo))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2217
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2218 (fset 'crypt-read-string-no-echo 'read-passwd)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2219
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2220 ;(defun crypt-read-string-no-echo (prompt &optional confirm)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2221 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2222 ; ;; Read a string from minibuffer, prompting with PROMPT, echoing periods.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2223 ; ;; Optional second argument CONFIRM non-nil means that the user will be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2224 ; ;; 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
2225 ; ;; mismatch, the whole process is repeated.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2226 ; ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2227 ; ;; Line editing keys are --
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2228 ; ;; C-h, DEL rubout
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2229 ; ;; C-u, C-x line kill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2230 ; ;; C-q, C-v literal next
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2231 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2232 ; (catch 'return-value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2233 ; (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2234 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2235 ; (let ((input-buffer (get-buffer-create (make-temp-name " *password*")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2236 ; char hold-password help-form kill-ring)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2237 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2238 ; (set-buffer input-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2239 ; ;; Don't add to undo ring.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2240 ; (buffer-disable-undo input-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2241 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2242 ; (let ((cursor-in-echo-area t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2243 ; (echo-keystrokes 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2244 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2245 ; (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2246 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2247 ; ;; BODYFORM
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2248 ; ;; Repeat until we get a `throw'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2249 ; (while t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2250 ; (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2251 ; (message prompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2252 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2253 ; ;; Read string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2254 ; (while (not (memq (setq char (read-char)) '(?\C-m ?\C-j)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2255 ; (if (setq help-form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2256 ; (cdr
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2257 ; (assq char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2258 ; '((?\C-h . (delete-char -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2259 ; (?\C-? . (delete-char -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2260 ; (?\C-u . (delete-region 1 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2261 ; (?\C-x . (delete-region 1 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2262 ; (?\C-q . (quoted-insert 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2263 ; (?\C-v . (quoted-insert 1))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2264 ; (condition-case error-data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2265 ; (eval help-form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2266 ; (error t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2267 ; ;; Just a plain character - insert into password buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2268 ; (insert char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2269 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2270 ; ;; I think crypt-read-string-no-echo should echo asterisks.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2271 ; ;; -- Jamie. How about periods like in ange-ftp? -- lrd
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2272 ; ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2273 ; (message "%s%s" prompt (make-string (buffer-size) ?.)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2274 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2275 ; ;; Do we have to confirm password?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2276 ; (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2277 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2278 ; ;; No confirmation requested - terminate.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2279 ; ((not confirm)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2280 ; (throw 'return-value (buffer-string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2281 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2282 ; ;; Can we compare (confirm) password values yet?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2283 ; (hold-password
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2284 ; (if (string= hold-password (buffer-string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2285 ; ;; The two passwords match - terminate.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2286 ; (throw 'return-value hold-password)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2287 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2288 ; ;; Mismatch - start over.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2289 ; (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2290 ; (message (concat prompt "[Mismatch. Start over]"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2291 ; (beep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2292 ; (sit-for 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2293 ; (fillarray hold-password 0) ; destroy extra copy now
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2294 ; (setq hold-password nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2295 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2296 ; ;; Store password and read again.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2297 ; (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2298 ; (setq hold-password (buffer-string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2299 ; (message (concat prompt "[Retype to confirm]"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2300 ; (sit-for 2))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2301 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2302 ; ;; UNWINDFORMS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2303 ; ;; Clean up.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2304 ; (set-buffer input-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2305 ; (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2306 ; (buffer-disable-undo input-buffer) ; redundant, but why not be safe.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2307 ; (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2308 ; (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2309 ; (while (not (eobp)) (delete-char 1) (insert "*")) ; destroy now
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2310 ; (kill-buffer input-buffer)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2311
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2312 (defun crypt-set-encryption-key (key &optional buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2313
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2314 "Set the encryption KEY, a string, for current buffer or optionally BUFFER.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2315 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
2316 needs to be saved with the new key."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2317
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2318 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2319 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2320 (barf-if-buffer-read-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2321 (list (crypt-read-string-no-echo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2322 (format "Encryption key for %s? [RET to ignore]: " (buffer-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2323 crypt-confirm-password))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2324
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2325 ;; For security reasons we remove `(crypt-set-encryption-key "password")'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2326 ;; from the `command-history' list if called interactively.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2327 (if (interactive-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2328 (setq command-history (cdr command-history)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2329
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2330 (or buffer (setq buffer (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2331
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2332 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2333 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2334 (if (equal key crypt-buffer-encryption-key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2335 (message "Key is identical to original, no change.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2336
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2337 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2338 ;; jwz: destroy old string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2339 (if (and crypt-buffer-encryption-key
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2340 (not (eq crypt-buffer-encryption-key key)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2341 (fillarray crypt-buffer-encryption-key 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2342 (setq crypt-buffer-encryption-key key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2343
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2344 ;; Don't touch the modify flag unless we're in `(crypt-encrypted-mode)'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2345 (if crypt-buffer-save-encrypted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2346 (set-buffer-modified-p t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2347
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2348 (crypt-reset-passwd-timer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2349 ))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2350
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2351
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2352 ;;;; Install hooks and mode indicators.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2353
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2354 ;;; Check if mode indicators are not already installed and then prepend them.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2355 (and (not (assq 'crypt-buffer-save-encrypted minor-mode-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2356 (setq minor-mode-alist (append crypt-minor-mode-alist minor-mode-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2357
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2358 ;;; Install the hooks.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2359
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2360 ;;; If add-hook isn't already defined overwrite it with our own.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2361 ;;; Note the `add-hook' function must take the optional APPEND argument.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2362 (if (not (fboundp 'add-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2363 ;; No add-hook found.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2364 ;; Use `add-hook' from GNU Emacs v19.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2365 (defun add-hook (hook function &optional append)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2366 "Add to the value of HOOK the function FUNCTION.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2367 FUNCTION is not added if already present.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2368 FUNCTION is added (if necessary) at the beginning of the hook list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2369 unless the optional argument APPEND is non-nil, in which case
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2370 FUNCTION is added at the end.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2371
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2372 HOOK should be a symbol, and FUNCTION may be any valid function. If
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2373 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
2374 function, it is changed to a list of functions."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2375 (or (boundp hook) (set hook nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2376 ;; If the hook value is a single function, turn it into a list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2377 (let ((old (symbol-value hook)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2378 (if (or (not (listp old)) (eq (car old) 'lambda))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2379 (set hook (list old))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2380 (or (if (consp function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2381 ;; Clever way to tell whether a given lambda-expression
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2382 ;; is equal to anything in the hook.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2383 (let ((tail (assoc (cdr function) (symbol-value hook))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2384 (equal function tail))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2385 (memq function (symbol-value hook)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2386 (set hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2387 (if append
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2388 (nconc (symbol-value hook) (list function))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2389 (cons function (symbol-value hook)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2390
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2391 ;;; Attach ourselves to the find-file-hooks and find-file-not-found-hooks.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2392 (add-hook 'find-file-hooks 'crypt-find-file-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2393 (add-hook 'find-file-not-found-hooks 'crypt-find-file-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2394
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2395 ;; 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
2396 ;; 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
2397 ;; everyone would upgrade - lrd 8/31/93.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2398 (condition-case err
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2399 (add-hook 'write-file-hooks 'crypt-write-file-hook t) ; *must* append this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2400 (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2401 ;; Do it by hand. Not as robust as `add-hook'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2402
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2403 ;; Contributed by Ken Laprade <laprade@trantor.harris-atd.com>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2404 ;; Really should use some sort of add-hook - 16 Feb 93 - KCL
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2405 (or (and (listp write-file-hooks) (not (eq (car write-file-hooks) 'lambda)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2406 (setq write-file-hooks (list write-file-hooks)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2407
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2408 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2409 ((not (memq 'crypt-write-file-hook write-file-hooks))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2410 ;; make this hook last on purpose
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2411 (setq write-file-hooks (append write-file-hooks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2412 (list 'crypt-write-file-hook)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2413
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2414 ;; In order that the tables and key-binding correctly reflect user's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2415 ;; preferences we add ourselves to the `after-init-hook' GNU Emacs v19 and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2416 ;; 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
2417 ;; (or earlier). These are run *after* ~/.emacs and ../lisp/default.el are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2418 ;; loaded. Unfortunately, v18 does not have `after-init-hook' and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2419 ;; `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
2420 ;; to work our functions in properly without overwriting the user's value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2421 ;; Therefore, we do nothing and hope they upgrade to v19 soon.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2422
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2423 (cond ((boundp 'after-init-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2424 ;; Must be running GNU Emacs v19 :->
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2425 (add-hook 'after-init-hook 'crypt-rebuild-tables)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2426 (add-hook 'after-init-hook 'crypt-rebuild-minor-modes-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2427 (add-hook 'after-init-hook 'crypt-bind-insert-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2428
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2429 ((and (string-match "^19" emacs-version) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2430 ;; Probably running Lucid Emacs v19.7 (or earlier) since it,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2431 ;; unfortunately, does not have `after-init-hook'. Use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2432 ;; `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
2433 ;; Emacs 19.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2434 (add-hook 'term-setup-hook 'crypt-rebuild-tables)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2435 (add-hook 'term-setup-hook 'crypt-rebuild-minor-modes-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2436 (add-hook 'term-setup-hook 'crypt-bind-insert-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2437
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2438
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2439 ;;; Code for conditionally decoding/decrypting an inserted file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2440
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
2441 (defcustom crypt-bind-insert-file t
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2442 "*t value means bind `crypt-insert-file' over `insert-file'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2443 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
2444 \\[crypt-bind-insert-file]."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
2445 :type 'boolean
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
2446 :group 'crypt)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2447
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
2448 (defcustom crypt-auto-decode-insert nil
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2449 "*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
2450 nil says to ask before doing this."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
2451 :type 'boolean
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 110
diff changeset
2452 :group 'crypt)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2453
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2454 ;;; Bind `crypt-insert-file' over wherever `insert-file' is bound?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2455 (defun crypt-bind-insert-file ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2456
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2457 "Bind `crypt-insert-file' in place of `insert-file' or reverse based on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2458 `crypt-bind-insert-file'. Part of `after-init-hook'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2459
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2460 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2461
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2462 (if (interactive-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2463 (setq crypt-bind-insert-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2464 (y-or-n-p "Bind crypt-insert-file over insert-file? ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2465
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2466 (if crypt-bind-insert-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2467 (substitute-key-definition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2468 'insert-file 'crypt-insert-file (current-global-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2469 (substitute-key-definition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2470 'crypt-insert-file 'insert-file (current-global-map))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2471
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2472 ;;; Now call it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2473 (crypt-bind-insert-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2474
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2475 ;;; crypt++ replacement for `insert-file'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2476 (defun crypt-insert-file (filename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2477 "Insert decoded/decrypted contents of file FILENAME into buffer after point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2478 Set mark after the inserted text.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2479
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2480 This function is meant for the user to run interactively.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2481 Don't call it from programs! Use `insert-file-contents' instead.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2482 \(Its calling sequence is different; see its documentation\).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2483
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2484 This version will attempt to decrypt and/or decode file before inserting.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2485 see variable `crypt-auto-decode-insert'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2486 (interactive "fInsert file: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2487 (if (file-directory-p filename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2488 (signal 'file-error (list "Opening input file" "file is a directory"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2489 filename)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2490 (let ((tem (crypt-insert-file-contents filename))) ; use crypt++ to insert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2491 (push-mark (+ (point) (car (cdr tem))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2492
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2493 (defun crypt-insert-file-contents (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2494
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2495 ;; Similar to `insert-file-contents' except decoding/decrypting of FILE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2496 ;; attempted. See `crypt-insert-file' and `crypt-auto-decode-insert'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2497
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2498 (let (temp-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2499 temp-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2500 (crypt-auto-decode-buffer crypt-auto-decode-insert)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2501 (orig-buffer (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2502
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2503 ;; Create a temporary buffer and decode and decrypt it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2504 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2505
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2506 ;; Temporary buffer, use the same name as the file to be inserted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2507 (setq temp-buffer (generate-new-buffer (file-name-nondirectory file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2508 (set-buffer temp-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2509
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2510 ;; Original insert-file-contents - save list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2511 (setq temp-list (insert-file-contents file nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2512
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2513 ;; Make temp-buffer unmodified.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2514 (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2515
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2516 ;; Need to set buffer name to file name for crypt++.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2517 (setq buffer-file-name file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2518
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2519 ;; Decode and decrypt, if necessary.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2520 (crypt-find-file-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2521
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2522 ;; Find the length of the file to be inserted. `insert-file-contents'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2523 ;; returns it for the original encoded/encrypted file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2524 (setcdr temp-list (cons (buffer-size) ()))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2525
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2526 ;; Now insert temp-buffer into original buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2527 (set-buffer orig-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2528 (insert-buffer temp-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2529
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2530 ;; Kill the temporary buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2531 (kill-buffer temp-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2532
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2533 ;; Return modified list from `insert-file-contents'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2534 temp-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2535
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2536
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2537 ;;;; BUG REPORTS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2538
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2539 ;;; This section is provided for reports.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2540 ;;; Using Barry A. Warsaw's reporter.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2541
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2542 (defconst crypt-version "2.82"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2543 "Revision number of crypt++.el -- handles compressed and encrypted files.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2544 Type \\[crypt-submit-report] to send a bug report. Available via anonymous
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2545 ftp in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2546
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2547 /roebling.poly.edu:/pub/lisp/crypt++.el.gz
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2548 /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
2549
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2550 (defconst crypt-help-address
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2551 "dodd@roebling.poly.edu"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2552 "Address(es) accepting submission of reports on crypt++.el.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2553
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2554 (defconst crypt-maintainer "Larry"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2555 "First name(s) of people accepting submission of reports on crypt++.el.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2556
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2557 (defconst crypt-file "crypt++.el"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2558 "Name of file containing emacs lisp code.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2559
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2560 (defconst crypt-variable-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2561 (list 'shell-file-name ; These
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2562 'load-path ; are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2563 'exec-path ; useful.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2564 'crypt-encryption-type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2565 'crypt-encryption-file-extension
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2566 'crypt-never-ever-decrypt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2567 'crypt-auto-write-buffer-encrypted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2568 'crypt-confirm-password
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2569 'crypt-encrypted-disable-auto-save
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2570 'crypt-auto-decode-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2571 'crypt-auto-write-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2572 'crypt-query-if-interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2573 'crypt-no-extension-implies-plain
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2574 'crypt-freeze-vs-fortran
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2575 'crypt-compact-vs-C++
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2576 'crypt-ignored-filenames
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2577 'crypt-default-encoding
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2578 'crypt-encoded-disable-auto-save
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2579 'crypt-bind-insert-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2580 'crypt-auto-decode-insert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2581 'crypt-encoding-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2582 'crypt-encryption-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2583 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2584 "List of variables to be appended to reports sent by `crypt-submit-report.'")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2585
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2586 (defun crypt-submit-report ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2587 "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
2588 version `crypt-version,' to `crypt-maintainer' at address `crypt-help-address'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2589 listing variables `crypt-variable-list' in the message."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2590 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2591
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2592 ;; In case we can't find reporter...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2593 (condition-case err
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2594 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2595 ;; Get it if we can.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2596 (require 'reporter)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2597
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2598 (reporter-submit-bug-report
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2599 crypt-help-address ; address
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2600 (concat crypt-file " " crypt-version) ; pkgname
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2601 crypt-variable-list ; varlist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2602 nil nil ; pre-hooks and post-hooks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2603 (concat "Yo! " crypt-maintainer ","))) ; salutation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2604
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2605 ;; ...fail gracefully.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2606 (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2607 (beep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2608
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2609 ;; Do they have ange-ftp?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2610 (if (and (featurep 'ange-ftp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2611 (y-or-n-p (concat "Sorry, reporter.el not found. "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2612 "Can I ange-ftp it for you? ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2613
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2614 ;; Yes. Then Ange-ftp a copy from roebling.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2615 (let ((ange-ftp-generate-anonymous-password t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2616 ;; Might want to use the elisp archive official site? But
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2617 ;; then it would have to be uncompressed, etc. Ick!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2618 (find-file-other-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2619 "/anonymous@roebling.poly.edu:/pub/reporter.el")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2620 (eval-current-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2621 (message (concat "Save reporter.el somewhere in `load-path' "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2622 "and try again.")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2623
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2624 ;; No ange-ftp.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2625 (message "Sorry, reporter.el not found.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2626 (sit-for 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2627 (message (concat "Get it from archive.cis.ohio-state.edu "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2628 "or roebling.poly.edu"))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2629
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2630 ;;; Provide this package as crypt++ as well as crypt.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2631 (provide 'crypt++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2632 (provide 'crypt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2633
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2634 ;;; crypt++.el ends here.