From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id 8MLHAsd+02Z4GQAAe85BDQ:P1 (envelope-from ) for ; Sat, 31 Aug 2024 20:36:23 +0000 Received: from aspmx1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id 8MLHAsd+02Z4GQAAe85BDQ (envelope-from ) for ; Sat, 31 Aug 2024 22:36:23 +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=YxEIiJgt; dkim=fail ("body hash did not verify") header.d=messagingengine.com header.s=fm1 header.b=LiL2+oIb; 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=1725136583; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=Tqq1l4vQHp//CBCtdvjWnjBa6gY6nDiSUYVybQ1bHV4=; b=dUY+Cw4m9cQFPpWJBlh3Xz0USe2N9NTCJFz86VUnYT8KntQAWb6tCU2czmlrIYQpV8PFXZ kYYuiCtzWD8C3h3JQXzTmqFdui/LTC90JFxwkcywaf+4T7s1NSHwJe75d9zgyNIka32oCW PmjTtFYR7zWXvEfdBttwpg7u6kx0tEKkYrTzRQ9FEQ+25+iIRxtObdf40U8PKV/tk5Snzo usLla4kvJGwsVZz2utspcWDl/mvFL0z+hmlFCau5Q4aLhTwcWV/jzKUxRgkCluJTjbEGgs OvTzSTu0+/b8rnag7fO/FM05SYUhug2wWYjbA0/gYPolLscznDm3LRoHFTp8kg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=adamkovic.org header.s=fm2 header.b=YxEIiJgt; dkim=fail ("body hash did not verify") header.d=messagingengine.com header.s=fm1 header.b=LiL2+oIb; 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=1725136583; a=rsa-sha256; cv=none; b=K1KG6cGK5rbL3tEXrdEp81In8ytoJY1QX6b3qOCfiV4jaHLfLMF6OiPjW3+8bP6WM8aA6y +1UsUWmlkVYJMtFBukpdF12yPPtvBKLPv6patISS8JxG9W3KyfDYJbdHzbS4uo/mcIG2uS tSs02ncUbWys4fq5GQkTiI9trZzRM26Cf7dAFN05W1kaxEHBpF6ldf/XX3Zy1pyqaCy+gQ D1xcsgzMbE2ydBdv7UheNse23zKrs3L/TiyFhiYx7kviP0J8pAks1MUDHUFvO0XRC5js06 eqHKVy3tCmGMGkt+OxFFgVXpubvtvrEe6G6HkT4CK9Kg2RxNNeUpXXzcCxOX6A== 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 2066970F33 for ; Sat, 31 Aug 2024 22:36:22 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1skUog-0003fK-0j; Sat, 31 Aug 2024 16:35:26 -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 1skUob-0003er-6U for emacs-orgmode@gnu.org; Sat, 31 Aug 2024 16:35:21 -0400 Received: from fhigh1-smtp.messagingengine.com ([103.168.172.152]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1skUoS-0005aq-2G for emacs-orgmode@gnu.org; Sat, 31 Aug 2024 16:35:13 -0400 Received: from phl-compute-05.internal (phl-compute-05.nyi.internal [10.202.2.45]) by mailfhigh.nyi.internal (Postfix) with ESMTP id B0DC21140128; Sat, 31 Aug 2024 16:35:09 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-05.internal (MEProxy); Sat, 31 Aug 2024 16:35:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adamkovic.org; h=cc:cc:content-transfer-encoding:content-type:date:date:from :from:in-reply-to:message-id:mime-version:reply-to:subject :subject:to:to; s=fm2; t=1725136509; x=1725222909; bh=w/9oxtjKzc Z40COSP6TZdh77lXDEbVLbf27YyYiIhaE=; b=YxEIiJgtt84XcNT+CE/5FlZO66 8zWXDQuiYrTTbYLzRFo3hY/QePYwnZMMAPwzLXOH7sitEKA6xcNFvY0gz6E5TlTD qIVX3oUKESj09VFriSvDF/LWOzCiQ7+78wroN4qSz9SIQuojbiqd2nZsWp8uHkjS nZB0ZGBvpSDSgjbkctMZi+vMQ+6b5qHuZUDunpPLLun6+8MUz21zQvSy9v6GxQZ8 G3neuNvpvVTEIyQTnOrI7quFsKJJu7Km0SH008KrgDZkAspxNHP6vbe1hIHq3ykl 6hzcfdcRc50JN2QvJ7VJ1PU5L2vToZzpGMmCFM4/N02VFj/RsUWH6zMLw5Bg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:message-id:mime-version:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; t=1725136509; x=1725222909; bh=w/9oxtjKzcZ40COSP6TZdh77lXDE bVLbf27YyYiIhaE=; b=LiL2+oIbT1855vHBTR9lJrVH/FpZ1ec+1OVgBKUNFi2j U0qCj9EVRZlWIOgIgsPaA+TfoUVg6fXpRiIXVB+kgdS7QARjHHeBjpBCi3sKut9P Z5ndf68nquUVQgoTMzs+fgwunt9tYApAdIW6+Vlo+bx7PUUWtqOP9AqW6t8cNpOC YpjZkCowSclLx/3JsTXnz9xmDil9fk5TQRxm9bH1xqr/8rX0ku9RkdPAgDPoJhRu M0EReFOFSXlnhz8k0LVNm0BaF4rVV4p2+faJ4PDZsSsv4ASkxh+MR2IXipIIPRg/ PHRDHc6T0mQcpttISTt1L/bgfXWUneXOkCPS7gLAig== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrudefkedgudehtdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecunecujfgurhephffvve fufffkofgggfestdekredtredtjeenucfhrhhomheptfhuugholhhfucetuggrmhhkohhv ihgtuceorhhuugholhhfsegruggrmhhkohhvihgtrdhorhhgqeenucggtffrrghtthgvrh hnpeekueehtedutddujeffieevueevlefggfelteeviedttdejieetfefgudeiudeljeen ucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehruhguoh hlfhesrggurghmkhhovhhitgdrohhrghdpnhgspghrtghpthhtohepvddpmhhouggvpehs mhhtphhouhhtpdhrtghpthhtohepvghmrggtshdqohhrghhmohguvgesghhnuhdrohhrgh dprhgtphhtthhopehruhguohhlfhesrggurghmkhhovhhitgdrohhrgh X-ME-Proxy: Feedback-ID: i88214938:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 31 Aug 2024 16:35:08 -0400 (EDT) From: =?UTF-8?q?Rudolf=20Adamkovi=C4=8D?= To: emacs-orgmode@gnu.org Cc: Rudolf Adamkovic Subject: [PATCH] ox-texinfo: Support numeric values of `toc' in `#+OPTIONS' Date: Sat, 31 Aug 2024 22:34:49 +0200 Message-ID: <20240831203449.31407-1-rudolf@adamkovic.org> X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=103.168.172.152; envelope-from=rudolf@adamkovic.org; helo=fhigh1-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, SPF_HELO_PASS=-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-Country: US X-Migadu-Flow: FLOW_IN X-Spam-Score: 3.92 X-Migadu-Queue-Id: 2066970F33 X-Migadu-Scanner: mx10.migadu.com X-Migadu-Spam-Score: 3.92 X-TUID: 6g8NsdrKhmNV From: Rudolf Adamkovic * etc/ORG-NEWS (Texinfo exporter now supports numeric =toc= values in =#+OPTIONS:=): Announce the new feature. * lisp/ox.el (org-export-excluded-from-toc-p): Return nil for all headlines that are above the `toc' value in export `#+OPTIONS'. * testing/lisp/test-ox-texinfo.el (test-ox-texinfo/headings-and-table-of-contents): Add a test. --- etc/ORG-NEWS | 12 ++++++ lisp/ox.el | 6 ++- testing/lisp/test-ox-texinfo.el | 66 +++++++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+), 1 deletion(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 392788055..f93776754 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -77,6 +77,18 @@ You can now create links to =shortdoc= documentation groups for Emacs Lisp functions (see =M-x shortdoc-display-group=). Requires Emacs 28 or newer. +<<<<<<< HEAD +======= +*** Texinfo exporter now supports 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. The latter will be instead exported as if they had +the =UNNUMBERED= property set to =notoc=, that is using the Texinfo +command given in the =unnumbered-no-toc-3= list position of the +=org-texinfo-classes= variable, as documented. + +>>>>>>> ox-texinfo: Support numeric values of `toc' in `#+OPTIONS' ** New and changed options # Chanes deadling with changing default values of customizations, diff --git a/lisp/ox.el b/lisp/ox.el index 7a0ab4dc7..acc535f72 100644 --- a/lisp/ox.el +++ b/lisp/ox.el @@ -5625,7 +5625,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..e2bacd4d9 100644 --- a/testing/lisp/test-ox-texinfo.el +++ b/testing/lisp/test-ox-texinfo.el @@ -345,5 +345,71 @@ body (should-not (org-element-contents section)) (should (eq first-heading (org-element-parent section))))))) + +;;; Headings and table of contents + +(ert-deftest test-ox-texinfo/headings-and-table-of-contents () + "Test headings with regards to table of contents." + (should + (org-test-with-temp-text + (string-join + (list "#+OPTIONS: h:2 toc:1 num:nil" + "* Level 1" + "** Level 1-1" + "*** Level 1-1-1" + "*** Level 1-1-2" + "** Level 1-2" + "*** Level 1-2-1" + "*** Level 1-2-2" + "* Level 2" + "** Level 2-1" + "*** Level 2-1-1" + "*** Level 2-1-2" + "** Level 2-2" + "*** Level 2-2-1" + "*** Level 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 "^* Level 1::$") + (re-search-forward "^* Level 2::$") + (re-search-forward "^@detailmenu$") + (re-search-forward "^Level 1$") + (re-search-forward "^* Level 1-1::$") + (re-search-forward "^* Level 1-2::$") + (re-search-forward "^Level 2$") + (re-search-forward "^* Level 2-1::$") + (re-search-forward "^* Level 2-2::$") + (re-search-forward "^@node Level 1$") + (re-search-forward "^@unnumbered Level 1$") + (re-search-forward "^@menu$") + (re-search-forward "^* Level 1-1::$") + (re-search-forward "^* Level 1-2::$") + (re-search-forward "^@heading Level 1-1$") + (re-search-forward "^@anchor{Level 1-1-1}Level 1-1-1$") + (re-search-forward "^@anchor{Level 1-1-2}Level 1-1-2$") + (re-search-forward "^@heading Level 1-2$") + (re-search-forward "^@anchor{Level 1-2-1}Level 1-2-1$") + (re-search-forward "^@anchor{Level 1-2-2}Level 1-2-2$") + (re-search-forward "^@node Level 2$") + (re-search-forward "^@unnumbered Level 2$") + (re-search-forward "^@menu$") + (re-search-forward "^* Level 2-1::$") + (re-search-forward "^* Level 2-2::$") + (re-search-forward "^@heading Level 2-1$") + (re-search-forward "^@anchor{Level 2-1-1}Level 2-1-1$") + (re-search-forward "^@anchor{Level 2-1-2}Level 2-1-2$") + (re-search-forward "^@anchor{Level 2-2}$") + (re-search-forward "^@heading Level 2-2$") + (re-search-forward "^@anchor{Level 2-2-1}Level 2-2-1$") + (re-search-forward "^@anchor{Level 2-2-2}Level 2-2-2$"))))))) + (provide 'test-ox-texinfo) ;;; test-ox-texinfo.el end here -- 2.46.0