From 25ebb11f07a170f154e6e2fcd654ce3ae930f078 Mon Sep 17 00:00:00 2001 From: Lucas Sta Maria Date: Tue, 8 Aug 2023 23:10:24 -0700 Subject: [PATCH] feat: add `gpg-decrypt-buffer` function Signed-off-by: Lucas Sta Maria --- .emacs.d/include/gpgconfig.el | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.emacs.d/include/gpgconfig.el b/.emacs.d/include/gpgconfig.el index a6d5472..8c94d17 100644 --- a/.emacs.d/include/gpgconfig.el +++ b/.emacs.d/include/gpgconfig.el @@ -70,5 +70,16 @@ (redraw-display) (term gpg-encrypt-command)))) +(defun gpg-decrypt-buffer (&optional filename) + "Decrypt the current file FILENAME with GPG." + (interactive) + + (let* ((filename (or filename + buffer-file-name + (read-string "Decrypt file: "))) + (buf (get-buffer-create "*gpg-decrypt*"))) + (switch-to-buffer buf) + (insert (shell-command-to-string (concat "gpg --decrypt " filename))))) + (provide 'gpgconfig) ;;; gpgconfig.el ends here