>From 9609227fb0b1c38471835ff9bd81217e3568562c Mon Sep 17 00:00:00 2001 From: galaunay Date: Sun, 13 Jan 2019 21:30:53 +0000 Subject: [PATCH 04/13] Add auth-source-pass-filename option * lisp/auth-source-pass.el (auth-source-pass) (auth-source-pass-filename): 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 | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lisp/auth-source-pass.el b/lisp/auth-source-pass.el index 4fcb1015e7..1fda698232 100644 --- a/lisp/auth-source-pass.el +++ b/lisp/auth-source-pass.el @@ -38,6 +38,17 @@ (require 'auth-source) (require 'url-parse) +(defgroup auth-source-pass nil + "password-store integration within auth-source." + :prefix "auth-source-pass-" + :group 'auth-source + :version "27.1") + +(defcustom auth-source-pass-filename "~/.password-store" + "Filename of the password-store folder." + :type 'directory + :version "27.1") + (cl-defun auth-source-pass-search (&rest spec &key backend type host user port &allow-other-keys) @@ -121,7 +132,7 @@ auth-source-pass--read-entry (with-temp-buffer (insert-file-contents (expand-file-name (format "%s.gpg" entry) - "~/.password-store")) + auth-source-pass-filename)) (buffer-substring-no-properties (point-min) (point-max)))) (defun auth-source-pass-parse-entry (entry) @@ -188,7 +199,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-filename))) (mapcar (lambda (file) (file-name-sans-extension (file-relative-name file store-dir))) (directory-files-recursively store-dir "\\.gpg$")))) -- 2.21.0