mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-11-21 06:55:39 +00:00
8903106bb7
* lisp/subr.el (if-let*, when-let*, if-let, when-let): Mark if-let and when-let obsolete (bug#73853 and elsewhere). Move docstring text around so that if-let* and when-let* descriptions no longer refer to if-let and when-let. * etc/NEWS: Announce the change. * admin/admin.el (reminder-for-release-blocking-bugs): * doc/misc/erc.texi (display-buffer): * lisp/ansi-color.el (ansi-color-apply) (ansi-color--face-vec-face): * lisp/ansi-osc.el (ansi-osc-apply-on-region) (ansi-osc-hyperlink): * lisp/arc-mode.el (archive-goto-file) (archive-next-file-displayer): * lisp/auth-source-pass.el (auth-source-pass-search) (auth-source-pass--parse-data) (auth-source-pass--find-match-many): * lisp/autorevert.el (auto-revert-notify-rm-watch): * lisp/buff-menu.el (Buffer-menu-unmark-all-buffers) (Buffer-menu-group-by-root): * lisp/calendar/parse-time.el (parse-iso8601-time-string): * lisp/cedet/pulse.el (pulse-tick): * lisp/comint.el (comint--fontify-input-ppss-flush-indirect) (comint--intersect-regions): * lisp/completion-preview.el (completion-preview--try-table) (completion-preview--capf-wrapper, completion-preview--update): * lisp/cus-edit.el (setopt--set) (custom-dirlocals-maybe-update-cons, custom-dirlocals-validate): * lisp/custom.el (load-theme): * lisp/descr-text.el (describe-char): * lisp/desktop.el (desktop--emacs-pid-running-p): * lisp/dired-x.el (menu): * lisp/dired.el (dired-font-lock-keywords) (dired-insert-directory, dired--insert-disk-space, dired-mode): * lisp/dnd.el (dnd-handle-multiple-urls): * lisp/dom.el (dom-remove-attribute): * lisp/emacs-lisp/byte-opt.el (byte-optimize-form-code-walker): * lisp/emacs-lisp/bytecomp.el (bytecomp--custom-declare): * lisp/emacs-lisp/comp-common.el (comp-function-type-spec): * lisp/emacs-lisp/comp-cstr.el (comp--all-classes) (comp-cstr-set-range-for-arithm, comp--cstr-union-1-no-mem) (comp-cstr-intersection-no-mem, comp-cstr-fixnum-p) (comp-cstr-type-p): * lisp/emacs-lisp/comp-run.el (comp-subr-trampoline-install) (native--compile-async): * lisp/emacs-lisp/comp.el (comp--get-function-cstr) (comp--function-pure-p, comp--intern-func-in-ctxt) (comp--addr-to-bb-name, comp--emit-assume, comp--maybe-add-vmvar) (comp--add-call-cstr, comp--compute-dominator-tree) (comp--dom-tree-walker, comp--ssa-rename) (comp--function-call-maybe-fold, comp--fwprop-call) (comp--call-optim-func): * lisp/emacs-lisp/edebug.el (edebug-global-prefix) (edebug-remove-instrumentation): * lisp/emacs-lisp/eieio.el (initialize-instance): * lisp/emacs-lisp/ert-x.el (ert-resource-directory): * lisp/emacs-lisp/ert.el (ert--expand-should-1) (ert-test-location, ert-write-junit-test-report) (ert-test--erts-test): * lisp/emacs-lisp/icons.el (icon-complete-spec, icon-string) (icons--create): * lisp/emacs-lisp/lisp-mode.el (lisp--local-defform-body-p): * lisp/emacs-lisp/loaddefs-gen.el (loaddefs-generate--make-autoload) (loaddefs-generate--parse-file): * lisp/emacs-lisp/multisession.el (multisession-edit-mode--revert, multisession-edit-value): * lisp/emacs-lisp/package-vc.el (package-vc--read-archive-data) (package-vc--version, package-vc--clone): * lisp/emacs-lisp/package.el (package--reload-previously-loaded): * lisp/emacs-lisp/pp.el (pp--insert-lisp): * lisp/emacs-lisp/subr-x.el (add-display-text-property): * lisp/emacs-lisp/tabulated-list.el (tabulated-list-print): * lisp/emacs-lisp/timer.el (run-at-time): * lisp/emacs-lisp/vtable.el (vtable-goto-table) (vtable-goto-column, vtable-update-object, vtable--insert-line) (vtable--compute-widths, vtable--make-keymap): * lisp/emacs-lisp/warnings.el (display-warning): * lisp/epa-file.el (epa-file-insert-file-contents): * lisp/epa.el (epa-show-key): * lisp/erc/erc-backend.el (erc--split-line, erc--conceal-prompt) (PRIVMSG, erc--get-isupport-entry): * lisp/erc/erc-button.el (erc-button-add-nickname-buttons) (erc--button-next): * lisp/erc/erc-common.el (erc--find-group): * lisp/erc/erc-fill.el (erc-fill, erc-fill-static) (erc-fill--wrap-escape-hidden-speaker) (erc-fill--wrap-unmerge-on-date-stamp) (erc-fill--wrap-massage-initial-message-post-clear) (erc-fill-wrap, erc-fill--wrap-rejigger-region): * lisp/erc/erc-goodies.el (erc--scrolltobottom-all) (erc--keep-place-indicator-on-window-buffer-change) (keep-place-indicator, erc--keep-place-indicator-adjust-on-clear) (erc-keep-place-move, erc--command-indicator-display): * lisp/erc/erc-ibuffer.el (erc-members): * lisp/erc/erc-join.el (erc-join--remove-requested-channel) (erc-autojoin--join): * lisp/erc/erc-networks.el (erc-networks--id-qualifying-init-parts, erc-networks--id-reload) (erc-networks--id-ensure-comparable) (erc-networks--reclaim-orphaned-target-buffers) (erc-networks--server-select): * lisp/erc/erc-nicks.el (erc-nicks-invert) (erc-nicks--redirect-face-widget-link, erc-nicks--highlight) (erc-nicks--highlight-button) (erc-nicks--list-faces-help-button-action, erc-nicks-list-faces) (erc-nicks-refresh, erc-nicks--colors-from-faces) (erc-nicks--track-prioritize) (erc-nicks--remember-face-for-track): * lisp/erc/erc-notify.el (querypoll, erc--querypoll-get-next) (erc--querypoll-on-352, erc--querypoll-send): * lisp/erc/erc-sasl.el (erc-sasl--read-password): * lisp/erc/erc-services.el (erc-services-issue-ghost-and-retry-nick): * lisp/erc/erc-speedbar.el (erc-speedbar--ensure, nickbar) (erc-speedbar-toggle-nicknames-window-lock) (erc-speedbar--compose-nicks-face): * lisp/erc/erc-stamp.el (erc-stamp--recover-on-reconnect) (erc-stamp-prefix-log-filter, erc--conceal-prompt) (erc--insert-timestamp-left, erc-insert-timestamp-right) (erc-stamp--defer-date-insertion-on-post-modify) (erc-insert-timestamp-left-and-right) (erc-stamp--redo-right-stamp-post-clear) (erc-stamp--reset-on-clear, erc-stamp--dedupe-date-stamps): * lisp/erc/erc-status-sidebar.el (bufbar) (erc-status-sidebar-prefer-target-as-name) (erc-status-sidebar-default-allsort, erc-status-sidebar-click): * lisp/erc/erc-track.el (erc-track--shortened-names-get) (erc-track--setup, erc-track--select-mode-line-face) (erc-track-modified-channels, erc-track--collect-faces-in) (erc-track--switch-buffer, erc-track--replace-killed-buffer): * lisp/erc/erc-truncate.el (erc-truncate--setup) (erc-truncate-buffer): * lisp/erc/erc.el (erc--ensure-query-member) (erc--ensure-query-members, erc--remove-channel-users-but) (erc--cusr-change-status, erc--find-mode, erc--update-modules) (erc-log-irc-protocol, erc--refresh-prompt) (erc--restore-important-text-props) (erc--order-text-properties-from-hash, erc-send-input-line) (erc-cmd-IGNORE, erc--unignore-user, erc-cmd-QUERY) (erc-cmd-BANLIST, erc--speakerize-nick) (erc--format-speaker-input-message, erc-channel-receive-names) (erc-send-current-line, erc-format-target-and/or-network) (erc-kill-buffer-function, erc-restore-text-properties) (erc--get-eq-comparable-cmd): * lisp/eshell/em-alias.el (eshell-maybe-replace-by-alias--which) (eshell-maybe-replace-by-alias): * lisp/eshell/em-glob.el (eshell-glob-convert): * lisp/eshell/em-pred.el (eshell-pred-user-or-group) (eshell-pred-file-time, eshell-pred-file-type) (eshell-pred-file-mode, eshell-pred-file-links) (eshell-pred-file-size): * lisp/eshell/em-prompt.el (eshell-forward-paragraph) (eshell-next-prompt): * lisp/eshell/esh-arg.el (eshell-resolve-current-argument): * lisp/eshell/esh-cmd.el (eshell-do-eval, eshell/which) (eshell-plain-command--which, eshell-plain-command): * lisp/eshell/esh-io.el (eshell-duplicate-handles) (eshell-protect-handles, eshell-get-target, eshell-close-target): * lisp/eshell/esh-proc.el (eshell-sentinel): * lisp/eshell/esh-var.el (eshell-parse-variable-ref) (eshell-get-variable, eshell-set-variable): * lisp/faces.el (face-at-point): * lisp/ffap.el (ffap-in-project): * lisp/filenotify.el (file-notify--rm-descriptor): * lisp/files-x.el (read-dir-locals-file) (connection-local-update-profile-variables) (connection-local-value): * lisp/files.el (file-remote-p, abbreviate-file-name) (set-auto-mode, hack-local-variables) (revert-buffer-restore-read-only): * lisp/find-dired.el (find-dired-sort-by-filename): * lisp/font-lock.el (font-lock--filter-keywords): * lisp/gnus/gnus-art.el (article-emojize-symbols): * lisp/gnus/gnus-int.el (gnus-close-server): * lisp/gnus/gnus-search.el (gnus-search-transform) (gnus-search-indexed-parse-output, gnus-search-server-to-engine): * lisp/gnus/gnus-sum.el (gnus-collect-urls, gnus-shorten-url): * lisp/gnus/gnus.el (gnus-check-backend-function): * lisp/gnus/message.el (message-send-mail): * lisp/gnus/mml.el (mml-generate-mime, mml-insert-mime-headers): * lisp/gnus/nnatom.el (nnatom--read-feed, nnatom--read-article) (nnatom--read-article-or-group-authors, nnatom--read-publish) (nnatom--read-update, nnatom--read-links): * lisp/gnus/nnfeed.el (nnfeed--read-server, nnfeed--write-server) (nnfeed--parse-feed, nnfeed--group-data, nnfeed-retrieve-article) (nnfeed-retrieve-headers, nnfeed--print-part) (nnfeed-request-article, nnfeed-request-group) (nnfeed-request-list, nnfeed--group-description) (nnfeed-request-group-description) (nnfeed-request-list-newsgroups, nnfeed-request-rename-group): * lisp/gnus/nnmh.el (nnmh-update-gnus-unreads): * lisp/help-fns.el (help-find-source) (help-fns--insert-menu-bindings, help-fns--mention-first-release) (help-fns--mention-shortdoc-groups) (help-fns--customize-variable-version) (help-fns--face-custom-version-info, describe-mode): * lisp/help-mode.el (help-make-xrefs): * lisp/help.el (help-key-description, help--describe-command): * lisp/hfy-cmap.el (htmlfontify-load-rgb-file): * lisp/ibuf-ext.el (ibuffer-jump-to-filter-group) (ibuffer-kill-filter-group, ibuffer-kill-line) (ibuffer-save-filter-groups, ibuffer-save-filters, filename) (basename, file-extension, ibuffer-diff-buffer-with-file-1) (ibuffer-mark-by-file-name-regexp) (ibuffer-mark-by-content-regexp): * lisp/ibuf-macs.el (ibuffer-aif, ibuffer-awhen): * lisp/ibuffer.el (ibuffer-mouse-toggle-mark) (ibuffer-toggle-marks, ibuffer-mark-interactive) (ibuffer-compile-format, process, ibuffer-map-lines): * lisp/image.el (image--compute-map) (image--compute-original-map): * lisp/image/exif.el (exif-parse-buffer): * lisp/image/image-converter.el (image-convert-p, image-convert) (image-converter--find-converter): * lisp/image/image-dired-util.el (image-dired-file-name-at-point): * lisp/image/image-dired.el (image-dired-track-original-file) (image-dired--on-file-in-dired-buffer) (image-dired--with-thumbnail-buffer) (image-dired-jump-original-dired-buffer) (image-dired--slideshow-step, image-dired-display-image): * lisp/image/wallpaper.el (wallpaper--init-action-kill) (wallpaper--find-setter, wallpaper--find-command) (wallpaper--find-command-args, wallpaper--x-monitor-name): * lisp/info-look.el (info-lookup-interactive-arguments) (info-complete)::(:mode): * lisp/info.el (info-pop-to-buffer, Info-read-node-name-1): * lisp/international/emoji.el (emoji--adjust-displayable-1) (emoji--add-recent): * lisp/jsonrpc.el (jsonrpc--call-deferred) (jsonrpc--process-sentinel, jsonrpc--remove): * lisp/keymap.el (keymap-local-lookup): * lisp/mail/emacsbug.el (report-emacs-bug-hook) (submit-emacs-patch): * lisp/mail/ietf-drums.el (ietf-drums-parse-addresses): * lisp/mail/mailclient.el (mailclient-send-it): * lisp/mail/rfc6068.el (rfc6068-parse-mailto-url): * lisp/mail/undigest.el (rmail-digest-parse-mixed-mime): * lisp/minibuffer.el (completion-metadata-get) (completions--after-change) (minibuffer-visible-completions--filter): * lisp/net/browse-url.el (browse-url-url-at-point) (browse-url-file-url, browse-url-emacs): * lisp/net/dbus.el (dbus-byte-array-to-string) (dbus-monitor-goto-serial): * lisp/net/dictionary.el (dictionary-search): * lisp/net/eww.el (eww--download-directory) (eww-auto-rename-buffer, eww-open-in-new-buffer, eww-submit) (eww-follow-link, eww-read-alternate-url) (eww-copy-alternate-url): * lisp/net/goto-addr.el (goto-address-at-point): * lisp/net/mailcap.el (mailcap-mime-info): * lisp/net/rcirc.el (rcirc, rcirc-connect, rcirc-send-string) (rcirc-kill-buffer-hook, rcirc-print, rcirc-when) (rcirc-color-attributes, rcirc-handler-NICK) (rcirc-handler-TAGMSG, rcirc-handler-BATCH): * lisp/net/shr.el (shr-descend, shr-adaptive-fill-function) (shr-correct-dom-case, shr-tag-a): * lisp/net/sieve.el (sieve-manage-quit): * lisp/outline.el (outline-cycle-buffer): * lisp/pcmpl-git.el (pcmpl-git--tracked-file-predicate): * lisp/proced.el (proced-auto-update-timer): * lisp/progmodes/bug-reference.el (bug-reference-try-setup-from-vc): * lisp/progmodes/c-ts-common.el (c-ts-common--fill-paragraph): * lisp/progmodes/c-ts-mode.el (c-ts-mode--preproc-offset) (c-ts-mode--anchor-prev-sibling, c-ts-mode-indent-defun): * lisp/progmodes/compile.el (compilation-error-properties) (compilation-find-file-1): * lisp/progmodes/eglot.el (eglot--check-object) (eglot--read-server, eglot-upgrade-eglot) (eglot-handle-notification, eglot--CompletionParams) (eglot-completion-at-point, eglot--sig-info) (eglot-register-capability): * lisp/progmodes/elisp-mode.el (emacs-lisp-native-compile-and-load) (elisp-eldoc-var-docstring-with-value): * lisp/progmodes/erts-mode.el (erts-mode--goto-start-of-test): * lisp/progmodes/flymake.el (flymake--update-eol-overlays) (flymake-eldoc-function): * lisp/progmodes/gdb-mi.el (gdb-breakpoints-list-handler-custom) (gdb-frame-handler): * lisp/progmodes/go-ts-mode.el (go-ts-mode-docstring) (go-ts-mode--comment-on-previous-line-p) (go-ts-mode--get-test-regexp-at-point) (go-ts-mode-test-this-file): * lisp/progmodes/grep.el (lgrep, rgrep-default-command) (grep-file-at-point): * lisp/progmodes/perl-mode.el (perl--end-of-format-p): * lisp/progmodes/php-ts-mode.el (php-ts-mode--anchor-prev-sibling, php-ts-mode--indent-defun): * lisp/progmodes/project.el (project--other-place-command) (project--find-default-from, project--transplant-file-name) (project-prefixed-buffer-name, project--remove-from-project-list) (project-prompt-project-name, project-remember-projects-under) (project--switch-project-command) (project-uniquify-dirname-transform, project-mode-line-format): * lisp/progmodes/python.el (python-font-lock-keywords-maximum-decoration) (python--treesit-fontify-union-types) (python-shell-get-process-name, python-shell-restart) (python-shell-completion-at-point, python-ffap-module-path) (python-util-comint-end-of-output-p, python--import-sources) (python-add-import, python-remove-import, python-fix-imports): * lisp/progmodes/xref.el (xref--add-log-current-defun): * lisp/repeat.el (repeat-echo-message-string): * lisp/saveplace.el (save-place-dired-hook): * lisp/server.el (server-save-buffers-kill-terminal): * lisp/shadowfile.el (shadow-make-fullname) (shadow-contract-file-name, shadow-define-literal-group): * lisp/shell.el (shell-highlight-undef-mode): * lisp/simple.el (command-completion-using-modes-p) (command-execute, file-user-uid, file-group-gid) (first-completion, last-completion, switch-to-completions): * lisp/startup.el (startup--load-user-init-file): * lisp/tab-line.el (tab-line-tabs-buffer-group-by-project): * lisp/tar-mode.el (tar-goto-file, tar-next-file-displayer): * lisp/term/android-win.el (android-encode-select-string) (gui-backend-set-selection): * lisp/term/haiku-win.el (haiku-dnd-convert-string) (haiku-select-encode-xstring, haiku-select-encode-utf-8-string): * lisp/textmodes/emacs-news-mode.el (emacs-news--buttonize): * lisp/textmodes/ispell.el (ispell-completion-at-point): * lisp/textmodes/sgml-mode.el (sgml-validate) (html-mode--complete-at-point): * lisp/textmodes/tex-mode.el (tex-recenter-output-buffer) (xref-backend-references): * lisp/thingatpt.el (thing-at-point-file-at-point) (thing-at-point-face-at-point): * lisp/thread.el (thread-list--get-status): * lisp/time.el (world-clock-copy-time-as-kill, world-clock): * lisp/touch-screen.el (touch-screen-handle-touch): * lisp/treesit.el (treesit-language-at, treesit-node-at) (treesit-node-on, treesit-buffer-root-node) (treesit-node-field-name, treesit-local-parsers-at) (treesit-local-parsers-on, treesit--cleanup-local-range-overlays) (treesit-font-lock-recompute-features) (treesit-font-lock-fontify-region, treesit-transpose-sexps) (treesit-add-log-current-defun, treesit-major-mode-setup) (treesit--explorer-refresh, treesit-install-language-grammar): * lisp/url/url.el (url-retrieve-synchronously): * lisp/vc/smerge-mode.el (smerge-diff): * lisp/vc/vc-dir.el (vc-dir): * lisp/vc/vc-dispatcher.el (vc-do-async-command): * lisp/vc/vc-git.el (vc-git-dir--branch-headers) (vc-git-dir--stash-headers, vc-git--log-edit-summary-check) (vc-git-stash-list): * lisp/vc/vc.el (vc-responsible-backend, vc-buffer-sync-fileset) (vc-clone): * lisp/visual-wrap.el (visual-wrap--apply-to-line): * lisp/wid-edit.el (widget-text) (widget-editable-list-insert-before): * lisp/window-tool-bar.el (window-tool-bar--keymap-entry-to-string): * lisp/window.el (display-buffer, display-buffer-full-frame) (window-point-context-set, window-point-context-use) (window-point-context-use-default-function): * lisp/xdg.el (xdg-current-desktop): * lisp/xwidget.el (xwidget-webkit-callback): * lisp/yank-media.el (yank-media--get-selection) (yank-media-types): * test/lisp/comint-tests.el (comint-tests/test-password-function): * test/lisp/completion-preview-tests.el (completion-preview-tests--capf): * test/lisp/cus-edit-tests.el (with-cus-edit-test): * test/lisp/erc/erc-scenarios-base-local-modules.el (-phony-sblm-): * test/lisp/erc/erc-scenarios-stamp.el (erc-scenarios-stamp--on-post-modify): * test/lisp/erc/erc-services-tests.el (erc-services-tests--asp-parse-entry): * test/lisp/erc/erc-tests.el (erc-modules--internal-property) (erc--find-mode, erc-tests--update-modules): * test/lisp/erc/resources/erc-d/erc-d-i.el (erc-d-i--parse-message): * test/lisp/erc/resources/erc-d/erc-d-t.el (erc-d-t-kill-related-buffers, erc-d-t-with-cleanup): * test/lisp/erc/resources/erc-d/erc-d-tests.el (erc-d-i--parse-message--irc-parser-tests): * test/lisp/erc/resources/erc-d/erc-d-u.el (erc-d-u--read-exchange-slowly): * test/lisp/erc/resources/erc-d/erc-d.el (erc-d--expire) (erc-d--finalize-done, erc-d--command-handle-all): * test/lisp/erc/resources/erc-scenarios-common.el (erc-scenarios-common-with-cleanup): * test/lisp/erc/resources/erc-tests-common.el (erc-tests--common-display-message) (erc-tests-common-create-subprocess): * test/lisp/ibuffer-tests.el (ibuffer-test-Bug25058): * test/lisp/international/mule-tests.el (mule-cmds-tests--ucs-names-missing-names): * test/lisp/progmodes/python-tests.el (python-tests-get-shell-interpreter) (python-tests--get-interpreter-info): * test/lisp/progmodes/ruby-ts-mode-tests.el (ruby-ts-resource-file): * test/lisp/replace-tests.el (replace-tests-with-undo): * test/src/emacs-tests.el (emacs-tests--seccomp-debug): * test/src/process-tests.el (process-tests--emacs-command) (process-tests--emacs-binary, process-tests--dump-file): * test/src/treesit-tests.el (treesit--ert-test-defun-navigation): Replace use of the now-obsolete if-let and when-let.
1298 lines
43 KiB
EmacsLisp
1298 lines
43 KiB
EmacsLisp
;;; epa.el --- the EasyPG Assistant -*- lexical-binding: t -*-
|
|
|
|
;; Copyright (C) 2006-2024 Free Software Foundation, Inc.
|
|
|
|
;; Author: Daiki Ueno <ueno@unixuser.org>
|
|
;; Keywords: PGP, GnuPG
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
|
;; it under the terms of the GNU General Public License as published by
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
;; (at your option) any later version.
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
;; GNU General Public License for more details.
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
|
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
;;; Commentary:
|
|
|
|
;;; Code:
|
|
|
|
(require 'epg)
|
|
(eval-when-compile (require 'subr-x))
|
|
(require 'derived)
|
|
|
|
;;; Options
|
|
|
|
(defgroup epa nil
|
|
"The EasyPG Assistant."
|
|
:version "23.1"
|
|
:link '(custom-manual "(epa) Top")
|
|
:group 'epg)
|
|
|
|
(defcustom epa-replace-original-text 'ask
|
|
"Whether the original text shall be replaced by the decrypted.
|
|
|
|
If t, replace the original text without any confirmation.
|
|
If nil, don't replace the original text and show the result in a new buffer.
|
|
If neither t nor nil, ask user for confirmation."
|
|
:version "26.1"
|
|
:type '(choice (const :tag "Never" nil)
|
|
(const :tag "Ask the user" ask)
|
|
(const :tag "Always" t))
|
|
:group 'epa)
|
|
|
|
(defcustom epa-popup-info-window t
|
|
"If non-nil, display status information from epa commands in another window."
|
|
:type 'boolean
|
|
:group 'epa)
|
|
|
|
(defcustom epa-info-window-height 5
|
|
"Number of lines used to display status information."
|
|
:type 'integer
|
|
:group 'epa)
|
|
|
|
(defcustom epa-mail-aliases nil
|
|
"Alist of aliases of email addresses that stand for encryption keys.
|
|
Each element is a list of email addresses (ALIAS EXPANSIONS...).
|
|
When one of the recipients of a message being encrypted is ALIAS,
|
|
instead of encrypting it for ALIAS, encrypt it for EXPANSIONS...
|
|
|
|
If EXPANSIONS is empty, ignore ALIAS as regards encryption.
|
|
This is a handy way to avoid warnings about addresses that you don't
|
|
have any key for.
|
|
|
|
The command `epa-mail-encrypt' uses this."
|
|
:type '(repeat (cons (string :tag "Alias") (repeat (string :tag "Expansion"))))
|
|
:group 'epa
|
|
:version "24.4")
|
|
|
|
(defcustom epa-keys-select-method 'buffer
|
|
"Method used to select keys in `epa-select-keys'.
|
|
If the value is \\='buffer, the default, keys are selected via a
|
|
pop-up buffer. If the value is \\='minibuffer, keys are selected
|
|
via the minibuffer instead, using `completing-read-multiple'.
|
|
Any other value is treated as \\='buffer."
|
|
:type '(choice (const :tag "Read keys from a pop-up buffer" buffer)
|
|
(const :tag "Read keys from minibuffer" minibuffer))
|
|
:group 'epa
|
|
:version "30.1")
|
|
|
|
;;; Faces
|
|
|
|
(defgroup epa-faces nil
|
|
"Faces for epa-mode."
|
|
:version "23.1"
|
|
:group 'epa)
|
|
|
|
(defface epa-validity-high
|
|
'((default :weight bold)
|
|
(((class color) (background dark)) :foreground "PaleTurquoise"))
|
|
"Face for high validity EPA information."
|
|
:group 'epa-faces)
|
|
|
|
(defface epa-validity-medium
|
|
'((default :slant italic)
|
|
(((class color) (background dark)) :foreground "PaleTurquoise"))
|
|
"Face for medium validity EPA information."
|
|
:group 'epa-faces)
|
|
|
|
(defface epa-validity-low
|
|
'((t :slant italic))
|
|
"Face used for displaying the low validity."
|
|
:group 'epa-faces)
|
|
|
|
(defface epa-validity-disabled
|
|
'((t :slant italic :inverse-video t))
|
|
"Face used for displaying the disabled validity."
|
|
:group 'epa-faces)
|
|
|
|
(defface epa-string
|
|
'((((class color) (background dark))
|
|
:foreground "lightyellow")
|
|
(((class color) (background light))
|
|
:foreground "blue4"))
|
|
"Face used for displaying the string."
|
|
:group 'epa-faces)
|
|
|
|
(defface epa-mark
|
|
'((default :weight bold)
|
|
(((class color) (background dark)) :foreground "orange")
|
|
(((class color) (background light)) :foreground "red"))
|
|
"Face used for displaying the high validity."
|
|
:group 'epa-faces)
|
|
|
|
(defface epa-field-name
|
|
'((default :weight bold)
|
|
(((class color) (background dark)) :foreground "PaleTurquoise"))
|
|
"Face for the name of the attribute field."
|
|
:version "28.1"
|
|
:group 'epa-faces)
|
|
|
|
(defface epa-field-body
|
|
'((default :slant italic)
|
|
(((class color) (background dark)) :foreground "turquoise"))
|
|
"Face for the body of the attribute field."
|
|
:version "28.1"
|
|
:group 'epa-faces)
|
|
|
|
(defcustom epa-validity-face-alist
|
|
'((unknown . epa-validity-disabled)
|
|
(invalid . epa-validity-disabled)
|
|
(disabled . epa-validity-disabled)
|
|
(revoked . epa-validity-disabled)
|
|
(expired . epa-validity-disabled)
|
|
(none . epa-validity-low)
|
|
(undefined . epa-validity-low)
|
|
(never . epa-validity-low)
|
|
(marginal . epa-validity-medium)
|
|
(full . epa-validity-high)
|
|
(ultimate . epa-validity-high))
|
|
"An alist mapping validity values to faces."
|
|
:version "28.1"
|
|
:type '(repeat (cons symbol face))
|
|
:group 'epa-faces)
|
|
|
|
;;; Variables
|
|
|
|
(defconst epa-pubkey-algorithm-letter-alist
|
|
'((1 . ?R)
|
|
(2 . ?r)
|
|
(3 . ?s)
|
|
(16 . ?g)
|
|
(17 . ?D)
|
|
(20 . ?G)))
|
|
|
|
(defvar epa-protocol 'OpenPGP
|
|
"The default protocol.
|
|
The value can be either OpenPGP or CMS.
|
|
|
|
You should bind this variable with `let', but do not set it globally.")
|
|
|
|
(defvar epa-armor nil
|
|
"If non-nil, epa commands create ASCII armored output.
|
|
|
|
You should bind this variable with `let', but do not set it globally.")
|
|
|
|
(defvar epa-textmode nil
|
|
"If non-nil, epa commands treat input files as text.
|
|
|
|
You should bind this variable with `let', but do not set it globally.")
|
|
|
|
(defvar epa-keys-buffer nil)
|
|
(defvar epa-key-buffer-alist nil)
|
|
(defvar epa-key nil)
|
|
(defvar epa-list-keys-arguments nil)
|
|
(defvar epa-info-buffer nil)
|
|
(defvar epa-error-buffer nil)
|
|
(defvar epa-suppress-error-buffer nil)
|
|
(defvar epa-last-coding-system-specified nil)
|
|
|
|
(defvar-keymap epa-key-list-mode-map
|
|
"RET" #'epa-show-key
|
|
"TAB" #'forward-button
|
|
"<backtab>" #'backward-button
|
|
"m" #'epa-mark-key
|
|
"u" #'epa-unmark-key
|
|
"d" #'epa-decrypt-file
|
|
"v" #'epa-verify-file
|
|
"s" #'epa-sign-file
|
|
"e" #'epa-encrypt-file
|
|
"r" #'epa-delete-keys
|
|
"i" #'epa-import-keys
|
|
"o" #'epa-export-keys
|
|
"g" #'revert-buffer
|
|
"n" #'next-line
|
|
"p" #'previous-line
|
|
"SPC" #'scroll-up-command
|
|
"S-SPC" #'scroll-down-command
|
|
"<delete>" #'scroll-down-command
|
|
"q" #'epa-exit-buffer)
|
|
|
|
(easy-menu-define epa-key-list-mode-menu epa-key-list-mode-map
|
|
"Menu for `epa-key-list-mode'."
|
|
'("Keys"
|
|
["Export Keys" epa-export-keys
|
|
:help "Export marked keys to a file"]
|
|
["Import Keys" epa-import-keys
|
|
:help "Import keys from a file"]
|
|
["Delete Keys" epa-delete-keys
|
|
:help "Delete Marked Keys"]
|
|
"---"
|
|
["Encrypt File..." epa-encrypt-file
|
|
:help "Encrypt file for recipients"]
|
|
["Decrypt File..." epa-decrypt-file
|
|
:help "Decrypt file"]
|
|
["Sign File..." epa-sign-file
|
|
:help "Sign file by signers keys selected"]
|
|
["Verify File..." epa-verify-file
|
|
:help "Verify file"]
|
|
"---"
|
|
["Mark Key" epa-mark-key
|
|
:help "Mark a key"]
|
|
["Unmark Key" epa-unmark-key
|
|
:help "Unmark a key"]))
|
|
|
|
(defvar-keymap epa-key-mode-map
|
|
"q" #'epa-exit-buffer)
|
|
|
|
(defvar epa-exit-buffer-function #'quit-window)
|
|
|
|
(defun epa--button-key-text (key)
|
|
(let ((primary-sub-key (car (epg-key-sub-key-list key)))
|
|
(primary-user-id (car (epg-key-user-id-list key)))
|
|
(validity (epg-sub-key-validity (car (epg-key-sub-key-list key)))))
|
|
(propertize
|
|
(concat
|
|
(propertize
|
|
(format "%c "
|
|
(if (epg-sub-key-validity primary-sub-key)
|
|
(car (rassq (epg-sub-key-validity primary-sub-key)
|
|
epg-key-validity-alist))
|
|
? ))
|
|
'help-echo (format "Validity: %s"
|
|
(epg-sub-key-validity primary-sub-key)))
|
|
(propertize
|
|
(concat
|
|
(epg-sub-key-id primary-sub-key)
|
|
" "
|
|
(if primary-user-id
|
|
(if (stringp (epg-user-id-string primary-user-id))
|
|
(epg-user-id-string primary-user-id)
|
|
(epg-decode-dn (epg-user-id-string primary-user-id)))
|
|
""))
|
|
'help-echo (format "Show %s"
|
|
(epg-sub-key-id (car (epg-key-sub-key-list key))))))
|
|
'face
|
|
(if validity
|
|
(cdr (assq validity epa-validity-face-alist))
|
|
'default))))
|
|
|
|
;;; Modes
|
|
|
|
(define-derived-mode epa-key-list-mode special-mode "EPA Keys"
|
|
"Major mode for `epa-list-keys'."
|
|
(buffer-disable-undo)
|
|
(setq truncate-lines t
|
|
buffer-read-only t)
|
|
(make-local-variable 'epa-exit-buffer-function)
|
|
(setq-local revert-buffer-function #'epa--key-list-revert-buffer))
|
|
|
|
(define-derived-mode epa-key-mode special-mode "EPA Key"
|
|
"Major mode for a key description."
|
|
(buffer-disable-undo)
|
|
(setq truncate-lines t
|
|
buffer-read-only t)
|
|
(make-local-variable 'epa-exit-buffer-function))
|
|
|
|
(define-derived-mode epa-info-mode special-mode "EPA Info"
|
|
"Major mode for `epa-info-buffer'."
|
|
(buffer-disable-undo)
|
|
(setq truncate-lines t
|
|
buffer-read-only t))
|
|
|
|
;;; Commands
|
|
;;;; Marking
|
|
|
|
(defun epa-mark-key (&optional arg)
|
|
"Mark a key on the current line.
|
|
If ARG is non-nil, unmark the key."
|
|
(interactive "P")
|
|
(let ((inhibit-read-only t)
|
|
buffer-read-only
|
|
properties)
|
|
(beginning-of-line)
|
|
(unless (get-text-property (point) 'epa-key)
|
|
(error "No key on this line"))
|
|
(setq properties (text-properties-at (point)))
|
|
(delete-char 1)
|
|
(insert (if arg " " "*"))
|
|
(set-text-properties (1- (point)) (point) properties)
|
|
(forward-line)))
|
|
|
|
(defun epa-unmark-key (&optional arg)
|
|
"Unmark a key on the current line.
|
|
If ARG is non-nil, mark the key."
|
|
(interactive "P")
|
|
(epa-mark-key (not arg)))
|
|
|
|
;;;; Quitting
|
|
|
|
(defun epa-exit-buffer ()
|
|
"Exit the current buffer using `epa-exit-buffer-function'."
|
|
(interactive)
|
|
(funcall epa-exit-buffer-function))
|
|
|
|
;;;; Listing and Selecting
|
|
|
|
(defun epa--insert-keys (keys)
|
|
(dolist (key keys)
|
|
(insert
|
|
(propertize
|
|
(concat " " (epa--button-key-text key))
|
|
'epa-key key
|
|
;; Allow TAB to tab to the key.
|
|
'button t
|
|
'category t))
|
|
(insert "\n")))
|
|
|
|
(defun epa--list-keys (name secret &optional doc)
|
|
"NAME specifies which key to list.
|
|
SECRET says list data on the secret key (default, the public key).
|
|
DOC is documentation text to insert at the start."
|
|
(unless (and epa-keys-buffer
|
|
(buffer-live-p epa-keys-buffer))
|
|
(setq epa-keys-buffer (generate-new-buffer "*Keys*")))
|
|
(set-buffer epa-keys-buffer)
|
|
(epa-key-list-mode)
|
|
(let ((inhibit-read-only t)
|
|
buffer-read-only
|
|
(point (point-min))
|
|
(context (epg-make-context epa-protocol)))
|
|
|
|
;; Find the end of the documentation text at the start.
|
|
;; Set POINT to where it ends, or nil if ends at eob.
|
|
(unless (get-text-property point 'epa-key)
|
|
(setq point (next-single-property-change point 'epa-key)))
|
|
|
|
;; If caller specified documentation text for that, replace the old
|
|
;; documentation text (if any) with what was specified.
|
|
;; Otherwise, preserve whatever intro text is present.
|
|
(when doc
|
|
(if (or point (not (eobp)))
|
|
(delete-region (point-min) point))
|
|
(insert doc)
|
|
(setq point (point)))
|
|
|
|
;; Now delete the key description text, if any.
|
|
(when point
|
|
(delete-region point
|
|
(or (next-single-property-change point 'epa-list-keys)
|
|
(point-max)))
|
|
(goto-char point))
|
|
|
|
(epa--insert-keys (epg-list-keys context name secret)))
|
|
(setq-local epa-list-keys-arguments (list name secret))
|
|
(goto-char (point-min))
|
|
(pop-to-buffer (current-buffer)))
|
|
|
|
;;;###autoload
|
|
(defun epa-list-keys (&optional name)
|
|
"List all keys matched with NAME from the public keyring."
|
|
(interactive
|
|
(if current-prefix-arg
|
|
(let ((name (read-string "Pattern: "
|
|
(if epa-list-keys-arguments
|
|
(car epa-list-keys-arguments)))))
|
|
(list (if (equal name "") nil name)))
|
|
(list nil)))
|
|
(epa--list-keys name nil
|
|
"The letters at the start of a line have these meanings.
|
|
e expired key. n never trust. m trust marginally. u trust ultimately.
|
|
f trust fully (keys you have signed, usually). r revoked key.
|
|
q trust status questionable. - trust status unspecified.
|
|
See GPG documentation for more explanation.
|
|
\n"))
|
|
|
|
;;;###autoload
|
|
(defun epa-list-secret-keys (&optional name)
|
|
"List all keys matched with NAME from the private keyring."
|
|
(interactive
|
|
(if current-prefix-arg
|
|
(let ((name (read-string "Pattern: "
|
|
(if epa-list-keys-arguments
|
|
(car epa-list-keys-arguments)))))
|
|
(list (if (equal name "") nil name)))
|
|
(list nil)))
|
|
(epa--list-keys name t))
|
|
|
|
(defun epa--key-list-revert-buffer (&optional _ignore-auto _noconfirm)
|
|
(apply #'epa--list-keys epa-list-keys-arguments))
|
|
|
|
(defun epa--marked-keys ()
|
|
(or (with-current-buffer epa-keys-buffer
|
|
(goto-char (point-min))
|
|
(let (keys key)
|
|
(while (re-search-forward "^\\*" nil t)
|
|
(if (setq key (get-text-property (match-beginning 0)
|
|
'epa-key))
|
|
(setq keys (cons key keys))))
|
|
(nreverse keys)))
|
|
(let ((key (get-text-property (line-beginning-position) 'epa-key)))
|
|
(if key
|
|
(list key)))))
|
|
|
|
(defun epa--select-keys (prompt keys)
|
|
(unless (and epa-keys-buffer
|
|
(buffer-live-p epa-keys-buffer))
|
|
(setq epa-keys-buffer (generate-new-buffer "*Keys*")))
|
|
(save-window-excursion
|
|
(with-current-buffer epa-keys-buffer
|
|
(epa-key-list-mode)
|
|
;; C-c C-c is the usual way to finish the selection (bug#11159).
|
|
(define-key (current-local-map) "\C-c\C-c" 'exit-recursive-edit)
|
|
(let ((inhibit-read-only t)
|
|
buffer-read-only)
|
|
(erase-buffer)
|
|
(insert prompt "\n"
|
|
(substitute-command-keys "\
|
|
- `\\[epa-mark-key]' to mark a key on the line
|
|
- `\\[epa-unmark-key]' to unmark a key on the line\n"))
|
|
(insert-button "[Cancel]"
|
|
'action (lambda (_button) (abort-recursive-edit)))
|
|
(insert " ")
|
|
(insert-button "[OK]"
|
|
'action (lambda (_button) (exit-recursive-edit)))
|
|
(insert "\n\n")
|
|
(epa--insert-keys keys)
|
|
(setq epa-exit-buffer-function #'abort-recursive-edit)
|
|
(goto-char (point-min))
|
|
(let ((display-buffer-mark-dedicated 'soft))
|
|
(pop-to-buffer (current-buffer))))
|
|
(unwind-protect
|
|
(progn
|
|
(recursive-edit)
|
|
(epa--marked-keys))
|
|
(kill-buffer epa-keys-buffer)))))
|
|
|
|
(defun epa--select-keys-in-minibuffer (prompt keys)
|
|
(let* ((prompt (pcase-let ((`(,first ,second ,third)
|
|
(string-split prompt "\\."))
|
|
(hint "(separated by comma)"))
|
|
(if third
|
|
(format "%s %s. %s: " first hint second)
|
|
(format "%s %s: " first hint))))
|
|
(keys-alist
|
|
(seq-map
|
|
(lambda (key)
|
|
(cons (substring-no-properties
|
|
(epa--button-key-text key))
|
|
key))
|
|
keys))
|
|
(selected-keys (completing-read-multiple prompt keys-alist)))
|
|
(seq-map
|
|
(lambda (key) (cdr (assoc key keys-alist)))
|
|
selected-keys)))
|
|
|
|
;;;###autoload
|
|
(defun epa-select-keys (context prompt &optional names secret)
|
|
"Display a user's keyring and ask him to select keys.
|
|
CONTEXT is an `epg-context'.
|
|
PROMPT is a string to prompt with.
|
|
NAMES is a list of strings to be matched with keys. If it is nil, all
|
|
the keys are listed.
|
|
If SECRET is non-nil, list secret keys instead of public keys."
|
|
(let ((keys (epg-list-keys context names secret)))
|
|
(pcase epa-keys-select-method
|
|
('minibuffer (epa--select-keys-in-minibuffer prompt keys))
|
|
(_ (epa--select-keys prompt keys)))))
|
|
|
|
;;;; Key Details
|
|
|
|
(defun epa-show-key ()
|
|
"Show a key on the current line."
|
|
(interactive)
|
|
(if-let* ((key (get-text-property (point) 'epa-key)))
|
|
(save-selected-window
|
|
(epa--show-key key))
|
|
(error "No key on this line")))
|
|
|
|
(defun epa--show-key (key)
|
|
(let* ((primary-sub-key (car (epg-key-sub-key-list key)))
|
|
(entry (assoc (epg-sub-key-id primary-sub-key)
|
|
epa-key-buffer-alist))
|
|
(inhibit-read-only t)
|
|
buffer-read-only
|
|
pointer)
|
|
(unless entry
|
|
(setq entry (cons (epg-sub-key-id primary-sub-key) nil)
|
|
epa-key-buffer-alist (cons entry epa-key-buffer-alist)))
|
|
(unless (and (cdr entry)
|
|
(buffer-live-p (cdr entry)))
|
|
(setcdr entry (generate-new-buffer
|
|
(format "*Key*%s" (epg-sub-key-id primary-sub-key)))))
|
|
(set-buffer (cdr entry))
|
|
(epa-key-mode)
|
|
(setq-local epa-key key)
|
|
(erase-buffer)
|
|
(setq pointer (epg-key-user-id-list key))
|
|
(while pointer
|
|
(if (car pointer)
|
|
(insert " "
|
|
(if (epg-user-id-validity (car pointer))
|
|
(char-to-string
|
|
(car (rassq (epg-user-id-validity (car pointer))
|
|
epg-key-validity-alist)))
|
|
" ")
|
|
" "
|
|
(if (stringp (epg-user-id-string (car pointer)))
|
|
(epg-user-id-string (car pointer))
|
|
(epg-decode-dn (epg-user-id-string (car pointer))))
|
|
"\n"))
|
|
(setq pointer (cdr pointer)))
|
|
(setq pointer (epg-key-sub-key-list key))
|
|
(while pointer
|
|
(insert " "
|
|
(if (epg-sub-key-validity (car pointer))
|
|
(char-to-string
|
|
(car (rassq (epg-sub-key-validity (car pointer))
|
|
epg-key-validity-alist)))
|
|
" ")
|
|
" "
|
|
(epg-sub-key-id (car pointer))
|
|
" "
|
|
(format "%dbits"
|
|
(epg-sub-key-length (car pointer)))
|
|
" "
|
|
(cdr (assq (epg-sub-key-algorithm (car pointer))
|
|
epg-pubkey-algorithm-alist))
|
|
"\n\tCreated: "
|
|
(condition-case nil
|
|
(format-time-string "%Y-%m-%d"
|
|
(epg-sub-key-creation-time (car pointer)))
|
|
(error "????-??-??"))
|
|
(if (epg-sub-key-expiration-time (car pointer))
|
|
(format (if (time-less-p nil
|
|
(epg-sub-key-expiration-time
|
|
(car pointer)))
|
|
"\n\tExpires: %s"
|
|
"\n\tExpired: %s")
|
|
(condition-case nil
|
|
(format-time-string "%Y-%m-%d"
|
|
(epg-sub-key-expiration-time
|
|
(car pointer)))
|
|
(error "????-??-??")))
|
|
"")
|
|
"\n\tCapabilities: "
|
|
(mapconcat #'symbol-name
|
|
(epg-sub-key-capability (car pointer))
|
|
" ")
|
|
"\n\tFingerprint: "
|
|
(epg-sub-key-fingerprint (car pointer))
|
|
"\n")
|
|
(setq pointer (cdr pointer)))
|
|
(goto-char (point-min))
|
|
(pop-to-buffer (current-buffer))))
|
|
|
|
;;;; Encryption and Signatures
|
|
|
|
(defun epa-display-info (info)
|
|
(if epa-popup-info-window
|
|
(save-selected-window
|
|
(unless (and epa-info-buffer (buffer-live-p epa-info-buffer))
|
|
(setq epa-info-buffer (generate-new-buffer "*Info*")))
|
|
(if (get-buffer-window epa-info-buffer)
|
|
(delete-window (get-buffer-window epa-info-buffer)))
|
|
(with-current-buffer epa-info-buffer
|
|
(let ((inhibit-read-only t)
|
|
buffer-read-only)
|
|
(erase-buffer)
|
|
(insert info))
|
|
(epa-info-mode)
|
|
(goto-char (point-min)))
|
|
(if (> (window-height)
|
|
epa-info-window-height)
|
|
(set-window-buffer (split-window nil (- (window-height)
|
|
epa-info-window-height))
|
|
epa-info-buffer)
|
|
(pop-to-buffer epa-info-buffer)
|
|
(if (> (window-height) epa-info-window-height)
|
|
(shrink-window (- (window-height) epa-info-window-height)))))
|
|
(message "%s" info)))
|
|
|
|
(defun epa-display-error (context)
|
|
(unless (or (equal (epg-context-error-output context) "")
|
|
epa-suppress-error-buffer)
|
|
(let ((buffer (get-buffer-create "*Error*")))
|
|
(save-selected-window
|
|
(unless (and epa-error-buffer (buffer-live-p epa-error-buffer))
|
|
(setq epa-error-buffer (generate-new-buffer "*Error*")))
|
|
(if (get-buffer-window epa-error-buffer)
|
|
(delete-window (get-buffer-window epa-error-buffer)))
|
|
(with-current-buffer buffer
|
|
(let ((inhibit-read-only t)
|
|
buffer-read-only)
|
|
(erase-buffer)
|
|
(insert (format
|
|
(pcase (epg-context-operation context)
|
|
('decrypt "Error while decrypting with \"%s\":")
|
|
('verify "Error while verifying with \"%s\":")
|
|
('sign "Error while signing with \"%s\":")
|
|
('encrypt "Error while encrypting with \"%s\":")
|
|
('import-keys "Error while importing keys with \"%s\":")
|
|
('export-keys "Error while exporting keys with \"%s\":")
|
|
(_ "Error while executing \"%s\":\n\n"))
|
|
(epg-context-program context))
|
|
"\n\n"
|
|
(epg-context-error-output context)
|
|
(if (string-search "Unexpected error"
|
|
(epg-context-error-output context))
|
|
"\n(File possibly not an encrypted file, but is perhaps a key ring file?)\n"
|
|
"")))
|
|
(epa-info-mode)
|
|
(goto-char (point-min)))
|
|
(display-buffer buffer)))))
|
|
|
|
(defun epa-passphrase-callback-function (context key-id handback)
|
|
(if (eq key-id 'SYM)
|
|
(read-passwd
|
|
(format "Passphrase for symmetric encryption%s: "
|
|
;; Add the file name to the prompt, if any.
|
|
(if (stringp handback)
|
|
(format " for %s" handback)
|
|
""))
|
|
(eq (epg-context-operation context) 'encrypt))
|
|
(read-passwd
|
|
(if (eq key-id 'PIN)
|
|
"Passphrase for PIN: "
|
|
(let ((entry (assoc key-id epg-user-id-alist)))
|
|
(if entry
|
|
(format "Passphrase for %s %s: " key-id (cdr entry))
|
|
(format "Passphrase for %s: " key-id)))))))
|
|
|
|
(defun epa-progress-callback-function (_context what _char current total
|
|
handback)
|
|
(let ((prompt (or handback
|
|
(format "Processing %s: " what))))
|
|
;; According to gnupg/doc/DETAIL: a "total" of 0 indicates that
|
|
;; the total amount is not known. The condition TOTAL && CUR ==
|
|
;; TOTAL may be used to detect the end of an operation.
|
|
(if (> total 0)
|
|
(if (= current total)
|
|
(message "%s...done" prompt)
|
|
(message "%s...%d%%" prompt
|
|
(floor (* 100.0 current) total)))
|
|
(message "%s..." prompt))))
|
|
|
|
(defun epa-read-file-name (input)
|
|
"Interactively read an output file name based on INPUT file name."
|
|
(setq input (file-name-sans-extension (expand-file-name input)))
|
|
(expand-file-name
|
|
(read-file-name
|
|
(format-prompt "To file" (file-name-nondirectory input))
|
|
(file-name-directory input)
|
|
input)))
|
|
|
|
;;;###autoload
|
|
(defun epa-decrypt-file (decrypt-file &optional plain-file)
|
|
"Decrypt DECRYPT-FILE into PLAIN-FILE.
|
|
If you do not specify PLAIN-FILE, this functions prompts for the value to use."
|
|
(interactive
|
|
(let* ((file (read-file-name "File to decrypt: "))
|
|
(plain (epa-read-file-name file)))
|
|
(list file plain)))
|
|
(or plain-file (setq plain-file (epa-read-file-name decrypt-file)))
|
|
(setq decrypt-file (expand-file-name decrypt-file))
|
|
(let ((context (epg-make-context epa-protocol)))
|
|
(epg-context-set-passphrase-callback context
|
|
#'epa-passphrase-callback-function)
|
|
(epg-context-set-progress-callback context
|
|
(cons
|
|
#'epa-progress-callback-function
|
|
(format "Decrypting %s..."
|
|
(file-name-nondirectory decrypt-file))))
|
|
(message "Decrypting %s..." (file-name-nondirectory decrypt-file))
|
|
(condition-case error
|
|
(epg-decrypt-file context decrypt-file plain-file)
|
|
(error
|
|
(epa-display-error context)
|
|
(signal (car error) (cdr error))))
|
|
(message "Decrypting %s...wrote %s" (file-name-nondirectory decrypt-file)
|
|
(file-name-nondirectory plain-file))
|
|
(if (epg-context-result-for context 'verify)
|
|
(epa-display-info (epg-verify-result-to-string
|
|
(epg-context-result-for context 'verify))))))
|
|
|
|
;;;###autoload
|
|
(defun epa-verify-file (file)
|
|
"Verify FILE."
|
|
(interactive "fFile: ")
|
|
(setq file (expand-file-name file))
|
|
(let* ((context (epg-make-context epa-protocol))
|
|
(plain (if (equal (file-name-extension file) "sig")
|
|
(file-name-sans-extension file))))
|
|
(epg-context-set-progress-callback context
|
|
(cons
|
|
#'epa-progress-callback-function
|
|
(format "Verifying %s..."
|
|
(file-name-nondirectory file))))
|
|
(message "Verifying %s..." (file-name-nondirectory file))
|
|
(condition-case error
|
|
(epg-verify-file context file plain)
|
|
(error
|
|
(epa-display-error context)
|
|
(signal (car error) (cdr error))))
|
|
(message "Verifying %s...done" (file-name-nondirectory file))
|
|
(if (epg-context-result-for context 'verify)
|
|
(epa-display-info (epg-verify-result-to-string
|
|
(epg-context-result-for context 'verify)))
|
|
(message "Verification not successful"))))
|
|
|
|
(defun epa--read-signature-type ()
|
|
(let (type c)
|
|
(while (null type)
|
|
(message "Signature type (n,c,d,?) ")
|
|
(setq c (read-char))
|
|
(cond ((eq c ?c)
|
|
(setq type 'clear))
|
|
((eq c ?d)
|
|
(setq type 'detached))
|
|
((eq c ??)
|
|
(with-output-to-temp-buffer "*Help*"
|
|
(with-current-buffer standard-output
|
|
(insert "\
|
|
n - Create a normal signature
|
|
c - Create a cleartext signature
|
|
d - Create a detached signature
|
|
? - Show this help
|
|
"))))
|
|
(t
|
|
(setq type 'normal))))
|
|
type))
|
|
|
|
;;;###autoload
|
|
(defun epa-sign-file (file signers mode)
|
|
"Sign FILE by SIGNERS keys selected."
|
|
(interactive
|
|
(let ((verbose current-prefix-arg))
|
|
(list (expand-file-name (read-file-name "File: "))
|
|
(if verbose
|
|
(epa-select-keys (epg-make-context epa-protocol)
|
|
"Select keys for signing.
|
|
If no one is selected, default secret key is used. "
|
|
nil t))
|
|
(if verbose
|
|
(epa--read-signature-type)
|
|
'clear))))
|
|
(let ((signature (concat file
|
|
(if (eq epa-protocol 'OpenPGP)
|
|
(if (or epa-armor
|
|
(not (memq mode
|
|
'(nil t normal detached))))
|
|
".asc"
|
|
(if (memq mode '(t detached))
|
|
".sig"
|
|
".gpg"))
|
|
(if (memq mode '(t detached))
|
|
".p7s"
|
|
".p7m"))))
|
|
(context (epg-make-context epa-protocol)))
|
|
(setf (epg-context-armor context) epa-armor)
|
|
(setf (epg-context-textmode context) epa-textmode)
|
|
(setf (epg-context-signers context) signers)
|
|
(epg-context-set-passphrase-callback context
|
|
#'epa-passphrase-callback-function)
|
|
(epg-context-set-progress-callback context
|
|
(cons
|
|
#'epa-progress-callback-function
|
|
(format "Signing %s..."
|
|
(file-name-nondirectory file))))
|
|
(message "Signing %s..." (file-name-nondirectory file))
|
|
(condition-case error
|
|
(epg-sign-file context file signature mode)
|
|
(error
|
|
(epa-display-error context)
|
|
(signal (car error) (cdr error))))
|
|
(message "Signing %s...wrote %s" (file-name-nondirectory file)
|
|
(file-name-nondirectory signature))))
|
|
|
|
;;;###autoload
|
|
(defun epa-encrypt-file (file recipients)
|
|
"Encrypt FILE for RECIPIENTS."
|
|
(interactive
|
|
(list (expand-file-name (read-file-name "File: "))
|
|
(epa-select-keys (epg-make-context epa-protocol)
|
|
"Select recipients for encryption.
|
|
If no one is selected, symmetric encryption will be performed. ")))
|
|
(let ((cipher (concat file (if (eq epa-protocol 'OpenPGP)
|
|
(if epa-armor ".asc" ".gpg")
|
|
".p7m")))
|
|
(context (epg-make-context epa-protocol)))
|
|
(setf (epg-context-armor context) epa-armor)
|
|
(setf (epg-context-textmode context) epa-textmode)
|
|
(epg-context-set-passphrase-callback context
|
|
#'epa-passphrase-callback-function)
|
|
(epg-context-set-progress-callback context
|
|
(cons
|
|
#'epa-progress-callback-function
|
|
(format "Encrypting %s..."
|
|
(file-name-nondirectory file))))
|
|
(message "Encrypting %s..." (file-name-nondirectory file))
|
|
(condition-case error
|
|
(epg-encrypt-file context file recipients cipher)
|
|
(error
|
|
(epa-display-error context)
|
|
(signal (car error) (cdr error))))
|
|
(message "Encrypting %s...wrote %s" (file-name-nondirectory file)
|
|
(file-name-nondirectory cipher))))
|
|
|
|
;;;###autoload
|
|
(defun epa-decrypt-region (start end &optional make-buffer-function)
|
|
"Decrypt the current region between START and END.
|
|
|
|
If MAKE-BUFFER-FUNCTION is non-nil, call it to prepare an output buffer.
|
|
It should return that buffer. If it copies the input, it should
|
|
delete the text now being decrypted. It should leave point at the
|
|
proper place to insert the plaintext.
|
|
|
|
Be careful about using this command in Lisp programs!
|
|
Since this function operates on regions, it does some tricks such
|
|
as coding-system detection and unibyte/multibyte conversion. If
|
|
you are sure how the data in the region should be treated, you
|
|
should consider using the string based counterpart
|
|
`epg-decrypt-string', or the file based counterpart
|
|
`epg-decrypt-file' instead.
|
|
|
|
For example:
|
|
|
|
\(let ((context (epg-make-context \\='OpenPGP)))
|
|
(decode-coding-string
|
|
(epg-decrypt-string context (buffer-substring start end))
|
|
\\='utf-8))"
|
|
(interactive "r")
|
|
(save-excursion
|
|
(let ((context (epg-make-context epa-protocol))
|
|
plain)
|
|
(epg-context-set-passphrase-callback context
|
|
#'epa-passphrase-callback-function)
|
|
(epg-context-set-progress-callback context
|
|
(cons
|
|
#'epa-progress-callback-function
|
|
"Decrypting..."))
|
|
(message "Decrypting...")
|
|
(condition-case error
|
|
(setq plain (epg-decrypt-string context (buffer-substring start end)))
|
|
(error
|
|
(epa-display-error context)
|
|
(signal (car error) (cdr error))))
|
|
(message "Decrypting...done")
|
|
(setq plain (decode-coding-string
|
|
plain
|
|
(or coding-system-for-read
|
|
(get-text-property start 'epa-coding-system-used)
|
|
'undecided)))
|
|
(if make-buffer-function
|
|
(with-current-buffer (funcall make-buffer-function)
|
|
(let ((inhibit-read-only t))
|
|
(insert plain)))
|
|
(if (or (eq epa-replace-original-text t)
|
|
(and epa-replace-original-text
|
|
(y-or-n-p "Replace the original text? ")))
|
|
(let ((inhibit-read-only t))
|
|
(delete-region start end)
|
|
(goto-char start)
|
|
(insert plain))
|
|
(with-output-to-temp-buffer "*Temp*"
|
|
(set-buffer standard-output)
|
|
(insert plain)
|
|
(epa-info-mode))))
|
|
(if (epg-context-result-for context 'verify)
|
|
(epa-display-info (epg-verify-result-to-string
|
|
(epg-context-result-for context 'verify)))))))
|
|
|
|
(defun epa--find-coding-system-for-mime-charset (mime-charset)
|
|
;; Find the first coding system which corresponds to MIME-CHARSET.
|
|
(let ((pointer (coding-system-list)))
|
|
(while (and pointer
|
|
(not (eq (coding-system-get (car pointer) 'mime-charset)
|
|
mime-charset)))
|
|
(setq pointer (cdr pointer)))
|
|
(car pointer)))
|
|
|
|
;;;###autoload
|
|
(defun epa-decrypt-armor-in-region (start end)
|
|
"Decrypt OpenPGP armors in the current region between START and END.
|
|
|
|
Don't use this command in Lisp programs!
|
|
See the reason described in the `epa-decrypt-region' documentation."
|
|
(declare (interactive-only t))
|
|
(interactive "r")
|
|
(save-excursion
|
|
(save-restriction
|
|
(narrow-to-region start end)
|
|
(goto-char start)
|
|
(let (armor-start armor-end)
|
|
(while (re-search-forward "-----BEGIN PGP MESSAGE-----$" nil t)
|
|
(setq armor-start (match-beginning 0)
|
|
armor-end (re-search-forward "^-----END PGP MESSAGE-----$"
|
|
nil t))
|
|
(unless armor-end
|
|
(error "Encryption armor beginning has no matching end"))
|
|
(goto-char armor-start)
|
|
(let ((coding-system-for-read
|
|
(or coding-system-for-read
|
|
(if (re-search-forward "^Charset: \\(.*\\)" armor-end t)
|
|
(epa--find-coding-system-for-mime-charset
|
|
(intern (downcase (match-string 1))))))))
|
|
(goto-char armor-end)
|
|
(epa-decrypt-region armor-start armor-end)))))))
|
|
|
|
;;;###autoload
|
|
(defun epa-verify-region (start end)
|
|
"Verify the current region between START and END.
|
|
|
|
Don't use this command in Lisp programs!
|
|
Since this function operates on regions, it does some tricks such
|
|
as coding-system detection and unibyte/multibyte conversion. If
|
|
you are sure how the data in the region should be treated, you
|
|
should consider using the string based counterpart
|
|
`epg-verify-string', or the file based counterpart
|
|
`epg-verify-file' instead.
|
|
|
|
For example:
|
|
|
|
\(let ((context (epg-make-context \\='OpenPGP)))
|
|
(decode-coding-string
|
|
(epg-verify-string context (buffer-substring start end))
|
|
\\='utf-8))"
|
|
(declare (interactive-only t))
|
|
(interactive "r")
|
|
(let ((context (epg-make-context epa-protocol))
|
|
plain)
|
|
(setf (epg-context-progress-callback context)
|
|
(cons
|
|
#'epa-progress-callback-function
|
|
"Verifying..."))
|
|
(message "Verifying...")
|
|
(condition-case error
|
|
(setq plain (epg-verify-string
|
|
context
|
|
(encode-coding-string
|
|
(buffer-substring start end)
|
|
(or coding-system-for-write
|
|
(get-text-property start 'epa-coding-system-used)))))
|
|
(error
|
|
(epa-display-error context)
|
|
(signal (car error) (cdr error))))
|
|
(message "Verifying...done")
|
|
(setq plain (decode-coding-string
|
|
plain
|
|
(or coding-system-for-read
|
|
(get-text-property start 'epa-coding-system-used)
|
|
'undecided)))
|
|
(unless (epg-context-result-for context 'verify)
|
|
(error "Unable to verify region"))
|
|
(if (or (eq epa-replace-original-text t)
|
|
(and epa-replace-original-text
|
|
(y-or-n-p "Replace the original text? ")))
|
|
(let ((inhibit-read-only t)
|
|
buffer-read-only)
|
|
(delete-region start end)
|
|
(goto-char start)
|
|
(insert plain))
|
|
(with-output-to-temp-buffer "*Temp*"
|
|
(set-buffer standard-output)
|
|
(insert plain)
|
|
(epa-info-mode)))
|
|
(if (epg-context-result-for context 'verify)
|
|
(epa-display-info (epg-verify-result-to-string
|
|
(epg-context-result-for context 'verify))))))
|
|
|
|
;;;###autoload
|
|
(defun epa-verify-cleartext-in-region (start end)
|
|
"Verify OpenPGP cleartext signed messages in current region from START to END.
|
|
|
|
Don't use this command in Lisp programs!
|
|
See the reason described in the `epa-verify-region' documentation."
|
|
(declare (interactive-only t))
|
|
(interactive "r")
|
|
(save-excursion
|
|
(save-restriction
|
|
(narrow-to-region start end)
|
|
(goto-char start)
|
|
(let (cleartext-start cleartext-end)
|
|
(while (re-search-forward "-----BEGIN PGP SIGNED MESSAGE-----$"
|
|
nil t)
|
|
(setq cleartext-start (match-beginning 0))
|
|
(unless (re-search-forward "^-----BEGIN PGP SIGNATURE-----$"
|
|
nil t)
|
|
(error "Invalid cleartext signed message"))
|
|
(setq cleartext-end (re-search-forward
|
|
"^-----END PGP SIGNATURE-----$"
|
|
nil t))
|
|
(unless cleartext-end
|
|
(error "No cleartext tail"))
|
|
(with-suppressed-warnings ((interactive-only epa-verify-region))
|
|
(epa-verify-region cleartext-start cleartext-end)))))))
|
|
|
|
;;;###autoload
|
|
(defun epa-sign-region (start end signers mode)
|
|
"Sign the current region between START and END by SIGNERS keys selected.
|
|
|
|
Don't use this command in Lisp programs!
|
|
Since this function operates on regions, it does some tricks such
|
|
as coding-system detection and unibyte/multibyte conversion. If
|
|
you are sure how the data should be treated, you should consider
|
|
using the string based counterpart `epg-sign-string', or the file
|
|
based counterpart `epg-sign-file' instead.
|
|
|
|
For example:
|
|
|
|
\(let ((context (epg-make-context \\='OpenPGP)))
|
|
(epg-sign-string
|
|
context
|
|
(encode-coding-string (buffer-substring start end) \\='utf-8)))"
|
|
(declare (interactive-only t))
|
|
(interactive
|
|
(let ((verbose current-prefix-arg))
|
|
(setq epa-last-coding-system-specified
|
|
(or coding-system-for-write
|
|
(select-safe-coding-system
|
|
(region-beginning) (region-end))))
|
|
(list (region-beginning) (region-end)
|
|
(if verbose
|
|
(epa-select-keys (epg-make-context epa-protocol)
|
|
"Select keys for signing.
|
|
If no one is selected, default secret key is used. "
|
|
nil t))
|
|
(if verbose
|
|
(epa--read-signature-type)
|
|
'clear))))
|
|
(save-excursion
|
|
(let ((context (epg-make-context epa-protocol))
|
|
signature)
|
|
;;(setf (epg-context-armor context) epa-armor)
|
|
(setf (epg-context-armor context) t)
|
|
;;(setf (epg-context-textmode context) epa-textmode)
|
|
(setf (epg-context-textmode context) t)
|
|
(setf (epg-context-signers context) signers)
|
|
(epg-context-set-passphrase-callback context
|
|
#'epa-passphrase-callback-function)
|
|
(epg-context-set-progress-callback context
|
|
(cons
|
|
#'epa-progress-callback-function
|
|
"Signing..."))
|
|
(message "Signing...")
|
|
(condition-case error
|
|
(setq signature (epg-sign-string context
|
|
(encode-coding-string
|
|
(buffer-substring start end)
|
|
epa-last-coding-system-specified)
|
|
mode))
|
|
(error
|
|
(epa-display-error context)
|
|
(signal (car error) (cdr error))))
|
|
(message "Signing...done")
|
|
(delete-region start end)
|
|
(goto-char start)
|
|
(add-text-properties (point)
|
|
(progn
|
|
(insert (decode-coding-string
|
|
signature
|
|
(or coding-system-for-read
|
|
epa-last-coding-system-specified)))
|
|
(point))
|
|
(list 'epa-coding-system-used
|
|
epa-last-coding-system-specified
|
|
'front-sticky nil
|
|
'rear-nonsticky t)))))
|
|
|
|
(define-obsolete-function-alias 'epa--derived-mode-p 'derived-mode-p "28.1")
|
|
|
|
;;;###autoload
|
|
(defun epa-encrypt-region (start end recipients sign signers)
|
|
"Encrypt the current region between START and END for RECIPIENTS.
|
|
|
|
Don't use this command in Lisp programs!
|
|
Since this function operates on regions, it does some tricks such
|
|
as coding-system detection and unibyte/multibyte conversion. If
|
|
you are sure how the data should be treated, you should consider
|
|
using the string based counterpart `epg-encrypt-string', or the
|
|
file based counterpart `epg-encrypt-file' instead.
|
|
|
|
For example:
|
|
|
|
\(let ((context (epg-make-context \\='OpenPGP)))
|
|
(epg-encrypt-string
|
|
context
|
|
(encode-coding-string (buffer-substring start end) \\='utf-8)
|
|
nil))"
|
|
(declare (interactive-only t))
|
|
(interactive
|
|
(let ((verbose current-prefix-arg)
|
|
(context (epg-make-context epa-protocol))
|
|
sign)
|
|
(setq epa-last-coding-system-specified
|
|
(or coding-system-for-write
|
|
(select-safe-coding-system
|
|
(region-beginning) (region-end))))
|
|
(list (region-beginning) (region-end)
|
|
(epa-select-keys context
|
|
"Select recipients for encryption.
|
|
If no one is selected, symmetric encryption will be performed. ")
|
|
(setq sign (if verbose (y-or-n-p "Sign? ")))
|
|
(if sign
|
|
(epa-select-keys context
|
|
"Select keys for signing. ")))))
|
|
(save-excursion
|
|
(let ((context (epg-make-context epa-protocol))
|
|
cipher)
|
|
;;(setf (epg-context-armor context) epa-armor)
|
|
(setf (epg-context-armor context) t)
|
|
;;(setf (epg-context-textmode context) epa-textmode)
|
|
(setf (epg-context-textmode context) t)
|
|
(if sign
|
|
(setf (epg-context-signers context) signers))
|
|
(epg-context-set-passphrase-callback context
|
|
#'epa-passphrase-callback-function)
|
|
(epg-context-set-progress-callback context
|
|
(cons
|
|
#'epa-progress-callback-function
|
|
"Encrypting..."))
|
|
(message "Encrypting...")
|
|
(condition-case error
|
|
(setq cipher (epg-encrypt-string context
|
|
(encode-coding-string
|
|
(buffer-substring start end)
|
|
epa-last-coding-system-specified)
|
|
recipients
|
|
sign))
|
|
(error
|
|
(epa-display-error context)
|
|
(signal (car error) (cdr error))))
|
|
(message "Encrypting...done")
|
|
(delete-region start end)
|
|
(goto-char start)
|
|
(add-text-properties (point)
|
|
(progn
|
|
(insert cipher)
|
|
(point))
|
|
(list 'epa-coding-system-used
|
|
epa-last-coding-system-specified
|
|
'front-sticky nil
|
|
'rear-nonsticky t)))))
|
|
|
|
;;;; Key Management
|
|
|
|
;;;###autoload
|
|
(defun epa-delete-keys (keys &optional allow-secret)
|
|
"Delete selected KEYS."
|
|
(interactive
|
|
(let ((keys (epa--marked-keys)))
|
|
(unless keys
|
|
(error "No keys selected"))
|
|
(list keys
|
|
(eq (nth 1 epa-list-keys-arguments) t))))
|
|
(let ((context (epg-make-context epa-protocol)))
|
|
(message "Deleting...")
|
|
(condition-case error
|
|
(epg-delete-keys context keys allow-secret)
|
|
(error
|
|
(epa-display-error context)
|
|
(signal (car error) (cdr error))))
|
|
(message "Deleting...done")
|
|
(apply #'epa--list-keys epa-list-keys-arguments)))
|
|
|
|
;;;###autoload
|
|
(defun epa-import-keys (file)
|
|
"Import keys from FILE."
|
|
(interactive "fFile: ")
|
|
(setq file (expand-file-name file))
|
|
(let ((context (epg-make-context epa-protocol)))
|
|
(message "Importing %s..." (file-name-nondirectory file))
|
|
(condition-case nil
|
|
(progn
|
|
(epg-import-keys-from-file context file)
|
|
(message "Importing %s...done" (file-name-nondirectory file)))
|
|
(error
|
|
(epa-display-error context)
|
|
(message "Importing %s...failed" (file-name-nondirectory file))))
|
|
(if (epg-context-result-for context 'import)
|
|
(epa-display-info (epg-import-result-to-string
|
|
(epg-context-result-for context 'import))))
|
|
;; FIXME: Why not use the derived-mode-p?
|
|
(if (eq major-mode 'epa-key-list-mode)
|
|
(apply #'epa--list-keys epa-list-keys-arguments))))
|
|
|
|
;;;###autoload
|
|
(defun epa-import-keys-region (start end)
|
|
"Import keys from the region."
|
|
(interactive "r")
|
|
(let ((context (epg-make-context epa-protocol)))
|
|
(message "Importing...")
|
|
(condition-case nil
|
|
(progn
|
|
(epg-import-keys-from-string context (buffer-substring start end))
|
|
(message "Importing...done"))
|
|
(error
|
|
(epa-display-error context)
|
|
(message "Importing...failed")))
|
|
(if (epg-context-result-for context 'import)
|
|
(epa-display-info (epg-import-result-to-string
|
|
(epg-context-result-for context 'import))))))
|
|
|
|
;;;###autoload
|
|
(defun epa-import-armor-in-region (start end)
|
|
"Import keys in the OpenPGP armor format in the current region from START to END."
|
|
(interactive "r")
|
|
(save-excursion
|
|
(save-restriction
|
|
(narrow-to-region start end)
|
|
(goto-char start)
|
|
(let (armor-start armor-end)
|
|
(while (re-search-forward
|
|
"-----BEGIN \\(PGP \\(PUBLIC\\|PRIVATE\\) KEY BLOCK\\)-----$"
|
|
nil t)
|
|
(setq armor-start (match-beginning 0)
|
|
armor-end (re-search-forward
|
|
(concat "^-----END " (match-string 1) "-----$")
|
|
nil t))
|
|
(unless armor-end
|
|
(error "No armor tail"))
|
|
(epa-import-keys-region armor-start armor-end))))))
|
|
|
|
;;;###autoload
|
|
(defun epa-export-keys (keys file)
|
|
"Export selected KEYS to FILE."
|
|
(interactive
|
|
(let ((keys (epa--marked-keys))
|
|
default-name)
|
|
(unless keys
|
|
(error "No keys selected"))
|
|
(setq default-name
|
|
(expand-file-name
|
|
(concat (epg-sub-key-id (car (epg-key-sub-key-list (car keys))))
|
|
(if epa-armor ".asc" ".gpg"))
|
|
default-directory))
|
|
(list keys
|
|
(expand-file-name
|
|
(read-file-name
|
|
(format-prompt "To file" (file-name-nondirectory default-name))
|
|
(file-name-directory default-name)
|
|
default-name)))))
|
|
(let ((context (epg-make-context epa-protocol)))
|
|
(setf (epg-context-armor context) epa-armor)
|
|
(message "Exporting to %s..." (file-name-nondirectory file))
|
|
(condition-case error
|
|
(epg-export-keys-to-file context keys file)
|
|
(error
|
|
(epa-display-error context)
|
|
(signal (car error) (cdr error))))
|
|
(message "Exporting to %s...done" (file-name-nondirectory file))))
|
|
|
|
;;;###autoload
|
|
(defun epa-insert-keys (keys)
|
|
"Insert selected KEYS after the point."
|
|
(interactive
|
|
(list (epa-select-keys (epg-make-context epa-protocol)
|
|
"Select keys to export.
|
|
If no one is selected, default public key is exported. ")))
|
|
(let ((context (epg-make-context epa-protocol)))
|
|
;;(setf (epg-context-armor context) epa-armor)
|
|
(setf (epg-context-armor context) t)
|
|
(condition-case error
|
|
(insert (epg-export-keys-to-string context keys))
|
|
(error
|
|
(epa-display-error context)
|
|
(signal (car error) (cdr error))))))
|
|
|
|
(provide 'epa)
|
|
|
|
;;; epa.el ends here
|