X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/7ad8fe5e2876518a8f33b80050f98dab4ff78398..affa9d2b30dab558bcba32a204500a848ed2e052:/lisp/epa.el diff --git a/lisp/epa.el b/lisp/epa.el index 2c86c5fdd4..d4f4fab2ee 100644 --- a/lisp/epa.el +++ b/lisp/epa.el @@ -1,5 +1,6 @@ -;;; epa.el --- the EasyPG Assistant -;; Copyright (C) 2006, 2007, 2008 Free Software Foundation, Inc. +;;; epa.el --- the EasyPG Assistant -*- lexical-binding: t -*- + +;; Copyright (C) 2006-2011 Free Software Foundation, Inc. ;; Author: Daiki Ueno ;; Keywords: PGP, GnuPG @@ -234,7 +235,7 @@ You should bind this variable with `let', but do not set it globally.") '(menu-item "Decrypt File..." epa-decrypt-file :help "Decrypt FILE")) (define-key menu-map [epa-encrypt-file] - '(menu-item "Encrypt File.." epa-encrypt-file + '(menu-item "Encrypt File..." epa-encrypt-file :help "Encrypt FILE for RECIPIENTS")) (define-key menu-map [separator-epa-key-list] '(menu-item "--")) (define-key menu-map [epa-key-list-delete-keys] @@ -268,8 +269,9 @@ You should bind this variable with `let', but do not set it globally.") :action 'epa--key-widget-action :help-echo 'epa--key-widget-help-echo) -(defun epa--key-widget-action (widget &optional event) - (epa--show-key (widget-get widget :value))) +(defun epa--key-widget-action (widget &optional _event) + (save-selected-window + (epa--show-key (widget-get widget :value)))) (defun epa--key-widget-value-create (widget) (let* ((key (widget-get widget :value)) @@ -458,12 +460,11 @@ If ARG is non-nil, mark the key." (list nil))) (epa--list-keys name t)) -(defun epa--key-list-revert-buffer (&optional ignore-auto noconfirm) +(defun epa--key-list-revert-buffer (&optional _ignore-auto _noconfirm) (apply #'epa--list-keys epa-list-keys-arguments)) (defun epa--marked-keys () - (or (save-excursion - (set-buffer epa-keys-buffer) + (or (with-current-buffer epa-keys-buffer (goto-char (point-min)) (let (keys key) (while (re-search-forward "^\\*" nil t) @@ -471,18 +472,15 @@ If ARG is non-nil, mark the key." 'epa-key)) (setq keys (cons key keys)))) (nreverse keys))) - (save-excursion - (beginning-of-line) - (let ((key (get-text-property (point) 'epa-key))) - (if key - (list key)))))) + (let ((key (get-text-property (point-at-bol) 'epa-key))) + (if key + (list key))))) (defun epa--select-keys (prompt keys) - (save-excursion - (unless (and epa-keys-buffer - (buffer-live-p epa-keys-buffer)) - (setq epa-keys-buffer (generate-new-buffer "*Keys*"))) - (set-buffer epa-keys-buffer) + (unless (and epa-keys-buffer + (buffer-live-p epa-keys-buffer)) + (setq epa-keys-buffer (generate-new-buffer "*Keys*"))) + (with-current-buffer epa-keys-buffer (epa-key-list-mode) (let ((inhibit-read-only t) buffer-read-only) @@ -492,13 +490,13 @@ If ARG is non-nil, mark the key." - `\\[epa-mark-key]' to mark a key on the line - `\\[epa-unmark-key]' to unmark a key on the line\n")) (widget-create 'link - :notify (lambda (&rest ignore) (abort-recursive-edit)) + :notify (lambda (&rest _ignore) (abort-recursive-edit)) :help-echo (substitute-command-keys "Click here or \\[abort-recursive-edit] to cancel") "Cancel") (widget-create 'link - :notify (lambda (&rest ignore) (exit-recursive-edit)) + :notify (lambda (&rest _ignore) (exit-recursive-edit)) :help-echo (substitute-command-keys "Click here or \\[exit-recursive-edit] to finish") @@ -509,13 +507,12 @@ If ARG is non-nil, mark the key." (set-keymap-parent (current-local-map) widget-keymap) (setq epa-exit-buffer-function #'abort-recursive-edit) (goto-char (point-min)) - (pop-to-buffer (current-buffer))) + (let ((display-buffer-mark-dedicated 'soft)) + (pop-to-buffer (current-buffer)))) (unwind-protect (progn (recursive-edit) (epa--marked-keys)) - (if (get-buffer-window epa-keys-buffer) - (delete-window (get-buffer-window epa-keys-buffer))) (kill-buffer epa-keys-buffer)))) ;;;###autoload @@ -585,7 +582,11 @@ If SECRET is non-nil, list secret keys instead of public keys." (epg-sub-key-creation-time (car pointer))) (error "????-??-??")) (if (epg-sub-key-expiration-time (car pointer)) - (format "\n\tExpires: %s" + (format (if (time-less-p (current-time) + (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 @@ -610,8 +611,7 @@ If SECRET is non-nil, list secret keys instead of public keys." (setq epa-info-buffer (generate-new-buffer "*Info*"))) (if (get-buffer-window epa-info-buffer) (delete-window (get-buffer-window epa-info-buffer))) - (save-excursion - (set-buffer epa-info-buffer) + (with-current-buffer epa-info-buffer (let ((inhibit-read-only t) buffer-read-only) (erase-buffer) @@ -630,12 +630,17 @@ If SECRET is non-nil, list secret keys instead of public keys." (defun epa-display-verify-result (verify-result) (epa-display-info (epg-verify-result-to-string verify-result))) -(make-obsolete 'epa-display-verify-result 'epa-display-info) +(make-obsolete 'epa-display-verify-result 'epa-display-info "23.1") (defun epa-passphrase-callback-function (context key-id handback) (if (eq key-id 'SYM) - (read-passwd "Passphrase for symmetric encryption: " - (eq (epg-context-operation context) 'encrypt)) + (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: " @@ -644,7 +649,7 @@ If SECRET is non-nil, list secret keys instead of public keys." (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 +(defun epa-progress-callback-function (_context what _char current total handback) (message "%s%d%% (%d/%d)" (or handback (concat what ": ")) @@ -711,8 +716,7 @@ If SECRET is non-nil, list secret keys instead of public keys." (setq type 'detached)) ((eq c ??) (with-output-to-temp-buffer "*Help*" - (save-excursion - (set-buffer standard-output) + (with-current-buffer standard-output (insert "\ n - Create a normal signature c - Create a cleartext signature @@ -720,7 +724,8 @@ d - Create a detached signature ? - Show this help ")))) (t - (setq type 'normal)))))) + (setq type 'normal)))) + type)) ;;;###autoload (defun epa-sign-file (file signers mode) @@ -824,7 +829,8 @@ For example: (setq plain (epa--decode-coding-string plain (or coding-system-for-read - (get-text-property start 'epa-coding-system-used)))) + (get-text-property start 'epa-coding-system-used) + 'undecided))) (if (y-or-n-p "Replace the original text? ") (let ((inhibit-read-only t) buffer-read-only) @@ -913,7 +919,8 @@ For example: (setq plain (epa--decode-coding-string plain (or coding-system-for-read - (get-text-property start 'epa-coding-system-used)))) + (get-text-property start 'epa-coding-system-used) + 'undecided))) (if (y-or-n-p "Replace the original text? ") (let ((inhibit-read-only t) buffer-read-only) @@ -957,7 +964,7 @@ See the reason described in the `epa-verify-region' documentation." (eval-and-compile (if (fboundp 'select-safe-coding-system) (defalias 'epa--select-safe-coding-system 'select-safe-coding-system) - (defun epa--select-safe-coding-system (from to) + (defun epa--select-safe-coding-system (_from _to) buffer-file-coding-system))) ;;;###autoload @@ -1243,5 +1250,4 @@ between START and END." (provide 'epa) -;; arch-tag: 38d20ced-20d5-4137-b17a-f206335423d7 ;;; epa.el ends here