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

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

[elpa] externals/tmr bdd99767bb 03/14: Add tmr-tabulated--refresh


From: ELPA Syncer
Subject: [elpa] externals/tmr bdd99767bb 03/14: Add tmr-tabulated--refresh
Date: Mon, 27 Jun 2022 12:58:04 -0400 (EDT)

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

    Add tmr-tabulated--refresh
    
    Refresh tabulated view when timers finished, are created, cancelled or 
modified.
---
 tmr-tabulated.el | 25 +++++++++++++------------
 tmr.el           |  1 +
 2 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/tmr-tabulated.el b/tmr-tabulated.el
index b734a1a5ba..2c07298a03 100644
--- a/tmr-tabulated.el
+++ b/tmr-tabulated.el
@@ -64,7 +64,7 @@
 (defvar tmr-tabulated-mode-map
   (let ((map (make-sparse-keymap)))
     (define-key map "k" #'tmr-tabulated-cancel)
-    (define-key map "K" #'tmr-tabulated-remove-finished)
+    (define-key map "K" #'tmr-remove-finished)
     (define-key map "+" #'tmr)
     (define-key map "c" #'tmr-tabulated-clone)
     (define-key map "w" #'tmr-tabulated-rewrite-description)
@@ -88,23 +88,14 @@ Interactively, use the timer at point.
 
 Optional NO-HOOKS has the same meaning as in `tmr-cancel'."
   (interactive (list (tmr-tabulated--get-timer-at-point) current-prefix-arg))
-  (tmr-cancel timer no-hooks)
-  ;; avoid point moving back to the beginning of the buffer:
   (tmr-tabulated--move-point-to-closest-entry)
-  (revert-buffer))
-
-(defun tmr-tabulated-remove-finished ()
-  "Remove all finished timers."
-  (interactive)
-  (tmr-remove-finished)
-  (revert-buffer))
+  (tmr-cancel timer no-hooks))
 
 (defun tmr-tabulated-clone (timer)
   "Create a new timer by cloning TIMER.
 Interactively, use the timer at point."
   (interactive (list (tmr-tabulated--get-timer-at-point)))
-  (tmr-clone timer)
-  (revert-buffer))
+  (tmr-clone timer))
 
 (defun tmr-tabulated-reschedule (timer)
   "Reschedule TIMER.
@@ -154,5 +145,15 @@ 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)
+  "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)
+
 (provide 'tmr-tabulated)
 ;;; tmr-tabulated.el ends here
diff --git a/tmr.el b/tmr.el
index 6e821ab4d7..8f5bbb4cf5 100644
--- a/tmr.el
+++ b/tmr.el
@@ -218,6 +218,7 @@ With optional NO-HOOKS refrain from calling
 (defun tmr-remove-finished ()
   "Remove all finished timers."
   (interactive)
+  ;; TODO call tabulated refresh
   (setq tmr--timers (cl-delete-if #'tmr--timer-donep tmr--timers)))
 
 (defun tmr--read-timer (&optional active description)



reply via email to

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