Initial Commit
[packages] / xemacs-packages / mailcrypt / mc-setversion.el
1 ;; mc-setversion.el, Support for multiple versions of PGP.
2 ;; Copyright (C) 1998  Len Budney <lbudney@pobox.com>
3
4 ;;{{{ Licensing
5 ;; This file is intended to be used with GNU Emacs.
6
7 ;; This program is free software; you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation; either version 2, or (at your option)
10 ;; any later version.
11
12 ;; This program is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 ;; GNU General Public License for more details.
16
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with GNU Emacs; see the file COPYING.  If not, write to
19 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
20 ;;}}}
21
22 (defvar mc-default-scheme 'mc-scheme-pgp
23   "*Set the default encryption scheme for Mailcrypt to use. Defaults
24 to pgp 2.6 for backward compatibility.")
25
26 (defun mc-setversion (&optional version)
27   "Reset path and argument information for the selected version of PGP.
28 Possible values of VERSION are 2.6, 5.0, and gpg."
29   (interactive)
30
31   (if (null version)
32       (let
33           ((oldversion
34             (cond
35              ((eq mc-default-scheme 'mc-scheme-pgp50) "5.0")
36              ((eq mc-default-scheme 'mc-scheme-pgp) "2.6")
37              ((eq mc-default-scheme 'mc-scheme-gpg) "gpg")
38              (t nil))
39             )
40            (completion-ignore-case t))
41         (setq version 
42               (completing-read 
43                (format "Select PGP version (currently %s): " oldversion)
44                '(
45                  ("2.6" 1) 
46                  ("5.0" 2)
47                  ("gpg" 3)
48                  ) nil 
49                    t   ; REQUIRE-MATCH
50                    nil ; INITIAL
51                    nil ; HIST
52                        ))
53         (if (equal (length version) 0)
54             (setq version oldversion))))
55
56   (cond
57    ((string-equal version "5.0")
58     (progn
59       (setq mc-default-scheme 'mc-scheme-pgp50)
60       (message "PGP version set to 5.0.")))
61    ((string-equal version "2.6")
62     (progn
63       (setq mc-default-scheme 'mc-scheme-pgp)
64       (message "PGP version set to 2.6.")))
65    ((string-equal version "gpg")
66     (progn
67       (setq mc-default-scheme 'mc-scheme-gpg)
68       (message "PGP version set to GPG.")))
69    (t (error "bad version string")) ; cannot happen
70 ))
71