m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorPeter Vasil <mail@petervasil.net>2015-10-27 14:49:24 -0700
committerSvend Sorensen <svend@ciffer.net>2015-10-27 14:49:27 -0700
commitbffca1ee21a38f1e808fa83e5df2fcf0f808cb9f (patch)
treed9c77de6ba7d94020fb21a1bcd20a1bc448e4e9f /contrib
parent85757e99bff29d6fa663a6b291c9047ccce8c6d3 (diff)
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.
Diffstat (limited to 'contrib')
-rw-r--r--contrib/emacs/password-store.el9
1 files changed, 8 insertions, 1 deletions
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)