[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/theme-buffet 96f123f44b 07/12: Refactor `theme-buffet--
|
From: |
ELPA Syncer |
|
Subject: |
[elpa] externals/theme-buffet 96f123f44b 07/12: Refactor `theme-buffet--define-timer' |
|
Date: |
Fri, 24 Nov 2023 15:58:48 -0500 (EST) |
branch: externals/theme-buffet
commit 96f123f44b54504df78e07cba706d3710b90e7ec
Author: bboal <egomet@bboal.com>
Commit: bboal <egomet@bboal.com>
Refactor `theme-buffet--define-timer'
---
theme-buffet.el | 38 ++++++++++++++++++--------------------
1 file changed, 18 insertions(+), 20 deletions(-)
diff --git a/theme-buffet.el b/theme-buffet.el
index 02a2355bb6..75c7f59d4d 100644
--- a/theme-buffet.el
+++ b/theme-buffet.el
@@ -359,32 +359,30 @@ An error message will appear if the theme is not
available to load through
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)))
- (max-mins 180) (min-mins 1)
- (max-hours 12) (min-hours -12)
- (factor
- (cond
- ((eq units 'mins) 60)
- ((eq units 'hours) 3600)
- (t (user-error
- "Bad `units' argument on `theme-buffet--define-timer %s'"
units)))))
+ (factor (pcase units
+ ('mins 60)
+ ('hours 3600)
+ (_ (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)
(interactive
(list (read-number ,(format "Theme Buffet service in how many %s? "
units)
nil
'theme-buffet-user-timers-history)))
- (let ((max-num ,(if (eq units 'mins) max-mins max-hours))
- (min-num ,(if (eq units 'mins) min-mins min-hours)))
- (if (or (not (natnump number))
- (> number max-num)
- (< number min-num))
- (message "The input number should be a natural between %s and %s
instead of `%s'."
- min-num max-num number)
- (let ((timer-secs (* ,factor number)))
- (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...")))))))
+ (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)))
+ (timer-secs (* ,factor number)))
+ (progn
+ (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)))))
;;;###autoload (autoload 'theme-buffet-timer-mins "theme-buffet")
(theme-buffet--define-timer mins) ; (theme-buffet-timer-mins n)
- [elpa] externals/theme-buffet c00d1e4097 01/12: First Commit, (continued)
- [elpa] externals/theme-buffet c00d1e4097 01/12: First Commit, ELPA Syncer, 2023/11/24
- [elpa] externals/theme-buffet 753800bb0e 06/12: More semantic and whitespace fix, ELPA Syncer, 2023/11/24
- [elpa] externals/theme-buffet 756a5f67c5 05/12: Whitespace cleanup and added double space on sentence end., ELPA Syncer, 2023/11/24
- [elpa] externals/theme-buffet 524a2eabbb 04/12: Reviewed some suggestions from Philip Kaludercic, ELPA Syncer, 2023/11/24
- [elpa] externals/theme-buffet e412016226 09/12: Corrected functions docstrings, ELPA Syncer, 2023/11/24
- [elpa] externals/theme-buffet 4e9a20f00a 03/12: Added README.md for short explanation of the package, ELPA Syncer, 2023/11/24
- [elpa] externals/theme-buffet ca58fb481a 02/12: Adding COPYING file for licensing purposes, ELPA Syncer, 2023/11/24
- [elpa] externals/theme-buffet 6b2d2dbba2 08/12: Remove period from user-error in `theme-buffet--define-timer' macro., ELPA Syncer, 2023/11/24
- [elpa] externals/theme-buffet dfcb3c5093 12/12: Added "Usage" heading in "Commentary" section, ELPA Syncer, 2023/11/24
- [elpa] externals/theme-buffet 3c049e1672 11/12: Improved messaging in `theme-buffet--reload-theme' function., ELPA Syncer, 2023/11/24
- [elpa] externals/theme-buffet 96f123f44b 07/12: Refactor `theme-buffet--define-timer',
ELPA Syncer <=
- [elpa] externals/theme-buffet 9b866c9eb4 10/12: Improved theme-buffet--define-timer macro., ELPA Syncer, 2023/11/24