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 N0cOLRPBWWHXuwAAgWs5BA (envelope-from ) for ; Sun, 03 Oct 2021 16:41:23 +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 WEUDKBPBWWHFLAAAB5/wlQ (envelope-from ) for ; Sun, 03 Oct 2021 14:41:23 +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 D1D91F823 for ; Sun, 3 Oct 2021 16:41:22 +0200 (CEST) Received: from localhost ([::1]:35060 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mX2g4-0005D5-4H for larch@yhetil.org; Sun, 03 Oct 2021 10:41:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57134) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mX2eP-000590-Q8 for emacs-orgmode@gnu.org; Sun, 03 Oct 2021 10:39:37 -0400 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]:42520) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mX2eN-000701-UN for emacs-orgmode@gnu.org; Sun, 03 Oct 2021 10:39:37 -0400 Received: by mail-pf1-x429.google.com with SMTP id q23so12299252pfs.9 for ; Sun, 03 Oct 2021 07:39:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version; bh=4YMEcVmcD71Ydf5LxrJj1LbK6Vd+rzqJ48/enMzJbe0=; b=A10z4YdJgKNpohoY6dhP6994LcxED8srkuHnmGTE5k6Gat4grgTfvjfFV+0SCNSS// B2NTrZ2wnt1p5WiV9GSDa2Aw95AAooBsj2pmGEzc+sWHB1dq/OWulTXtv6uCHRBjP6gf f5JoA+eRk8wnENZ/rwsfxcmmqt0bDgIZlTxa63jJDKRwWOscfviYT1W1Z56P180D7Syf go8n4aMUF7POrDTn4jXOpteeIy/P2FIlxBY8/7FDcFvN3CbMa1KGZZwEcz8gPvoTL/X+ cJtdYEgSroWRBbVFt9ny6+QigofI0mCQokQ4p3qTBe/UpnaTSJAVCLN+FblID4ibgbpf RAGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=4YMEcVmcD71Ydf5LxrJj1LbK6Vd+rzqJ48/enMzJbe0=; b=0xmenGqKhfsfMUVeMOleX4n6Kl3VjcmuU64QReGCPJsaGF3vEw8rYpBGd53gYJ7t2c R2LwY3DbrrE5g80tYHidasjHaBie1bhGpCWDO7P78csolCC79VSwtf0SAhtpw/oWK6ys 6JGt6Ae09NL7J56/fddtBVtFpo1lKctHLVq03sn1avqwbJPjeJk57RdKxLL++7NqsKMr 6QRlghuMPOZ2fPZb3Zm3WYF+9PvlkW7Dt31VvzhtSZ/Nq0DwLeTz86crU7gb9GkSIMOy YvqLVok1VN4GzwWZOfOUmBug1elxjtKK+YYDRVSvlvPv+DjfcwFxumIYG9Cxn45usEsr tQwg== X-Gm-Message-State: AOAM531eJvANWOKWQebsS0vGkoirIH1NEBY97ec3qtPbvFrijPcrMa3J 7AYzc6e2+8rjvbQX34U3e7dzVBD/G2r8Gcba X-Google-Smtp-Source: ABdhPJyJ6nEEJO8pfSI8Ix2L5w+QOMGl7CVkqHFY9KIRlAePAFRUrjINT/bci/DjP3ZIdO8GEwRp+g== X-Received: by 2002:a65:6a0c:: with SMTP id m12mr6981888pgu.168.1633271973078; Sun, 03 Oct 2021 07:39:33 -0700 (PDT) Received: from localhost (211-22-147-226.hinet-ip.hinet.net. [211.22.147.226]) by smtp.gmail.com with ESMTPSA id t2sm10413721pjo.4.2021.10.03.07.39.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Oct 2021 07:39:31 -0700 (PDT) From: Ihor Radchenko To: Johan =?utf-8?Q?Tol=C3=B6?= Subject: [PATCH] org-attach-use-inheritance inherits from sibling In-Reply-To: <87zgrqqlcs.fsf@toloe.se> References: <87y28avyjf.fsf@toloe.se> <87v92gde01.fsf@localhost> <87zgrqqlcs.fsf@toloe.se> Date: Sun, 03 Oct 2021 22:40:50 +0800 Message-ID: <87o886cgst.fsf@localhost> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2607:f8b0:4864:20::429; envelope-from=yantar92@gmail.com; helo=mail-pf1-x429.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.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: emacs-orgmode@gnu.org 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=1633272082; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=4YMEcVmcD71Ydf5LxrJj1LbK6Vd+rzqJ48/enMzJbe0=; b=UR384E0axQM2l6cuS4E8efYuwO1HY4Z5OyZvJubkBuyPOMAPE22/9PE82lz/CS9e3+1kun umKMjhsot7BuvGtRrnjdJjq3PSi7eS6QOUckmIu6UUTvLuMAVbeLXZIPshOa2gj3Hi6BbO sdUlSpI3CHugsynv88V47pEF7hYkQVh6PX2Qpd8TLoI5F4K8OZnvvQuY7yEoaJ+ithqSw+ 870aeK70OdduN7EZ2aZA2QNNZ1rE599cggkc1K8AlQ/6vCzrtYxv/cTbhtZK89mMwiK47i onCIceRpIAqXmrAqMmAqSs+RjAwTCwCM4SDs6nD/aAzwdR9ouZVBmEF9ETJozQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1633272082; a=rsa-sha256; cv=none; b=Ydm331E0qAgfD/+qoVmFmIKziRRxOgzkZpBWfqyOhACsi/5GCuwKw07tMbALGtW0JTLv7N jzXACrTHN1EGH/4qpCA4F+jlbWa7Q0d0pxIC2qiHyVovuVl8MQw0se3i2IAdJbEPWyj8rB flvsccPnHTOiLtyzysYsFGYd6nV8gFkcnJPp3ZwacefO2GrPtcA6/Bt0vol64x0bCuJwxq K2S2M0+mdc5Qi1OP7qckLML3BudYp3pOOtIk0o1EYNrKJwPJQe7MnOAJnQ6dj9poUjXdg2 YNP+EHXrmx4anmhtultd2D3sY4+tGGRVpInJuzFKsrHxr30pPDS3Rs+QQxrZ/w== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=A10z4YdJ; dmarc=pass (policy=none) header.from=gmail.com; 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.61 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=A10z4YdJ; dmarc=pass (policy=none) header.from=gmail.com; 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: D1D91F823 X-Spam-Score: -2.61 X-Migadu-Scanner: scn0.migadu.com X-TUID: wj/TsTc98eME --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Johan Tol=C3=B6 writes: > If "* Top heading" is the first heading in the buffer with nothing=20 > above it, not even a whitespace/newline, then '(org-entry-get nil=20 > "id" t)' with point in "* Second heading" will return the id of=20 > "Top heading". If there is anything before "Top heading" then=20 > 'nil' will be returned. > > This happens when I run 'emacs -Q' from within the "lisp"=20 > directory of a newly cloned "org-mode" main branch. Ouch. Thanks for reporting! Confirmed The fix is attached. Dear all, I had to fix one of the tests, that apparently was only working because the bug existed. Please double check. Best, Ihor --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-org.el-Do-not-unconditionally-inherit-from-headline-.patch >From 199e64cf8264025cc78f79c3bdb278920685281f Mon Sep 17 00:00:00 2001 Message-Id: <199e64cf8264025cc78f79c3bdb278920685281f.1633271912.git.yantar92@gmail.com> From: Ihor Radchenko Date: Sun, 3 Oct 2021 22:10:31 +0800 Subject: [PATCH] org.el: Do not unconditionally inherit from headline right at BOB * lisp/org.el (org-entry-get-with-inheritance): Consider scenario when there is a headline starting at BOB and we are getting an inherited property at non-child headline below. Previous implementation would erroneously inherit the property value from the first headline in buffer. * testing/lisp/test-org.el (test-org/entry-get): Add test and fix an existing test that worked because this bug existed. Fixes https://list.orgmode.org/87zgrqqlcs.fsf@toloe.se/T/#mfcab9bd710d837a0cd9d4cf331655ee39b8ad3ca --- lisp/org.el | 14 ++++++++++++-- testing/lisp/test-org.el | 6 +++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index bc0ea24be..bcb38f07f 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -13163,7 +13163,7 @@ (defun org-entry-get-with-inheritance (property &optional literal-nil) However, if LITERAL-NIL is set, return the string value \"nil\" instead." (move-marker org-entry-property-inherited-from nil) (org-with-wide-buffer - (let (value) + (let (value at-bob-no-heading) (catch 'exit (while t (let ((v (org--property-local-values property literal-nil))) @@ -13177,7 +13177,17 @@ (defun org-entry-get-with-inheritance (property &optional literal-nil) (org-back-to-heading-or-point-min t) (move-marker org-entry-property-inherited-from (point)) (throw 'exit nil)) - ((org-up-heading-or-point-min)) + ((or (org-up-heading-safe) + (and (not (bobp)) + (goto-char (point-min)) + nil) + ;; `org-up-heading-safe' returned nil. We are at low + ;; level heading or bob. If there is headline + ;; there, do not try to fetch its properties. + (and (bobp) + (not at-bob-no-heading) + (not (org-at-heading-p)) + (setq at-bob-no-heading t)))) (t (let ((global (org--property-global-or-keyword-value property literal-nil))) (cond ((not global)) diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el index 18d41a0d2..7b1ce8cd0 100644 --- a/testing/lisp/test-org.el +++ b/testing/lisp/test-org.el @@ -5831,6 +5831,10 @@ (ert-deftest test-org/entry-get () (org-test-with-temp-text "* H\n:PROPERTIES:\n:A: 1\n:END:\n** H2" (let ((org-use-property-inheritance nil)) (org-entry-get (point-max) "A" 'selective)))) + (should-not + (org-test-with-temp-text "* H\n:PROPERTIES:\n:A: 1\n:END:\n* H2" + (let ((org-use-property-inheritance t)) + (org-entry-get (point-max) "A" t)))) (should (equal "1 2" @@ -5853,7 +5857,7 @@ (ert-deftest test-org/entry-get () (equal "1 2" (org-test-with-temp-text - "* H1\n:PROPERTIES:\n:A: 1\n:END:\n* H2.1\n* H2.2\n:PROPERTIES:\n:A+: 2\n:END:" + "* H1\n:PROPERTIES:\n:A: 1\n:END:\n** H2.1\n** H2.2\n:PROPERTIES:\n:A+: 2\n:END:" (org-entry-get (point-max) "A" t)))) (should (equal "1" -- 2.32.0 --=-=-=--