From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id Dt/ZNwYjVmPPWgEAbAwnHQ (envelope-from ) for ; Mon, 24 Oct 2022 07:30:46 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id mOTnNgYjVmMkXgEA9RJhRA (envelope-from ) for ; Mon, 24 Oct 2022 07:30:46 +0200 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 8CA163A1E7 for ; Mon, 24 Oct 2022 07:30:46 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1omj4Y-0003k8-A7 for larch@yhetil.org; Sun, 23 Oct 2022 18:03:58 -0400 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 1omJLf-0005vQ-80 for emacs-orgmode@gnu.org; Sat, 22 Oct 2022 14:35:57 -0400 Received: from mx.flintfam.org ([2001:19f0:6401:1c4:5400:ff:fe4b:c898]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1omJLc-0000hE-1q for emacs-orgmode@gnu.org; Sat, 22 Oct 2022 14:35:54 -0400 Received: by mx.flintfam.org (Postfix, from userid 114) id 38FE91F594; Sat, 22 Oct 2022 18:35:51 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.9.2 mx.flintfam.org 38FE91F594 Received: from landau.flintfam.org (162-210-5-149.lnk.ne.static.allophone.net [162.210.5.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx.flintfam.org (Postfix) with ESMTPSA id 24AF71F561 for ; Sat, 22 Oct 2022 18:35:49 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.9.2 mx.flintfam.org 24AF71F561 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=flintfam.org; s=mail; t=1666463749; bh=a1LsLmrjY8ocvabzSsSf+ZYRM9vCJICIGa+uCmttZMk=; h=Resent-To:Resent-From:Resent-Date:From:To:Subject:Date:From; b=QA9SRALQyYmMu+Twx+k1qhdhyvcoHT7H3M7AcVdl4HGmdQ1Gd0IhU73Sdxil+iNGs wSok3COM5EC66Oj48QcQEGfCpWTbfrMLjIv8KaEECr4PNQmBBjd+9I8O96E40qCgu4 hT8xXu3O1gNV2Y54uXzDKdiqYTGDcJw3bfQKaVq5TbN4K+nYL94cIyRxv2vC3vYuez nlXGaTl/GHXZA1VDj999D9uSksmcJH088LUYvnboQt6BKISzs+PtWPd1oaBc/wR/7Y 5PkCjyzNCvaIUcHGDAjnEtJCeZiCgwnXixkAnaRoeBKDY6ccViS34ShS2AjW5XhuJm JxpPc5v1orgOQ== Resent-To: "Org-Mode" Resent-From: "Samuel W. Flint" Resent-Date: Sat, 22 Oct 2022 13:35:47 -0500 Resent-Message-ID: <87k04rvh8c.fsf@flintfam.org> X-From-Line: nobody Sat Oct 22 13:29:27 2022 From: "Samuel W. Flint" To: "Org-Mode" Subject: [PATCH 1/2] lisp/org-clock.el: Make switching states on clock-in/-out easier Date: Sat, 22 Oct 2022 13:29:24 -0500 Message-ID: <87sfjfvhiz.fsf@flintfam.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=2001:19f0:6401:1c4:5400:ff:fe4b:c898; envelope-from=swflint+orgmode@flintfam.org; helo=mx.flintfam.org X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 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_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1666589446; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-to: resent-from:resent-message-id:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=a1LsLmrjY8ocvabzSsSf+ZYRM9vCJICIGa+uCmttZMk=; b=HpsZBq5g8vU/c+EZRXnh/Aj9tgUupH0CkYe/Cx0ZWzRClTUgvmG4fR3va7+aBOaOMT3jBD O0fmSpcydGQohcXIEF20LBFWXBtcncIQQ/g8RghcyzlYFyhmrdFv5LFUVmcdrN5VetQ9Xu oFTNW0YtzPqhthxmJUbn2ikIUZOmw/IMmT6lW6gzIr+BwqQiRUmEfR4Llc+/NcCKjjoDE3 lTd+3e9b3dfRyecuLsZ9Imw4A57yLWqWZAsT09i5yq8gKOvQXSbxP5oOtdzOXin9EfZpma VnzWKs18VDnYiRElwfBTEX3IN2s5b/U5pD8+yh/OvX+OoC/qGRux3plAUJijSQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1666589446; a=rsa-sha256; cv=none; b=BgHiU/va71zaHydXUUM3cNiE8uMxQBMMxaELh2FskrpGItinKByW8MYQeJUbLBwcCUgiNd SJSBPeWGLVEwcF2mPeRYPInjQDI/D7Ijn3a/NnN01Hk5vdgOBWB8Cr9BZ9wb4slWzPZVD7 gWsaXsLVm6hq3jfYHagZTHm/TcKdVx2fUJtJkOZvr798di4eVbCCFiXNScEHkwYUZkSvJ7 yfV06NVWhy/AXbxiqSdgOY7i3Ac/Fk3U9In3Zu2f0CW5gaoXzW9NgyQcneEREl4nTxE2Hh fX2xV69xiLaFTxxxjIAFEA23fCT+4ODtuF0p3RaQOdTbpXTVZUCKbyqiW6GHSw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=flintfam.org header.s=mail header.b=QA9SRALQ; dmarc=none; 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" X-Migadu-Spam-Score: -6.20 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=flintfam.org header.s=mail header.b=QA9SRALQ; dmarc=none; 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" X-Migadu-Queue-Id: 8CA163A1E7 X-Spam-Score: -6.20 X-Migadu-Scanner: scn0.migadu.com X-TUID: ERHMECdkDlRl * lisp/org-clock.el (org-clock-in-next-state, org-clock-out-next-state): Define and document customizeable variables to describe the "next state" on clock-in/-out. (org-clock-in-switch-to-state, org-clock-out-switch-to-state): Add options to use the `org-clock-{in,out}-next-state' variables to change on clock-in/-out. (org-clock-in-next-state-function, org-clock-out-next-state-function): Define functions which can be used to select the next TODO state on clock-in/-out. --- lisp/org-clock.el | 48 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) diff --git a/lisp/org-clock.el b/lisp/org-clock.el index 6332399bb..18cd83988 100644 --- a/lisp/org-clock.el +++ b/lisp/org-clock.el @@ -145,6 +145,16 @@ out time will be 14:50." :group 'org-clock :type 'boolean) =20 +(defcustom org-clock-in-next-state nil + "Alist of next TODO states for clocking out. +The symbol `error' may be used to prevent clocking out on tasks." + :group 'org-clock + :group 'org-todo + :type '(alist :key-value (string :tag "Current State:") + :value-type (choice :tag "Next State :" + (string :tag "TODO Keyword") + (const :tag "Block Clock-In" 'error))= )) + (defcustom org-clock-in-switch-to-state nil "Set task to a special todo state while clocking it. The value should be the state to which the entry should be @@ -156,7 +166,18 @@ state to switch it to." :type '(choice (const :tag "Don't force a state" nil) (string :tag "State") - (symbol :tag "Function"))) + (const :tag "Use `org-clock-in-next-state'" 'org-clock-in-next-state-fu= nction) + (symbol :tag "Function"))) + +(defcustom org-clock-out-next-state nil + "Alist of next TODO states for clocking out. +The symbol `error' may be used to prevent clocking in on tasks." + :group 'org-clock + :group 'org-todo + :type '(alist :key-value (string :tag "Current State:") + :value-type (choice :tag "Next State :" + (string :tag "TODO Keyword") + (const :tag "Block Clock-Out" 'error)= ))) =20 (defcustom org-clock-out-switch-to-state nil "Set task to a special todo state after clocking out. @@ -169,7 +190,8 @@ state to switch it to." :type '(choice (const :tag "Don't force a state" nil) (string :tag "State") - (symbol :tag "Function"))) + (const :tag "Use `org-clock-out-next-state'" 'org-clock-out-next-state-= function) + (symbol :tag "Function"))) =20 (defcustom org-clock-history-length 5 "Number of clock tasks to remember in history. @@ -1256,6 +1278,17 @@ so long." (defvar org-clock-out-time nil) ; store the time of the last clock-out (defvar org--msg-extra) =20 +(defun org-clock-in-next-state-function (state) + "Change state to the next logical TODO STATE on clock-in. + +Use `org-clock-in-next-state'." + (when-let ((state-pair (assoc state org-clock-in-next-state)) + (next-state (cdr state-pair))) + (if (and (symbolp next-state) + (eq 'error next-state)) + (user-error (format "Cannot clock into %s task, change to a valid = TODO state." state)) + next-state))) + ;;;###autoload (defun org-clock-in (&optional select start-time) "Start the clock on the current item. @@ -1650,6 +1683,17 @@ and current `frame-title-format' is equal to `org-cl= ock-frame-title-format'." (equal frame-title-format org-clock-frame-title-format)) (setq frame-title-format org-frame-title-format-backup))) =20 +(defun org-clock-out-next-state-function (state) + "Change state to the next logical TODO STATE on clock-out. + +Use `org-clock-out-next-state'." + (when-let ((state-pair (assoc state org-clock-out-next-state)) + (next-state (cdr state-pair))) + (if (and (symbolp next-state) + (eq 'error next-state)) + (user-error (format "Cannot clock into %s task, change to a valid = TODO state." state)) + next-state))) + ;;;###autoload (defun org-clock-out (&optional switch-to-state fail-quietly at-time) "Stop the currently running clock. --=20 2.37.3 --=20 Samuel W. Flint 4096R/FA13D704 (F50D 862B 4F65 5943 A8C2 EF0E 86C9 3E7A FA13 D704) =CE=BBs.(s s) =CE=BBs.(s s) O< ascii ribbon campaign - stop html mail - www.asciiribbon.org