[PATCH] emacs: Prefer use Emacs builtin customization machinery
tino.calancha at gmail.com
tino.calancha at gmail.com
Sun Jul 21 13:13:45 CEST 2019
From: Tino Calancha <tino.calancha at gmail.com>
Using a customizable variable is the preferred way to set
a parameter within Emacs.
* contrib/emacs/password-store.el (password-store-dir):
If the user has loaded `auth-source-pass', then
use `auth-source-pass-filename'.
(password-store-time-before-clipboard-restore): New option.
(password-store-timeout): Delete it.
Use the new option instead; all callers updated.
---
contrib/emacs/password-store.el | 27 ++++++++++++++++-----------
1 file changed, 16 insertions(+), 11 deletions(-)
diff --git a/contrib/emacs/password-store.el b/contrib/emacs/password-store.el
index fe9271d..bb3ee5d 100644
--- a/contrib/emacs/password-store.el
+++ b/contrib/emacs/password-store.el
@@ -3,7 +3,7 @@
;; Copyright (C) 2014-2019 Svend Sorensen <svend at svends.net>
;; Author: Svend Sorensen <svend at svends.net>
-;; 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)
@@ -227,7 +230,7 @@ When CALLBACK is non-`NIL', call CALLBACK with the first line instead."
Clear previous password from kill ring. Pointer to kill ring is
stored in `password-store-kill-ring-pointer'. Password is cleared
-after `password-store-timeout' seconds."
+after `password-store-time-before-clipboard-restore' seconds."
(interactive (list (password-store--completing-read)))
(password-store-get
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.20.1
More information about the Password-Store
mailing list