[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: epg encrypt non interactive
From: |
GH |
Subject: |
Re: epg encrypt non interactive |
Date: |
Thu, 07 Jul 2022 16:33:27 +0200 |
Jean Louis <bugs@gnu.support> writes:
> `epg-encrypt-string' does not have proper documentation.
Works, but I think that I can do it using `epg-encrypt-string', just I
need a function that return the keys
This function based in (epa--select-keys) work but you need type C-c C-c
to return the keys:
#+begin_src elisp
(defun epg-return-key (uid)
(let* ((context (epg-make-context epa-protocol))
(keys (epg-list-keys context uid)))
(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)
(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))))))
(epg-return-key "your@mail.com")
#+end_src
C-c C-c run (exit-recursive-edit), but I dont know how do it without
interaction
Any idea?