[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/tmr e18496d187 07/14: Add tmr--update-hook
From: |
ELPA Syncer |
Subject: |
[elpa] externals/tmr e18496d187 07/14: Add tmr--update-hook |
Date: |
Mon, 27 Jun 2022 12:58:04 -0400 (EDT) |
branch: externals/tmr
commit e18496d187894a0aae4498da09beb2bc9bd2fc30
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Protesilaos Stavrou <info@protesilaos.com>
Add tmr--update-hook
This hook should be called always when tmr--timers or
any timer changes.
---
tmr-tabulated.el | 8 +++-----
tmr.el | 10 ++++++++--
2 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/tmr-tabulated.el b/tmr-tabulated.el
index 2c07298a03..35d9254ab0 100644
--- a/tmr-tabulated.el
+++ b/tmr-tabulated.el
@@ -115,7 +115,7 @@ prompt for a duration."
(tmr-tabulated--get-timer-at-point)
(tmr--description-prompt)))
(setf (tmr--timer-description timer) description)
- (revert-buffer))
+ (run-hooks 'tmr--update-hook))
(defun tmr-tabulated--move-point-to-closest-entry ()
"Move the point to the next entry if there is one or to the previous one.
@@ -145,15 +145,13 @@ Point isn't moved if point is on the only entry."
"Return the timer on the current line or nil."
(tmr--get-timer-by-creation-date (tabulated-list-get-id)))
-(defun tmr-tabulated--refresh (_timer)
+(defun tmr-tabulated--refresh ()
"Refresh *tmr-tabulated-view* buffer if it exists."
(when-let (buf (get-buffer "*tmr-tabulated-view*"))
(with-current-buffer buf
(revert-buffer))))
-(add-hook 'tmr-timer-completed-functions #'tmr-tabulated--refresh)
-(add-hook 'tmr-timer-created-functions #'tmr-tabulated--refresh)
-(add-hook 'tmr-timer-cancelled-functions #'tmr-tabulated--refresh)
+(add-hook 'tmr--update-hook #'tmr-tabulated--refresh)
(provide 'tmr-tabulated)
;;; tmr-tabulated.el ends here
diff --git a/tmr.el b/tmr.el
index 23bd4d60de..b6ec15e746 100644
--- a/tmr.el
+++ b/tmr.el
@@ -190,6 +190,9 @@ original input for TIMER's duration."
"List of timer objects.
Populated by `tmr' and then operated on by `tmr-cancel'.")
+(defvar tmr--update-hook nil
+ "Hooks to execute when timers are changed.")
+
(defun tmr--active-timers ()
"Retun list of active timers."
(cl-remove-if
@@ -215,13 +218,14 @@ With optional NO-HOOKS refrain from calling
(cancel-timer (tmr--timer-timer-object timer))
(setq tmr--timers (delete timer tmr--timers))
(unless no-hooks
+ (run-hooks 'tmr--update-hook)
(run-hook-with-args 'tmr-timer-cancelled-functions timer))))
(defun tmr-remove-finished ()
"Remove all finished timers."
(interactive)
- ;; TODO call tabulated refresh
- (setq tmr--timers (cl-delete-if #'tmr--timer-donep tmr--timers)))
+ (setq tmr--timers (cl-delete-if #'tmr--timer-donep tmr--timers))
+ (run-hooks 'tmr--update-hook))
(defun tmr--read-timer (&optional active description)
"Let the user choose a timer among all timers.
@@ -308,6 +312,7 @@ If optional DEFAULT is provided use it as a default
candidate."
(defun tmr--complete (timer)
"Mark TIMER as completed and execute `tmr-timer-completed-functions'."
(setf (tmr--timer-donep timer) t)
+ (run-hooks 'tmr--update-hook)
(run-hook-with-args 'tmr-timer-completed-functions timer))
;;;###autoload
@@ -345,6 +350,7 @@ command `tmr-with-description' instead of this one."
#'tmr--complete timer)))
(setf (tmr--timer-timer-object timer) timer-object)
(push timer tmr--timers)
+ (run-hooks 'tmr--update-hook)
(run-hook-with-args 'tmr-timer-created-functions timer)))
;;;###autoload
- [elpa] externals/tmr updated (704242b6ba -> 907756ce8d), ELPA Syncer, 2022/06/27
- [elpa] externals/tmr bdd99767bb 03/14: Add tmr-tabulated--refresh, ELPA Syncer, 2022/06/27
- [elpa] externals/tmr 38c9089597 08/14: tmr-remove-finished: Add autoload, ELPA Syncer, 2022/06/27
- [elpa] externals/tmr 9f0dee563b 06/14: Move tmr-sound.el back into tmr.el, ELPA Syncer, 2022/06/27
- [elpa] externals/tmr cfd798b066 11/14: Add tmr-reschedule and tmr-edit-description, ELPA Syncer, 2022/06/27
- [elpa] externals/tmr 907756ce8d 14/14: Acknowledge Daniel Mendler for the latest patches, ELPA Syncer, 2022/06/27
- [elpa] externals/tmr 448be30775 09/14: Improve tmr-clone: Only prompt for description if pressing C-u C-u, ELPA Syncer, 2022/06/27
- [elpa] externals/tmr 6f3b096f2c 13/14: Greatly simplify tmr-tabulated, reuse tmr--read-timer, ELPA Syncer, 2022/06/27
- [elpa] externals/tmr 58d30c4896 12/14: Remove single line functions which were used only once, ELPA Syncer, 2022/06/27
- [elpa] externals/tmr 58224191d0 01/14: Rename struct tmr-timer to tmr--timer, ELPA Syncer, 2022/06/27
- [elpa] externals/tmr e18496d187 07/14: Add tmr--update-hook,
ELPA Syncer <=
- [elpa] externals/tmr e9c6c8861f 02/14: Get rid of tmr-descriptions-list, ELPA Syncer, 2022/06/27
- [elpa] externals/tmr 9974a28933 04/14: Remove unnecessary declare-function, ELPA Syncer, 2022/06/27
- [elpa] externals/tmr d6d5e4d22d 05/14: Warn if dbus is unavailable, ELPA Syncer, 2022/06/27
- [elpa] externals/tmr 92d6163dd0 10/14: Remove no-hooks argument, ELPA Syncer, 2022/06/27