From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <emacs-orgmode-bounces+larch=yhetil.org@gnu.org>
Received: from mp1 ([2001:41d0:2:bcc0::])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	by ms0.migadu.com with LMTPS
	id 6ISYLBDntGArtgAAgWs5BA
	(envelope-from <emacs-orgmode-bounces+larch=yhetil.org@gnu.org>)
	for <larch@yhetil.org>; Mon, 31 May 2021 15:39:28 +0200
Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	by mp1 with LMTPS
	id eLjoJxDntGBJcQAAbx9fmQ
	(envelope-from <emacs-orgmode-bounces+larch=yhetil.org@gnu.org>)
	for <larch@yhetil.org>; Mon, 31 May 2021 13:39:28 +0000
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 632A617BD2
	for <larch@yhetil.org>; Mon, 31 May 2021 15:39:27 +0200 (CEST)
Received: from localhost ([::1]:53500 helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <emacs-orgmode-bounces+larch=yhetil.org@gnu.org>)
	id 1lni8c-0001qL-D3
	for larch@yhetil.org; Mon, 31 May 2021 09:39:26 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:54594)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <yantar92@gmail.com>)
 id 1lni7y-0001po-Vt
 for emacs-orgmode@gnu.org; Mon, 31 May 2021 09:38:47 -0400
Received: from mail-lf1-x132.google.com ([2a00:1450:4864:20::132]:34531)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <yantar92@gmail.com>)
 id 1lni7v-00045J-OE
 for emacs-orgmode@gnu.org; Mon, 31 May 2021 09:38:46 -0400
Received: by mail-lf1-x132.google.com with SMTP id f30so16970755lfj.1
 for <emacs-orgmode@gnu.org>; Mon, 31 May 2021 06:38:43 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=from:to:subject:in-reply-to:references:cc:date:message-id
 :mime-version; bh=zk3eOmbUmzTCZ47by6gcz4PY1Ln/iVqfWUzRFstrN3I=;
 b=kaFhMbXhKbBu5Vp8uGBayN+6i+v2xbBB0lQnP7svFMk4rbz2P50CQB7/MlQaKOMNl7
 78Uv7Xhj8EyM6PnKUYcJixMvqiGmkSkQa9UiPbAVRMpb9q6oc1njGW0HCCgl+KeOlRVS
 DaVe1L3H8Akg7TOwP/m2yhRvF86sGhc8MfyPd6cHP2Lh3mcB13myqtXv+kPpKsQWLigl
 FPTv2rPoBpwOTzKQPua8J+JMH1LhmohG+PAbqztfXuFd7vgaMh+ewVqxyYXQUYUug3FX
 qpNOZOyNkoqZYSZ7hGeOLoULff9vbrL1VWxnBAH2bvsaUmWXH8RKVJ4Eb7J/uxfmhmUB
 rSWA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:from:to:subject:in-reply-to:references:cc:date
 :message-id:mime-version;
 bh=zk3eOmbUmzTCZ47by6gcz4PY1Ln/iVqfWUzRFstrN3I=;
 b=cXu9FLUbpoznyb9tsB7nloc2q1Gdp7c1YiGgVQIUNHcozRDQh6tCxToNbZqHPSgzeY
 mXVHknULI0POL0hAUcgVUokLim/Yh1pOOtby/p6ssbdq05OstuhOqSFZ4TezEDbLUgoW
 y4UKF7GqZEKWTKT7Csc9RhDX2jaEZSyhfKGLY8Z/tY5FOVrWqf3hB8r1E19vcYMxNXA+
 q7yMV8oYOXRNTnsLq9PF61quKCu6G4Dt8GwWeNWFNmWhPsMghVvoMovxWqVWw74+o8Nm
 S3bP6SgKxo0B9jJOxUZBoRcHqS6QqnsuwYwO2MeHW85qtcSU2/VaNT75IcpCsU4bdFrH
 SdbQ==
X-Gm-Message-State: AOAM533igkUnJPPHUI7dJU7alUD8IgpST7ENP4nCVUw5kvAJZ+JajacP
 h/1avYTixW67S3e2ofSwSRA=
X-Google-Smtp-Source: ABdhPJyeOaNthpMzmES991RmAGAgT+Ly/oyMJ/nl726hGGXUhBOkN3EfunGWlnlB31C1rGg2G3F47g==
X-Received: by 2002:ac2:4246:: with SMTP id m6mr15016112lfl.611.1622468322027; 
 Mon, 31 May 2021 06:38:42 -0700 (PDT)
Received: from localhost ([158.255.2.9])
 by smtp.gmail.com with ESMTPSA id y22sm1346160lfh.154.2021.05.31.06.38.40
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Mon, 31 May 2021 06:38:41 -0700 (PDT)
From: Ihor Radchenko <yantar92@gmail.com>
To: "Jorge P. de Morais Neto" <jorge+list@disroot.org>
Subject: Re: Bug: Reclocking errors out if org-log-note-clock-out is t
 [9.4.6 (9.4.6-gab9f2a @
 /gnu/store/2pny4z6mbi2aybgzzxz0yrzkds7hbpmq-emacs-org-9.4.6/share/emacs/site-lisp/org-9.4.6/)]
In-Reply-To: <87h7ilm484.fsf@disroot.org>
References: <87h7ilm484.fsf@disroot.org>
X-Woof-Patch: yes
Date: Mon, 31 May 2021 21:43:23 +0800
Message-ID: <877djf10jo.fsf@localhost>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
Received-SPF: pass client-ip=2a00:1450:4864:20::132;
 envelope-from=yantar92@gmail.com; helo=mail-lf1-x132.google.com
