>From d46e8dd1bbc3a1c7ac6506e3e6cfe3d87e57e99e Mon Sep 17 00:00:00 2001 From: galaunay Date: Sun, 13 Jan 2019 21:30:53 +0000 Subject: [PATCH 04/12] Add auth-source-pass-path option * lisp/auth-source-pass.el (auth-source-pass): (auth-source-pass-path): Add option to specify a customized password-store path. (auth-source-pass--read-entry): (auth-source-pass-entries): Use the new option instead of hard-coded `~/.password-store'. --- lisp/auth-source-pass.el | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lisp/auth-source-pass.el b/lisp/auth-source-pass.el index 4fcb1015e7..a029946f6c 100644 --- a/lisp/auth-source-pass.el +++ b/lisp/auth-source-pass.el @@ -38,6 +38,15 @@ (require 'auth-source) (require 'url-parse) +(defgroup auth-source-pass nil + "password-store integration within auth-source." + :prefix "auth-source-pass-" + :group 'auth-source) + +(defcustom auth-source-pass-path "~/.password-store" + "Path to the password-store folder." + :type 'directory) + (cl-defun auth-source-pass-search (&rest spec &key backend type host user port &allow-other-keys) @@ -121,7 +130,7 @@ auth-source-pass--read-entry (with-temp-buffer (insert-file-contents (expand-file-name (format "%s.gpg" entry) - "~/.password-store")) + auth-source-pass-path)) (buffer-substring-no-properties (point-min) (point-max)))) (defun auth-source-pass-parse-entry (entry) @@ -188,7 +197,7 @@ auth-source-pass--entry-valid-p ;; in Emacs (defun auth-source-pass-entries () "Return a list of all password store entries." - (let ((store-dir (expand-file-name "~/.password-store/"))) + (let ((store-dir (expand-file-name auth-source-pass-path))) (mapcar (lambda (file) (file-name-sans-extension (file-relative-name file store-dir))) (directory-files-recursively store-dir "\\.gpg$")))) -- 2.21.0