From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id yBiqFTCO12ZPPQEA62LTzQ:P1 (envelope-from ) for ; Tue, 03 Sep 2024 22:31:12 +0000 Received: from aspmx1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id yBiqFTCO12ZPPQEA62LTzQ (envelope-from ) for ; Wed, 04 Sep 2024 00:31:12 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=adamkovic.org header.s=fm2 header.b="q YX5vsL"; dkim=fail ("body hash did not verify") header.d=messagingengine.com header.s=fm1 header.b=NgNlJEuC; dmarc=fail reason="SPF not aligned (relaxed)" header.from=adamkovic.org (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-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1725402672; 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=8JsgXoX7uU8tBjb9670g47KdpBf1Hlbu1sl7TSDiQuw=; b=gOz458XTYT2ZgIs4QxkZoI7bpJ38yL06CAvYIbFJ0LNcRtwnYYNVP1BH8UuTWZE0dLh3RQ j51tIeJPjOFsmnBteArxAbuEABahjquXydtDoN5PRuz6cOusRtZiGkdtNI+41tHLRY5Djo CCy883X0hK1T5zUEHoLzqX7+JHA0MWt+tslj4iBFd5Q58BFZM8k+g1CD6JFPdPqf7+jtPd y3NGnf23s8RbG//ALJrvvsoTzszwtFlRlNOEeKSpIpGDNbCqzYVhokVr2bR2SUPlhCRYfh Jb7Y1943BDgqpe9qfabfJCQyNzyAbfTwt7/naq3PsB9RJTE9G+eUQ1eZjLM24A== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1725402672; a=rsa-sha256; cv=none; b=kwDN1ML+VFQdBYuAvn4dLhL1VsQ1FNX5mndZQ87kV9/+i8xqwni79i8X0GH/ocnJ4pri0E CtgTjqPIPJ5NMvqUVJRemrrNwx63UPRWKZ1CGlQB+Mv2oF3AtGxOiBoYp09z5ZUZMrkhDP IeVyH6vvTXUuYQU4aLlvwJqfFQ+ddbwZfcouV2aDaqF6cnKUyU9BYlkDrICXD1yenwFjRA 5MHvyQvudJ1Gm37a/r68MtI0OFaWlU+bdnWjQbzKEmo1euYd7SHsZQ9ZQ9kVbHQkSGG4bV Ccych1ECOrQxLPr+kTeapxKMMqYoGLvNE2UAkmc8I9cnkAuClLkpmCWlO20hNQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=adamkovic.org header.s=fm2 header.b="q YX5vsL"; dkim=fail ("body hash did not verify") header.d=messagingengine.com header.s=fm1 header.b=NgNlJEuC; dmarc=fail reason="SPF not aligned (relaxed)" header.from=adamkovic.org (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" 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 7D26167157 for ; Wed, 4 Sep 2024 00:31:11 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1slc23-0004eN-5C; Tue, 03 Sep 2024 18:29:55 -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 1slc1p-0004cM-Ok for emacs-orgmode@gnu.org; Tue, 03 Sep 2024 18:29:38 -0400 Received: from fout3-smtp.messagingengine.com ([103.168.172.146] helo=pfout3-smtp.messagingengine.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1slc1n-0002en-Ad for emacs-orgmode@gnu.org; Tue, 03 Sep 2024 18:29:37 -0400 Received: from phl-compute-05.internal (phl-compute-05.phl.internal [10.202.2.45]) by mailfout.phl.internal (Postfix) with ESMTP id 9B6A41380335; Tue, 3 Sep 2024 18:29:33 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-05.internal (MEProxy); Tue, 03 Sep 2024 18:29:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adamkovic.org; h=cc:cc:content-type:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm2; t=1725402573; x= 1725488973; bh=GdWtJ7lpi6kYKJr3WKRu0dmRPFvJVMikCEcwUyVZ67c=; b=q YX5vsLGCcZZMHS2hDPHtHRmZZBVFnZTh2phq2EwUBNUnBf28IpF1rbsOCxBwWJGj 6baKtEuLKo+Zr03+xCQctyKy0J+ivooxIVq+MXBmU3+YAEcOMPiv1UC/AJr9GN9o hvdGjmIoUs6jcwAdjjCn1R84YZe8Zv0zXM8dEDJc5dTo0babBONr2QfDyXer7EZv nYGJiApB9dkmTdpDy1KObgMmR3UoG+yPve7OGR5J3PVw9zIpUIZdP3NvvAUGDPRc v8RH/6MzfTeN8g6l6Uld4vpkuci1EO7SOTqXvfLCDySYFJaze8B6L6EZL42Fb6Xw f1aLdu3Npx0XR/u9AjxZw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; t=1725402573; x=1725488973; bh=GdWtJ7lpi6kYKJr3WKRu0dmRPFvJ VMikCEcwUyVZ67c=; b=NgNlJEuCEQ+hG9hDmHYb6axsaV+OLIItCUSofwC+u+Ql g4pAtf4iPt3E6Euux8sl5aTWRdVuPaGcs24+6BbbMq/mUbF5nGdSwgj48UjCYcx3 MBOSizGr+bNCVK036znJN8egH8L09anDV7oRctO+zTRmh95q0Q96NF0k4MxRlsqd Q0IxGOnCWwH853Mbzs0+5Hj0RMiH9faPpqim4q9G197ZFFqyVNZYCB0aOOu3kLjV 2c1X1dHJkczlhkrg0W8p+xyx/CuDzXYFqhs7sUwSZ2aU5saL7/sCRDE0vTOTbpUw CRaHLdweHC3F81AARd1oWNU891lqaKcZnqTXk8mNeA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrudehiedgtdelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevuf gjfhffkfggtgesmhdtreertddtjeenucfhrhhomheptfhuugholhhfucetuggrmhhkohhv ihgtuceorhhuugholhhfsegruggrmhhkohhvihgtrdhorhhgqeenucggtffrrghtthgvrh hnpeevkeekhfeuvdethedtjeejheduleduueeliedugfegveefjeekjeevtdetlefgveen ucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehruhguoh hlfhesrggurghmkhhovhhitgdrohhrghdpnhgspghrtghpthhtohepvddpmhhouggvpehs mhhtphhouhhtpdhrtghpthhtohepvghmrggtshdqohhrghhmohguvgesghhnuhdrohhrgh dprhgtphhtthhopeihrghnthgrrhelvdesphhoshhtvghordhnvght X-ME-Proxy: Feedback-ID: i88214938:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 3 Sep 2024 18:29:32 -0400 (EDT) From: Rudolf =?utf-8?Q?Adamkovi=C4=8D?= To: Ihor Radchenko Cc: emacs-orgmode@gnu.org Subject: Re: [PATCH] ox-texinfo: Support numeric values of `toc' in `#+OPTIONS' In-Reply-To: <87jzfvpb8q.fsf@localhost> References: <20240831203449.31407-1-rudolf@adamkovic.org> <87jzfvpb8q.fsf@localhost> Date: Wed, 04 Sep 2024 00:29:29 +0200 Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=103.168.172.146; envelope-from=rudolf@adamkovic.org; helo=pfout3-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: 7D26167157 X-Migadu-Scanner: mx12.migadu.com X-Migadu-Spam-Score: -5.48 X-Spam-Score: -5.48 X-TUID: T6xSzZ8clHfq --=-=-= Content-Type: text/plain Ihor Radchenko writes: > AFAIU, it is a bugfix. Right? > > If it is, the patch name is rather confusing. I can never tell! Fixed. > Also, what about `org-export-collect-headlines'. It also ignores > numeric value of :with-toc. Fixed. Thank you for letting me know! I am exporting only to HTML, where Org-generated top-level menus do not appear. So, I missed it. P.S. I also fixed the incorrect test. Rudy --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-ox-texinfo-Support-numeric-values-of-toc-in-OPTIONS.patch >From 54ff91953d1a456852506ac162eee2a0cf99d3b0 Mon Sep 17 00:00:00 2001 From: Rudolf Adamkovic Date: Sat, 24 Aug 2024 15:26:18 +0200 Subject: [PATCH] ox-texinfo: Support numeric values of `toc' in `#+OPTIONS' * etc/ORG-NEWS (Texinfo exporter now supports numeric =toc= values in =#+OPTIONS:=): Announce the change. * lisp/ox.el (org-export-excluded-from-toc-p): Return nil for all headlines that are above the `toc' value in the export `#+OPTIONS'. (org-export-collect-headlines): Exclude all headlines that are above the `toc' value in the export `#+OPTIONS' , using the updated `org-export-excluded-from-toc-p' function. * testing/lisp/test-ox-texinfo.el (test-ox-texinfo/menus-nodes-headings): Add a test. --- etc/ORG-NEWS | 6 +++ lisp/ox.el | 16 ++++--- testing/lisp/test-ox-texinfo.el | 81 +++++++++++++++++++++++++++++++++ 3 files changed, 96 insertions(+), 7 deletions(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 392788055..344591ebb 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -223,6 +223,12 @@ This way, attachments will remain accessible when opening symlinked Org file. When no attach dir exists, Org mode will still prefer creating it in the "default" directory - where the symlink is located. +*** Texinfo exporter now considers numeric =toc= values in =#+OPTIONS:= + +For example, given =H:3= and =toc:2= in =#+OPTIONS:=, all headings at +the 1st and 2nd level appear in the table of contents and those at the +3rd level do not. + * Version 9.7 ** Important announcements and breaking changes diff --git a/lisp/ox.el b/lisp/ox.el index 7a0ab4dc7..c16e3acf6 100644 --- a/lisp/ox.el +++ b/lisp/ox.el @@ -5555,12 +5555,10 @@ Footnote sections are ignored." (+ (org-export-get-relative-level scope info) n)) limit)))) (org-element-map (org-element-contents scope) 'headline - (lambda (h) - (and (not (org-element-property :footnote-section-p h)) - (not (equal "notoc" - (org-export-get-node-property :UNNUMBERED h t))) - (>= n (org-export-get-relative-level h info)) - h)) + (lambda (headline) + (and (not (org-export-excluded-from-toc-p headline info)) + (>= n (org-export-get-relative-level headline info)) + headline)) info))) (defun org-export-collect-elements (type info &optional predicate) @@ -5625,7 +5623,11 @@ contents. However, it is useful if some additional processing is required on headlines excluded from table of contents." (or (org-element-property :footnote-section-p headline) (org-export-low-level-p headline info) - (equal "notoc" (org-export-get-node-property :UNNUMBERED headline t)))) + (equal "notoc" (org-export-get-node-property :UNNUMBERED headline t)) + (let ((toc-depth (plist-get info :with-toc))) + (and (wholenump toc-depth) + (> (org-element-property :level headline) + toc-depth))))) (defun org-export-toc-entry-backend (parent &rest transcoders) "Return an export backend appropriate for table of contents entries. diff --git a/testing/lisp/test-ox-texinfo.el b/testing/lisp/test-ox-texinfo.el index b16a344e7..fc9b6dabd 100644 --- a/testing/lisp/test-ox-texinfo.el +++ b/testing/lisp/test-ox-texinfo.el @@ -345,5 +345,86 @@ body (should-not (org-element-contents section)) (should (eq first-heading (org-element-parent section))))))) + +;;; Structure + +(ert-deftest test-ox-texinfo/menus-nodes-headings () + "Test menus, nodes, and headings." + (should + (org-test-with-temp-text + (string-join + (list "#+OPTIONS: H:3 toc:2 num:nil" + "* Heading 1" + "** Heading 1-1" + "*** Heading 1-1-1" + "*** Heading 1-1-2" + "** Heading 1-2" + "*** Heading 1-2-1" + "*** Heading 1-2-2" + "* Heading 2" + "** Heading 2-1" + "*** Heading 2-1-1" + "*** Heading 2-1-2" + "** Heading 2-2" + "*** Heading 2-2-1" + "*** Heading 2-2-2") + "\n") + (let ((export-buffer "*Test Texinfo Export*") + (org-export-show-temporary-export-buffer nil)) + (org-export-to-buffer 'texinfo export-buffer + nil nil nil nil nil + #'texinfo-mode) + (with-current-buffer export-buffer + (goto-char (point-min)) + (and + (re-search-forward "^@menu$") + (re-search-forward "^* Heading 1::$") + (re-search-forward "^* Heading 2::$") + (re-search-forward "^@detailmenu$") + (re-search-forward "^Heading 1$") + (re-search-forward "^* Heading 1-1::$") + (re-search-forward "^* Heading 1-2::$") + (re-search-forward "^Heading 2$") + (re-search-forward "^* Heading 2-1::$") + (re-search-forward "^* Heading 2-2::$") + (re-search-forward "^@end detailmenu$") + (re-search-forward "^@end menu$") + (re-search-forward "^@node Heading 1$") + (re-search-forward "^@unnumbered Heading 1$") + (re-search-forward "^@menu$") + (re-search-forward "^* Heading 1-1::$") + (re-search-forward "^* Heading 1-2::$") + (re-search-forward "^@end menu$") + (re-search-forward "^@node Heading 1-1$") + (re-search-forward "^@unnumberedsec Heading 1-1$") + (re-search-forward "^@anchor{Heading 1-1-1}$") + (re-search-forward "^@subheading Heading 1-1-1$") + (re-search-forward "^@anchor{Heading 1-1-2}$") + (re-search-forward "^@subheading Heading 1-1-2$") + (re-search-forward "^@node Heading 1-2$") + (re-search-forward "^@unnumberedsec Heading 1-2$") + (re-search-forward "^@anchor{Heading 1-2-1}$") + (re-search-forward "^@subheading Heading 1-2-1$") + (re-search-forward "^@anchor{Heading 1-2-2}$") + (re-search-forward "^@subheading Heading 1-2-2$") + (re-search-forward "^@node Heading 2$") + (re-search-forward "^@unnumbered Heading 2$") + (re-search-forward "^@menu$") + (re-search-forward "^* Heading 2-1::$") + (re-search-forward "^* Heading 2-2::$") + (re-search-forward "^@end menu$") + (re-search-forward "^@node Heading 2-1$") + (re-search-forward "^@unnumberedsec Heading 2-1$") + (re-search-forward "^@anchor{Heading 2-1-1}$") + (re-search-forward "^@subheading Heading 2-1-1$") + (re-search-forward "^@anchor{Heading 2-1-2}$") + (re-search-forward "^@subheading Heading 2-1-2$") + (re-search-forward "^@node Heading 2-2$") + (re-search-forward "^@unnumberedsec Heading 2-2$") + (re-search-forward "^@anchor{Heading 2-2-1}$") + (re-search-forward "^@subheading Heading 2-2-1$") + (re-search-forward "^@anchor{Heading 2-2-2}$") + (re-search-forward "^@subheading Heading 2-2-2$"))))))) + (provide 'test-ox-texinfo) ;;; test-ox-texinfo.el end here -- 2.39.3 (Apple Git-146) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable --=20 "I love deadlines. I love the whooshing noise they make as they go by." --- Douglas Adams, The Salmon of Doubt, 2002 Rudolf Adamkovi=C4=8D [he/him] http://adamkovic.org --=-=-=--