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

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

[elpa] externals/theme-buffet 9b866c9eb4 10/12: Improved theme-buffet--d


From: ELPA Syncer
Subject: [elpa] externals/theme-buffet 9b866c9eb4 10/12: Improved theme-buffet--define-timer macro.
Date: Fri, 24 Nov 2023 15:58:49 -0500 (EST)

branch: externals/theme-buffet
commit 9b866c9eb4650d6ebd63a1289d251bd5d875659f
Author: bboal <egomet@bboal.com>
Commit: bboal <egomet@bboal.com>

    Improved theme-buffet--define-timer macro.
---
 theme-buffet.el | 34 +++++++++++++++++-----------------
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/theme-buffet.el b/theme-buffet.el
index 79195adb6e..5bcb4383af 100644
--- a/theme-buffet.el
+++ b/theme-buffet.el
@@ -351,38 +351,38 @@ An error message will appear if the theme is not 
available to load through
   (when-let (((boundp timer-obj))
              (obj (symbol-value timer-obj)))
     (cancel-timer obj)
-    (set timer-obj nil)))
+    (set timer-obj nil)
+    (message "Break time in the Theme-Buffet kitchen!")))
 
 
-(defmacro theme-buffet--define-timer(units)
+(defmacro theme-buffet--define-timer (units)
   "Define interactive functions to set timer in UNITS.
 UNITS is an unquoted symbol, mins or hours and refers to timer of the same
 naming."
   (let ((fn-name (intern (format "theme-buffet-timer-%s" units)))
-        (factor (pcase units
-                  ('mins 60)
-                  ('hours 3600)
-                  (_ (user-error
-                      "Bad `units' arg on `theme-buffet--define-timer %s'" 
units)))))
+        factor max-num)
+    (pcase units
+      ('mins (setq factor 60 max-num 180))
+      ('hours (setq factor 3600 max-num 12))
+      (_ (user-error
+          "Bad `units' arg on `theme-buffet--define-timer %s'" units)))
     `(defun ,fn-name (number)
-       ,(format "Set interactively the timer for NUMBER of %s." units)
+       ,(format "Set interactively the timer for NUMBER of %s.
+When NUMBER is 0, the timer is cancelled. Maximum value is %s" units max-num)
        (interactive
-        (list (read-number ,(format "Theme Buffet service in how many %s? " 
units)
-                           nil
+        (list (read-number ,(format "Theme Buffet service in how many %s? " 
units) nil
                            'theme-buffet-user-timers-history)))
        (if-let (((natnump number))
-                (max-num ,(if (eq units 'mins) 180 12))
-                (min-num ,(if (eq units 'mins) 1 -12))
-                ((and (>= number min-num)
-                      (<= number max-num)))
+                ((<= number ,max-num))
                 (timer-secs (* ,factor number)))
-           (progn
+           (if (equal number 0)
+               (theme-buffet--free-timer ',fn-name)
              (setq ,fn-name (run-at-time timer-secs timer-secs
                                          #'theme-buffet--load-random
                                          (theme-buffet--get-period-keyword)))
              (message "Theme-Buffet Sous-Chef is rushing into the kitchen..."))
-         (user-error "The input number should be a natural between %s and %s 
instead of `%s'"
-                  min-num max-num number)))))
+         (user-error "The input number should be a natural up to %s instead of 
`%s'"
+                     ,max-num number)))))
 
 ;;;###autoload (autoload 'theme-buffet-timer-mins "theme-buffet")
 (theme-buffet--define-timer mins)   ; (theme-buffet-timer-mins n)



reply via email to

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