From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id UFGgJwtnmmANTAAAgWs5BA (envelope-from ) for ; Tue, 11 May 2021 13:14:19 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id 4JJBIwtnmmDLVgAAB5/wlQ (envelope-from ) for ; Tue, 11 May 2021 11:14:19 +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 C859325103 for ; Tue, 11 May 2021 13:14:18 +0200 (CEST) Received: from localhost ([::1]:43324 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgQLA-0003RP-Ao for larch@yhetil.org; Tue, 11 May 2021 07:14:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51766) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgQJt-0003PZ-M4 for emacs-orgmode@gnu.org; Tue, 11 May 2021 07:12:57 -0400 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:51293) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgQJo-0003jP-9w for emacs-orgmode@gnu.org; Tue, 11 May 2021 07:12:57 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 0E0F75C00F2 for ; Tue, 11 May 2021 07:12:51 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Tue, 11 May 2021 07:12:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=n07+Vs OaScj4W2NJS6nRjJt9fQCj0980ZZDgqOoEREw=; b=KLK38+yDbnNQoTUXNMNeLc ROdrMY5kBtKNyT9GqswkRxrIR1Vip5oEhzwWO6vbIVrl8dkMUnhcguitqIjaWXUG Jgh1uGLB2gwEIC9OeB4I7/FVzsSwstwAzIQ84QL/tEONtS0McC5/IRaMsX/99Ny8 aXXFxYfGnZXFx0OLMtDHiXuf7W7HrXD9GDogRr8vVhHj3z96QwH2pjm5oWhHbTOG 8QwZ+8xRI7YyfuZwwsm5/FNDNPJSnqkGuvlwVpsLy5WaHPvnMhLS53Ow3yobfYow Sr8mbXxIYCjEOnjsnb8rG2skv+p4gFOrwx7zCKarsS+BBBFhdz/hZ6hq7OOcxnIg == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrvdehtddgfeekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefuvfhfhffkffgfgggjtgesmhdtre ertdefjeenucfhrhhomheppfhitghkucfurghvrghgvgcuoehnihgtkhesnhhitghkshgr vhgrghgvrdgtrgeqnecuggftrfgrthhtvghrnhepveelgffgudethfekleduvdegleekud fggffhvefhtddugfefheekledtueefveehnecuffhomhgrihhnpehrvgguughithdrtgho mhenucfkphepvddtiedrudejvddruddtledrieenucevlhhushhtvghrufhiiigvpedtne curfgrrhgrmhepmhgrihhlfhhrohhmpehnihgtkhesnhhitghkshgrvhgrghgvrdgtrg X-ME-Proxy: Received: from [192.168.0.67] (bras-base-aylmpq0104w-grc-13-206-172-109-6.dsl.bell.ca [206.172.109.6]) by mail.messagingengine.com (Postfix) with ESMTPA for ; Tue, 11 May 2021 07:12:50 -0400 (EDT) Subject: Re: [bug] C-u org-update-statitics-cookies errors out with "Non-existent agenda file" if current file isn't saved To: emacs-orgmode@gnu.org References: <670485e3bc62d5fde5f32fd60d2af6f3@kisaragi-hiu.com> From: Nick Savage Message-ID: <197f9fdd-474c-cbdb-e06d-eade0b1cc989@nicksavage.ca> Date: Tue, 11 May 2021 07:12:50 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 MIME-Version: 1.0 In-Reply-To: <670485e3bc62d5fde5f32fd60d2af6f3@kisaragi-hiu.com> Content-Type: multipart/mixed; boundary="------------59DB26EDF3B4D85B1F36C3CC" Content-Language: en-US Received-SPF: none client-ip=66.111.4.27; envelope-from=nick@nicksavage.ca; helo=out3-smtp.messagingengine.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, NICE_REPLY_A=-0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_NONE=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." 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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1620731659; 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:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=n07+VsOaScj4W2NJS6nRjJt9fQCj0980ZZDgqOoEREw=; b=Y1QxReeNZX0BsEPBNSVHQ76ty7neIeI9+7DVw+UTLNwL9xyYduC5tyYDTLgIMa8/QNVI4J 4Puwl1vGVkgJ8k8VWZ6JigX/eHQPGtYNky9AZzgEkP92ShWzsysZ0WENLPSMGEeG7VJQUy LztD1NyWoMO7EgcGkbX35Uoh97z9zI4Nz17XS91pdU4je4Q+1b4SQhzi6PutBAOLwaMMXL e3GoXG0e3hLk4Vh+NtccEo97dx/v4Q8Xjt9VEFYQ6OdMzI6s5/Ro0EbhbxCeBg6F/omgc7 qYSffTqpkDLLtz5XAYFrMRm+zY12G+wAl/M1XsidOGC/9PbWMeBTDpUgEXWpUw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1620731659; a=rsa-sha256; cv=none; b=sAV5C3g9Ql2rZN6bHNF7QMk1azlEqfZtDDxbhK3DNSGWnlinpC3xpWTAaqnp6r6O9tlHla I6x0RSiMqv740+wregOQS0L5egUIRYSIw9zpCmWuUmFK2c70ccPXj6/PBQ/2eE80aSULbr 7fx0UTcWE9k3rAFhYBxKECemo44fYglq+BMXlbZONAE+vO10QaqINPhrxJJSyZeobZHYmN TBPhp+kaD74nzIcCo4jm6Xa6AOLH/FnVA8kcryRooOTiUjbSwzGXZhZqYmEqHtkBP7agtQ foEOAuk7ge4r9V0+UjW0if5mlH4/yX/dukbFZTIQ2TuxKfwVtLP0KOTLQidypg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=messagingengine.com header.s=fm2 header.b=KLK38+yD; 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.65 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=messagingengine.com header.s=fm2 header.b=KLK38+yD; dmarc=none; 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: C859325103 X-Spam-Score: -2.65 X-Migadu-Scanner: scn0.migadu.com X-TUID: 2sjnrvdskvKl This is a multi-part message in MIME format. --------------59DB26EDF3B4D85B1F36C3CC Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Thanks for the bug report, I can confirm this is happening. I encountered a similar bug where org-agenda-prepare-buffers was causing the same issue when the file hadn't been saved to disk, and I agree that the solution looks good. I've formatted this into a patch and attached it. Might be worth considering too if this is happening anywhere else too, since this is the second time it has come up. On 5/11/21 6:07 AM, mail@kisaragi-hiu.com wrote: > * Reproduction > > 1. emacs -Q > 2. C-x C-f /tmp/new.org RET > 3. Type anything > 4. Type C-u C-c # (C-u org-update-statistics-cookies) to try to update all statistics cookies in the buffer > 5. Notice the "Non-existent agenda file /tmp/new.org." error. > > This doesn't happen if the file already exists. > > I first saw this reported in this reddit thread: https://www.reddit.com/r/orgmode/comments/n9g1yf/is_this_a_bug_with_orgupdatestatisticcookies/ (u/flyin1501 is me) > > * Expectation > > All statistics cookies in the buffer are updated no matter if the buffer's associated file is already created or not. > > * Why this is happening > > - `org-update-statistics-cookies` (C-c #) uses `org-map-entries` to update all cookies. > - `org-map-entries` uses `org-agenda-prepare-buffers` to prepare the file when SCOPE is nil. Excerpt: > > (if (not scope) > (progn > (org-agenda-prepare-buffers > (and buffer-file-name (list buffer-file-name))) > (setq res > (org-scan-tags > func matcher org--matcher-tags-todo-only start-level))) > > - This function complains if the file does not exist, causing the error. > > * Solution (IMO) > > `org-map-entries` is quite complex because of its matching and scoping features; `org-update-statistics-cookies` only updates the current buffer and should use `org-map-region` instead. IMO it should go from > > (if all > (progn > (org-update-checkbox-count 'all) > (org-map-entries 'org-update-parent-todo-statistics)) > > to: > > (if all > (progn > (org-update-checkbox-count 'all) > (org-map-region 'org-update-parent-todo-statistics (point-min) (point-max))) > --------------59DB26EDF3B4D85B1F36C3CC Content-Type: text/x-patch; charset=UTF-8; name="0001-lisp-org.el-Fix-org-update-statistics-cookies-error.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-lisp-org.el-Fix-org-update-statistics-cookies-error.pat"; filename*1="ch" >From 2081a1d2bd628dd8e5a1ad9fc4ffd58a4f951972 Mon Sep 17 00:00:00 2001 From: Nicholas Savage Date: Tue, 11 May 2021 06:59:14 -0400 Subject: [PATCH] lisp/org.el: Fix org-update-statistics-cookies error * lisp/org.el (org-update-statistics-cookies): Replace usage of `org-map-entries' with `org-map-region' to prevent bug where an error was thrown if the current buffer had not yet been saved to disk. Formatted from a patch proposal by mail@kisaragi-hiu.com Reported-by: mail@kisaragi-hiu.com --- lisp/org.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/org.el b/lisp/org.el index 6dbf33abc..fc5197642 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -9989,7 +9989,7 @@ all statistics cookies in the buffer." (if all (progn (org-update-checkbox-count 'all) - (org-map-entries 'org-update-parent-todo-statistics)) + (org-map-region 'org-update-parent-todo-statistics (point-min) (point-max))) (if (not (org-at-heading-p)) (org-update-checkbox-count) (let ((pos (point-marker)) -- 2.20.1 --------------59DB26EDF3B4D85B1F36C3CC--