From bffca1ee21a38f1e808fa83e5df2fcf0f808cb9f Mon Sep 17 00:00:00 2001 From: Peter Vasil Date: Tue, 27 Oct 2015 14:49:24 -0700 Subject: emacs: Add defvar for timeout timer Use a defvar for the timeout timer in order to have better control and not starting multiple timers when calling password-store-copy. --- contrib/emacs/password-store.el | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/contrib/emacs/password-store.el b/contrib/emacs/password-store.el index 79aa4f3..a1be788 100644 --- a/contrib/emacs/password-store.el +++ b/contrib/emacs/password-store.el @@ -48,6 +48,9 @@ (executable-find "pass") "Pass executable.") +(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") @@ -178,6 +181,9 @@ Returns the first line of the password data." (defun password-store-clear () "Clear password in kill ring." (interactive) + (when password-store-timeout-timer + (cancel-timer password-store-timeout-timer) + (setq password-store-timeout-timer nil)) (when password-store-kill-ring-pointer (setcar password-store-kill-ring-pointer "") (setq password-store-kill-ring-pointer nil) @@ -196,7 +202,8 @@ after `password-store-timeout' seconds." (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)) - (run-at-time (password-store-timeout) nil 'password-store-clear))) + (setq password-store-timeout-timer + (run-at-time (password-store-timeout) nil 'password-store-clear)))) ;;;###autoload (defun password-store-init (gpg-id) -- cgit v1.2.3