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

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

[elpa] externals/tmr bf9c46ad1e 2/4: tmr: Add tmr-clone to create a time


From: ELPA Syncer
Subject: [elpa] externals/tmr bf9c46ad1e 2/4: tmr: Add tmr-clone to create a timer from an existing one
Date: Fri, 13 May 2022 13:57:57 -0400 (EDT)

branch: externals/tmr
commit bf9c46ad1e7dbf21ea390dcafa4d840e8b807eb1
Author: Damien Cassou <damien@cassou.me>
Commit: Protesilaos Stavrou <info@protesilaos.com>

    tmr: Add tmr-clone to create a timer from an existing one
---
 tmr.el | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/tmr.el b/tmr.el
index a29c577e02..583f191445 100644
--- a/tmr.el
+++ b/tmr.el
@@ -335,9 +335,10 @@ Optionally include DESCRIPTION."
 (defvar tmr--duration-hist '()
   "Minibuffer history of `tmr' durations.")
 
-(defun tmr--read-duration ()
-  "Ask the user to type a duration."
-  (let ((def (nth 0 tmr--duration-hist)))
+(defun tmr--read-duration (&optional default)
+  "Ask the user to type a duration.
+If DEFAULT is provided, use that as a default."
+  (let ((def (or default (nth 0 tmr--duration-hist))))
     (read-string
      (if def
          (format "N minutes for timer (append `h' or `s' for other units) 
[%s]: " def)
@@ -409,5 +410,13 @@ user uses a prefix argument (\\[universal-argument])."
     (tmr--description-prompt)))
   (tmr time description))
 
+;;;###autoload
+(defun tmr-clone (timer)
+  "Create a new timer by cloning TIMER."
+  (interactive (list (tmr--read-timer)))
+  (tmr (tmr--read-duration
+        (format "%ss" (tmr--timer-duration timer)))
+       (tmr--timer-description timer)))
+
 (provide 'tmr)
 ;;; tmr.el ends here



reply via email to

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