From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id uGIKMKT2j2A7hgEAgWs5BA (envelope-from ) for ; Mon, 03 May 2021 15:12:04 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id cDzXK6T2j2B2IQAA1q6Kng (envelope-from ) for ; Mon, 03 May 2021 13:12:04 +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 01908249A4 for ; Mon, 3 May 2021 15:12:04 +0200 (CEST) Received: from localhost ([::1]:40980 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ldYMj-0000dv-Hv for larch@yhetil.org; Mon, 03 May 2021 09:12:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38094) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ldYEn-0000oN-63 for emacs-orgmode@gnu.org; Mon, 03 May 2021 09:03:49 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:52843) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ldYEi-0002Xw-OE for emacs-orgmode@gnu.org; Mon, 03 May 2021 09:03:48 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id E5E705C0046 for ; Mon, 3 May 2021 09:03:43 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Mon, 03 May 2021 09:03:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:message-id :mime-version:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; bh=GZeYTz/Zx1Cpim0exCWVolyJSdGBy QoZwt0W7ZLN+nA=; b=PTLdF681skEy3TacWtoq7xAiM0td0w+rDPIuf4IbzXZd6 K5SWreJZ9RReweWhChQDBmW+0s+Qudqe9IKkaJY62zCgTFr17gpkIotL9eVGzNqo 2Pt1O9yO4mmXuw93IdlDPcVznUdaBB8wleEBcOGGYbrXxr8vYjgTGIz9LRnXN9fn QJCqX+SXTka1hd5XVgBZwrRRUwakIqUJ9WHBp2K801Pkn6WzJ41FNEiESrn3NiEQ fPEqUzWgSAxLDIphgfgLHhHY1xJYzQaZmpXaShPC/oudYpUnKPBGoLGVgKlNIKBl QMnal7BpGNxpff5yj5yrVMxQpfSIN8tqga+P65tuQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrvdefgedgiedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffukffffgggtgesmhdtreertd efjeenucfhrhhomheppfhitghkucfurghvrghgvgcuoehnihgtkhesnhhitghkshgrvhgr ghgvrdgtrgeqnecuggftrfgrthhtvghrnhepudelkeeiveekleeuheduffetfeefuddvge elfeehveduieeugeekueffveevlefhnecuffhomhgrihhnpehtvghsthdrohhrghdpsghu fhhfvghrrdhorhhgpdhnohhtrdhorhhgnecukfhppedujeegrdelfedrudeihedrudefne cuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepnhhitghk sehnihgtkhhsrghvrghgvgdrtggr X-ME-Proxy: Received: from [192.168.0.140] (bras-base-aylmpq0104w-grc-46-174-93-165-13.dsl.bell.ca [174.93.165.13]) by mail.messagingengine.com (Postfix) with ESMTPA for ; Mon, 3 May 2021 09:03:43 -0400 (EDT) From: Nick Savage To: emacs-orgmode@gnu.org Subject: [PATCH] Replace call in org-columns of org-map-entries with org-scan-tags Message-ID: <4b165e5f-05fb-8cae-5b89-cc4fb96d0639@nicksavage.ca> Date: Mon, 3 May 2021 09:03:43 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------0CF84616EE02E4F09C145793" Content-Language: en-US Received-SPF: none client-ip=66.111.4.25; envelope-from=nick@nicksavage.ca; helo=out1-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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=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=1620047524; 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:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=GZeYTz/Zx1Cpim0exCWVolyJSdGByQoZwt0W7ZLN+nA=; b=CxV4yOV0bo09vRwXw37ftMlZkSyeYDbrHphRzq6onif3CeVJfDb19tlfHKtqrJI/3PW8/W hq/3Fml76U6I0WxwMA38jvfX01g7bmKYECw7qOat99kD6JvV7gOa6bl6quAp5W6hHenbRf u1EzjZq3P90pkuFaw6i+rK8vi2ieOpV84CsTO3RYXZwtE0K2fFlCfkNpDWnod0zOiP2im4 eNVYkSvPOBER0ZLqkVJXVGxCVibRmXmkVrDEGb2TO5j9igTu2+BB4cuSpQJrjBDHhhH5Jz n60CKZl6B2R+EdpBcBEZA5bZbN+1sjqCRu9z/9ttI6O2p229yhumbpEMkS1H7Q== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1620047524; a=rsa-sha256; cv=none; b=PnvxnQ8K2HiIbELOSMB4ARewPGmtcf4i8qYTiK2JkRBCSvxqmbrX4WP5oFpyCZM1ZDvuyT QIZBlQf9ytnrIbHlwr7lcGDFTavbMrVJEhfQOLA2ICubgVW1+jh4+2sOhhsuaWHybcu/I2 15ekNJzRZr9IWYFvUILIGE4FZzqSEwgdYDTwY7Qd3bZeYgHBCvyzvWFMv9XU1JwfDAlTV/ karWkWZhzvfIWurZ4NxOZm9sMS2vy4a0K0Mh+wVIi25WQX30kCK7jl2ZPwnpostQiBEZlJ vJ0IYs8+k1ipd7HgL62Ivzcu3q0f9KxnfyQ16g1AcQWhpR8Pm9cMorDYU1VHCw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=messagingengine.com header.s=fm2 header.b=PTLdF681; 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.66 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=messagingengine.com header.s=fm2 header.b=PTLdF681; 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: 01908249A4 X-Spam-Score: -2.66 X-Migadu-Scanner: scn0.migadu.com X-TUID: IJchzAMj3SqG This is a multi-part message in MIME format. --------------0CF84616EE02E4F09C145793 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Hello all, I was trying to track down the source of a bug encountered when I was submitting my last patch about org-columns. I'm going to walk you through my thought process and summarize at the end. As part of my experimenting, I did the following: 1. emacs -Q 2. open a new buffer at "/tmp/test.org" 3. Add a headline (something like "* test"), and run org-columns only be greeted by an unexpected error: "Non-existent agenda file /tmp/test.org.  [R]emove from list or [A]bort?" It's clear that /tmp/test.org is not part of the agenda since it's a brand new file, but I was surprised that org-columns cares at all. Pressing "R" to remove it from the list tells the user that it wasn't in the agenda list (as you'd expect) and then continues to display columns as expected, which made me wonder why it is doing that at all. This issue only appears though when /tmp/test.org is not saved to disk, which looks like expected behaviour as per the following. I looked into what's going on, and it relates to org-map-entries, which builds a list of what is in the buffer. org-map-entries calls org-agenda-prepare-buffers. This checks whether the given files are actual files or not and opens them up if they are. This makes sense I believe from an org-agenda perspective since it has to make sure all of the files are open in order to return a list of the headlines, but for org-columns it does not. org-columns is an interactive function that is only run on the current buffer, so the buffer should always be open. org-map-entries has a lot of different paths in it based on the parameters, but essentially the call from org-columns does two things: 1) call org-agenda-prepare-buffers and 2) sets "res" to the output of org-scan-tags. I believe that the former is unnecessary and that the latter is the only necessary code to run in this instance. To summarize: I've attached a patch to this that makes a change to this. It replaces org-map-entries with a call instead to org-scan-tags. This fixes the bug I noted above, and I believe (if I'm using the profiler correct), makes org-columns a bit faster since it's not calling a bunch of functions that doesn't matter to its output. As far as I can tell, my patch works as expected with no obvious behaviour changes. All of the tests continue to pass as well. I've tested it on my own files and it is working as expected as well. I'd appreciate any feedback on this, or if there are edge cases that the removed code breaks that I haven't been able to identify. Nick --------------0CF84616EE02E4F09C145793 Content-Type: text/x-patch; charset=UTF-8; name="0001-org-colview.el-org-columns-Replace-org-map-entries-w.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-org-colview.el-org-columns-Replace-org-map-entries-w.pa"; filename*1="tch" >From f8425ef6fe0ae59c9c4df0b71f3cb61c7bc7e975 Mon Sep 17 00:00:00 2001 From: Nicholas Savage Date: Mon, 3 May 2021 08:49:11 -0400 Subject: [PATCH] org-colview.el (org-columns): Replace org-map-entries with org-scan-tags * lisp/org-colview.el (org-columns): Replace call to `org-map-entries' to build cache with `org-scan-tags'. Simplifies `org-columns' to call `org-scan-tags' instead of `org-map-entries'. This is to fix a bug where an unexpected non-existent agenda file error was thrown if the buffer that `org-columns' was called on was not yet saved to disk. This also simplifies `org-columns' and prevents unnecessary agenda preparation functions from running. --- lisp/org-colview.el | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/lisp/org-colview.el b/lisp/org-colview.el index 517bcdf1c..ac3fd9326 100644 --- a/lisp/org-colview.el +++ b/lisp/org-colview.el @@ -836,12 +836,11 @@ Also sets `org-columns-top-level-marker' to the new position." (defun org-columns (&optional global columns-fmt-string) "Turn on column view on an Org mode file. -Column view applies to the whole buffer if point is before the -first headline. Otherwise, it applies to the first ancestor -setting \"COLUMNS\" property. If there is none, it defaults to -the current headline. With a `\\[universal-argument]' prefix \ -argument, turn on column -view for the whole buffer unconditionally. +Column view applies to the whole buffer if point is before the first +headline. Otherwise, it applies to the first ancestor setting +\"COLUMNS\" property. If there is none, it defaults to the current +headline. With a `\\[universal-argument]' prefix \ argument, GLOBAL, +turn on column view for the whole buffer unconditionally. When COLUMNS-FMT-STRING is non-nil, use it as the column format." (interactive "P") @@ -867,9 +866,8 @@ When COLUMNS-FMT-STRING is non-nil, use it as the column format." (let ((cache ;; Collect contents of columns ahead of time so as to ;; compute their maximum width. - (org-map-entries - (lambda () (cons (point) (org-columns--collect-values))) - nil nil (and org-columns-skip-archived-trees 'archive)))) + (org-scan-tags + (lambda () (cons (point) (org-columns--collect-values))) t org--matcher-tags-todo-only))) (when cache (org-columns--set-widths cache) (org-columns--display-here-title) -- 2.20.1 --------------0CF84616EE02E4F09C145793--