From 69b8220f3bdb5ae4bc7b617964cf2bd43e812cee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20A=2E=20Gomes?= Date: Fri, 8 Oct 2021 18:35:53 +0300 Subject: [PATCH 25/76] Deprecate org-export-collect-headlines. --- lisp/org-compat.el | 2 ++ lisp/ox-ascii.el | 2 +- lisp/ox-html.el | 2 +- lisp/ox-md.el | 6 +++--- lisp/ox-odt.el | 2 +- lisp/ox-texinfo.el | 2 +- lisp/ox.el | 6 +++--- testing/lisp/test-ox.el | 28 ++++++++++++++-------------- 8 files changed, 26 insertions(+), 24 deletions(-) diff --git a/lisp/org-compat.el b/lisp/org-compat.el index fdf823d83..02370b3fb 100644 --- a/lisp/org-compat.el +++ b/lisp/org-compat.el @@ -356,6 +356,8 @@ Counting starts at 1." 'org-element-heading-interpreter "9.5") (define-obsolete-function-alias 'org-element-headline-parser 'org-element-heading-parser "9.5") +(define-obsolete-function-alias 'org-export-collect-headlines + 'org-export-collect-headings "9.5") (defun org-in-fixed-width-region-p () "Non-nil if point in a fixed-width region." diff --git a/lisp/ox-ascii.el b/lisp/ox-ascii.el index 7b4232c4f..f848947fc 100644 --- a/lisp/ox-ascii.el +++ b/lisp/ox-ascii.el @@ -773,7 +773,7 @@ contents according to the specified scope." (or (not (plist-get info :with-tags)) (eq (plist-get info :with-tags) 'not-in-toc)) 'toc)))) - (org-export-collect-headlines info n scope) "\n")))) + (org-export-collect-headings info n scope) "\n")))) (defun org-ascii--list-listings (keyword info) "Return a list of listings. diff --git a/lisp/ox-html.el b/lisp/ox-html.el index f48c09be4..39b3aec49 100644 --- a/lisp/ox-html.el +++ b/lisp/ox-html.el @@ -2315,7 +2315,7 @@ of contents as a string, or nil if it is empty." (mapcar (lambda (heading) (cons (org-html--format-toc-headline heading info) (org-export-get-relative-level heading info))) - (org-export-collect-headlines info depth scope)))) + (org-export-collect-headings info depth scope)))) (when toc-entries (let ((toc (concat "
" (org-html--toc-text toc-entries) diff --git a/lisp/ox-md.el b/lisp/ox-md.el index 9fb75fa57..78f5cafa6 100644 --- a/lisp/ox-md.el +++ b/lisp/ox-md.el @@ -168,7 +168,7 @@ of contents can refer to headings." ;; Global table of contents includes HEADING. (and (plist-get info :with-toc) (memq heading - (org-export-collect-headlines info (plist-get info :with-toc)))) + (org-export-collect-headings info (plist-get info :with-toc)))) ;; A local table of contents includes HEADING. (cl-some (lambda (h) @@ -186,7 +186,7 @@ of contents can refer to headings." (string-to-number (match-string 0 value)))) (local? (string-match-p "\\" value))) (memq heading - (org-export-collect-headlines + (org-export-collect-headings info n (and local? keyword)))))))) info t)))) (org-element-lineage heading)) @@ -258,7 +258,7 @@ contents according to the specified element." (org-make-tag-string (org-export-get-tags heading info))))) (concat indentation bullet title tags))) - (org-export-collect-headlines info n scope) "\n") + (org-export-collect-headings info n scope) "\n") "\n")) (defun org-md--footnote-formatted (footnote info) diff --git a/lisp/ox-odt.el b/lisp/ox-odt.el index 4da41be2c..c5ef01c75 100644 --- a/lisp/ox-odt.el +++ b/lisp/ox-odt.el @@ -1148,7 +1148,7 @@ table of contents as a string, or nil." ;; ;; Likewise, links, footnote references and regular targets are also ;; suppressed. - (let* ((headings (org-export-collect-headlines info depth scope)) + (let* ((headings (org-export-collect-headings info depth scope)) (backend (org-export-toc-entry-backend (org-export-backend-name (plist-get info :back-end))))) (when headings diff --git a/lisp/ox-texinfo.el b/lisp/ox-texinfo.el index bae16a9b8..6dbc18ad2 100644 --- a/lisp/ox-texinfo.el +++ b/lisp/ox-texinfo.el @@ -1240,7 +1240,7 @@ holding contextual information." (lambda (h) (or (org-not-nil (org-export-get-node-property :COPYING h t)) (< max-depth (org-export-get-relative-level h info)))) - (org-export-collect-headlines info 1 scope)) + (org-export-collect-headings info 1 scope)) cache))))) ;;;; Node Property diff --git a/lisp/ox.el b/lisp/ox.el index 58e59f552..b9863d7e5 100644 --- a/lisp/ox.el +++ b/lisp/ox.el @@ -5253,7 +5253,7 @@ return nil." ;;;; For Tables of Contents ;; -;; `org-export-collect-headlines' builds a list of all exportable +;; `org-export-collect-headings' builds a list of all exportable ;; heading elements, maybe limited to a certain depth. One can then ;; easily parse it and transcode it. ;; @@ -5265,7 +5265,7 @@ return nil." ;; `org-export-toc-entry-backend' builds a special anonymous back-end ;; useful to export table of contents' entries. -(defun org-export-collect-headlines (info &optional n scope) +(defun org-export-collect-headings (info &optional n scope) "Collect headings in order to build a table of contents. INFO is a plist used as a communication channel. @@ -5357,7 +5357,7 @@ Return a list of `src-block' elements with a caption." INFO is a plist used as a communication channel. Note that such headings are already excluded from -`org-export-collect-headlines'. Therefore, this function is not +`org-export-collect-headings'. Therefore, this function is not necessary if you only need to list headings in the table of contents. However, it is useful if some additional processing is required on headings excluded from table of contents." diff --git a/testing/lisp/test-ox.el b/testing/lisp/test-ox.el index 20c85da12..de6d5957e 100644 --- a/testing/lisp/test-ox.el +++ b/testing/lisp/test-ox.el @@ -2594,7 +2594,7 @@ Para2" (should (= 1 (let ((org-footnote-section "Footnotes")) (length (org-test-with-parsed-data "* H1\n* Footnotes\n" - (org-export-collect-headlines info)))))) + (org-export-collect-headings info)))))) (should (equal '(2) (let ((org-footnote-section "Footnotes")) @@ -4745,37 +4745,37 @@ This test does not cover listings and custom environments." ;;; Tables of Contents (ert-deftest test-org-export/collect-headlines () - "Test `org-export-collect-headlines' specifications." + "Test `org-export-collect-headings' specifications." ;; Standard test. (should (equal '("H1" "H2") (org-test-with-parsed-data "* H1\n** H2" (mapcar (lambda (h) (org-element-property :raw-value h)) - (org-export-collect-headlines info))))) + (org-export-collect-headings info))))) ;; Do not collect headings below optional argument. (should (equal '("H1") (org-test-with-parsed-data "* H1\n** H2" (mapcar (lambda (h) (org-element-property :raw-value h)) - (org-export-collect-headlines info 1))))) + (org-export-collect-headings info 1))))) ;; Never collect headings below maximum heading level. (should (equal '("H1") (org-test-with-parsed-data "#+OPTIONS: H:1\n* H1\n** H2" (mapcar (lambda (h) (org-element-property :raw-value h)) - (org-export-collect-headlines info))))) + (org-export-collect-headings info))))) (should (equal '("H1") (org-test-with-parsed-data "#+OPTIONS: H:1\n* H1\n** H2" (mapcar (lambda (h) (org-element-property :raw-value h)) - (org-export-collect-headlines info 2))))) + (org-export-collect-headings info 2))))) ;; Do not collect footnote section. (should (equal '("H1") (let ((org-footnote-section "Footnotes")) (org-test-with-parsed-data "* H1\n** Footnotes" (mapcar (lambda (h) (org-element-property :raw-value h)) - (org-export-collect-headlines info)))))) + (org-export-collect-headings info)))))) ;; Do not collect headings with UNNUMBERED property set to "notoc". ;; Headings with another value for the property are still ;; collected. UNNUMBERED property is inherited. @@ -4784,25 +4784,25 @@ This test does not cover listings and custom environments." (org-test-with-parsed-data "* H1\n* H2\n:PROPERTIES:\n:UNNUMBERED: notoc\n:END:" (mapcar (lambda (h) (org-element-property :raw-value h)) - (org-export-collect-headlines info))))) + (org-export-collect-headings info))))) (should-not (org-test-with-parsed-data "* H1\n:PROPERTIES:\n:UNNUMBERED: notoc\n:END:\n** H2" (mapcar (lambda (h) (org-element-property :raw-value h)) - (org-export-collect-headlines info)))) + (org-export-collect-headings info)))) (should (equal '("H1" "H2") (org-test-with-parsed-data "* H1\n* H2\n:PROPERTIES:\n:UNNUMBERED: t\n:END:" (mapcar (lambda (h) (org-element-property :raw-value h)) - (org-export-collect-headlines info))))) + (org-export-collect-headings info))))) ;; Collect headings locally. (should (equal '("H2" "H3") (org-test-with-parsed-data "* H1\n** H2\n** H3" (let ((scope (org-element-map tree 'headline #'identity info t))) (mapcar (lambda (h) (org-element-property :raw-value h)) - (org-export-collect-headlines info nil scope)))))) + (org-export-collect-headings info nil scope)))))) ;; Collect headings from a scope specified by a fuzzy match (should (equal '("H3" "H4") @@ -4820,7 +4820,7 @@ This test does not cover listings and custom environments." " (mapcar (lambda (h) (org-element-property :raw-value h)) - (org-export-collect-headlines + (org-export-collect-headings info nil (org-export-resolve-fuzzy-link @@ -4845,7 +4845,7 @@ This test does not cover listings and custom environments." " (mapcar (lambda (h) (org-element-property :raw-value h)) - (org-export-collect-headlines + (org-export-collect-headings info nil (org-export-resolve-id-link @@ -4859,7 +4859,7 @@ This test does not cover listings and custom environments." (org-test-with-parsed-data "* H1\n** H2\n*** H3" (let ((scope (org-element-map tree 'headline #'identity info t))) (mapcar (lambda (h) (org-element-property :raw-value h)) - (org-export-collect-headlines info 1 scope))))))) + (org-export-collect-headings info 1 scope))))))) (ert-deftest test-org-export/excluded-from-toc-p () "Test `org-export-excluded-from-toc-p' specifications." -- 2.33.0