From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id 8NDWDZwnTmOQbgEAbAwnHQ (envelope-from ) for ; Tue, 18 Oct 2022 06:12:12 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id yHUPDZwnTmOugAAAG6o9tA (envelope-from ) for ; Tue, 18 Oct 2022 06:12:12 +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 D87281FE11 for ; Tue, 18 Oct 2022 06:12:11 +0200 (CEST) Received: from localhost ([::1]:58962 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1okdxa-00038i-W7 for larch@yhetil.org; Tue, 18 Oct 2022 00:12:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38254) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okdx1-00038K-Bx for emacs-orgmode@gnu.org; Tue, 18 Oct 2022 00:11:35 -0400 Received: from mout02.posteo.de ([185.67.36.66]:44649) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okdwo-0006Wj-AE for emacs-orgmode@gnu.org; Tue, 18 Oct 2022 00:11:35 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 5B0BB240105 for ; Tue, 18 Oct 2022 06:11:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1666066279; bh=RxswcN8tAwXjNwRhwUf9PBKMOiZcC11CqzDJYi/64fg=; h=From:To:Cc:Subject:Date:From; b=hHb5OReea473IqqdWLP0224DTGb3idux/pxD2RFzTnhbC4faz66tbdDUwSDDEEjTq D4lqbD8/OpDSdXAk9lC53hQBml7EEDeQyzKbSNe8dXVyAmOjsEK1My7jgqeHLO7R7c nESXDywAo7RocsSDdndnA7DhA4165U+fy0zw/lyjJEPtIiWCCGBL/Sj4kmzm0B7TsM /IIXkLAtMqebhuavJCNBMBO7dBNOK0Hie+L126ka9yDLBU6F1Pnv1uMlTysp8n8XzA EAV92WMztV4S6pJHeS5QIG5apUdwTK4pHIuAEp/qfvcy1YIsZg0rsVxLr+LTg5adQR bHhvpbi0f1CeA== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Ms0m56lRqz6tmH; Tue, 18 Oct 2022 06:11:17 +0200 (CEST) From: Ihor Radchenko To: Kaushal Modi Cc: emacs-org list , Nicolas Goaziou Subject: Re: Possible bug in `org-subtree--get-subtree-options`? In-Reply-To: References: Date: Tue, 18 Oct 2022 04:12:04 +0000 Message-ID: <87pmephisr.fsf@localhost> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=185.67.36.66; envelope-from=yantar92@posteo.net; helo=mout02.posteo.de 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_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" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1666066331; 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=RbuSsN3a1OH+V32ftRG1LniDQ18P7eBDvE9RpjsVgwQ=; b=iYgXEOPFGgYco4VWvn6adw86eKI0TXgtthp81G7NU7ctEsiWX76ux2JnR1NQaJClRvZEWx GgwfNgOjf2OZ3JJmXP6hw/LL7uD5RJCF0kjkXfVcEuxSgRd2s/Q2R0b/NM0PlcrkuojPIq LdmhTfdCbxJN65NNL3jhyb0/0P8QXH6mEmqh2IqD9j9//htb5Jj/1aaUnV4BUJ94oJtLi3 zj9W4gtE5n4cSAAXgCprqx1oi5PykQKLn4iLsQ1npGPPvUz5opbxI39tbui8r4DIz1dTMp wnhZwcpzPmHxTKrjH6gfL5IbwBQUwWP8DoGkdOUqvXxEFA6Jn5msE9Z9BAGr1g== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1666066331; a=rsa-sha256; cv=none; b=qBVtvppXW6EO9ewnKdK8JVkG7oR0uxxlKoGbvMlfINXq/wY19gZIlKsAzsBygmQ4DzJTIb kstN8SMclQ8r9gvxwthCyzUKlrpe3UeGACEPus+b6rr0HDgZRg6xn7Q24nv90jp39KfllS wYgD5tp63je/zjbsXXZpGjrlVA2xhfAOcsHu00mzrU7Tj6iBFPJvAJFacXajdv2GV+bjqC ANiPj3Ct6sj1k0SclG9YLDDqy5y5X6KKFhbX7f5UqnZjg1er61sZ+lRL/BbJlObHkDt6mz FO4tHs7OFsYPR6Mo0aVsdMmoxu+GXhpdn0HHLurOkB5BKNoVp55yeOlCq6yt3g== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=hHb5ORee; dmarc=pass (policy=none) header.from=posteo.net; 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-Spam-Score: -3.92 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=hHb5ORee; dmarc=pass (policy=none) header.from=posteo.net; 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: D87281FE11 X-Spam-Score: -3.92 X-Migadu-Scanner: scn0.migadu.com X-TUID: fFRnE1B9BoTW --=-=-= Content-Type: text/plain Kaushal Modi writes: > Today I was debugging something where a subtree export wasn't recognizing > the EXPORT_OPTIONS property set in that subtree. > > MWE: > > ===== > * Top level > ** Allow broken links, but mark them > :PROPERTIES: > :EXPORT_FILE_NAME: allow-broken-links-but-mark-them > :EXPORT_OPTIONS: broken-links:mark > :END: > ===== > > 1. Move cursor to BOL of "** Allow broken links, but mark them" line. > 2. M-: (org-export--get-subtree-options) > > Output: > > (:title (#("Top level" 0 9 (:parent #1)))) > > Issue: Point is already on a heading, but it is jumping to the parent > heading and returning that heading's properties. > > Debugging through how the export options got parsed in subtree exports, I > reached the `org-export--get-subtree-options' function and this line in > there: > > ;; > https://git.savannah.gnu.org/cgit/emacs/org-mode.git/tree/lisp/ox.el#n1425 > (if (org-at-heading-p) (org-up-heading-safe) (org-back-to-heading t)) > > It looks like the if condition actions are swapped here. Not really swapped. A simple (org-back-to-heading t) will probably be enough. See the attached patch. However, I am concerned that one of the tests is actually assuming that current subtree in the below example includes "Heading". * Heading ** Child ** Child --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-org-export-get-subtree-options-Do-not-jump-to-parent.patch >From e2c1dc3955eb54cee7ce137d548c687e378f4c8a Mon Sep 17 00:00:00 2001 Message-Id: From: Ihor Radchenko Date: Tue, 18 Oct 2022 12:07:37 +0800 Subject: [PATCH] org-export--get-subtree-options: Do not jump to parent subtree * lisp/ox.el: Never jump to parent heading even when point is at an existing heading. * testing/lisp/test-ox.el (test-org-export/get-subtree-options): Fix test assuming that current subtree may include parent. Reported-by: Kaushal Modi Link: https://orgmode.org/list/CAFyQvY3mxi4DRTS+W-AX7bFELVujqH4DODEYPy3hyGRRuMEPSw@mail.gmail.com --- lisp/ox.el | 2 +- testing/lisp/test-ox.el | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lisp/ox.el b/lisp/ox.el index 92f6010a0..9f44ec3ef 100644 --- a/lisp/ox.el +++ b/lisp/ox.el @@ -1434,7 +1434,7 @@ (defun org-export--get-subtree-options (&optional backend) ;; property is the keyword with "EXPORT_" appended to it. (org-with-wide-buffer ;; Make sure point is at a heading. - (if (org-at-heading-p) (org-up-heading-safe) (org-back-to-heading t)) + (org-back-to-heading t) (let ((plist ;; EXPORT_OPTIONS are parsed in a non-standard way. Take ;; care of them right from the start. diff --git a/testing/lisp/test-ox.el b/testing/lisp/test-ox.el index 42867919b..0d39160b6 100644 --- a/testing/lisp/test-ox.el +++ b/testing/lisp/test-ox.el @@ -388,7 +388,7 @@ (ert-deftest test-org-export/get-subtree-options () (plist-get (org-export-get-environment nil t) :date)))) ;; Still grab correct options when section above is empty. (should - (equal '("H1") + (equal '("H12") (org-test-with-temp-text "* H1\n** H11\n** H12" (plist-get (org-export-get-environment nil t) :title)))) ;; More than one property can refer to the same node property. -- 2.35.1 --=-=-= Content-Type: text/plain -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at --=-=-=--