emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/tmr a9d4ca04a6 1/7: Simplify tmr--read-timer


From: ELPA Syncer
Subject: [elpa] externals/tmr a9d4ca04a6 1/7: Simplify tmr--read-timer
Date: Tue, 28 Jun 2022 03:57:59 -0400 (EDT)

branch: externals/tmr
commit a9d4ca04a6fb76329b70b6552d69aa6f6b749c98
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Protesilaos Stavrou <info@protesilaos.com>

    Simplify tmr--read-timer
---
 tmr.el | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/tmr.el b/tmr.el
index 1fec868e94..f4de620ac3 100644
--- a/tmr.el
+++ b/tmr.el
@@ -269,7 +269,7 @@ there are no timers, return nil.
 If optional ACTIVE is non-nil, limit the list of timers to those
 that are still running.
 
-If optional DESCRIPTION is provided use it to format the
+If optional DESCRIPTION function is provided use it to format the
 completion candidates."
   (or
    (run-hook-with-args-until-success 'tmr--read-timer-hook)
@@ -281,9 +281,11 @@ completion candidates."
      (`(,timer) timer)
      (timers
       (let* ((formatter (or description #'tmr--long-description))
-             (timer-descriptions (mapcar formatter timers))
-             (selection (completing-read "Timer: " timer-descriptions nil t)))
-        (cl-find selection timers :test #'string= :key formatter))))))
+             (timer-alist (mapcar
+                           (lambda (x)
+                             (cons (funcall formatter x) x))
+                           timers)))
+        (cdr (assoc (completing-read "Timer: " timer-alist nil t) 
timer-alist)))))))
 
 ;; NOTE 2022-04-21: Emacs has a `play-sound' function but it only
 ;; supports .wav and .au formats.  Also, it does not work on all



reply via email to

[Prev in Thread] Current Thread [Next in Thread]