From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id sBdfM1angmeT8wAAe85BDQ:P1 (envelope-from ) for ; Sat, 11 Jan 2025 17:16:07 +0000 Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id sBdfM1angmeT8wAAe85BDQ (envelope-from ) for ; Sat, 11 Jan 2025 18:16:06 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=AuXH2kON; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=posteo.net ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1736615766; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=6Kfkv7Xzy5c0WnG13wOYG5ZK9GPDoxQi8cQ/GNaPQE8=; b=aYTR2rnxRGYFMEpMqbsZ0rxvI/HU9YbWdHJx2J1ByQjmJgRqAjqR9hjPmBxbf0+voaOGWj Cy2HFx0PF8AQx3Lcr6KOp2i1uddYol9kAAYwwq1pn7Ja1i1s4mKLFrVmlrbc/h8912pCEl axE7EKAJRRDw1MZZiW/No0KgnmkZ0dUCES5Lh8ltBFg2h5gVOwLXwsfRrrPg3XQdfirtXS 7HQcq8UsfozxXUo8Es9uHMiVBg2ON2gsrbpqbjFgLwczrhHjptP+c7SYpcwvyso1Xjjj94 7X2+mP10Loh73nR5d/OmqSXQ2MW+6v7ggD0aOBdHUvhKbURkPblUYGapkPxLVA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=AuXH2kON; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=posteo.net ARC-Seal: i=1; s=key1; d=yhetil.org; t=1736615766; a=rsa-sha256; cv=none; b=bHxMeSdlR/4nmVTNoWfcHBxRQNYjRACYYiwWHMRU5Pdiz3GhlJdO0KZudoIiWf1bHuRQQq PY3rAVPlDGafS5w3HBqcMZAt370EtNFummbrNjagQcqTkaGqQ+2CPI8SWte7zfQWfosfHb xoLBuRigHZksCBd8YJjPjlGpRzE9lyAlnr6hKnGjDRyNckbaDqXFWRBefoei1VuTO6brX9 Uy/0JucjKDWeo/go0TfDIvN0EQxvx5PihCApR+y4LCcy0+XAcNElCe2NJKM+Aem84TcAwc XfybpSY97UzjscxYxAY+OWH0DkcSWth+VJSizDzFPkYJ/GHE91kpH0l5xMSMRQ== Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 2E4625042B for ; Sat, 11 Jan 2025 18:16:06 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tWf4r-0001kt-P0; Sat, 11 Jan 2025 12:15:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tWf4o-0001js-1v for emacs-orgmode@gnu.org; Sat, 11 Jan 2025 12:15:10 -0500 Received: from mout01.posteo.de ([185.67.36.65]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tWf4j-000116-Nl for emacs-orgmode@gnu.org; Sat, 11 Jan 2025 12:15:09 -0500 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 99A80240029 for ; Sat, 11 Jan 2025 18:15:00 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1736615700; bh=nzWrsbSrnH9lrNF4DfVuUaF5+KULydShmrrY+kKop88=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: From; b=AuXH2kON71FjX9x+UfCNbHE0n6cqjaQ/bamRpnqAXMKiE1GBUGB2SXFXTE5Uuh24v T7lw9ZnsgJjkg5QkXls0CbW8Mg1Nabl03NgcoEQsrK5ROctIzIm+nOMOVT/4Th+StU mv8ADkedUnBGgAuRC9wA4J/2gAIiCc2BmQAYhotb4pPOlZqeWBqqqQOMFmZeDcYq2j C2aansJbJKbMNpnCS2+xLeIQ9fvRIQAqDe+Gq9qFkfO6y+2sj9jkwcp90K1TBfYyKB kYUA3CkYVlPfCvPByEIm3VM1IUwesQKmfxXJmeHd7IC98YTGlASDQlxfS/W+D9thAB 9dAIxjLUWpwiw== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4YVlWl34cLz9rxK; Sat, 11 Jan 2025 18:14:59 +0100 (CET) From: Ihor Radchenko To: Stefan van der Walt Cc: emacs-orgmode@gnu.org Subject: Re: org-timer: let done hook access time, allow silencing notification In-Reply-To: References: Date: Sat, 11 Jan 2025 17:17:19 +0000 Message-ID: <87a5bxz2w0.fsf@localhost> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=185.67.36.65; envelope-from=yantar92@posteo.net; helo=mout01.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-Migadu-Queue-Id: 2E4625042B X-Migadu-Scanner: mx13.migadu.com X-Migadu-Spam-Score: -0.86 X-Spam-Score: -0.86 X-TUID: +Lgs9NB5ATwd --=-=-= Content-Type: text/plain "Stefan van der Walt" writes: > I have two small improvement suggestions for org-timer, and would like to hear your thoughts. > > 1. I use org-timer to run pomodoro-style clocks. When the timer finishes, I would like to generate a log entry. It would be helpful to be able to access the duration of the clock; however, in org-timer--run-countdown-timer, the variable org-timer-start-time is reset BEFORE the org-timer-done-hook is run. > > Could we reset the variable *after* the hooks are run instead, so that they can access the timer value? Yes, that would make sense. See the attached tentative patch. > 2. I have a custom notification for when the timer is done, installed via the done hook. I would like to suppress the existing notification, but there seems to be no option to do so. Would it make sense to provide a mechanism to override/silence the notification? We can do it. One would need to implement analogues to org-timer-start/stop/pause/continue/set/done-hook that will hold what Org does by default at that point (turn on/off mode line, play sound, print message, etc). Something like org-timer-start/stop/...-default-hook. Then, users can additionally customize those variables to their preference. Patches welcome! --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-org-timer-done-hook-Run-before-the-timer-is-stopped.patch >From ca98848895da7c540e4f20049df53d08dcadddd9 Mon Sep 17 00:00:00 2001 Message-ID: From: Ihor Radchenko Date: Sat, 11 Jan 2025 18:07:43 +0100 Subject: [PATCH] org-timer-done-hook: Run before the timer is stopped * lisp/org-timer.el (org-timer--run-countdown-timer): Stop the timer and unset variables _after_ `org-timer-done-hook' is ran. This way, timer data is available for the hook functions. * etc/ORG-NEWS (~org-timer-done-hook~ is now ran before the timer is stopped): Announce the change. Link: https://orgmode.org/list/a25376e4-f6f6-421d-a8f2-ce280e8d2b15@app.fastmail.com --- etc/ORG-NEWS | 5 +++++ lisp/org-timer.el | 13 +++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index c9bb192de3..328accc216 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -391,6 +391,11 @@ capture ~:tree-type~ options]], the internal variable undocumented helper function ~org-datetree-insert-line~. ** Miscellaneous +*** ~org-timer-done-hook~ is now ran before the timer is stopped + +Previously, ~org-timer-countdown-timer~ and ~org-timer-start-time~ +were unset when the hook is ran. Now, they still hold the timer info. + *** ox-latex: LaTeX images are now stored alongside the exported =.html= file Previously, LaTeX images (when HTML export does use images for LaTeX) diff --git a/lisp/org-timer.el b/lisp/org-timer.el index 9d4e350429..ee13fbe193 100644 --- a/lisp/org-timer.el +++ b/lisp/org-timer.el @@ -108,7 +108,8 @@ (defvar org-timer-set-hook nil "Hook run after countdown timer is set.") (defvar org-timer-done-hook nil - "Hook run after countdown timer reaches zero.") + "Hook run after countdown timer reaches zero. +The hook is ran before the timer is actually stopped.") ;;;###autoload (defun org-timer-start (&optional offset) @@ -470,11 +471,11 @@ (defun org-timer--run-countdown-timer (secs title) (sound org-clock-sound)) (run-with-timer secs nil (lambda () - (setq org-timer-countdown-timer nil - org-timer-start-time nil) - (org-notify msg sound) - (org-timer-set-mode-line 'off) - (run-hooks 'org-timer-done-hook))))) + (org-notify msg sound) + (org-timer-set-mode-line 'off) + (run-hooks 'org-timer-done-hook) + (setq org-timer-countdown-timer nil + org-timer-start-time nil))))) (defun org-timer--get-timer-title () "Construct timer title. -- 2.47.1 --=-=-= Content-Type: text/plain -- Ihor Radchenko // yantar92, Org mode maintainer, Learn more about Org mode at . Support Org development at , or support my work at --=-=-=--