From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id 0EA/KKvdZWe5KAEA62LTzQ:P1 (envelope-from ) for ; Fri, 20 Dec 2024 21:12:11 +0000 Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id 0EA/KKvdZWe5KAEA62LTzQ (envelope-from ) for ; Fri, 20 Dec 2024 22:12:11 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=adamkovic.org header.s=fm3 header.b="b XlZLHA"; dkim=fail ("body hash did not verify") header.d=messagingengine.com header.s=fm1 header.b=wp8BEmHa; 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=fail reason="SPF not aligned (relaxed)" header.from=adamkovic.org (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1734729131; 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=t5Mbu++VR7obcLs1k1p6zQl8g7He2+yfB1bEIhoLqpo=; b=nHKuR3WvBVaDL8+9glQaRBbkVqaog0fA3gVXubavy6E8m8nkQi7dFcMM/872fr2TqcLOn9 O0DHjLlCDeDXfAP20aP//t4q41YMG8OEmB6BN789fCzqOaOymn3V7hRiJYDgVgHen4GHih R/+6IikW7w0xaqEdHaHMb+Vy5NO4op6diOh6rA2kaMK5gai5zWHkxR9xe3IKVh0y6Nn9kE CnRzF7jXb3m5bbpKe2mKpZWn/ya2k69BzpF4ZaU1T0dru6wjUQQ+v8I74YNyOAhrYNT6ly DniR8FQ+L5hYMGn4fA9/dGB7XbS3amtD72E1xtstsgnVmxNlK8b/JwpX/m9uKw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=adamkovic.org header.s=fm3 header.b="b XlZLHA"; dkim=fail ("body hash did not verify") header.d=messagingengine.com header.s=fm1 header.b=wp8BEmHa; 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=fail reason="SPF not aligned (relaxed)" header.from=adamkovic.org (policy=none) ARC-Seal: i=1; s=key1; d=yhetil.org; t=1734729131; a=rsa-sha256; cv=none; b=Opsz929kxueSDmRjT+hCWH1vbUz3HO3hoMzgUaZQ1TXLZpiH6iZaSxKtCRcQP1jIgnumgx W/uXqID/NuBHXZj0y58GhzkmNS7IA5fhP7KXAv6EbHhQzq8WBZ+/OLA4E1Yz8WtnimAN4T Fnwavv+iPxbtRN3u0N0Pkua33IqmqKy1bGRC4vhVRWE8xHyjCQbEKICSap5M/v3WxPFrRV 3ycXdDe8MSUOBWE0Ofzbq/Pd6sayaxf4pQUEBWJoEuSTSyMt8uR+758xpXb/RRhMxobWob eHkt96IBGyycF90go+5msTlrGTQXtu3/osXsCTXOuzKH+hZ7mpMunjS5/YgEFg== 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 09B5947F27 for ; Fri, 20 Dec 2024 22:12:10 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tOjag-00048p-Vh; Fri, 20 Dec 2024 15:27:19 -0500 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 1tOjaV-00048R-HD for emacs-orgmode@gnu.org; Fri, 20 Dec 2024 15:27:08 -0500 Received: from fout-b4-smtp.messagingengine.com ([202.12.124.147]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tOjaT-0007lC-05 for emacs-orgmode@gnu.org; Fri, 20 Dec 2024 15:27:07 -0500 Received: from phl-compute-03.internal (phl-compute-03.phl.internal [10.202.2.43]) by mailfout.stl.internal (Postfix) with ESMTP id B1481114012F; Fri, 20 Dec 2024 15:27:01 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-03.internal (MEProxy); Fri, 20 Dec 2024 15:27:01 -0500 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=fm3; t=1734726421; x= 1734812821; bh=hnpXBI8vwKPeaUi6mSAzAiMGKPEIHqOdBeQVSUaPgZU=; b=b XlZLHAZ8Fhl78mmT5MF+Wdba7SKHWhaHUVkQB+BLbW4Yjrbi2OhPKyBLyFv+Eywe 0oQBkpgI8ZOzO7gOIuhqMExpY1r3A7km3VjrJyKebD1rGGF0iUAdGrPPW5oPwiLa KhRcTEtSfSr6sgTSfyitVaUtYHNn4Yp26FPBRhSRIITQ8Afm69NZ+/ZY3DeHamKh BjsLzMkvVnpne7ox0D4asC2oNVz2Ogi4AzaNM5ZnHPwYM3u/qbQX8/YkgO6lqJjk ys025WP10pyr4h9zlQp0bZkGJ4B2lTsntmaClKcqKzVerlj8+JXk5eYBwpj+Gamg bFU50CvDNXR68uwACgfKA== 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-sender:x-me-sender:x-sasl-enc; s=fm1; t= 1734726421; x=1734812821; bh=hnpXBI8vwKPeaUi6mSAzAiMGKPEIHqOdBeQ VSUaPgZU=; b=wp8BEmHagEv6zYxytNpLFHMMfH+Of/4LkA3G8xve3aKaYfsggsX t0/VEB1zU+gIxfPZHL+C0iFhT6knEtltr2M0NZJO/Au2erqVHJzeVgmAL3vSoSQ0 ocLW3SorcyFwNCSaEtrDyeXtj9LQKU8IpNqwMhrmRwDCS4MAYwbvqnuJIrCOSitS vub8rvFqdNzZHpvd3TAj+4Oyj1yZ4DJy1dvgLjGZYR4fKd19X3hgzEE8rwJHcShz V5ktS42gK+061cZmVUDmV43JR9J4tN3NHvMOGrSYFj/prYdZFGUy2bdhhf/CGjtj floKYHw8TT+SXdSzJEqWcuvn7wz4kQK3rNw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddruddtvddgudefgecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecunecujfgurhephffvve fujghffffkgggtsehmtderredttdejnecuhfhrohhmpeftuhguohhlfhcutegurghmkhho vhhitgcuoehruhguohhlfhesrggurghmkhhovhhitgdrohhrgheqnecuggftrfgrthhtvg hrnhepveekkefhuedvteehtdejjeehudeludeuleeiudfggeevfeejkeejvedtteelgfev necuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprhhuug holhhfsegruggrmhhkohhvihgtrdhorhhgpdhnsggprhgtphhtthhopedvpdhmohguvgep shhmthhpohhuthdprhgtphhtthhopegvmhgrtghsqdhorhhgmhhouggvsehgnhhurdhorh hgpdhrtghpthhtohephigrnhhtrghrledvsehpohhsthgvohdrnhgvth X-ME-Proxy: Feedback-ID: i88214938:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 20 Dec 2024 15:27:00 -0500 (EST) 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: <871py9chbr.fsf@localhost> References: <20240831203449.31407-1-rudolf@adamkovic.org> <87jzfvpb8q.fsf@localhost> <87o74wpv5k.fsf@localhost> <87ttehjemw.fsf@localhost> <871py9chbr.fsf@localhost> Date: Fri, 20 Dec 2024 21:26:58 +0100 Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=202.12.124.147; envelope-from=rudolf@adamkovic.org; helo=fout-b4-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_PASS=-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-Scanner: mx11.migadu.com X-Migadu-Spam-Score: 5.27 X-Spam-Score: 5.27 X-Migadu-Queue-Id: 09B5947F27 X-TUID: 5MtRRjG4gZ+j --=-=-= Content-Type: text/plain Ihor Radchenko writes: > It has been a while since the last message in this thread. > May I know if you need any further help with the patch? My apologies for the radio silence, I was busy with school. Please see the attached patch! Will this do? Rudy --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-ox-texinfo-Support-numeric-values-of-toc-in-OPTIONS.patch >From ec7316614463d1c8217dac434fb8bad48446cd09 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 08857962b..3b2ca5f46 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -355,6 +355,12 @@ The Texinfo exporter no longer removes links from headings. This applies to all headings, below and above the =H= and =toc= export =#+OPTIONS:=. +*** 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 8410acc2b..6ddbd245c 100644 --- a/lisp/ox.el +++ b/lisp/ox.el @@ -5558,12 +5558,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) @@ -5628,7 +5626,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-export-get-relative-level headline info) + 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 681af7363..61f939ce1 100644 --- a/testing/lisp/test-ox-texinfo.el +++ b/testing/lisp/test-ox-texinfo.el @@ -484,5 +484,86 @@ body (should (search-forward "@uref{https://example.com, Foo@comma{} Bar}")) (should (search-forward "@uref{https://example.com, Foo@comma{} Bar@}}"))))))) + +;;; 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.5 (Apple Git-154) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable --=20 "The whole science is nothing more than a refinement of everyday thinking." --- Albert Einstein, 1879-1955 Rudolf Adamkovi=C4=8D [he/him] http://adamkovic.org --=-=-=--