X-Spam_score_int: -17
X-Spam_score: -1.8
X-Spam_bar: -
X-Spam_report: (-1.8 / 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,
 FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001,
 RCVD_IN_DNSWL_NONE=-0.0001, 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.23
Precedence: list
List-Id: "General discussions about Org-mode." <emacs-orgmode.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/emacs-orgmode>,
 <mailto:emacs-orgmode-request@gnu.org?subject=unsubscribe>
List-Archive: <https://lists.gnu.org/archive/html/emacs-orgmode>
List-Post: <mailto:emacs-orgmode@gnu.org>
List-Help: <mailto:emacs-orgmode-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/emacs-orgmode>,
 <mailto:emacs-orgmode-request@gnu.org?subject=subscribe>
Cc: emacs-orgmode@gnu.org
Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org
Sender: "Emacs-orgmode" <emacs-orgmode-bounces+larch=yhetil.org@gnu.org>
X-Migadu-Flow: FLOW_IN
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org;
	s=key1; t=1622468368;
	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=zk3eOmbUmzTCZ47by6gcz4PY1Ln/iVqfWUzRFstrN3I=;
	b=rp/XE9tSl4YXc2R1MlgC9sZBz1eQIcmz2o4xFnBfhunzsXVPt7RegNykDVOK8qBGRE55yP
	QfLZ3aZA0yyajF9AAmA53ehV9lbA3AWrpgLOluBe74/nn83ptCah7CxtlJ96pruNMgKAgb
	na6XRIsqAsKQ+KKGKWUbULtlyP4Nl3VsvJ9t/YTgdMF8pjixsHrww2OuYyE/kb0BuI+z9A
	saoKe52u8RBH+iyIA0GDn1Uo94s3TIAIXVJQTX+CmuXc4ZWOKRr7JqQyksHG5LVfuOBWJN
	rKWi69fTSNATCs85sC0inip7FpumMolgD1sh61Olqv6BTF8ParHj+1ALhUZGXg==
ARC-Seal: i=1; s=key1; d=yhetil.org; t=1622468368; a=rsa-sha256; cv=none;
	b=ir5WgLHcS0dWTX/glxvTz58hak5TSv7/MDGPitQQ+9ue3X/CSz4VvuJm9VljDSNRUZGmgA
	Bn0DDRCmYj+WF+BWuSLyiMlLgBVpoMip5YV73k17X/j8B7j63yXCbjyGHA9Izlkl06mxJ6
	BuAXVpsy5Gf3F8jCtmWSxnnFFrYn5fMYyj3etN9lkIgoWfvhIqkZqLlgy5f6bcUCwWnE6E
	rQ6uosK7eh8nyNCjPf+H9oRV4VcBPMCOazv2le1GIPIYM6gVdQVejB3kMnjafubqK4D0z1
	PojBYGwjQ11TUqSjtLRP9VDPfpb0w9qlP9SBzpjbK4ATcur7eZlNUUq6LUG9ww==
ARC-Authentication-Results: i=1;
	aspmx1.migadu.com;
	dkim=pass header.d=gmail.com header.s=20161025 header.b=kaFhMbXh;
	dmarc=pass (policy=none) header.from=gmail.com;
	spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org
X-Migadu-Spam-Score: -2.63
Authentication-Results: aspmx1.migadu.com;
	dkim=pass header.d=gmail.com header.s=20161025 header.b=kaFhMbXh;
	dmarc=pass (policy=none) header.from=gmail.com;
	spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org
X-Migadu-Queue-Id: 632A617BD2
X-Spam-Score: -2.63
X-Migadu-Scanner: scn1.migadu.com
X-TUID: WFLQ44iYBEs8

--=-=-=
Content-Type: text/plain

"Jorge P. de Morais Neto" <jorge+list@disroot.org> writes:

> - Expected behavior: Org should clock in the first heading, then clock
>   out from it, prompt for a note, and clock in the second heading (in
>   batch mode, Emacs should print some clocking messages and then exit
>   successfully).
> - What happens: Org errors out:
>   user-error: Before first headline at position 164 in buffer *Org Note*

Confirmed

The fix is attached.

Best,
Ihor


--=-=-=
Content-Type: text/x-diff
Content-Disposition: inline;
 filename=0001-Correctly-handle-org-log-note-clock-out-non-interact.patch

>From 7dc855ae1d7992eaacc2cab13a39c6000e4e66bf Mon Sep 17 00:00:00 2001
Message-Id: <7dc855ae1d7992eaacc2cab13a39c6000e4e66bf.1622468529.git.yantar92@gmail.com>
From: Ihor Radchenko <yantar92@gmail.com>
Date: Mon, 31 May 2021 21:39:51 +0800
Subject: [PATCH] Correctly handle org-log-note-clock-out non-interactively

* lisp/org-clock.el (org-clock-out): Delay log popup to
after-command-hook to avoid messing up non-interactive calls.
`org-add-log-setup' without 'note argument would raise interactive
note buffer immediately, so we do pass the 'note argument.
---
 lisp/org-clock.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index 3b7d97639..0328bddd3 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -1691,7 +1691,7 @@ (defun org-clock-out (&optional switch-to-state fail-quietly at-time)
 				(line-beginning-position 2)))
 		(org-log-note-clock-out
 		 (org-add-log-setup
-		  'clock-out nil nil nil
+		  'clock-out nil nil 'note
 		  (concat "# Task: " (org-get-heading t) "\n\n"))))
 	  (when org-clock-mode-line-timer
 	    (cancel-timer org-clock-mode-line-timer)
-- 
2.26.3


--=-=-=--