1
0
Fork 0

feat: add gpg-encrypt-sign-save-buffer function

Signed-off-by: Lucas Sta Maria <lucas@priime.dev>
This commit is contained in:
Lucas Sta Maria 2023-08-06 22:20:40 -07:00
parent 68593c4e6b
commit c3cd4201fc
No known key found for this signature in database
GPG key ID: F07FB16A826E3B47

View file

@ -49,5 +49,26 @@
(setq info (-filter (lambda (s) (not (string-match "image" (car s)))) info))
info)))
(defun gpg-encrypt-sign-save-buffer (&optional filename)
"Encrypt, sign, and save the buffer as FILENAME.asc for the recipients."
(interactive)
(let* ((key-alist (gpg-public-keys))
(recipients (completing-read-multiple "Recipients: " key-alist))
(recipient-keys (mapcar (lambda (x) (cdr (assoc x key-alist)))
recipients))
(recipients-cli-args (mapconcat (lambda (s) (concat "-r " s))
recipient-keys
" ")))
(unless (or filename buffer-file-name)
(setq filename (read-string "Filename: " nil nil)))
(let ((gpg-encrypt-command
(concat "gpg --encrypt --sign --armor "
recipients-cli-args
" "
(or filename buffer-file-name))))
(redraw-display)
(term gpg-encrypt-command))))
(provide 'gpgconfig)
;;; gpgconfig.el ends here