annotate lisp/epa.el @ 110410:f2e111723c3a

Merge changes made in Gnus trunk. Reimplement nnimap, and do tweaks to the rest of the code to support that. * gnus-int.el (gnus-finish-retrieve-group-infos) (gnus-retrieve-group-data-early): New functions. * gnus-range.el (gnus-range-nconcat): New function. * gnus-start.el (gnus-get-unread-articles): Support early retrieval of data. (gnus-read-active-for-groups): Support finishing the early retrieval of data. * gnus-sum.el (gnus-summary-move-article): Pass the move-to group name if the move is internal, so that nnimap can do fast internal moves. * gnus.el (gnus-article-special-mark-lists): Add uid/active tuples, for nnimap usage. * nnimap.el: Rewritten. * nnmail.el (nnmail-inhibit-default-split-group): New internal variable to allow the mail splitting to not return a default group. This is useful for nnimap, which will leave unmatched mail in the inbox. * utf7.el (utf7-encode): Autoload. Implement shell connection. * nnimap.el (nnimap-open-shell-stream): New function. (nnimap-open-connection): Use it. Get the number of lines by using BODYSTRUCTURE. (nnimap-transform-headers): Get the number of lines in each message. (nnimap-retrieve-headers): Query for BODYSTRUCTURE so that we get the number of lines. Not all servers return UIDNEXT. Work past this problem. Remove junk from end of file. Fix typo in "bogus" section. Make capabilties be case-insensitive. Require cl when compiling. Don't bug out if the LIST command doesn't have any parameters. 2010-09-17 Knut Anders Hatlen <kahatlen@gmail.com> (tiny change) * nnimap.el (nnimap-get-groups): Don't bug out if the LIST command doesn't have any parameters. (mm-text-html-renderer): Document gnus-article-html. 2010-09-17 Julien Danjou <julien@danjou.info> (tiny fix) * mm-decode.el (mm-text-html-renderer): Document gnus-article-html. * dgnushack.el: Define netrc-credentials. If the user doesn't have a /etc/services, supply some sensible port defaults. Have `unseen-or-unread' select an unread unseen article first. (nntp-open-server): Return whether the open was successful or not. Throughout all files, replace (save-excursion (set-buffer ...)) with (with-current-buffer ... ). Save result so that it doesn't say "failed" all the time. Add ~/.authinfo to the default, since that's probably most useful for users. Don't use the "finish" method when we're reading from the agent. Add some more nnimap-relevant agent stuff to nnagent.el. * nnimap.el (nnimap-with-process-buffer): Removed. Revert one line that was changed by mistake in the last checkin. (nnimap-open-connection): Don't error out when we can't make a connection nnimap-related changes to avoid bugging out if we can't contact a server. * gnus-start.el (gnus-get-unread-articles): Don't try to scan groups from methods that are denied. * nnimap.el (nnimap-possibly-change-group): Return nil if we can't log in. (nnimap-finish-retrieve-group-infos): Make sure we're not waiting for nothing. * gnus-sum.el (gnus-select-newsgroup): Indent.
author Katsumi Yamaoka <yamaoka@jpl.org>
date Sat, 18 Sep 2010 10:02:19 +0000
parents 5a957bb32b66
children f60f4abe5849 376148b31b5e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
91647
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1 ;;; epa.el --- the EasyPG Assistant
106815
1d1d5d9bd884 Add 2010 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 105994
diff changeset
2 ;; Copyright (C) 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
91647
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
3
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
4 ;; Author: Daiki Ueno <ueno@unixuser.org>
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
5 ;; Keywords: PGP, GnuPG
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
6
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
7 ;; This file is part of GNU Emacs.
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
8
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94490
diff changeset
9 ;; GNU Emacs is free software: you can redistribute it and/or modify
91647
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
10 ;; it under the terms of the GNU General Public License as published by
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94490
diff changeset
11 ;; the Free Software Foundation, either version 3 of the License, or
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94490
diff changeset
12 ;; (at your option) any later version.
91647
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
13
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
14 ;; GNU Emacs is distributed in the hope that it will be useful,
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
17 ;; GNU General Public License for more details.
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
18
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
19 ;; You should have received a copy of the GNU General Public License
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94490
diff changeset
20 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
91647
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
21
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
22 ;;; Code:
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
23
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
24 (require 'epg)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
25 (require 'font-lock)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
26 (require 'widget)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
27 (eval-when-compile (require 'wid-edit))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
28 (require 'derived)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
29
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
30 (defgroup epa nil
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
31 "The EasyPG Assistant"
91703
bda1e76bc03b * epa.el (epa-faces, epa):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 91687
diff changeset
32 :version "23.1"
91647
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
33 :group 'epg)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
34
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
35 (defcustom epa-popup-info-window t
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
36 "If non-nil, status information from epa commands is displayed on
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
37 the separate window."
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
38 :type 'boolean
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
39 :group 'epa)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
40
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
41 (defcustom epa-info-window-height 5
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
42 "Number of lines used to display status information."
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
43 :type 'integer
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
44 :group 'epa)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
45
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
46 (defgroup epa-faces nil
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
47 "Faces for epa-mode."
91703
bda1e76bc03b * epa.el (epa-faces, epa):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 91687
diff changeset
48 :version "23.1"
91647
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
49 :group 'epa)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
50
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
51 (defface epa-validity-high
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
52 `((((class color) (background dark))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
53 (:foreground "PaleTurquoise"
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
54 ,@(if (assq ':weight custom-face-attributes)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
55 '(:weight bold)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
56 '(:bold t))))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
57 (t
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
58 (,@(if (assq ':weight custom-face-attributes)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
59 '(:weight bold)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
60 '(:bold t)))))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
61 "Face used for displaying the high validity."
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
62 :group 'epa-faces)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
63
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
64 (defface epa-validity-medium
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
65 `((((class color) (background dark))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
66 (:foreground "PaleTurquoise"
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
67 ,@(if (assq ':slant custom-face-attributes)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
68 '(:slant italic)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
69 '(:italic t))))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
70 (t
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
71 (,@(if (assq ':slant custom-face-attributes)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
72 '(:slant italic)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
73 '(:italic t)))))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
74 "Face used for displaying the medium validity."
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
75 :group 'epa-faces)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
76
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
77 (defface epa-validity-low
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
78 `((t
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
79 (,@(if (assq ':slant custom-face-attributes)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
80 '(:slant italic)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
81 '(:italic t)))))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
82 "Face used for displaying the low validity."
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
83 :group 'epa-faces)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
84
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
85 (defface epa-validity-disabled
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
86 `((t
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
87 (,@(if (assq ':slant custom-face-attributes)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
88 '(:slant italic)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
89 '(:italic t))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
90 :inverse-video t)))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
91 "Face used for displaying the disabled validity."
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
92 :group 'epa-faces)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
93
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
94 (defface epa-string
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
95 '((((class color) (background dark))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
96 (:foreground "lightyellow"))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
97 (((class color) (background light))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
98 (:foreground "blue4")))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
99 "Face used for displaying the string."
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
100 :group 'epa-faces)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
101
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
102 (defface epa-mark
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
103 `((((class color) (background dark))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
104 (:foreground "orange"
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
105 ,@(if (assq ':weight custom-face-attributes)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
106 '(:weight bold)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
107 '(:bold t))))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
108 (((class color) (background light))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
109 (:foreground "red"
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
110 ,@(if (assq ':weight custom-face-attributes)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
111 '(:weight bold)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
112 '(:bold t))))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
113 (t
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
114 (,@(if (assq ':weight custom-face-attributes)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
115 '(:weight bold)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
116 '(:bold t)))))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
117 "Face used for displaying the high validity."
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
118 :group 'epa-faces)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
119
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
120 (defface epa-field-name
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
121 `((((class color) (background dark))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
122 (:foreground "PaleTurquoise"
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
123 ,@(if (assq ':weight custom-face-attributes)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
124 '(:weight bold)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
125 '(:bold t))))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
126 (t
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
127 (,@(if (assq ':weight custom-face-attributes)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
128 '(:weight bold)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
129 '(:bold t)))))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
130 "Face for the name of the attribute field."
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
131 :group 'epa)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
132
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
133 (defface epa-field-body
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
134 `((((class color) (background dark))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
135 (:foreground "turquoise"
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
136 ,@(if (assq ':slant custom-face-attributes)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
137 '(:slant italic)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
138 '(:italic t))))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
139 (t
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
140 (,@(if (assq ':slant custom-face-attributes)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
141 '(:slant italic)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
142 '(:italic t)))))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
143 "Face for the body of the attribute field."
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
144 :group 'epa)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
145
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
146 (defcustom epa-validity-face-alist
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
147 '((unknown . epa-validity-disabled)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
148 (invalid . epa-validity-disabled)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
149 (disabled . epa-validity-disabled)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
150 (revoked . epa-validity-disabled)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
151 (expired . epa-validity-disabled)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
152 (none . epa-validity-low)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
153 (undefined . epa-validity-low)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
154 (never . epa-validity-low)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
155 (marginal . epa-validity-medium)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
156 (full . epa-validity-high)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
157 (ultimate . epa-validity-high))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
158 "An alist mapping validity values to faces."
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
159 :type '(repeat (cons symbol face))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
160 :group 'epa)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
161
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
162 (defvar epa-font-lock-keywords
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
163 '(("^\\*"
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
164 (0 'epa-mark))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
165 ("^\t\\([^\t:]+:\\)[ \t]*\\(.*\\)$"
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
166 (1 'epa-field-name)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
167 (2 'epa-field-body)))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
168 "Default expressions to addon in epa-mode.")
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
169
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
170 (defconst epa-pubkey-algorithm-letter-alist
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
171 '((1 . ?R)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
172 (2 . ?r)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
173 (3 . ?s)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
174 (16 . ?g)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
175 (17 . ?D)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
176 (20 . ?G)))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
177
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
178 (defvar epa-protocol 'OpenPGP
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
179 "*The default protocol.
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
180 The value can be either OpenPGP or CMS.
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
181
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
182 You should bind this variable with `let', but do not set it globally.")
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
183
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
184 (defvar epa-armor nil
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
185 "*If non-nil, epa commands create ASCII armored output.
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
186
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
187 You should bind this variable with `let', but do not set it globally.")
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
188
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
189 (defvar epa-textmode nil
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
190 "*If non-nil, epa commands treat input files as text.
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
191
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
192 You should bind this variable with `let', but do not set it globally.")
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
193
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
194 (defvar epa-keys-buffer nil)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
195 (defvar epa-key-buffer-alist nil)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
196 (defvar epa-key nil)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
197 (defvar epa-list-keys-arguments nil)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
198 (defvar epa-info-buffer nil)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
199 (defvar epa-last-coding-system-specified nil)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
200
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
201 (defvar epa-key-list-mode-map
94471
ecd293096a4b Daiki Ueno <ueno at unixuser.org>
Glenn Morris <rgm@gnu.org>
parents: 94417
diff changeset
202 (let ((keymap (make-sparse-keymap))
ecd293096a4b Daiki Ueno <ueno at unixuser.org>
Glenn Morris <rgm@gnu.org>
parents: 94417
diff changeset
203 (menu-map (make-sparse-keymap)))
91647
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
204 (define-key keymap "m" 'epa-mark-key)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
205 (define-key keymap "u" 'epa-unmark-key)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
206 (define-key keymap "d" 'epa-decrypt-file)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
207 (define-key keymap "v" 'epa-verify-file)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
208 (define-key keymap "s" 'epa-sign-file)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
209 (define-key keymap "e" 'epa-encrypt-file)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
210 (define-key keymap "r" 'epa-delete-keys)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
211 (define-key keymap "i" 'epa-import-keys)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
212 (define-key keymap "o" 'epa-export-keys)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
213 (define-key keymap "g" 'revert-buffer)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
214 (define-key keymap "n" 'next-line)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
215 (define-key keymap "p" 'previous-line)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
216 (define-key keymap " " 'scroll-up)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
217 (define-key keymap [delete] 'scroll-down)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
218 (define-key keymap "q" 'epa-exit-buffer)
94471
ecd293096a4b Daiki Ueno <ueno at unixuser.org>
Glenn Morris <rgm@gnu.org>
parents: 94417
diff changeset
219 (define-key keymap [menu-bar epa-key-list-mode] (cons "Keys" menu-map))
94490
dcbaed9de6ff (epa-key-list-mode-map): Add more menu entries.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 94471
diff changeset
220 (define-key menu-map [epa-key-list-unmark-key]
dcbaed9de6ff (epa-key-list-mode-map): Add more menu entries.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 94471
diff changeset
221 '(menu-item "Unmark Key" epa-unmark-key
dcbaed9de6ff (epa-key-list-mode-map): Add more menu entries.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 94471
diff changeset
222 :help "Unmark a key"))
dcbaed9de6ff (epa-key-list-mode-map): Add more menu entries.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 94471
diff changeset
223 (define-key menu-map [epa-key-list-mark-key]
dcbaed9de6ff (epa-key-list-mode-map): Add more menu entries.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 94471
diff changeset
224 '(menu-item "Mark Key" epa-mark-key
dcbaed9de6ff (epa-key-list-mode-map): Add more menu entries.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 94471
diff changeset
225 :help "Mark a key"))
dcbaed9de6ff (epa-key-list-mode-map): Add more menu entries.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 94471
diff changeset
226 (define-key menu-map [separator-epa-file] '(menu-item "--"))
dcbaed9de6ff (epa-key-list-mode-map): Add more menu entries.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 94471
diff changeset
227 (define-key menu-map [epa-verify-file]
dcbaed9de6ff (epa-key-list-mode-map): Add more menu entries.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 94471
diff changeset
228 '(menu-item "Verify File..." epa-verify-file
dcbaed9de6ff (epa-key-list-mode-map): Add more menu entries.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 94471
diff changeset
229 :help "Verify FILE"))
dcbaed9de6ff (epa-key-list-mode-map): Add more menu entries.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 94471
diff changeset
230 (define-key menu-map [epa-sign-file]
dcbaed9de6ff (epa-key-list-mode-map): Add more menu entries.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 94471
diff changeset
231 '(menu-item "Sign File..." epa-sign-file
dcbaed9de6ff (epa-key-list-mode-map): Add more menu entries.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 94471
diff changeset
232 :help "Sign FILE by SIGNERS keys selected"))
dcbaed9de6ff (epa-key-list-mode-map): Add more menu entries.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 94471
diff changeset
233 (define-key menu-map [epa-decrypt-file]
dcbaed9de6ff (epa-key-list-mode-map): Add more menu entries.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 94471
diff changeset
234 '(menu-item "Decrypt File..." epa-decrypt-file
dcbaed9de6ff (epa-key-list-mode-map): Add more menu entries.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 94471
diff changeset
235 :help "Decrypt FILE"))
dcbaed9de6ff (epa-key-list-mode-map): Add more menu entries.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 94471
diff changeset
236 (define-key menu-map [epa-encrypt-file]
105275
b78ceb253d15 * speedbar.el (speedbar-item-delete):
Juanma Barranquero <lekktu@gmail.com>
parents: 104395
diff changeset
237 '(menu-item "Encrypt File..." epa-encrypt-file
94490
dcbaed9de6ff (epa-key-list-mode-map): Add more menu entries.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 94471
diff changeset
238 :help "Encrypt FILE for RECIPIENTS"))
dcbaed9de6ff (epa-key-list-mode-map): Add more menu entries.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 94471
diff changeset
239 (define-key menu-map [separator-epa-key-list] '(menu-item "--"))
94471
ecd293096a4b Daiki Ueno <ueno at unixuser.org>
Glenn Morris <rgm@gnu.org>
parents: 94417
diff changeset
240 (define-key menu-map [epa-key-list-delete-keys]
ecd293096a4b Daiki Ueno <ueno at unixuser.org>
Glenn Morris <rgm@gnu.org>
parents: 94417
diff changeset
241 '(menu-item "Delete keys" epa-delete-keys
94490
dcbaed9de6ff (epa-key-list-mode-map): Add more menu entries.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 94471
diff changeset
242 :help "Delete Marked Keys"))
94471
ecd293096a4b Daiki Ueno <ueno at unixuser.org>
Glenn Morris <rgm@gnu.org>
parents: 94417
diff changeset
243 (define-key menu-map [epa-key-list-import-keys]
94490
dcbaed9de6ff (epa-key-list-mode-map): Add more menu entries.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 94471
diff changeset
244 '(menu-item "Import Keys" epa-import-keys
94471
ecd293096a4b Daiki Ueno <ueno at unixuser.org>
Glenn Morris <rgm@gnu.org>
parents: 94417
diff changeset
245 :help "Import keys from a file"))
ecd293096a4b Daiki Ueno <ueno at unixuser.org>
Glenn Morris <rgm@gnu.org>
parents: 94417
diff changeset
246 (define-key menu-map [epa-key-list-export-keys]
94490
dcbaed9de6ff (epa-key-list-mode-map): Add more menu entries.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 94471
diff changeset
247 '(menu-item "Export Keys" epa-export-keys
94471
ecd293096a4b Daiki Ueno <ueno at unixuser.org>
Glenn Morris <rgm@gnu.org>
parents: 94417
diff changeset
248 :help "Export marked keys to a file"))
91647
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
249 keymap))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
250
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
251 (defvar epa-key-mode-map
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
252 (let ((keymap (make-sparse-keymap)))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
253 (define-key keymap "q" 'epa-exit-buffer)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
254 keymap))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
255
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
256 (defvar epa-info-mode-map
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
257 (let ((keymap (make-sparse-keymap)))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
258 (define-key keymap "q" 'delete-window)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
259 keymap))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
260
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
261 (defvar epa-exit-buffer-function #'bury-buffer)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
262
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
263 (define-widget 'epa-key 'push-button
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
264 "Button for representing a epg-key object."
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
265 :format "%[%v%]"
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
266 :button-face-get 'epa--key-widget-button-face-get
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
267 :value-create 'epa--key-widget-value-create
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
268 :action 'epa--key-widget-action
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
269 :help-echo 'epa--key-widget-help-echo)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
270
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
271 (defun epa--key-widget-action (widget &optional event)
97719
73388588c9b4 (epa--key-widget-action): Save the selected window to
Daiki Ueno <ueno@unixuser.org>
parents: 96760
diff changeset
272 (save-selected-window
73388588c9b4 (epa--key-widget-action): Save the selected window to
Daiki Ueno <ueno@unixuser.org>
parents: 96760
diff changeset
273 (epa--show-key (widget-get widget :value))))
91647
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
274
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
275 (defun epa--key-widget-value-create (widget)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
276 (let* ((key (widget-get widget :value))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
277 (primary-sub-key (car (epg-key-sub-key-list key)))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
278 (primary-user-id (car (epg-key-user-id-list key))))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
279 (insert (format "%c "
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
280 (if (epg-sub-key-validity primary-sub-key)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
281 (car (rassq (epg-sub-key-validity primary-sub-key)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
282 epg-key-validity-alist))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
283 ? ))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
284 (epg-sub-key-id primary-sub-key)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
285 " "
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
286 (if primary-user-id
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
287 (if (stringp (epg-user-id-string primary-user-id))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
288 (epg-user-id-string primary-user-id)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
289 (epg-decode-dn (epg-user-id-string primary-user-id)))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
290 ""))))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
291
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
292 (defun epa--key-widget-button-face-get (widget)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
293 (let ((validity (epg-sub-key-validity (car (epg-key-sub-key-list
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
294 (widget-get widget :value))))))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
295 (if validity
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
296 (cdr (assq validity epa-validity-face-alist))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
297 'default)))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
298
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
299 (defun epa--key-widget-help-echo (widget)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
300 (format "Show %s"
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
301 (epg-sub-key-id (car (epg-key-sub-key-list
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
302 (widget-get widget :value))))))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
303
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
304 (eval-and-compile
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
305 (if (fboundp 'encode-coding-string)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
306 (defalias 'epa--encode-coding-string 'encode-coding-string)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
307 (defalias 'epa--encode-coding-string 'identity)))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
308
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
309 (eval-and-compile
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
310 (if (fboundp 'decode-coding-string)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
311 (defalias 'epa--decode-coding-string 'decode-coding-string)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
312 (defalias 'epa--decode-coding-string 'identity)))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
313
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
314 (defun epa-key-list-mode ()
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
315 "Major mode for `epa-list-keys'."
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
316 (kill-all-local-variables)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
317 (buffer-disable-undo)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
318 (setq major-mode 'epa-key-list-mode
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
319 mode-name "Keys"
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
320 truncate-lines t
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
321 buffer-read-only t)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
322 (use-local-map epa-key-list-mode-map)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
323 (make-local-variable 'font-lock-defaults)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
324 (setq font-lock-defaults '(epa-font-lock-keywords t))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
325 ;; In XEmacs, auto-initialization of font-lock is not effective
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
326 ;; if buffer-file-name is not set.
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
327 (font-lock-set-defaults)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
328 (make-local-variable 'epa-exit-buffer-function)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
329 (make-local-variable 'revert-buffer-function)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
330 (setq revert-buffer-function 'epa--key-list-revert-buffer)
96760
b056a93eb26f (epa-key-list-mode): Use run-mode-hooks.
Daiki Ueno <ueno@unixuser.org>
parents: 94678
diff changeset
331 (run-mode-hooks 'epa-key-list-mode-hook))
91647
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
332
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
333 (defun epa-key-mode ()
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
334 "Major mode for a key description."
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
335 (kill-all-local-variables)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
336 (buffer-disable-undo)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
337 (setq major-mode 'epa-key-mode
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
338 mode-name "Key"
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
339 truncate-lines t
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
340 buffer-read-only t)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
341 (use-local-map epa-key-mode-map)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
342 (make-local-variable 'font-lock-defaults)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
343 (setq font-lock-defaults '(epa-font-lock-keywords t))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
344 ;; In XEmacs, auto-initialization of font-lock is not effective
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
345 ;; if buffer-file-name is not set.
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
346 (font-lock-set-defaults)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
347 (make-local-variable 'epa-exit-buffer-function)
96760
b056a93eb26f (epa-key-list-mode): Use run-mode-hooks.
Daiki Ueno <ueno@unixuser.org>
parents: 94678
diff changeset
348 (run-mode-hooks 'epa-key-mode-hook))
91647
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
349
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
350 (defun epa-info-mode ()
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
351 "Major mode for `epa-info-buffer'."
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
352 (kill-all-local-variables)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
353 (buffer-disable-undo)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
354 (setq major-mode 'epa-info-mode
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
355 mode-name "Info"
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
356 truncate-lines t
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
357 buffer-read-only t)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
358 (use-local-map epa-info-mode-map)
96760
b056a93eb26f (epa-key-list-mode): Use run-mode-hooks.
Daiki Ueno <ueno@unixuser.org>
parents: 94678
diff changeset
359 (run-mode-hooks 'epa-info-mode-hook))
91647
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
360
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
361 (defun epa-mark-key (&optional arg)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
362 "Mark a key on the current line.
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
363 If ARG is non-nil, unmark the key."
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
364 (interactive "P")
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
365 (let ((inhibit-read-only t)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
366 buffer-read-only
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
367 properties)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
368 (beginning-of-line)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
369 (unless (get-text-property (point) 'epa-key)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
370 (error "No key on this line"))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
371 (setq properties (text-properties-at (point)))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
372 (delete-char 1)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
373 (insert (if arg " " "*"))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
374 (set-text-properties (1- (point)) (point) properties)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
375 (forward-line)))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
376
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
377 (defun epa-unmark-key (&optional arg)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
378 "Unmark a key on the current line.
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
379 If ARG is non-nil, mark the key."
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
380 (interactive "P")
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
381 (epa-mark-key (not arg)))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
382
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
383 (defun epa-exit-buffer ()
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
384 "Exit the current buffer.
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
385 `epa-exit-buffer-function' is called if it is set."
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
386 (interactive)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
387 (funcall epa-exit-buffer-function))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
388
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
389 (defun epa--insert-keys (keys)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
390 (save-excursion
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
391 (save-restriction
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
392 (narrow-to-region (point) (point))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
393 (let (point)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
394 (while keys
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
395 (setq point (point))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
396 (insert " ")
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
397 (add-text-properties point (point)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
398 (list 'epa-key (car keys)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
399 'front-sticky nil
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
400 'rear-nonsticky t
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
401 'start-open t
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
402 'end-open t))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
403 (widget-create 'epa-key :value (car keys))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
404 (insert "\n")
91731
7efbdc83b944 EasyPG: Implement some suggestions from emacs-devel.
Michael Olson <mwolson@gnu.org>
parents: 91703
diff changeset
405 (setq keys (cdr keys))))
91647
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
406 (add-text-properties (point-min) (point-max)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
407 (list 'epa-list-keys t
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
408 'front-sticky nil
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
409 'rear-nonsticky t
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
410 'start-open t
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
411 'end-open t)))))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
412
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
413 (defun epa--list-keys (name secret)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
414 (unless (and epa-keys-buffer
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
415 (buffer-live-p epa-keys-buffer))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
416 (setq epa-keys-buffer (generate-new-buffer "*Keys*")))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
417 (set-buffer epa-keys-buffer)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
418 (epa-key-list-mode)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
419 (let ((inhibit-read-only t)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
420 buffer-read-only
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
421 (point (point-min))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
422 (context (epg-make-context epa-protocol)))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
423 (unless (get-text-property point 'epa-list-keys)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
424 (setq point (next-single-property-change point 'epa-list-keys)))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
425 (when point
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
426 (delete-region point
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
427 (or (next-single-property-change point 'epa-list-keys)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
428 (point-max)))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
429 (goto-char point))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
430 (epa--insert-keys (epg-list-keys context name secret))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
431 (widget-setup)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
432 (set-keymap-parent (current-local-map) widget-keymap))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
433 (make-local-variable 'epa-list-keys-arguments)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
434 (setq epa-list-keys-arguments (list name secret))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
435 (goto-char (point-min))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
436 (pop-to-buffer (current-buffer)))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
437
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
438 ;;;###autoload
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
439 (defun epa-list-keys (&optional name)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
440 "List all keys matched with NAME from the public keyring."
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
441 (interactive
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
442 (if current-prefix-arg
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
443 (let ((name (read-string "Pattern: "
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
444 (if epa-list-keys-arguments
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
445 (car epa-list-keys-arguments)))))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
446 (list (if (equal name "") nil name)))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
447 (list nil)))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
448 (epa--list-keys name nil))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
449
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
450 ;;;###autoload
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
451 (defun epa-list-secret-keys (&optional name)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
452 "List all keys matched with NAME from the private keyring."
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
453 (interactive
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
454 (if current-prefix-arg
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
455 (let ((name (read-string "Pattern: "
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
456 (if epa-list-keys-arguments
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
457 (car epa-list-keys-arguments)))))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
458 (list (if (equal name "") nil name)))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
459 (list nil)))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
460 (epa--list-keys name t))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
461
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
462 (defun epa--key-list-revert-buffer (&optional ignore-auto noconfirm)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
463 (apply #'epa--list-keys epa-list-keys-arguments))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
464
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
465 (defun epa--marked-keys ()
105994
009383a57ce8 * x-dnd.el (x-dnd-maybe-call-test-function):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105275
diff changeset
466 (or (with-current-buffer epa-keys-buffer
91647
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
467 (goto-char (point-min))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
468 (let (keys key)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
469 (while (re-search-forward "^\\*" nil t)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
470 (if (setq key (get-text-property (match-beginning 0)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
471 'epa-key))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
472 (setq keys (cons key keys))))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
473 (nreverse keys)))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
474 (save-excursion
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
475 (beginning-of-line)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
476 (let ((key (get-text-property (point) 'epa-key)))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
477 (if key
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
478 (list key))))))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
479
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
480 (defun epa--select-keys (prompt keys)
105994
009383a57ce8 * x-dnd.el (x-dnd-maybe-call-test-function):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105275
diff changeset
481 (unless (and epa-keys-buffer
009383a57ce8 * x-dnd.el (x-dnd-maybe-call-test-function):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105275
diff changeset
482 (buffer-live-p epa-keys-buffer))
009383a57ce8 * x-dnd.el (x-dnd-maybe-call-test-function):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105275
diff changeset
483 (setq epa-keys-buffer (generate-new-buffer "*Keys*")))
009383a57ce8 * x-dnd.el (x-dnd-maybe-call-test-function):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105275
diff changeset
484 (with-current-buffer epa-keys-buffer
91647
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
485 (epa-key-list-mode)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
486 (let ((inhibit-read-only t)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
487 buffer-read-only)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
488 (erase-buffer)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
489 (insert prompt "\n"
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
490 (substitute-command-keys "\
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
491 - `\\[epa-mark-key]' to mark a key on the line
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
492 - `\\[epa-unmark-key]' to unmark a key on the line\n"))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
493 (widget-create 'link
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
494 :notify (lambda (&rest ignore) (abort-recursive-edit))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
495 :help-echo
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
496 (substitute-command-keys
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
497 "Click here or \\[abort-recursive-edit] to cancel")
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
498 "Cancel")
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
499 (widget-create 'link
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
500 :notify (lambda (&rest ignore) (exit-recursive-edit))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
501 :help-echo
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
502 (substitute-command-keys
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
503 "Click here or \\[exit-recursive-edit] to finish")
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
504 "OK")
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
505 (insert "\n\n")
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
506 (epa--insert-keys keys)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
507 (widget-setup)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
508 (set-keymap-parent (current-local-map) widget-keymap)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
509 (setq epa-exit-buffer-function #'abort-recursive-edit)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
510 (goto-char (point-min))
108668
5a957bb32b66 * epa.el (epa--select-keys): Don't explicitly delete the window since
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106815
diff changeset
511 (let ((display-buffer-mark-dedicated 'soft))
5a957bb32b66 * epa.el (epa--select-keys): Don't explicitly delete the window since
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106815
diff changeset
512 (pop-to-buffer (current-buffer))))
91647
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
513 (unwind-protect
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
514 (progn
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
515 (recursive-edit)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
516 (epa--marked-keys))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
517 (kill-buffer epa-keys-buffer))))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
518
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
519 ;;;###autoload
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
520 (defun epa-select-keys (context prompt &optional names secret)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
521 "Display a user's keyring and ask him to select keys.
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
522 CONTEXT is an epg-context.
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
523 PROMPT is a string to prompt with.
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
524 NAMES is a list of strings to be matched with keys. If it is nil, all
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
525 the keys are listed.
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
526 If SECRET is non-nil, list secret keys instead of public keys."
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
527 (let ((keys (epg-list-keys context names secret)))
93506
c895a1d0e007 minor fixes for EasyPG
Michael Olson <mwolson@gnu.org>
parents: 91787
diff changeset
528 (epa--select-keys prompt keys)))
91647
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
529
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
530 (defun epa--show-key (key)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
531 (let* ((primary-sub-key (car (epg-key-sub-key-list key)))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
532 (entry (assoc (epg-sub-key-id primary-sub-key)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
533 epa-key-buffer-alist))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
534 (inhibit-read-only t)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
535 buffer-read-only
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
536 pointer)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
537 (unless entry
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
538 (setq entry (cons (epg-sub-key-id primary-sub-key) nil)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
539 epa-key-buffer-alist (cons entry epa-key-buffer-alist)))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
540 (unless (and (cdr entry)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
541 (buffer-live-p (cdr entry)))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
542 (setcdr entry (generate-new-buffer
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
543 (format "*Key*%s" (epg-sub-key-id primary-sub-key)))))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
544 (set-buffer (cdr entry))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
545 (epa-key-mode)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
546 (make-local-variable 'epa-key)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
547 (setq epa-key key)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
548 (erase-buffer)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
549 (setq pointer (epg-key-user-id-list key))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
550 (while pointer
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
551 (if (car pointer)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
552 (insert " "
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
553 (if (epg-user-id-validity (car pointer))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
554 (char-to-string
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
555 (car (rassq (epg-user-id-validity (car pointer))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
556 epg-key-validity-alist)))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
557 " ")
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
558 " "
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
559 (if (stringp (epg-user-id-string (car pointer)))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
560 (epg-user-id-string (car pointer))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
561 (epg-decode-dn (epg-user-id-string (car pointer))))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
562 "\n"))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
563 (setq pointer (cdr pointer)))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
564 (setq pointer (epg-key-sub-key-list key))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
565 (while pointer
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
566 (insert " "
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
567 (if (epg-sub-key-validity (car pointer))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
568 (char-to-string
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
569 (car (rassq (epg-sub-key-validity (car pointer))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
570 epg-key-validity-alist)))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
571 " ")
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
572 " "
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
573 (epg-sub-key-id (car pointer))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
574 " "
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
575 (format "%dbits"
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
576 (epg-sub-key-length (car pointer)))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
577 " "
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
578 (cdr (assq (epg-sub-key-algorithm (car pointer))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
579 epg-pubkey-algorithm-alist))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
580 "\n\tCreated: "
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
581 (condition-case nil
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
582 (format-time-string "%Y-%m-%d"
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
583 (epg-sub-key-creation-time (car pointer)))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
584 (error "????-??-??"))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
585 (if (epg-sub-key-expiration-time (car pointer))
100175
be17c10d7381 (epa--show-key): Use past tense of "expire" if the key
Daiki Ueno <ueno@unixuser.org>
parents: 97719
diff changeset
586 (format (if (time-less-p (current-time)
be17c10d7381 (epa--show-key): Use past tense of "expire" if the key
Daiki Ueno <ueno@unixuser.org>
parents: 97719
diff changeset
587 (epg-sub-key-expiration-time
be17c10d7381 (epa--show-key): Use past tense of "expire" if the key
Daiki Ueno <ueno@unixuser.org>
parents: 97719
diff changeset
588 (car pointer)))
be17c10d7381 (epa--show-key): Use past tense of "expire" if the key
Daiki Ueno <ueno@unixuser.org>
parents: 97719
diff changeset
589 "\n\tExpires: %s"
be17c10d7381 (epa--show-key): Use past tense of "expire" if the key
Daiki Ueno <ueno@unixuser.org>
parents: 97719
diff changeset
590 "\n\tExpired: %s")
91647
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
591 (condition-case nil
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
592 (format-time-string "%Y-%m-%d"
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
593 (epg-sub-key-expiration-time
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
594 (car pointer)))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
595 (error "????-??-??")))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
596 "")
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
597 "\n\tCapabilities: "
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
598 (mapconcat #'symbol-name
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
599 (epg-sub-key-capability (car pointer))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
600 " ")
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
601 "\n\tFingerprint: "
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
602 (epg-sub-key-fingerprint (car pointer))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
603 "\n")
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
604 (setq pointer (cdr pointer)))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
605 (goto-char (point-min))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
606 (pop-to-buffer (current-buffer))))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
607
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
608 (defun epa-display-info (info)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
609 (if epa-popup-info-window
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
610 (save-selected-window
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
611 (unless (and epa-info-buffer (buffer-live-p epa-info-buffer))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
612 (setq epa-info-buffer (generate-new-buffer "*Info*")))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
613 (if (get-buffer-window epa-info-buffer)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
614 (delete-window (get-buffer-window epa-info-buffer)))
105994
009383a57ce8 * x-dnd.el (x-dnd-maybe-call-test-function):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105275
diff changeset
615 (with-current-buffer epa-info-buffer
91647
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
616 (let ((inhibit-read-only t)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
617 buffer-read-only)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
618 (erase-buffer)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
619 (insert info))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
620 (epa-info-mode)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
621 (goto-char (point-min)))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
622 (if (> (window-height)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
623 epa-info-window-height)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
624 (set-window-buffer (split-window nil (- (window-height)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
625 epa-info-window-height))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
626 epa-info-buffer)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
627 (pop-to-buffer epa-info-buffer)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
628 (if (> (window-height) epa-info-window-height)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
629 (shrink-window (- (window-height) epa-info-window-height)))))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
630 (message "%s" info)))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
631
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
632 (defun epa-display-verify-result (verify-result)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
633 (epa-display-info (epg-verify-result-to-string verify-result)))
104395
df3d3d6c4426 * net/newst-treeview.el (newsticker-groups-filename):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 103324
diff changeset
634 (make-obsolete 'epa-display-verify-result 'epa-display-info "23.1")
91647
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
635
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
636 (defun epa-passphrase-callback-function (context key-id handback)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
637 (if (eq key-id 'SYM)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
638 (read-passwd "Passphrase for symmetric encryption: "
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
639 (eq (epg-context-operation context) 'encrypt))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
640 (read-passwd
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
641 (if (eq key-id 'PIN)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
642 "Passphrase for PIN: "
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
643 (let ((entry (assoc key-id epg-user-id-alist)))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
644 (if entry
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
645 (format "Passphrase for %s %s: " key-id (cdr entry))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
646 (format "Passphrase for %s: " key-id)))))))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
647
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
648 (defun epa-progress-callback-function (context what char current total
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
649 handback)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
650 (message "%s%d%% (%d/%d)" (or handback
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
651 (concat what ": "))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
652 (if (> total 0) (floor (* (/ current (float total)) 100)) 0)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
653 current total))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
654
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
655 ;;;###autoload
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
656 (defun epa-decrypt-file (file)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
657 "Decrypt FILE."
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
658 (interactive "fFile: ")
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
659 (setq file (expand-file-name file))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
660 (let* ((default-name (file-name-sans-extension file))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
661 (plain (expand-file-name
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
662 (read-file-name
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
663 (concat "To file (default "
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
664 (file-name-nondirectory default-name)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
665 ") ")
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
666 (file-name-directory default-name)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
667 default-name)))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
668 (context (epg-make-context epa-protocol)))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
669 (epg-context-set-passphrase-callback context
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
670 #'epa-passphrase-callback-function)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
671 (epg-context-set-progress-callback context
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
672 (cons
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
673 #'epa-progress-callback-function
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
674 (format "Decrypting %s..."
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
675 (file-name-nondirectory file))))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
676 (message "Decrypting %s..." (file-name-nondirectory file))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
677 (epg-decrypt-file context file plain)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
678 (message "Decrypting %s...wrote %s" (file-name-nondirectory file)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
679 (file-name-nondirectory plain))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
680 (if (epg-context-result-for context 'verify)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
681 (epa-display-info (epg-verify-result-to-string
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
682 (epg-context-result-for context 'verify))))))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
683
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
684 ;;;###autoload
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
685 (defun epa-verify-file (file)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
686 "Verify FILE."
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
687 (interactive "fFile: ")
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
688 (setq file (expand-file-name file))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
689 (let* ((context (epg-make-context epa-protocol))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
690 (plain (if (equal (file-name-extension file) "sig")
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
691 (file-name-sans-extension file))))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
692 (epg-context-set-progress-callback context
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
693 (cons
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
694 #'epa-progress-callback-function
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
695 (format "Verifying %s..."
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
696 (file-name-nondirectory file))))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
697 (message "Verifying %s..." (file-name-nondirectory file))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
698 (epg-verify-file context file plain)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
699 (message "Verifying %s...done" (file-name-nondirectory file))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
700 (if (epg-context-result-for context 'verify)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
701 (epa-display-info (epg-verify-result-to-string
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
702 (epg-context-result-for context 'verify))))))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
703
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
704 (defun epa--read-signature-type ()
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
705 (let (type c)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
706 (while (null type)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
707 (message "Signature type (n,c,d,?) ")
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
708 (setq c (read-char))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
709 (cond ((eq c ?c)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
710 (setq type 'clear))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
711 ((eq c ?d)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
712 (setq type 'detached))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
713 ((eq c ??)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
714 (with-output-to-temp-buffer "*Help*"
105994
009383a57ce8 * x-dnd.el (x-dnd-maybe-call-test-function):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105275
diff changeset
715 (with-current-buffer standard-output
91647
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
716 (insert "\
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
717 n - Create a normal signature
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
718 c - Create a cleartext signature
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
719 d - Create a detached signature
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
720 ? - Show this help
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
721 "))))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
722 (t
103138
55823cc572a6 (epa--read-signature-type): Fix typo.
Daiki Ueno <ueno@unixuser.org>
parents: 100908
diff changeset
723 (setq type 'normal))))
55823cc572a6 (epa--read-signature-type): Fix typo.
Daiki Ueno <ueno@unixuser.org>
parents: 100908
diff changeset
724 type))
91647
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
725
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
726 ;;;###autoload
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
727 (defun epa-sign-file (file signers mode)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
728 "Sign FILE by SIGNERS keys selected."
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
729 (interactive
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
730 (let ((verbose current-prefix-arg))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
731 (list (expand-file-name (read-file-name "File: "))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
732 (if verbose
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
733 (epa-select-keys (epg-make-context epa-protocol)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
734 "Select keys for signing.
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
735 If no one is selected, default secret key is used. "
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
736 nil t))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
737 (if verbose
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
738 (epa--read-signature-type)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
739 'clear))))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
740 (let ((signature (concat file
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
741 (if (eq epa-protocol 'OpenPGP)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
742 (if (or epa-armor
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
743 (not (memq mode
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
744 '(nil t normal detached))))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
745 ".asc"
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
746 (if (memq mode '(t detached))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
747 ".sig"
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
748 ".gpg"))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
749 (if (memq mode '(t detached))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
750 ".p7s"
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
751 ".p7m"))))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
752 (context (epg-make-context epa-protocol)))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
753 (epg-context-set-armor context epa-armor)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
754 (epg-context-set-textmode context epa-textmode)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
755 (epg-context-set-signers context signers)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
756 (epg-context-set-passphrase-callback context
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
757 #'epa-passphrase-callback-function)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
758 (epg-context-set-progress-callback context
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
759 (cons
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
760 #'epa-progress-callback-function
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
761 (format "Signing %s..."
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
762 (file-name-nondirectory file))))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
763 (message "Signing %s..." (file-name-nondirectory file))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
764 (epg-sign-file context file signature mode)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
765 (message "Signing %s...wrote %s" (file-name-nondirectory file)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
766 (file-name-nondirectory signature))))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
767
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
768 ;;;###autoload
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
769 (defun epa-encrypt-file (file recipients)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
770 "Encrypt FILE for RECIPIENTS."
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
771 (interactive
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
772 (list (expand-file-name (read-file-name "File: "))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
773 (epa-select-keys (epg-make-context epa-protocol)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
774 "Select recipients for encryption.
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
775 If no one is selected, symmetric encryption will be performed. ")))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
776 (let ((cipher (concat file (if (eq epa-protocol 'OpenPGP)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
777 (if epa-armor ".asc" ".gpg")
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
778 ".p7m")))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
779 (context (epg-make-context epa-protocol)))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
780 (epg-context-set-armor context epa-armor)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
781 (epg-context-set-textmode context epa-textmode)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
782 (epg-context-set-passphrase-callback context
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
783 #'epa-passphrase-callback-function)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
784 (epg-context-set-progress-callback context
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
785 (cons
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
786 #'epa-progress-callback-function
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
787 (format "Encrypting %s..."
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
788 (file-name-nondirectory file))))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
789 (message "Encrypting %s..." (file-name-nondirectory file))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
790 (epg-encrypt-file context file recipients cipher)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
791 (message "Encrypting %s...wrote %s" (file-name-nondirectory file)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
792 (file-name-nondirectory cipher))))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
793
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
794 ;;;###autoload
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
795 (defun epa-decrypt-region (start end)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
796 "Decrypt the current region between START and END.
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
797
93506
c895a1d0e007 minor fixes for EasyPG
Michael Olson <mwolson@gnu.org>
parents: 91787
diff changeset
798 Don't use this command in Lisp programs!
c895a1d0e007 minor fixes for EasyPG
Michael Olson <mwolson@gnu.org>
parents: 91787
diff changeset
799 Since this function operates on regions, it does some tricks such
c895a1d0e007 minor fixes for EasyPG
Michael Olson <mwolson@gnu.org>
parents: 91787
diff changeset
800 as coding-system detection and unibyte/multibyte conversion. If
c895a1d0e007 minor fixes for EasyPG
Michael Olson <mwolson@gnu.org>
parents: 91787
diff changeset
801 you are sure how the data in the region should be treated, you
c895a1d0e007 minor fixes for EasyPG
Michael Olson <mwolson@gnu.org>
parents: 91787
diff changeset
802 should consider using the string based counterpart
c895a1d0e007 minor fixes for EasyPG
Michael Olson <mwolson@gnu.org>
parents: 91787
diff changeset
803 `epg-decrypt-string', or the file based counterpart
c895a1d0e007 minor fixes for EasyPG
Michael Olson <mwolson@gnu.org>
parents: 91787
diff changeset
804 `epg-decrypt-file' instead.
c895a1d0e007 minor fixes for EasyPG
Michael Olson <mwolson@gnu.org>
parents: 91787
diff changeset
805
c895a1d0e007 minor fixes for EasyPG
Michael Olson <mwolson@gnu.org>
parents: 91787
diff changeset
806 For example:
c895a1d0e007 minor fixes for EasyPG
Michael Olson <mwolson@gnu.org>
parents: 91787
diff changeset
807
c895a1d0e007 minor fixes for EasyPG
Michael Olson <mwolson@gnu.org>
parents: 91787
diff changeset
808 \(let ((context (epg-make-context 'OpenPGP)))
c895a1d0e007 minor fixes for EasyPG
Michael Olson <mwolson@gnu.org>
parents: 91787
diff changeset
809 (decode-coding-string
c895a1d0e007 minor fixes for EasyPG
Michael Olson <mwolson@gnu.org>
parents: 91787
diff changeset
810 (epg-decrypt-string context (buffer-substring start end))
c895a1d0e007 minor fixes for EasyPG
Michael Olson <mwolson@gnu.org>
parents: 91787
diff changeset
811 'utf-8))"
91647
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
812 (interactive "r")
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
813 (save-excursion
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
814 (let ((context (epg-make-context epa-protocol))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
815 plain)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
816 (epg-context-set-passphrase-callback context
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
817 #'epa-passphrase-callback-function)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
818 (epg-context-set-progress-callback context
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
819 (cons
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
820 #'epa-progress-callback-function
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
821 "Decrypting..."))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
822 (message "Decrypting...")
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
823 (setq plain (epg-decrypt-string context (buffer-substring start end)))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
824 (message "Decrypting...done")
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
825 (setq plain (epa--decode-coding-string
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
826 plain
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
827 (or coding-system-for-read
103324
6f4c24703dac (epa-decrypt-region): Detect encoding if
Daiki Ueno <ueno@unixuser.org>
parents: 103138
diff changeset
828 (get-text-property start 'epa-coding-system-used)
6f4c24703dac (epa-decrypt-region): Detect encoding if
Daiki Ueno <ueno@unixuser.org>
parents: 103138
diff changeset
829 'undecided)))
91647
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
830 (if (y-or-n-p "Replace the original text? ")
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
831 (let ((inhibit-read-only t)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
832 buffer-read-only)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
833 (delete-region start end)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
834 (goto-char start)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
835 (insert plain))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
836 (with-output-to-temp-buffer "*Temp*"
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
837 (set-buffer standard-output)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
838 (insert plain)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
839 (epa-info-mode)))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
840 (if (epg-context-result-for context 'verify)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
841 (epa-display-info (epg-verify-result-to-string
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
842 (epg-context-result-for context 'verify)))))))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
843
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
844 (defun epa--find-coding-system-for-mime-charset (mime-charset)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
845 (if (featurep 'xemacs)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
846 (if (fboundp 'find-coding-system)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
847 (find-coding-system mime-charset))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
848 (let ((pointer (coding-system-list)))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
849 (while (and pointer
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
850 (eq (coding-system-get (car pointer) 'mime-charset)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
851 mime-charset))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
852 (setq pointer (cdr pointer)))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
853 pointer)))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
854
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
855 ;;;###autoload
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
856 (defun epa-decrypt-armor-in-region (start end)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
857 "Decrypt OpenPGP armors in the current region between START and END.
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
858
93506
c895a1d0e007 minor fixes for EasyPG
Michael Olson <mwolson@gnu.org>
parents: 91787
diff changeset
859 Don't use this command in Lisp programs!
c895a1d0e007 minor fixes for EasyPG
Michael Olson <mwolson@gnu.org>
parents: 91787
diff changeset
860 See the reason described in the `epa-decrypt-region' documentation."
91647
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
861 (interactive "r")
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
862 (save-excursion
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
863 (save-restriction
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
864 (narrow-to-region start end)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
865 (goto-char start)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
866 (let (armor-start armor-end)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
867 (while (re-search-forward "-----BEGIN PGP MESSAGE-----$" nil t)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
868 (setq armor-start (match-beginning 0)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
869 armor-end (re-search-forward "^-----END PGP MESSAGE-----$"
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
870 nil t))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
871 (unless armor-end
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
872 (error "No armor tail"))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
873 (goto-char armor-start)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
874 (let ((coding-system-for-read
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
875 (or coding-system-for-read
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
876 (if (re-search-forward "^Charset: \\(.*\\)" armor-end t)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
877 (epa--find-coding-system-for-mime-charset
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
878 (intern (downcase (match-string 1))))))))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
879 (goto-char armor-end)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
880 (epa-decrypt-region armor-start armor-end)))))))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
881
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
882 ;;;###autoload
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
883 (defun epa-verify-region (start end)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
884 "Verify the current region between START and END.
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
885
93506
c895a1d0e007 minor fixes for EasyPG
Michael Olson <mwolson@gnu.org>
parents: 91787
diff changeset
886 Don't use this command in Lisp programs!
c895a1d0e007 minor fixes for EasyPG
Michael Olson <mwolson@gnu.org>
parents: 91787
diff changeset
887 Since this function operates on regions, it does some tricks such
c895a1d0e007 minor fixes for EasyPG
Michael Olson <mwolson@gnu.org>
parents: 91787
diff changeset
888 as coding-system detection and unibyte/multibyte conversion. If
c895a1d0e007 minor fixes for EasyPG
Michael Olson <mwolson@gnu.org>
parents: 91787
diff changeset
889 you are sure how the data in the region should be treated, you
c895a1d0e007 minor fixes for EasyPG
Michael Olson <mwolson@gnu.org>
parents: 91787
diff changeset
890 should consider using the string based counterpart
c895a1d0e007 minor fixes for EasyPG
Michael Olson <mwolson@gnu.org>
parents: 91787
diff changeset
891 `epg-verify-string', or the file based counterpart
c895a1d0e007 minor fixes for EasyPG
Michael Olson <mwolson@gnu.org>
parents: 91787
diff changeset
892 `epg-verify-file' instead.
c895a1d0e007 minor fixes for EasyPG
Michael Olson <mwolson@gnu.org>
parents: 91787
diff changeset
893
c895a1d0e007 minor fixes for EasyPG
Michael Olson <mwolson@gnu.org>
parents: 91787
diff changeset
894 For example:
c895a1d0e007 minor fixes for EasyPG
Michael Olson <mwolson@gnu.org>
parents: 91787
diff changeset
895
c895a1d0e007 minor fixes for EasyPG
Michael Olson <mwolson@gnu.org>
parents: 91787
diff changeset
896 \(let ((context (epg-make-context 'OpenPGP)))
c895a1d0e007 minor fixes for EasyPG
Michael Olson <mwolson@gnu.org>
parents: 91787
diff changeset
897 (decode-coding-string
c895a1d0e007 minor fixes for EasyPG
Michael Olson <mwolson@gnu.org>
parents: 91787
diff changeset
898 (epg-verify-string context (buffer-substring start end))
c895a1d0e007 minor fixes for EasyPG
Michael Olson <mwolson@gnu.org>
parents: 91787
diff changeset
899 'utf-8))"
91647
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
900 (interactive "r")
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
901 (let ((context (epg-make-context epa-protocol))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
902 plain)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
903 (epg-context-set-progress-callback context
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
904 (cons
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
905 #'epa-progress-callback-function
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
906 "Verifying..."))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
907 (message "Verifying...")
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
908 (setq plain (epg-verify-string
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
909 context
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
910 (epa--encode-coding-string
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
911 (buffer-substring start end)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
912 (or coding-system-for-write
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
913 (get-text-property start 'epa-coding-system-used)))))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
914 (message "Verifying...done")
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
915 (setq plain (epa--decode-coding-string
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
916 plain
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
917 (or coding-system-for-read
103324
6f4c24703dac (epa-decrypt-region): Detect encoding if
Daiki Ueno <ueno@unixuser.org>
parents: 103138
diff changeset
918 (get-text-property start 'epa-coding-system-used)
6f4c24703dac (epa-decrypt-region): Detect encoding if
Daiki Ueno <ueno@unixuser.org>
parents: 103138
diff changeset
919 'undecided)))
91647
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
920 (if (y-or-n-p "Replace the original text? ")
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
921 (let ((inhibit-read-only t)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
922 buffer-read-only)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
923 (delete-region start end)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
924 (goto-char start)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
925 (insert plain))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
926 (with-output-to-temp-buffer "*Temp*"
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
927 (set-buffer standard-output)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
928 (insert plain)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
929 (epa-info-mode)))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
930 (if (epg-context-result-for context 'verify)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
931 (epa-display-info (epg-verify-result-to-string
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
932 (epg-context-result-for context 'verify))))))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
933
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
934 ;;;###autoload
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
935 (defun epa-verify-cleartext-in-region (start end)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
936 "Verify OpenPGP cleartext signed messages in the current region
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
937 between START and END.
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
938
93506
c895a1d0e007 minor fixes for EasyPG
Michael Olson <mwolson@gnu.org>
parents: 91787
diff changeset
939 Don't use this command in Lisp programs!
c895a1d0e007 minor fixes for EasyPG
Michael Olson <mwolson@gnu.org>
parents: 91787
diff changeset
940 See the reason described in the `epa-verify-region' documentation."
91647
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
941 (interactive "r")
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
942 (save-excursion
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
943 (save-restriction
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
944 (narrow-to-region start end)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
945 (goto-char start)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
946 (let (cleartext-start cleartext-end)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
947 (while (re-search-forward "-----BEGIN PGP SIGNED MESSAGE-----$"
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
948 nil t)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
949 (setq cleartext-start (match-beginning 0))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
950 (unless (re-search-forward "^-----BEGIN PGP SIGNATURE-----$"
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
951 nil t)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
952 (error "Invalid cleartext signed message"))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
953 (setq cleartext-end (re-search-forward
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
954 "^-----END PGP SIGNATURE-----$"
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
955 nil t))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
956 (unless cleartext-end
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
957 (error "No cleartext tail"))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
958 (epa-verify-region cleartext-start cleartext-end))))))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
959
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
960 (eval-and-compile
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
961 (if (fboundp 'select-safe-coding-system)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
962 (defalias 'epa--select-safe-coding-system 'select-safe-coding-system)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
963 (defun epa--select-safe-coding-system (from to)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
964 buffer-file-coding-system)))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
965
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
966 ;;;###autoload
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
967 (defun epa-sign-region (start end signers mode)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
968 "Sign the current region between START and END by SIGNERS keys selected.
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
969
93506
c895a1d0e007 minor fixes for EasyPG
Michael Olson <mwolson@gnu.org>
parents: 91787
diff changeset
970 Don't use this command in Lisp programs!
c895a1d0e007 minor fixes for EasyPG
Michael Olson <mwolson@gnu.org>
parents: 91787
diff changeset
971 Since this function operates on regions, it does some tricks such
c895a1d0e007 minor fixes for EasyPG
Michael Olson <mwolson@gnu.org>
parents: 91787
diff changeset
972 as coding-system detection and unibyte/multibyte conversion. If
c895a1d0e007 minor fixes for EasyPG
Michael Olson <mwolson@gnu.org>
parents: 91787
diff changeset
973 you are sure how the data should be treated, you should consider
c895a1d0e007 minor fixes for EasyPG
Michael Olson <mwolson@gnu.org>
parents: 91787
diff changeset
974 using the string based counterpart `epg-sign-string', or the file
c895a1d0e007 minor fixes for EasyPG
Michael Olson <mwolson@gnu.org>
parents: 91787
diff changeset
975 based counterpart `epg-sign-file' instead.
c895a1d0e007 minor fixes for EasyPG
Michael Olson <mwolson@gnu.org>
parents: 91787
diff changeset
976
c895a1d0e007 minor fixes for EasyPG
Michael Olson <mwolson@gnu.org>
parents: 91787
diff changeset
977 For example:
c895a1d0e007 minor fixes for EasyPG
Michael Olson <mwolson@gnu.org>
parents: 91787
diff changeset
978
c895a1d0e007 minor fixes for EasyPG
Michael Olson <mwolson@gnu.org>
parents: 91787
diff changeset
979 \(let ((context (epg-make-context 'OpenPGP)))
c895a1d0e007 minor fixes for EasyPG
Michael Olson <mwolson@gnu.org>
parents: 91787
diff changeset
980 (epg-sign-string
c895a1d0e007 minor fixes for EasyPG
Michael Olson <mwolson@gnu.org>
parents: 91787
diff changeset
981 context
c895a1d0e007 minor fixes for EasyPG
Michael Olson <mwolson@gnu.org>
parents: 91787
diff changeset
982 (encode-coding-string (buffer-substring start end) 'utf-8)))"
91647
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
983 (interactive
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
984 (let ((verbose current-prefix-arg))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
985 (setq epa-last-coding-system-specified
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
986 (or coding-system-for-write
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
987 (epa--select-safe-coding-system
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
988 (region-beginning) (region-end))))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
989 (list (region-beginning) (region-end)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
990 (if verbose
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
991 (epa-select-keys (epg-make-context epa-protocol)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
992 "Select keys for signing.
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
993 If no one is selected, default secret key is used. "
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
994 nil t))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
995 (if verbose
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
996 (epa--read-signature-type)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
997 'clear))))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
998 (save-excursion
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
999 (let ((context (epg-make-context epa-protocol))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1000 signature)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1001 ;;(epg-context-set-armor context epa-armor)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1002 (epg-context-set-armor context t)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1003 ;;(epg-context-set-textmode context epa-textmode)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1004 (epg-context-set-textmode context t)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1005 (epg-context-set-signers context signers)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1006 (epg-context-set-passphrase-callback context
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1007 #'epa-passphrase-callback-function)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1008 (epg-context-set-progress-callback context
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1009 (cons
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1010 #'epa-progress-callback-function
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1011 "Signing..."))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1012 (message "Signing...")
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1013 (setq signature (epg-sign-string context
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1014 (epa--encode-coding-string
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1015 (buffer-substring start end)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1016 epa-last-coding-system-specified)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1017 mode))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1018 (message "Signing...done")
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1019 (delete-region start end)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1020 (goto-char start)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1021 (add-text-properties (point)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1022 (progn
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1023 (insert (epa--decode-coding-string
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1024 signature
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1025 (or coding-system-for-read
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1026 epa-last-coding-system-specified)))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1027 (point))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1028 (list 'epa-coding-system-used
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1029 epa-last-coding-system-specified
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1030 'front-sticky nil
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1031 'rear-nonsticky t
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1032 'start-open t
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1033 'end-open t)))))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1034
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1035 (eval-and-compile
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1036 (if (fboundp 'derived-mode-p)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1037 (defalias 'epa--derived-mode-p 'derived-mode-p)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1038 (defun epa--derived-mode-p (&rest modes)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1039 "Non-nil if the current major mode is derived from one of MODES.
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1040 Uses the `derived-mode-parent' property of the symbol to trace backwards."
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1041 (let ((parent major-mode))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1042 (while (and (not (memq parent modes))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1043 (setq parent (get parent 'derived-mode-parent))))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1044 parent))))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1045
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1046 ;;;###autoload
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1047 (defun epa-encrypt-region (start end recipients sign signers)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1048 "Encrypt the current region between START and END for RECIPIENTS.
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1049
93506
c895a1d0e007 minor fixes for EasyPG
Michael Olson <mwolson@gnu.org>
parents: 91787
diff changeset
1050 Don't use this command in Lisp programs!
c895a1d0e007 minor fixes for EasyPG
Michael Olson <mwolson@gnu.org>
parents: 91787
diff changeset
1051 Since this function operates on regions, it does some tricks such
c895a1d0e007 minor fixes for EasyPG
Michael Olson <mwolson@gnu.org>
parents: 91787
diff changeset
1052 as coding-system detection and unibyte/multibyte conversion. If
c895a1d0e007 minor fixes for EasyPG
Michael Olson <mwolson@gnu.org>
parents: 91787
diff changeset
1053 you are sure how the data should be treated, you should consider
c895a1d0e007 minor fixes for EasyPG
Michael Olson <mwolson@gnu.org>
parents: 91787
diff changeset
1054 using the string based counterpart `epg-encrypt-string', or the
c895a1d0e007 minor fixes for EasyPG
Michael Olson <mwolson@gnu.org>
parents: 91787
diff changeset
1055 file based counterpart `epg-encrypt-file' instead.
c895a1d0e007 minor fixes for EasyPG
Michael Olson <mwolson@gnu.org>
parents: 91787
diff changeset
1056
c895a1d0e007 minor fixes for EasyPG
Michael Olson <mwolson@gnu.org>
parents: 91787
diff changeset
1057 For example:
c895a1d0e007 minor fixes for EasyPG
Michael Olson <mwolson@gnu.org>
parents: 91787
diff changeset
1058
c895a1d0e007 minor fixes for EasyPG
Michael Olson <mwolson@gnu.org>
parents: 91787
diff changeset
1059 \(let ((context (epg-make-context 'OpenPGP)))
c895a1d0e007 minor fixes for EasyPG
Michael Olson <mwolson@gnu.org>
parents: 91787
diff changeset
1060 (epg-encrypt-string
c895a1d0e007 minor fixes for EasyPG
Michael Olson <mwolson@gnu.org>
parents: 91787
diff changeset
1061 context
c895a1d0e007 minor fixes for EasyPG
Michael Olson <mwolson@gnu.org>
parents: 91787
diff changeset
1062 (encode-coding-string (buffer-substring start end) 'utf-8)
c895a1d0e007 minor fixes for EasyPG
Michael Olson <mwolson@gnu.org>
parents: 91787
diff changeset
1063 nil))"
91647
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1064 (interactive
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1065 (let ((verbose current-prefix-arg)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1066 (context (epg-make-context epa-protocol))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1067 sign)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1068 (setq epa-last-coding-system-specified
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1069 (or coding-system-for-write
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1070 (epa--select-safe-coding-system
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1071 (region-beginning) (region-end))))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1072 (list (region-beginning) (region-end)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1073 (epa-select-keys context
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1074 "Select recipients for encryption.
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1075 If no one is selected, symmetric encryption will be performed. ")
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1076 (setq sign (if verbose (y-or-n-p "Sign? ")))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1077 (if sign
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1078 (epa-select-keys context
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1079 "Select keys for signing. ")))))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1080 (save-excursion
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1081 (let ((context (epg-make-context epa-protocol))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1082 cipher)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1083 ;;(epg-context-set-armor context epa-armor)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1084 (epg-context-set-armor context t)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1085 ;;(epg-context-set-textmode context epa-textmode)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1086 (epg-context-set-textmode context t)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1087 (if sign
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1088 (epg-context-set-signers context signers))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1089 (epg-context-set-passphrase-callback context
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1090 #'epa-passphrase-callback-function)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1091 (epg-context-set-progress-callback context
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1092 (cons
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1093 #'epa-progress-callback-function
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1094 "Encrypting..."))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1095 (message "Encrypting...")
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1096 (setq cipher (epg-encrypt-string context
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1097 (epa--encode-coding-string
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1098 (buffer-substring start end)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1099 epa-last-coding-system-specified)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1100 recipients
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1101 sign))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1102 (message "Encrypting...done")
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1103 (delete-region start end)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1104 (goto-char start)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1105 (add-text-properties (point)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1106 (progn
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1107 (insert cipher)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1108 (point))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1109 (list 'epa-coding-system-used
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1110 epa-last-coding-system-specified
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1111 'front-sticky nil
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1112 'rear-nonsticky t
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1113 'start-open t
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1114 'end-open t)))))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1115
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1116 ;;;###autoload
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1117 (defun epa-delete-keys (keys &optional allow-secret)
93506
c895a1d0e007 minor fixes for EasyPG
Michael Olson <mwolson@gnu.org>
parents: 91787
diff changeset
1118 "Delete selected KEYS."
91647
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1119 (interactive
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1120 (let ((keys (epa--marked-keys)))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1121 (unless keys
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1122 (error "No keys selected"))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1123 (list keys
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1124 (eq (nth 1 epa-list-keys-arguments) t))))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1125 (let ((context (epg-make-context epa-protocol)))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1126 (message "Deleting...")
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1127 (epg-delete-keys context keys allow-secret)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1128 (message "Deleting...done")
94471
ecd293096a4b Daiki Ueno <ueno at unixuser.org>
Glenn Morris <rgm@gnu.org>
parents: 94417
diff changeset
1129 (apply #'epa--list-keys epa-list-keys-arguments)))
91647
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1130
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1131 ;;;###autoload
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1132 (defun epa-import-keys (file)
93506
c895a1d0e007 minor fixes for EasyPG
Michael Olson <mwolson@gnu.org>
parents: 91787
diff changeset
1133 "Import keys from FILE."
91647
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1134 (interactive "fFile: ")
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1135 (setq file (expand-file-name file))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1136 (let ((context (epg-make-context epa-protocol)))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1137 (message "Importing %s..." (file-name-nondirectory file))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1138 (condition-case nil
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1139 (progn
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1140 (epg-import-keys-from-file context file)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1141 (message "Importing %s...done" (file-name-nondirectory file)))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1142 (error
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1143 (message "Importing %s...failed" (file-name-nondirectory file))))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1144 (if (epg-context-result-for context 'import)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1145 (epa-display-info (epg-import-result-to-string
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1146 (epg-context-result-for context 'import))))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1147 (if (eq major-mode 'epa-key-list-mode)
94471
ecd293096a4b Daiki Ueno <ueno at unixuser.org>
Glenn Morris <rgm@gnu.org>
parents: 94417
diff changeset
1148 (apply #'epa--list-keys epa-list-keys-arguments))))
91647
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1149
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1150 ;;;###autoload
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1151 (defun epa-import-keys-region (start end)
93506
c895a1d0e007 minor fixes for EasyPG
Michael Olson <mwolson@gnu.org>
parents: 91787
diff changeset
1152 "Import keys from the region."
91647
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1153 (interactive "r")
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1154 (let ((context (epg-make-context epa-protocol)))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1155 (message "Importing...")
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1156 (condition-case nil
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1157 (progn
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1158 (epg-import-keys-from-string context (buffer-substring start end))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1159 (message "Importing...done"))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1160 (error
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1161 (message "Importing...failed")))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1162 (if (epg-context-result-for context 'import)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1163 (epa-display-info (epg-import-result-to-string
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1164 (epg-context-result-for context 'import))))))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1165
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1166 ;;;###autoload
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1167 (defun epa-import-armor-in-region (start end)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1168 "Import keys in the OpenPGP armor format in the current region
93506
c895a1d0e007 minor fixes for EasyPG
Michael Olson <mwolson@gnu.org>
parents: 91787
diff changeset
1169 between START and END."
91647
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1170 (interactive "r")
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1171 (save-excursion
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1172 (save-restriction
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1173 (narrow-to-region start end)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1174 (goto-char start)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1175 (let (armor-start armor-end)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1176 (while (re-search-forward
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1177 "-----BEGIN \\(PGP \\(PUBLIC\\|PRIVATE\\) KEY BLOCK\\)-----$"
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1178 nil t)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1179 (setq armor-start (match-beginning 0)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1180 armor-end (re-search-forward
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1181 (concat "^-----END " (match-string 1) "-----$")
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1182 nil t))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1183 (unless armor-end
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1184 (error "No armor tail"))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1185 (epa-import-keys-region armor-start armor-end))))))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1186
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1187 ;;;###autoload
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1188 (defun epa-export-keys (keys file)
93506
c895a1d0e007 minor fixes for EasyPG
Michael Olson <mwolson@gnu.org>
parents: 91787
diff changeset
1189 "Export selected KEYS to FILE."
91647
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1190 (interactive
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1191 (let ((keys (epa--marked-keys))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1192 default-name)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1193 (unless keys
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1194 (error "No keys selected"))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1195 (setq default-name
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1196 (expand-file-name
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1197 (concat (epg-sub-key-id (car (epg-key-sub-key-list (car keys))))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1198 (if epa-armor ".asc" ".gpg"))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1199 default-directory))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1200 (list keys
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1201 (expand-file-name
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1202 (read-file-name
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1203 (concat "To file (default "
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1204 (file-name-nondirectory default-name)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1205 ") ")
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1206 (file-name-directory default-name)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1207 default-name)))))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1208 (let ((context (epg-make-context epa-protocol)))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1209 (epg-context-set-armor context epa-armor)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1210 (message "Exporting to %s..." (file-name-nondirectory file))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1211 (epg-export-keys-to-file context keys file)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1212 (message "Exporting to %s...done" (file-name-nondirectory file))))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1213
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1214 ;;;###autoload
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1215 (defun epa-insert-keys (keys)
93506
c895a1d0e007 minor fixes for EasyPG
Michael Olson <mwolson@gnu.org>
parents: 91787
diff changeset
1216 "Insert selected KEYS after the point."
91647
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1217 (interactive
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1218 (list (epa-select-keys (epg-make-context epa-protocol)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1219 "Select keys to export. ")))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1220 (let ((context (epg-make-context epa-protocol)))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1221 ;;(epg-context-set-armor context epa-armor)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1222 (epg-context-set-armor context t)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1223 (insert (epg-export-keys-to-string context keys))))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1224
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1225 ;; (defun epa-sign-keys (keys &optional local)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1226 ;; "Sign selected KEYS.
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1227 ;; If a prefix-arg is specified, the signature is marked as non exportable.
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1228
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1229 ;; Don't use this command in Lisp programs!"
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1230 ;; (interactive
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1231 ;; (let ((keys (epa--marked-keys)))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1232 ;; (unless keys
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1233 ;; (error "No keys selected"))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1234 ;; (list keys current-prefix-arg)))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1235 ;; (let ((context (epg-make-context epa-protocol)))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1236 ;; (epg-context-set-passphrase-callback context
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1237 ;; #'epa-passphrase-callback-function)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1238 ;; (epg-context-set-progress-callback context
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1239 ;; (cons
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1240 ;; #'epa-progress-callback-function
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1241 ;; "Signing keys..."))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1242 ;; (message "Signing keys...")
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1243 ;; (epg-sign-keys context keys local)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1244 ;; (message "Signing keys...done")))
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1245 ;; (make-obsolete 'epa-sign-keys "Do not use.")
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1246
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1247 (provide 'epa)
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1248
91687
d125b90283d2 Add arch tagline
Miles Bader <miles@gnu.org>
parents: 91647
diff changeset
1249 ;; arch-tag: 38d20ced-20d5-4137-b17a-f206335423d7
91647
f9692dfe86e7 EasyPG: Initial check-in.
Michael Olson <mwolson@gnu.org>
parents:
diff changeset
1250 ;;; epa.el ends here