From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:403:4789::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id cFs2A4FD7WSyEAEA9RJhRA:P1 (envelope-from ) for ; Tue, 29 Aug 2023 03:01:53 +0200 Received: from aspmx1.migadu.com ([2001:41d0:403:4789::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id cFs2A4FD7WSyEAEA9RJhRA (envelope-from ) for ; Tue, 29 Aug 2023 03:01:53 +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 A9A16409F5 for ; Tue, 29 Aug 2023 03:01:52 +0200 (CEST) Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=plD426eM; 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"; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1693270913; 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=1xrFgreDdWf78Qph1MSPVVgDq41e9lCTGM97MVC4bXA=; b=qXqe8mmt7KbfJPhfMrIfodwf0nwdBOzdsblGHluD8fu4/MaaBSuuG0LPDd5SukpUc6vHoN RnOWPkdDHEGigrTRk3rfxKWfX6Gr/E6Ep6iTSbuKoeNYh5z98B4KFFDNcL89Nft2UETYfF H47D1U2oEuomNB6LOj/BvQ9P/E/RiZXdlbN+jpn5/q9DH9zXPWDqVuRPe7r743Zg4iawmk uCASCCPwPs1U2W/ly3ZYmd9I06aCdOfH2GR4FdAnR/9jaK/+vX2O4sqy8hYqxc9vVdlyrB jTlaxvQ4K1pTD5PDL8AWfS+0ykg/i+rZTmz2DSLxtb8MB5Ie0QZSKF16To4aWg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1693270913; a=rsa-sha256; cv=none; b=VY9Xw0L+rJbI427xTcSNvtnSfj6JsMCkaHv09EnWN4epR1bETjOBix/XiEkULTdmrpz8Gm 3c9guTOrl5I4d1jyLHM7N0S2XtzLWluAcMnez3ZYMRoPWS4kjELGm3HvEF5GSXzFjFdgmv e5kLObl9fRDpKoMUQ1VfFf6EkM/URM01iWnxU6RyvZAl61jv3hTPuiQaG1YhS6PRCV1NWk THJqK2AGr/ZPlr8iLE84tpIHAHrQ/+92m5wYCi9RGkFYr2MN7phDXqdujDyTzOiI5kC4KQ 5/Q/hQ9dsHBtYSs7koodH6v5/bv1V4Oe9kFxFonb2BFIh5KkYxhQ8cHi5xHKMw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=plD426eM; 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"; dmarc=pass (policy=none) header.from=gmail.com Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qan65-0004Wr-Mf; Mon, 28 Aug 2023 21:00:45 -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 1qan62-0004WT-LA for emacs-orgmode@gnu.org; Mon, 28 Aug 2023 21:00:43 -0400 Received: from mail-vs1-xe33.google.com ([2607:f8b0:4864:20::e33]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qan5z-0003NO-6B for emacs-orgmode@gnu.org; Mon, 28 Aug 2023 21:00:42 -0400 Received: by mail-vs1-xe33.google.com with SMTP id ada2fe7eead31-44e8ddf1f1aso2995349137.1 for ; Mon, 28 Aug 2023 18:00:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693270838; x=1693875638; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=1xrFgreDdWf78Qph1MSPVVgDq41e9lCTGM97MVC4bXA=; b=plD426eM9r0B3LWXa47D7RgM4vClk0A0CrxBeNEFaa7riJr8OtKe5fdJ2/LZMOVO53 o9abx/GuQ7U2qEBT+Jiuz4jg6QsmD42F/vr6QcNABJVpz0q7rPr+Y8V0Grskmrpfjp2x nD67/1v7w4aju3yKShaVez23ZfUxbL2IuX2bL+p3NU5ETu2BW/EWl8mC66aTsvrZauR/ xw51FJupdZZLyrasRAcpX7WUO4crUxD6euxZcFyGFbhAh2SZXN8DPtu5qbFLlJ4OAt+x zhOYRTe2TTkUx7tnAVoi43w0WP62amQEApRf86Aq5Q/e7pxRtzrYJP3QEdVUrOD5biPp wooA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693270838; x=1693875638; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=1xrFgreDdWf78Qph1MSPVVgDq41e9lCTGM97MVC4bXA=; b=ORfSG84e1NafT49/UMGiGW8FWVn4IAlQCeF1yQ7xrlWc5N1KdbPs3fuGM2VqMaq4HG /6l1AKJlJXA6bo3Eejq8k08KjAsBVUPzv6gyxuF8OXQc6EkRSxlfNqg6KIkjIhY/X5Xq 9fcuk4AxXbs4umuxujEGcAsxbcZqrmM3lKRBhQWZmaaOPpDXvytJgwaXbKLQ8a8Rwr2T Wvu1nayjfHikRpnrshD0eMhkMnq0c3PSepGwxS3YW4jq5/J37lRA1WOo9n1iU9EoOfj1 l/Wmx8oP+lrA1obrzTbqP73cB7xIOveD6ITdGCCIbhm+plY18RjTP2MeTD1EjrgnOWA3 A8VQ== X-Gm-Message-State: AOJu0YzG0pBHNr9Gp53PZa2RZl0dH3KofRUpNCYXh2gs9MS0auqQkoQt Ry04jsNv9ZrcL5/F7PucXio9vI7zHkK2cWnP4UIGH0S6Of0= X-Google-Smtp-Source: AGHT+IH4nL1l4GJIn0zgnyXDdlShoOJZtS3GT9hJj6xCmBl0dkiJYUcN3Zlv6TF8yT5iL45DgGbBrx6JT2CMrHiedUk= X-Received: by 2002:a05:6102:3bc5:b0:44d:acfd:6f0a with SMTP id a5-20020a0561023bc500b0044dacfd6f0amr787810vsv.16.1693270837806; Mon, 28 Aug 2023 18:00:37 -0700 (PDT) MIME-Version: 1.0 From: Rodrigo Morales Date: Tue, 29 Aug 2023 01:00:22 +0000 Message-ID: Subject: [BUG][org-map-entries] Using (widen) in FUNC when SCOPE is equal to 'tree iterates through headlines outside the tree To: org-mode-email Content-Type: text/plain; charset="UTF-8" Received-SPF: pass client-ip=2607:f8b0:4864:20::e33; envelope-from=moralesrodrigo1100@gmail.com; helo=mail-vs1-xe33.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.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-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: -9.59 X-Spam-Score: -9.59 X-Migadu-Queue-Id: A9A16409F5 X-Migadu-Scanner: mx1.migadu.com X-TUID: s+FttfTiylbU The following result is expected behavior. We iterate through all headlines starting at headline =* 1=. #+HEADER: :results value #+HEADER: :results verbatim #+begin_src elisp (with-temp-buffer (org-mode) (insert "* 1 ,** 1.1 ,** 1.2 ,** 1.3 ,* 2 ,** 2.1 ,** 2.2 ,** 2.3 ") (goto-char (point-min)) (org-map-entries (lambda () (org-entry-get nil "ITEM")) nil 'tree)) #+end_src #+RESULTS: #+begin_example ("1" "1.1" "1.2" "1.3") #+end_example To me, the following result is unexpected behavior, because we are iterating through headlines that are outside =* 1=, the tree in which =org-map-entries= was called. #+begin_quote SCOPE determines the scope of this command. It can be any of: nil The current buffer, respecting the restriction if any tree The subtree started with the entry at point region The entries within the active region, if any region-start-level The entries within the active region, but only those at the same level than the first one. #+end_quote #+HEADER: :results value #+HEADER: :results verbatim #+HEADER: :results value #+begin_src elisp (with-temp-buffer (org-mode) (insert "* 1 ,** 1.1 ,** 1.2 ,** 1.3 ,* 2 ,** 2.1 ,** 2.2 ,** 2.3 ") (goto-char (point-min)) (org-map-entries (lambda () (widen) (org-entry-get nil "ITEM")) nil 'tree)) #+end_src #+RESULTS: #+begin_example ("1" "1.1" "1.2" "1.3" "2" "2.1" "2.2" "2.3") #+end_example According to the docstring of =org-map-entries=, when SCOPE is =tree=, we only iterate to the entries under the subtree starting with the entry at point (relevant part of docstring =org-map-entries= shown below). #+begin_quote SCOPE determines the scope of this command. It can be any of: nil The current buffer, respecting the restriction if any tree The subtree started with the entry at point region The entries within the active region, if any region-start-level The entries within the active region, but only those at the same level than the first one. #+end_quote The second result shown above proved this wrong. * Personal thoughts I have come up with two possible solutions to handle this scenario. Solution no. 1: Update the description of =tree= in the docstring of =org-map-entries= to indicate the user that =widen= shouldn't be used in FUNC, since otherwise, =org-map-entries= will iterate through headlines outside the tree at point. Solution no. 2: Execute the parameter =FUNC=, which is passed to =org-map-entries=, inside =save-restriction= to ensure that in every iteration the restriction is not affected, thus only moving forward to the proper headlines only.