password-store

Simple password manager using gpg and ordinary unix directories
git clone https://git.zx2c4.com/password-store
Log | Files | Refs | README | LICENSE

commit 09cb7e1f7c85b0ed0d3c682fee833294050f2c3b
parent 38ec1c72e29c872ec0cdde82f75490640d4019bf
Author: Svend Sorensen <svend@ciffer.net>
Date:   Wed, 26 Jul 2017 13:13:41 -0700

emacs: Use with-editor to wrap "pass edit"

Instead of editing the password file directly using Emacs, "pass edit" is
run. This allows password-store's git change tracking to work.

This adds a dependency on the with-editor Emacs package.

Diffstat:
Mcontrib/emacs/Cask | 2+-
Mcontrib/emacs/password-store.el | 24++++++++++++++++--------
2 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/contrib/emacs/Cask b/contrib/emacs/Cask @@ -4,9 +4,9 @@ (package-file "password-store.el") (development - (depends-on "dash") (depends-on "f") (depends-on "s") + (depends-on "with-editor") (depends-on "ecukes") (depends-on "ert-runner") (depends-on "el-mock")) diff --git a/contrib/emacs/password-store.el b/contrib/emacs/password-store.el @@ -1,10 +1,10 @@ ;;; password-store.el --- Password store (pass) support -;; Copyright (C) 2014 Svend Sorensen <svend@ciffer.net> +;; Copyright (C) 2014-2017 Svend Sorensen <svend@ciffer.net> ;; Author: Svend Sorensen <svend@ciffer.net> ;; Version: 0.1 -;; Package-Requires: ((f "0.11.0") (s "1.9.0")) +;; Package-Requires: ((f "0.11.0") (s "1.9.0") (with-editor "2.5.11")) ;; Keywords: pass ;; This file is not part of GNU Emacs. @@ -33,6 +33,7 @@ (require 'f) (require 's) +(require 'with-editor) (defgroup password-store '() "Emacs mode for password-store." @@ -77,6 +78,15 @@ outputs error message on failure." (s-chomp (buffer-string)) (error (s-chomp (buffer-string))))))) +(defun password-store--run-async (&rest args) + "Run pass asynchronously with ARGS. + +Nil arguments are ignored." + (with-editor-async-shell-command + (mapconcat 'identity + (cons password-store-executable + (delq nil args)) " "))) + (defun password-store--run-init (gpg-ids &optional folder) (apply 'password-store--run "init" (if folder (format "--path=%s" folder)) @@ -99,7 +109,8 @@ outputs error message on failure." (error "Not implemented")) (defun password-store--run-edit (entry) - (error "Not implemented")) + (password-store--run-async "edit" + entry)) (defun password-store--run-generate (entry password-length &optional force no-symbols) (password-store--run "generate" @@ -163,12 +174,9 @@ outputs error message on failure." ;;;###autoload (defun password-store-edit (entry) - "Edit password for ENTRY. - -This edits the password file directly in Emacs, so changes will -need to be commited manually if git is being used." + "Edit password for ENTRY." (interactive (list (password-store--completing-read))) - (find-file (password-store--entry-to-file entry))) + (password-store--run-edit entry)) ;;;###autoload (defun password-store-get (entry)