[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/tmr b623d90190 2/2: tmr-tabulated: add redescribe and r
From: |
ELPA Syncer |
Subject: |
[elpa] externals/tmr b623d90190 2/2: tmr-tabulated: add redescribe and reschedule cmds |
Date: |
Sun, 15 May 2022 04:58:01 -0400 (EDT) |
branch: externals/tmr
commit b623d901906a5faabcfee75ef8dbceba969fc53c
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>
tmr-tabulated: add redescribe and reschedule cmds
Thanks to Damien Cassou for suggesting this idea:
<https://lists.sr.ht/~protesilaos/tmr/%3C87ilq9bej3.fsf@cassou.me%3E#%3C87zgjka4kv.fsf@cassou.me%3E>.
---
tmr-tabulated.el | 32 ++++++++++++++++++++++++++++----
tmr.el | 2 +-
2 files changed, 29 insertions(+), 5 deletions(-)
diff --git a/tmr-tabulated.el b/tmr-tabulated.el
index 5f5aa81ecd..44e2f205e0 100644
--- a/tmr-tabulated.el
+++ b/tmr-tabulated.el
@@ -63,6 +63,8 @@
(define-key map "k" #'tmr-tabulated-cancel)
(define-key map "+" #'tmr)
(define-key map "c" #'tmr-tabulated-clone)
+ (define-key map "w" #'tmr-tabulated-rewrite-description)
+ (define-key map "r" #'tmr-tabulated-reschedule)
map)
"Keybindings for `tmr-tabulated-mode-map'.")
@@ -76,11 +78,13 @@
(add-hook 'tabulated-list-revert-hook #'tmr-tabulated--set-entries nil t)
(tabulated-list-init-header))
-(defun tmr-tabulated-cancel (timer)
+(defun tmr-tabulated-cancel (timer &optional no-hooks)
"Stop TIMER and remove it from the list.
-Interactively, use the timer at point."
- (interactive (list (tmr-tabulated--get-timer-at-point)))
- (tmr-cancel timer)
+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))
@@ -92,6 +96,26 @@ Interactively, use the timer at point."
(tmr-clone timer)
(revert-buffer))
+(defun tmr-tabulated-reschedule (timer)
+ "Reschedule TIMER.
+This is the same as cloning it and cancelling the original one.
+
+If TIMER has a description, prompt for one. Otherwise only
+prompt for a duration."
+ (interactive (list (tmr-tabulated--get-timer-at-point)))
+ (tmr-clone timer :prompt)
+ ;; Cancel the old timer
+ (tmr-tabulated-cancel timer :no-hooks))
+
+(defun tmr-tabulated-rewrite-description (timer description)
+ "Change TIMER description with that of DESCRIPTION."
+ (interactive
+ (list
+ (tmr-tabulated--get-timer-at-point)
+ (tmr--description-prompt)))
+ (setf (tmr--timer-description timer) description)
+ (revert-buffer))
+
(defun tmr-tabulated--move-point-to-closest-entry ()
"Move the point to the next entry if there is one or to the previous one.
Point isn't moved if point is on the only entry."
diff --git a/tmr.el b/tmr.el
index 1ca6fd124c..8c90918eba 100644
--- a/tmr.el
+++ b/tmr.el
@@ -177,7 +177,7 @@ Each function must accept a timer as argument."
:documentation "The original input which is internally interpreted as a
duration.")
(description
nil
- :read-only t
+ :read-only nil
:documentation "Optional string describing the purpose of the timer, e.g.,
\"Stop the oven\"."))
(defun tmr--long-description (timer)