[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/tmr f5dcca3588 07/10: tmr: use only active timers for t
From: |
ELPA Syncer |
Subject: |
[elpa] externals/tmr f5dcca3588 07/10: tmr: use only active timers for tmr-cancel |
Date: |
Sun, 15 May 2022 02:58:18 -0400 (EDT) |
branch: externals/tmr
commit f5dcca358876aba3e700210d7adaf2dd922d716a
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>
tmr: use only active timers for tmr-cancel
---
tmr.el | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/tmr.el b/tmr.el
index e698cda16a..1ae4118970 100644
--- a/tmr.el
+++ b/tmr.el
@@ -248,6 +248,14 @@ Populated by `tmr' and then operated on by `tmr-cancel'.")
(declare-function cl-find "cl-seq" (cl-item cl-seq &rest cl-keys))
(declare-function cl-delete "cl-seq" (cl-item cl-seq &rest cl-keys))
+(declare-function cl-remove-if "cl-seq" (cl-pred cl-list &rest cl-keys))
+
+(defun tmr--active-timers ()
+ "Retun list of active timers."
+ (cl-remove-if
+ (lambda (timer)
+ (tmr--timer-donep timer))
+ tmr--timers))
(defun tmr--get-timer-by-creation-date (creation-date)
"Return the timer which was started at CREATION-DATE."
@@ -258,19 +266,22 @@ Populated by `tmr' and then operated on by `tmr-cancel'.")
"Cancel TIMER object set with `tmr' command.
Interactively, let the user choose which timer to cancel with
completion."
- (interactive (list (tmr--read-timer)))
+ (interactive (list (tmr--read-timer :active)))
(if (not timer)
(user-error "No `tmr' to cancel")
(cancel-timer (tmr--timer-timer-object timer))
(setq tmr--timers (cl-delete timer tmr--timers))
(run-hook-with-args 'tmr-timer-cancelled-functions timer)))
-(defun tmr--read-timer ()
+(defun tmr--read-timer (&optional active)
"Let the user choose a timer among all timers.
Return the selected timer. If there is a single timer, use that.
If there are multiple timers, prompt for one with completion. If
-there are no timers, return nil."
- (let ((timers tmr--timers))
+there are no timers, return nil.
+
+If optional ACTIVE is non-nil, limit the list of timers to those
+that are still running."
+ (let ((timers (if active (tmr--active-timers) tmr--timers)))
(cond
((= (length timers) 1)
(car timers))
- [elpa] externals/tmr updated (3d9242be83 -> 407da662a2), ELPA Syncer, 2022/05/15
- [elpa] externals/tmr b2b322a00f 03/10: tmr: placate the compiler about cl-lib and related, ELPA Syncer, 2022/05/15
- [elpa] externals/tmr 6602891c8f 02/10: Decompose tmr.el into several files, ELPA Syncer, 2022/05/15
- [elpa] externals/tmr 32f6f93aba 04/10: tmr-notification: remove needless quotes, ELPA Syncer, 2022/05/15
- [elpa] externals/tmr 0ceb744885 01/10: tmr: Improve tmr--long-description, ELPA Syncer, 2022/05/15
- [elpa] externals/tmr f5dcca3588 07/10: tmr: use only active timers for tmr-cancel,
ELPA Syncer <=
- [elpa] externals/tmr 3f8674546b 09/10: tmr: accept optional default in description prompt, ELPA Syncer, 2022/05/15
- [elpa] externals/tmr 407da662a2 10/10: tmr: make tmr-clone prompt optionally, ELPA Syncer, 2022/05/15
- [elpa] externals/tmr c7e0f6f118 06/10: tmr: tweak message for completed tmr, ELPA Syncer, 2022/05/15
- [elpa] externals/tmr b2903077f5 08/10: tmr: store the original input of a timer, ELPA Syncer, 2022/05/15
- [elpa] externals/tmr c1e7580eec 05/10: tmr: print message for cancelled timer, ELPA Syncer, 2022/05/15