[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/tmr 41c44c2154 3/7: tmr-tabulated: Bind "k" to the new
From: |
ELPA Syncer |
Subject: |
[elpa] externals/tmr 41c44c2154 3/7: tmr-tabulated: Bind "k" to the new tmr-tabulated-cancel command |
Date: |
Wed, 11 May 2022 04:57:55 -0400 (EDT) |
branch: externals/tmr
commit 41c44c2154c8f493d1de272b36611c890ef399ad
Author: Damien Cassou <damien@cassou.me>
Commit: Protesilaos Stavrou <info@protesilaos.com>
tmr-tabulated: Bind "k" to the new tmr-tabulated-cancel command
---
tmr-tabulated.el | 38 ++++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/tmr-tabulated.el b/tmr-tabulated.el
index 8422644024..ca1f8e4066 100644
--- a/tmr-tabulated.el
+++ b/tmr-tabulated.el
@@ -55,6 +55,7 @@
(defvar tmr-tabulated-mode-map
(let ((map (make-sparse-keymap)))
+ (define-key map "k" #'tmr-tabulated-cancel)
map)
"Keybindings for `tmr-tabulated-mode-map'.")
@@ -68,5 +69,42 @@
(add-hook 'tabulated-list-revert-hook #'tmr-tabulated--set-entries)
(tabulated-list-init-header))
+(defun tmr-tabulated-cancel (timer)
+ "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)
+ ;; avoid point moving back to the beginning of the buffer:
+ (tmr-tabulated--move-point-to-closest-entry)
+ (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."
+ (if (tmr-tabulated--next-entry)
+ (next-line)
+ (when (tmr-tabulated--previous-entry)
+ (previous-line))))
+
+(defun tmr-tabulated--previous-entry ()
+ "Return the entry on the line before point, nil if none."
+ (save-excursion
+ (setf (point) (line-beginning-position))
+ (unless (bobp)
+ (previous-line)
+ (tabulated-list-get-id))))
+
+(defun tmr-tabulated--next-entry ()
+ "Return the entry on the line after point, nil if none."
+ (save-excursion
+ (setf (point) (line-end-position))
+ (unless (eobp)
+ (next-line)
+ (tabulated-list-get-id))))
+
+(defun tmr-tabulated--get-timer-at-point ()
+ "Return the timer on the current line or nil."
+ (tmr--get-timer-by-creation-date (tabulated-list-get-id)))
+
(provide 'tmr-tabulated)
;;; tmr-tabulated.el ends here
- [elpa] externals/tmr updated (4bf30baacb -> d8071f7476), ELPA Syncer, 2022/05/11
- [elpa] externals/tmr 41c44c2154 3/7: tmr-tabulated: Bind "k" to the new tmr-tabulated-cancel command,
ELPA Syncer <=
- [elpa] externals/tmr 81aa6ce65c 6/7: Use forward-line instead of {next, previous}-line, ELPA Syncer, 2022/05/11
- [elpa] externals/tmr 15089d145e 2/7: tmr-tabulated: Add documentation to the Commentary section, ELPA Syncer, 2022/05/11
- [elpa] externals/tmr b240741a14 4/7: Add Damien Cassou as author, ELPA Syncer, 2022/05/11
- [elpa] externals/tmr 4d8c70530c 1/7: tmr-cancel: Fix, ELPA Syncer, 2022/05/11
- [elpa] externals/tmr d8071f7476 7/7: Use let bound variable in tmr--read-timer, ELPA Syncer, 2022/05/11
- [elpa] externals/tmr 90526a0310 5/7: Fix placement of comma for Authors, ELPA Syncer, 2022/05/11