Follow a more idiomatic way to set up the paremeters:
- Use `auth-source-pass-filename', if bound.
- Prefer a customization var to set the number of seconds before restore
  the clipboard.

Tino
From 8a47cc321c6b259670403f4fa9a9376e8f43e5d7 Mon Sep 17 00:00:00 2001
From: Tino Calancha <[email protected]>
Date: Sat, 6 Jul 2019 00:56:59 +0900
Subject: [PATCH] emacs: Prefer use Emacs builtin customization machinery

Using a customizable variable is the preferred way to set
a parameter within Emacs.

* contrib/emacs/password-store.el (password-store-dir):
Use `auth-source-pass-filename', if available.

(password-store-time-before-clipboard-restore): New option.
(password-store-timeout): Delete this function.
---
 contrib/emacs/password-store.el | 25 +++++++++++++++----------
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/contrib/emacs/password-store.el b/contrib/emacs/password-store.el
index fe9271d..d8dc74d 100644
--- a/contrib/emacs/password-store.el
+++ b/contrib/emacs/password-store.el
@@ -3,7 +3,7 @@
 ;; Copyright (C) 2014-2019 Svend Sorensen <[email protected]>
 
 ;; Author: Svend Sorensen <[email protected]>
-;; Version: 2.0.2
+;; Version: 2.0.3
 ;; URL: https://www.passwordstore.org/
 ;; Package-Requires: ((emacs "25") (f "0.11.0") (s "1.9.0") (with-editor "2.5.11"))
 ;; Keywords: tools pass password password-store
@@ -46,6 +46,14 @@
   :group 'password-store
   :type 'number)
 
+(defcustom password-store-time-before-clipboard-restore
+  (if (getenv "PASSWORD_STORE_CLIP_TIME")
+      (string-to-number (getenv "PASSWORD_STORE_CLIP_TIME"))
+    45)
+  "Number of seconds to wait before restoring the clipboard."
+  :group 'password-store
+  :type 'number)
+
 (defvar password-store-executable
   (executable-find "pass")
   "Pass executable.")
@@ -53,12 +61,6 @@
 (defvar password-store-timeout-timer nil
   "Timer for clearing clipboard.")
 
-(defun password-store-timeout ()
-  "Number of seconds to wait before clearing the password."
-  (if (getenv "PASSWORD_STORE_CLIP_TIME")
-      (string-to-number (getenv "PASSWORD_STORE_CLIP_TIME"))
-    45))
-
 (defun password-store--run-1 (callback &rest args)
   "Run pass with ARGS.
 
@@ -166,7 +168,8 @@ Nil arguments are ignored.  Output is discarded."
 
 (defun password-store-dir ()
   "Return password store directory."
-  (or (getenv "PASSWORD_STORE_DIR")
+  (or (bound-and-true-p auth-source-pass-filename)
+      (getenv "PASSWORD_STORE_DIR")
       "~/.password-store"))
 
 (defun password-store--entry-to-file (entry)
@@ -235,9 +238,11 @@ after `password-store-timeout' seconds."
      (password-store-clear)
      (kill-new password)
      (setq password-store-kill-ring-pointer kill-ring-yank-pointer)
-     (message "Copied %s to the kill ring. Will clear in %s seconds." entry (password-store-timeout))
+     (message "Copied %s to the kill ring. Will clear in %s seconds."
+              entry password-store-time-before-clipboard-restore)
      (setq password-store-timeout-timer
-           (run-at-time (password-store-timeout) nil 'password-store-clear)))))
+           (run-at-time password-store-time-before-clipboard-restore
+                        nil 'password-store-clear)))))
 
 ;;;###autoload
 (defun password-store-init (gpg-id)
-- 
2.11.0

_______________________________________________
Password-Store mailing list
[email protected]
https://lists.zx2c4.com/mailman/listinfo/password-store

Reply via email to