]> git.eshelyaron.com Git - emacs.git/commitdiff
Add auth-source-pass-filename option
authorgalaunay <gaby.launay@tutanota.com>
Sun, 13 Jan 2019 21:30:53 +0000 (21:30 +0000)
committerDamien Cassou <damien@cassou.me>
Mon, 24 Jun 2019 07:15:40 +0000 (09:15 +0200)
* 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

index 4fcb1015e76f57e667ecd6e18b6a140a696b4f20..1fda698232866cc085b89cfc7d5916a6ebe01c20 100644 (file)
 (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 @@ key2: value2"
   (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 @@ often."
 ;; 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$"))))