1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-15 10:30:25 -08:00

Fix problem of having the wrong window selected after saving foo.gpg

* lisp/epa.el (epa--select-keys): Restore the window configuration
after selecting the key to use (bug#43703).  This also ensures
that the buffer we were editing ends up as the current buffer
after saving it, instead of selecting a different window.
This commit is contained in:
Lars Ingebrigtsen 2020-09-30 17:36:39 +02:00
parent a190a446ee
commit 0bd221b29f

View file

@ -435,33 +435,35 @@ q trust status questionable. - trust status unspecified.
(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)
;; 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 "\
(let ((conf (current-window-configuration)))
(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))))
(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)
(set-window-configuration conf)))))
;;;###autoload
(defun epa-select-keys (context prompt &optional names secret)