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 ON+5Hx3M22QHXQAASxT56A (envelope-from ) for ; Tue, 15 Aug 2023 21:03:57 +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 MEvEHx3M22TBZQAA9RJhRA (envelope-from ) for ; Tue, 15 Aug 2023 21:03:57 +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 D7B874C378 for ; Tue, 15 Aug 2023 21:03:56 +0200 (CEST) Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=LiKPyLpX; 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=1692126237; 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=vqgh88RjtidWH4WyC8rti9rWZIgoYJd2o0qnwIHfxVc=; b=TWFwu2x02DlOLbSH3C/bWunnL0sPBFhCP61bXPRRK1PWAt4wdW87tX8Ah2bRW6g32lHpiH ko72c1wfVvH9cKG2Yn9jNSK37Nkf91dvgKaDiPBDlx/ZuQ8WWkW7yhu4wx6JKZ8ePZX9yn I7To2BWsqLIQx4wFUrm/kbtSagbqAomcJgnVqvEk9lDK9miTloTZmdxcPOwTkG3HsU1QzW iTPDtj7BvTPdOma2MlGFpUyRYu0zQjTtOCRK+B2UMLLjue6y2Gcx82mcA0pctcKZtKNhGD vT4Py3ngQY17xEPE8BuzM19KB1wZodiAYIauETiRxaP18WJaCT7+bfdNsHSw6Q== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=LiKPyLpX; 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-Seal: i=1; s=key1; d=yhetil.org; t=1692126237; a=rsa-sha256; cv=none; b=aCxTk97ap/ww1wQ2k64vT9DB7XJEnbJP/HRkb28BTPYsE4Y3uKhEd3xXO2GwnEHL+ghlXR DoIZmazr0DoLWGBBmLJnmHl0i1q5wzWwjohMWjoI+z8CcBvkv8xy56owTFR1ns4ihHRLqk zHi6R70cjGowO2hck3LHLOk+RuKfU/FOyOwY+5m7HJUAmA2+HohdQpyeWA/wD/DMYcvpeY SEvcBUgz1TNzjT1G2mW6zNKmgExIf8MuHEJ75y4d9NGx+Vqi++UPfQ0CKTJZ/CyWwAgcHP H5HpP7pGCSOQtGXlUyDk6ho6ZnlSVeIkZmvOrT7iEx/ppwlQAiBfCmlNT2YdrA== Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qVzKN-00050M-8a; Tue, 15 Aug 2023 15:03:39 -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 1qVzKL-0004yO-5w for emacs-orgmode@gnu.org; Tue, 15 Aug 2023 15:03:37 -0400 Received: from mail-ua1-x930.google.com ([2607:f8b0:4864:20::930]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qVzKI-0006QI-QY for emacs-orgmode@gnu.org; Tue, 15 Aug 2023 15:03:36 -0400 Received: by mail-ua1-x930.google.com with SMTP id a1e0cc1a2514c-79ddb700ad4so623745241.3 for ; Tue, 15 Aug 2023 12:03:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692126213; x=1692731013; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=vqgh88RjtidWH4WyC8rti9rWZIgoYJd2o0qnwIHfxVc=; b=LiKPyLpXqDKKUxY60fvXiooo9Z/lyr3ZDjQY9iAeS4vLwMQFZ6dR1HXyCS8em9iDvK B4jVm67TzTKMQHt/B6VhDhtUVemR+t2poP3KalOrSo2VAEYfbJU84AMwqCnnFfZKmoOl fFhG6ka36Xi1ZWEtr96Kr7KTayDxGDXMl91k2Z3uFqsvJJjB7xZsO/UzQWrMcLJXNoOP mVyRLgc3cWh8ap6i+Ag0ucm9s2qrhSR202qDWsnnm5NCOjMh+pth1OWMjecxUq5rfBot 8yNUrJkpawrYI3ABTaf1vIJoK9qjNbLZ+x42F1xsKOrCqB73g+tS4vCrHyakxq/6ViN9 fTSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692126213; x=1692731013; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=vqgh88RjtidWH4WyC8rti9rWZIgoYJd2o0qnwIHfxVc=; b=LCerk7N/fyS539DWmjnnoaeJn1F400KmwbQAScWsg263yMxdOIEqsorFLV5+oQsTUz 9OYpao+WARGJmvaWlbsRXLEZzKKL4q22GNyCPw4NIS8xxgtgt5EkC442orXdTy9tb5jw EYZb50qMpjdgrbhJb7ZneriID84ZqdPc5CnzHWghq4El/3ndzthAIilTfrJBH1VR8aTQ sgq3apqnu8im0q5Mhl6P4JaAgaV1BhA1/4VRrYze8GO4FecQCgw8rIzodCJvZQhg8SXB o28h7ZTC7oK7EcshwVHcmOvWigYCSCcE9I8WZKi+AGh/DCDCnLCtV8fWkWMcJ0HSgzUb EK+A== X-Gm-Message-State: AOJu0YyZWwOPgXRnsC5U4HBNNg4iAdPdEv1h59Tl37bJkbcSYEmRTQSl afM0n2yryYcv9ApF2aCG00UKtojY9zg2Bb50O/4oLHrGfe8= X-Google-Smtp-Source: AGHT+IGlvhahrgkIxh9blwuWflMz9bIdyh7AlUhNu9QNDki0XRqbVtvX7xYDZLbeSvc8pwsdkA3JFxZLRGVFKfcXS8A= X-Received: by 2002:a05:6102:7ac:b0:443:7516:450b with SMTP id x12-20020a05610207ac00b004437516450bmr11135148vsg.35.1692126213570; Tue, 15 Aug 2023 12:03:33 -0700 (PDT) MIME-Version: 1.0 From: Rodrigo Morales Date: Tue, 15 Aug 2023 19:03:17 +0000 Message-ID: Subject: [BUG] org-get-outline-path misbehave in some scenarios when org-element-use-cache is t Inbox To: org-mode-email Content-Type: text/plain; charset="UTF-8" Received-SPF: pass client-ip=2607:f8b0:4864:20::930; envelope-from=moralesrodrigo1100@gmail.com; helo=mail-ua1-x930.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-Queue-Id: D7B874C378 X-Migadu-Scanner: mx1.migadu.com X-Spam-Score: -6.57 X-Migadu-Spam-Score: -6.57 X-TUID: SLZNcblg9rSr I've noticed that =org-get-outline-path= report incorrect information when =org-element-use-cache= is =t=. This mail shows some experiments that demonstrates this bug. * Experiment 1 In this experiment, we define a =func= which contains the sexps that we want to run when =org-element-use-cache= is =t= and when it is =nil=. In =func=, we use =org-map-entries= to loop through headlines that have depth 2. In each headline, we move the point two lines below and insert a new line containing =FOO=. #+HEADER: :results output #+begin_src elisp (let ((func (lambda () (with-temp-buffer (org-mode) (insert "* 1 ,** 1-1 a ,** 1-2 a ,* 2 ,** 2-1 b ,** 2-2 b ") (princ (format "--- before\n%s\n--- before\n" (buffer-substring-no-properti es (point-min) (point-max)))) (org-map-entries (lambda () ;; We get the outline path before calling ;; (forward-line 2) to ensure that we are referring ;; to the headline in the current iteration (princ (format "org-get-outline-path: %s\n" (org-get-outline-path t))) ;; Move two lines below the current headline A. After ;; executing (forward-line 2), the point is where ;; the next headline B starts. (forward-line 2) ;; We add a line which moves the headline B, one ;; line below (insert "FOO" "\n")) "LEVEL=2") (princ (format "--- after \n%s\n---after\n" (buffer-substring-no-properti es (point-min) (point-max)))))))) (princ "Experiment 1.1 (org-element-use-cache nil)\n") (let ((org-element-use-cache nil)) (funcall func)) (princ "Experiment 1.2 (org-element-use-cache t)\n") (let ((org-element-use-cache t)) (funcall func))) #+end_src #+RESULTS: #+begin_example Experiment 1.1 (org-element-use-cache nil) --- before ,* 1 ,** 1-1 a ,** 1-2 a ,* 2 ,** 2-1 b ,** 2-2 b --- before org-get-outline-path: (1 1-1) org-get-outline-path: (1 1-2) org-get-outline-path: (2 2-1) org-get-outline-path: (2 2-2) --- after ,* 1 ,** 1-1 a FOO ,** 1-2 a FOO ,* 2 ,** 2-1 b FOO ,** 2-2 b FOO ---after Experiment 1.2 (org-element-use-cache t) --- before ,* 1 ,** 1-1 a ,** 1-2 a ,* 2 ,** 2-1 b ,** 2-2 b --- before org-get-outline-path: (1 1-1) org-get-outline-path: (1 1-1 1-2) org-get-outline-path: (1 2 2-1) org-get-outline-path: (1 2 2-2) --- after ,* 1 ,** 1-1 a FOO ,** 1-2 a FOO ,* 2 ,** 2-1 b FOO ,** 2-2 b FOO ---after #+end_example In the results above, we can see that in =Experiment 1.2=, =org-get-outline-path= returns wrong information (note that the results are lists of length 3), while in =Experiment 1.1= this doesn't happen. * Experiment 2 I noticed that when we pass one paameter (i.e. ="FOO\n"=) instead of two as we did in the previous experiment (i.e. ="FOO" "\n"=) to =insert=, the bug doesn't happen. See minimal reproducible example below. In this group of experiments we pass ="FOO\n"= instead of ="FOO" "\n"= to =insert=. #+HEADER: :results output #+begin_src elisp (let ((func (lambda () (with-temp-buffer (org-mode) (insert "* 1 ,** 1-1 a ,** 1-2 a ,* 2 ,** 2-1 b ,** 2-2 b ") (princ (format "--- before\n%s\n--- before\n" (buffer-substring-no-properties (point-min) (point-max)))) (org-map-entries (lambda () (princ (format "org-get-outline-path: %s\n" (org-get-outline-path t))) (forward-line 2) (insert "FOO\n")) "LEVEL=2") (princ (format "--- after \n%s\n---after\n" (buffer-substring-no-properties (point-min) (point-max)))))))) (princ "Experiment 2.1 (org-element-use-cache nil)\n") (let ((org-element-use-cache nil)) (funcall func)) (princ "Experiment 2.2 (org-element-use-cache t)\n") (let ((org-element-use-cache t)) (funcall func))) #+end_src #+RESULTS: #+begin_example Experiment 2.1 (org-element-use-cache nil) --- before ,* 1 ,** 1-1 a ,** 1-2 a ,* 2 ,** 2-1 b ,** 2-2 b --- before org-get-outline-path: (1 1-1) org-get-outline-path: (1 1-2) org-get-outline-path: (2 2-1) org-get-outline-path: (2 2-2) --- after ,* 1 ,** 1-1 a FOO ,** 1-2 a FOO ,* 2 ,** 2-1 b FOO ,** 2-2 b FOO ---after Experiment 2.2 (org-element-use-cache t) --- before ,* 1 ,** 1-1 a ,** 1-2 a ,* 2 ,** 2-1 b ,** 2-2 b --- before org-get-outline-path: (1 1-1) org-get-outline-path: (1 1-2) org-get-outline-path: (2 2-1) org-get-outline-path: (2 2-2) --- after ,* 1 ,** 1-1 a FOO ,** 1-2 a FOO ,* 2 ,** 2-1 b FOO ,** 2-2 b FOO ---after #+end_example In the results above, we can see that both Experiment 2.1 and Experiment 2.2 have the same output. * Personal thoughts With regards to experiment 2, we know that passing either ="FOO\n"= or ="FOO" "\n"= insert the same content, so I'm wondering how come passing different parameters to =insert= which result in the same outcome can affect the behavior of =org-get-outline-path=.