From: Lars Ingebrigtsen Date: Wed, 30 Sep 2020 15:36:39 +0000 (+0200) Subject: Fix problem of having the wrong window selected after saving foo.gpg X-Git-Tag: emacs-28.0.90~5809 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=0bd221b29fa29ebcd4b168d9abc67745ef5f85c2;p=emacs.git 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. --- diff --git a/lisp/epa.el b/lisp/epa.el index 609ac5d1917..a2fb7f2bd1d 100644 --- a/lisp/epa.el +++ b/lisp/epa.el @@ -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)