[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/base32 0feadbc485 025/103: Make the cancel-this-timer func
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/base32 0feadbc485 025/103: Make the cancel-this-timer function more generic |
Date: |
Sat, 10 Feb 2024 13:00:01 -0500 (EST) |
branch: elpa/base32
commit 0feadbc4855d20efe21fa68d0248e3020ed8c6ac
Author: Vivek Das Mohapatra <vivek@collabora.co.uk>
Commit: Vivek Das Mohapatra <vivek@collabora.co.uk>
Make the cancel-this-timer function more generic
We can now identify the callback function and arguments
automatically using backtrace-frame so we don't need to
pass any arguments to totp-cancel-this-timer.
---
totp.el | 23 ++++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/totp.el b/totp.el
index cc14d3a763..907743bcf1 100644
--- a/totp.el
+++ b/totp.el
@@ -481,12 +481,21 @@ and EXPIRY is the seconds after the epoch when the TOTP
expires."
(defvar totp-display-expiry nil)
(defvar totp-display-secret nil)
-(defun totp-cancel-timer (fun buf)
- "Cancel timers which call FUN with buffer BUF as the first argument."
- (dolist (timer timer-list)
- (if (and (eq (timer--function timer) fun)
- (eq (car (timer--args timer)) buf))
- (cancel-timer timer))))
+(defun totp-cancel-this-timer ()
+ "Cancel the timer whose callback this is called from."
+ (let ((n 1) (cancelled 0) f cb cb-args)
+ (while (and (setq f (backtrace-frame n #'totp-cancel-this-timer))
+ (not (car f)))
+ (setq n (1+ n)))
+ (when (and f (car f))
+ (setq cb (cadr f)
+ cb-args (cddr f))
+ (dolist (timer timer-list)
+ (when (and (eq (timer--function timer) cb)
+ (equal (timer--args timer) cb-args))
+ (cancel-timer timer)
+ (setq cancelled (1+ cancelled)))))
+ cancelled))
(defun totp-update-token-display (buf &optional otp token)
(if (buffer-live-p buf)
@@ -510,7 +519,7 @@ and EXPIRY is the seconds after the epoch when the TOTP
expires."
totp-display-expiry (nth 2 otp)))
(insert (format "TOTP %s [%02ds]: %s\n"
totp-display-label totp-display-ttl token)))
- (totp-cancel-timer #'totp-update-token-display buf)))
+ (totp-cancel-this-timer)))
(defun totp-display-token (secret &optional label)
(let (ui-buffer)
- [nongnu] elpa/base32 34d9df6232 006/103: Split out the standard label generation code, (continued)
- [nongnu] elpa/base32 34d9df6232 006/103: Split out the standard label generation code, ELPA Syncer, 2024/02/10
- [nongnu] elpa/base32 0146fe6b91 010/103: Minor formatting trivia in the test file, ELPA Syncer, 2024/02/10
- [nongnu] elpa/base32 b7e1daca76 009/103: Comment out some spurious calls in the test file, ELPA Syncer, 2024/02/10
- [nongnu] elpa/base32 4432d44bce 012/103: Trivia: clean up some docstrings, ELPA Syncer, 2024/02/10
- [nongnu] elpa/base32 a683df1a74 013/103: Add a separate instance of an `auth-sources' list just for TOTP, ELPA Syncer, 2024/02/10
- [nongnu] elpa/base32 5c902928f7 017/103: Fix bug in otpauth-migration URL decoder, ELPA Syncer, 2024/02/10
- [nongnu] elpa/base32 f27043d432 019/103: Fix some byte compilation warnings, ELPA Syncer, 2024/02/10
- [nongnu] elpa/base32 417a3d03f6 020/103: Dedup secrets manually instead of relying on freedesktop secrets API, ELPA Syncer, 2024/02/10
- [nongnu] elpa/base32 800de931a0 023/103: Autoload totp-import-file and update its docstring, ELPA Syncer, 2024/02/10
- [nongnu] elpa/base32 3e5a779479 022/103: Reduce totp-minimum-ui-grace default value to 3 from 5, ELPA Syncer, 2024/02/10
- [nongnu] elpa/base32 0feadbc485 025/103: Make the cancel-this-timer function more generic,
ELPA Syncer <=
- [nongnu] elpa/base32 94f41a945e 028/103: Implement auto-copying of TOTP tokens, ELPA Syncer, 2024/02/10
- [nongnu] elpa/base32 a61f9c27b1 032/103: Remove unnecessary file, ELPA Syncer, 2024/02/10
- [nongnu] elpa/base32 e9c9329661 033/103: Prepare for package archive inclusion, ELPA Syncer, 2024/02/10
- [nongnu] elpa/base32 e18cb077d7 035/103: Note in TODO that we may be able to drop custom hmac support now, ELPA Syncer, 2024/02/10
- [nongnu] elpa/base32 ff7061d7ef 036/103: Bump version to 0.2 for release attempt, ELPA Syncer, 2024/02/10
- [nongnu] elpa/base32 1e14f7c45f 016/103: Remove references to debug function that doesn't exist anymore, ELPA Syncer, 2024/02/10
- [nongnu] elpa/base32 c29822d2f1 015/103: Add totp-pkg.el in preparation for publishing to a package archive, ELPA Syncer, 2024/02/10
- [nongnu] elpa/base32 47bcc107b8 021/103: Enable substring matching for TOTP secret selection, ELPA Syncer, 2024/02/10
- [nongnu] elpa/base32 9b6ac038a1 018/103: Eliminate reference to obsolete internal variable in an error path, ELPA Syncer, 2024/02/10
- [nongnu] elpa/base32 8925afa85b 027/103: Clarify that totp-alt-xdg-schemas is used only to read secrets, ELPA Syncer, 2024/02/10