From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id EFgMDsMK02O1QQAAbAwnHQ (envelope-from ) for ; Fri, 27 Jan 2023 00:20:35 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id wJI7DcMK02N6pAAAG6o9tA (envelope-from ) for ; Fri, 27 Jan 2023 00:20:35 +0100 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 A6E6E10691 for ; Fri, 27 Jan 2023 00:20:34 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pLBWs-0002x5-L6; Thu, 26 Jan 2023 18:19:38 -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 1pLBWp-0002wq-KA for emacs-orgmode@gnu.org; Thu, 26 Jan 2023 18:19:35 -0500 Received: from brokenwa.re ([188.166.29.179]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pLBWn-0006QM-5p for emacs-orgmode@gnu.org; Thu, 26 Jan 2023 18:19:35 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brokenwa.re; s=mail; t=1674775135; h=from:from: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:in-reply-to: references; bh=ba+4AjkSmfGh0MVc5g1EFX4BJmt/2xp9ti8Jt8C/v9g=; b=SIAM3TLZFrgEoDBa4bhL0CwSyC49DbFycjgA3PjEr3gGJMjKyYvmcZjv3UcVy/Bk1qcm6l 7nRy81uPnHi3oCoq85HiaQE/77Uir6tnQnMbVHG671AI7Xlw32PivEO05T4WknesdBE+sZ cUKLAzMcFb4YgPpvQdQmykzBVh70WhI= Date: Fri, 27 Jan 2023 00:18:43 +0100 From: Matthieu Caneill To: emacs-orgmode@gnu.org Subject: [PATCH] org-element-cache-map: Fix handling of continue-from Message-ID: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="AZ1689w7k3Cg+0EE" Content-Disposition: inline Received-SPF: pass client-ip=188.166.29.179; envelope-from=matt@brokenwa.re; helo=brokenwa.re X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, SPF_HELO_PASS=-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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1674775234; 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=ba+4AjkSmfGh0MVc5g1EFX4BJmt/2xp9ti8Jt8C/v9g=; b=J7R63pwxlwHqwdOo1LZ4gDZWXZyjpNPYrHY3WBEIFkd3ziMBEYP0ObV4JfZx3IMvqHlXG2 CckhoszTSVi6U33ZXFEe+gV1qSv28OO1EZNTTDuOOrrT73QwGP6iAI/0U/glYvHAEqDGH5 eeXrHbGrtVXty4AIWb3jXZQ6WZ+J+KYSzJFccsiBDmpcYUYuqTtVZBVgYlK9hvKn2QCPiy vaetZGCGvpCeTt25cFkdl1d24MJR9cjH70fMX8eyPShc0mitvUQGmKLUerZlPlkQ60PcwF OoF9pDKFOrijbHnAJrDihtkR1WGRWcyv6DyhiL4DNwUQNrmjps+FFXxNYlAUoQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=brokenwa.re header.s=mail header.b=SIAM3TLZ; dmarc=fail reason="SPF not aligned (relaxed)" header.from=brokenwa.re (policy=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" ARC-Seal: i=1; s=key1; d=yhetil.org; t=1674775234; a=rsa-sha256; cv=none; b=JXFT6Li75AHvnSZpn477moYq5oKxcjyfjgCEiqQ9DIVShmfFrkWeFkgeIpNtbvzjAz8DnR FPg05tYPT+bflkcGViPG1lwvfmjK14dxlqrl2Pb3f7LvE/2IMdTFCR1bjzKiI/aGu25tOR fbSJSI5Oo8lR9qnnJAuOWkIIgfdc3Mx6VAHl9MVELJGwVsjUyNyj/MbBA4UZZ+KbPlkIPx 0LhiK6UE/n5tzEUO55cBR22cFtGP44WlXZAkvcS1NjxuyA+oTDnYtmE+iNiSiw1ZHo30iG 7R5uo08F/6AJ5rBBBGBXLzTZ4BZbZr6D+Fz0JGdIJOOQBq2Ea4sMRqPMQNDL0Q== X-Spam-Score: 5.53 X-Migadu-Spam-Score: 5.53 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=brokenwa.re header.s=mail header.b=SIAM3TLZ; dmarc=fail reason="SPF not aligned (relaxed)" header.from=brokenwa.re (policy=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: A6E6E10691 X-Migadu-Scanner: scn1.migadu.com X-TUID: UFCGZwphbjXb --AZ1689w7k3Cg+0EE Content-Type: multipart/mixed; boundary="6zamfukKhHpzhKoX" Content-Disposition: inline --6zamfukKhHpzhKoX Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi, I'm hit by the following bug in `org-element-cache-map'. When I use `tags' or `tags-todo' in an agenda, with the option `(org-tags-match-list-sublevels nil)', all sub-elements of a matching item are correctly skipped except the last one. It can be reproduced with the following org file: * TODO Parent ** TODO Child 1 ** TODO Child 2 and the following agenda: (setq org-agenda-custom-commands '( ("t" "Test" ( (tags-todo "-foo" ((org-tags-match-list-sublevels nil))) (tags "-foo" ((org-tags-match-list-sublevels nil))) ) ((org-agenda-files '("~/org/test.org")))))) With `(org-tags-match-list-sublevels t)', I correctly see all 3 elements. With `(org-tags-match-list-sublevels nil)', I see Parent and Child 2. This wasn't the case on an older version of org-element that didn't make use of the cache. I understand the option `org-tags-match-list-sublevels' is semi-deprecated in favor of proper tag inheritance configuration. However, to the best of my understanding, I can't accomplish "list all todo items except those tagged with foo, and skip children of matching entries" with tag inheritance. Patch is attached. Happy to iterate over it in case my understanding of this rather complex function is flawed. I tested it on my org files, and would of course appreciate if others could test. Best, -- Matthieu --6zamfukKhHpzhKoX Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0001-org-element-cache-map-Fix-handling-of-continue-from.patch" Content-Transfer-Encoding: quoted-printable =46rom 5d0e2beb9c8b8a239c41dab2f3b44d1fe83bff0c Mon Sep 17 00:00:00 2001 =46rom: Matthieu Caneill Date: Thu, 26 Jan 2023 23:51:05 +0100 Subject: [PATCH] org-element-cache-map: Fix handling of continue-from * lisp/org-element.el (org-element-cache-map): When the receiving function sets `org-element-cache-map-continue-from', value of START should be set accordingly. * lisp/org.el (org-scan-tags): Reset `org-map-continue-from' for every iteration, and set it to the end of the element when sub-elements should be skipped following `org-tags-match-list-sublevels'. TINYCHANGE --- lisp/org-element.el | 3 ++- lisp/org.el | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lisp/org-element.el b/lisp/org-element.el index a3d909290..0a1d31bee 100644 --- a/lisp/org-element.el +++ b/lisp/org-element.el @@ -7700,7 +7700,8 @@ the cache." ;; If FUNC moved point forward, update ;; START. (when org-element-cache-map-continue-from - (goto-char org-element-cache-map-continue-= =66rom)) + (goto-char org-element-cache-map-continue-= =66rom) + (setq start org-element-cache-map-continue= -from)) (when (> (point) start) (move-start-to-next-match nil)) ;; Drop nil. diff --git a/lisp/org.el b/lisp/org.el index ac2acfefb..dc9b7da7f 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -11010,6 +11010,7 @@ headlines matching this string." org-outline-regexp)))) (org-element-cache-map (lambda (el) + (setq org-map-continue-from nil) (goto-char (org-element-property :begin el)) (setq todo (org-element-property :todo-keyword el) level (org-element-property :level el) @@ -11084,7 +11085,6 @@ headlines matching this string." 'type (concat "tagsmatch" ts-date-type)) (push txt rtn)) ((functionp action) - (setq org-map-continue-from nil) (save-excursion (setq rtn1 (funcall action)) (push rtn1 rtn))) @@ -11092,7 +11092,8 @@ headlines matching this string." =20 ;; if we are to skip sublevels, jump to end of subtree (unless org-tags-match-list-sublevels - (goto-char (1- (org-element-property :end el)))))) + (goto-char (1- (org-element-property :end el))) + (setq org-map-continue-from (org-element-property :en= d el))))) ;; Get the correct position from where to continue (when org-map-continue-from (setq org-element-cache-map-continue-from org-map-continu= e-from) --=20 2.30.2 --6zamfukKhHpzhKoX-- --AZ1689w7k3Cg+0EE Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEETKwrT8AciV0PsiZW9iB93P27QkEFAmPTCjwACgkQ9iB93P27 QkETig/+LAUwwh2FIjPVDj2t+NBtrqBu+iGIWVUR1RND2uwHCyWopVkn9RFYN1Cs V6B1Bl5ZneAh0dKUTaVwa284tysrCu0JdeXjTXGPtc7QpYmjcD2a/kDjD85Hg2J8 Gsvpu4DKwRA+COER2x73YFIPCytEK1xsK4oV66zM4OmvjiNCQzj83kFYzxFyICOO NV1iaGwV9ld8a5q21asPiHXypW4ZwJaO1xWOuowbd2kyScQN7S570fjgCHT4fvGs FifK/oqThNxHy40Bp5pzwH4Z3REZm40bTJ8vdtv3Ior7uGJESu498tDnwVbGQGlw 6eO6ulVoaVAVG4fuyo1ycz9uJUCj7fWdHXzq0L7thQufMFzwPfJxRqshVVsPrX6i pIYcwghjrdH4MsBOGXT56CYbH6uPTjKNsiFwE9yH+rbrdlpA2F424kRHISF5YR7K OsyPxuX7RqnttXiZKWrqvMpeoCeRXw2NBFoCLFrAhy53BD3YQBFXrXaxgTBaYzzv R8Ee3yCkE36+xzUpoAb73T2zjMBN6Z3fj0qfhVTLS/HSI8pv6Vi607rEE4U+PFOa QDoWXdHE1N+ZQ+UnkvLlg8A3vStbk+Jl8aYylN1x9t5s6u7djHqFa85TNgCnVjBJ Zj2gGOOFsZYaa5t5Kv4qHiOASCIMKzpM2Q2byRBkxPlpdIsqLjI= =01x0 -----END PGP SIGNATURE----- --AZ1689w7k3Cg+0EE--