[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/tmr 71b835d71b 15/21: Add message log in "*tmr-messages
From: |
ELPA Syncer |
Subject: |
[elpa] externals/tmr 71b835d71b 15/21: Add message log in "*tmr-messages*" buffer |
Date: |
Thu, 21 Apr 2022 14:58:10 -0400 (EDT) |
branch: externals/tmr
commit 71b835d71b39692d3923382d9bfab31d6b56dc63
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>
Add message log in "*tmr-messages*" buffer
---
tmr.el | 37 +++++++++++++++++++++++++++++++------
1 file changed, 31 insertions(+), 6 deletions(-)
diff --git a/tmr.el b/tmr.el
index 64c6157f80..bac7b5befb 100644
--- a/tmr.el
+++ b/tmr.el
@@ -96,6 +96,28 @@ such notifications."
(call-process-shell-command
(format "ffplay -nodisp -autoexit %s >/dev/null 2>&1" sound) nil 0))))
+(defun tmr--log-in-buffer (log)
+ "Insert LOG message in tmr buffer."
+ (when-let ((buf (get-buffer-create "*tmr-messages*")))
+ (with-current-buffer buf
+ (messages-buffer-mode)
+ (goto-char (point-max))
+ (let ((inhibit-read-only t))
+ (insert (concat log "\n"))))))
+
+(defun tmr-view-echo-area-messages ()
+ "View the '*tmr-messages*' buffer if present."
+ (interactive)
+ (if-let ((buf (get-buffer "*tmr-messages*")))
+ (with-current-buffer buf
+ (goto-char (point-max))
+ (let ((win (display-buffer (current-buffer))))
+ ;; If the buffer is already displayed, we need to forcibly set
+ ;; the window point to scroll to the end of the buffer.
+ (set-window-point win (point))
+ win))
+ (user-error "No *tmr-messages* buffer; have you used `tmr'?")))
+
(defun tmr--notify-send (start &optional description)
"Send system notification for timer with START time.
Optionally include DESCRIPTION."
@@ -115,7 +137,6 @@ Optionally include DESCRIPTION."
:app-name "GNU Emacs"
:urgency tmr-notification-urgency
:sound-file tmr-sound-file)
- ;; TODO 2021-10-01: Maybe add those messages to a tmr buffer?
(message
"TMR %s %s ; %s %s%s"
(propertize "Start:" 'face 'success) start
@@ -138,14 +159,17 @@ argument, prompt for selection among available timers."
(if-let ((timers tmr--timers))
(cond
((= (length timers) 1)
- (let ((object (cdr (car timers))))
- (cancel-timer object)
+ (let ((cell (car timers)))
+ (cancel-timer (cdr cell))
+ (tmr--log-in-buffer (format "CANCELLED <<%s>>" (car cell)))
(setq tmr--timers nil)))
((or select (> (length timers) 1))
(let* ((selection (completing-read "Cancel timer: " (mapc #'car
timers) nil t))
(cell (assoc selection timers #'string-match-p))
+ (key (car cell))
(object (cdr cell)))
(cancel-timer object)
+ (tmr--log-in-buffer (format "CANCELLED <<%s>>" key))
(setq tmr--timers (delete cell tmr--timers)))))
(user-error "No `tmr' to cancel")))
@@ -202,15 +226,16 @@ To cancel the timer, use the `tmr-cancel' command."
(let* ((start (format-time-string "%T"))
(unit (tmr--unit time))
(object-desc (if description
- (format "Started at %s with unit %s and description
'%s'" start unit description)
- (format "Started at %s with unit %s" start unit))))
+ (format "Started at %s with input '%s' and
description '%s'" start time description)
+ (format "Started at %s with input '%s'" start time))))
(tmr--echo-area time description)
(push (cons
object-desc
(run-with-timer
unit nil
'tmr--notify-send start description))
- tmr--timers)))
+ tmr--timers)
+ (tmr--log-in-buffer object-desc)))
(provide 'tmr)
;;; tmr.el ends here
- [elpa] externals/tmr 30784cbe2e 21/21: Bump version to 0.2.1, (continued)
- [elpa] externals/tmr 30784cbe2e 21/21: Bump version to 0.2.1, ELPA Syncer, 2022/04/21
- [elpa] externals/tmr 7ded018cd6 20/21: Use consistent faces, ELPA Syncer, 2022/04/21
- [elpa] externals/tmr d1b9c31dfb 06/21: Prepare initial version of the manual, ELPA Syncer, 2022/04/21
- [elpa] externals/tmr 92ff3e0a39 04/21: Add directory local Elisp variables, ELPA Syncer, 2022/04/21
- [elpa] externals/tmr a7b3f47628 09/21: Clarify docstring about notification urgency, ELPA Syncer, 2022/04/21
- [elpa] externals/tmr 80007165bb 12/21: Use local variable in function, ELPA Syncer, 2022/04/21
- [elpa] externals/tmr cba45349dc 16/21: Tweak tmr--notify-send, ELPA Syncer, 2022/04/21
- [elpa] externals/tmr f48af7b5ff 14/21: Use 'format' instead of 'concat', ELPA Syncer, 2022/04/21
- [elpa] externals/tmr 5b759f7387 19/21: Rewrite documentation, ELPA Syncer, 2022/04/21
- [elpa] externals/tmr 1081feb0b9 11/21: Add comment on Emacs 'play-sound', ELPA Syncer, 2022/04/21
- [elpa] externals/tmr 71b835d71b 15/21: Add message log in "*tmr-messages*" buffer,
ELPA Syncer <=
- [elpa] externals/tmr 807933dd08 01/21: Create tmr.el repository, ELPA Syncer, 2022/04/21
- [elpa] externals/tmr 4c4025e8b4 02/21: Use https link to repo for read access, ELPA Syncer, 2022/04/21
- [elpa] externals/tmr 2749935a01 10/21: Clarify wording of error message, ELPA Syncer, 2022/04/21
- [elpa] externals/tmr 11c3da3559 08/21: Add FSF as copyright holder, ELPA Syncer, 2022/04/21
- [elpa] externals/tmr 183cbff598 13/21: Make 'tmr' and 'tmr-cancel' use list of timers, ELPA Syncer, 2022/04/21