branch: externals/tmr
commit 6d4bc6ffb12b938b79ac75196736003afde5ffc9
Author: Protesilaos Stavrou <[email protected]>
Commit: Protesilaos Stavrou <[email protected]>
Add user option tmr-tabulated-refresh-interval
---
README.org | 9 +++++++++
tmr.el | 14 ++++++++++++--
2 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/README.org b/README.org
index 70dc061764..cee5c8ebc6 100644
--- a/README.org
+++ b/README.org
@@ -210,6 +210,15 @@ While in this grid view, one can perform all the
operations on timers we
have already covered herein (the =C-h m= will show you their key
bindings in this mode).
+By default, the ~tmr-tabulated-view~ buffer is updated automatically
+every 5 seconds. Users can change the number of seconds by modifying
+the user option ~tmr-tabulated-refresh-interval~. A ~nil~ value means
+to never refresh that buffer automatically: users can update it
+manually by invoking the command ~revert-buffer~, which is bound to
+=g= by default. [ This is part of {{{development-version}}}, instead
+of the old arrangement of updating the buffer every second without an
+option to change it. ]
+
#+vindex: tmr-list-timers-action-alist
The user option ~tmr-list-timers-action-alist~ controls how the
command ~tmr-tabulated-view~ displays its buffer. Its default
diff --git a/tmr.el b/tmr.el
index 77d4f96f3a..cf291288ad 100644
--- a/tmr.el
+++ b/tmr.el
@@ -125,6 +125,15 @@ Each function must accept a timer as argument."
:package-version '(tmr . "1.0.0")
:type 'string)
+(defcustom tmr-tabulated-refresh-interval 5
+ "Refresh the `tmr-tabulated-view' buffer after these many seconds.
+If the value is nil, then never automatically refresh that buffer: the
+user can do that manually by invoking the command `revert-buffer'."
+ :package-version '(tmr . "1.3.0")
+ :type '(choice
+ (natnum :tag "Seconds to auto-refresh the `tmr-tabulated-view'
buffer")
+ (const :tag "Never auto-refresh the `tmr-tabulated-view' buffer")))
+
(defun tmr-select-and-resize (window)
"Select WINDOW and fit it to its buffer."
(select-window window)
@@ -897,8 +906,9 @@ they are set to reasonable default values."
(cancel-timer timer)
(setq tmr-tabulated--refresh-timer nil)))
(cancel-timer timer)))))
- (setq timer (run-at-time 1 1 refresh)
- tmr-tabulated--refresh-timer timer)))
+ (when (natnump tmr-tabulated-refresh-interval)
+ (setq timer (run-at-time nil tmr-tabulated-refresh-interval
refresh)
+ tmr-tabulated--refresh-timer timer))))
(when tmr-tabulated--refresh-timer
(cancel-timer tmr-tabulated--refresh-timer)
(setq tmr-tabulated--refresh-timer nil))))