All comments addressed.

All tests pass after each commit on emacs 30.

All tests pass after final commit on emacs 28 and 29.

No new warnings during compilation or running the tests for all previously
mentioned runs.

Ihor Radchenko <[email protected]> writes:

> Morgan Smith <[email protected]> writes:
>
>> Subject: [PATCH 2/8] Move `org-element-at-point-no-context' definition before
>>  first use
>>
>> When compiling the test files, both `test-org/map-entries' and
>> `test-org/entry-properties' would fail with the following error:
>>
>> invalid-function (org-element-with-disabled-cache)
>>
>> * lisp/org-element.el (org-element-at-point-no-context): Move before
>> first use.
>
> I am not sure if it is the best idea. By moving that function you will
> break sectioning structure of org-element.el. Maybe we should instead
> make it a simple defun.

As someone who seems to be regularly fighting the compiler, I like this idea.

>> --- a/lisp/ob-C.el
>> +++ b/lisp/ob-C.el
>> @@ -38,7 +38,6 @@
>>
>>  (require 'cc-mode)
>>  (require 'ob)
>> -(require 'org-macs)
>
> This is actually intentional. I wanted to
> keep
> (require 'org-macs)
> (org-assert-version)
> separate, as it is a semi-temporary workaround that we should eventually
> get rid of.

Sounds good.  I still updated org.el so that it looks the same as all the other
files (patch 7).

>From c47a52b9befd1410af954ec9c9d4e0a134682c8e Mon Sep 17 00:00:00 2001
From: Morgan Smith <[email protected]>
Date: Mon, 27 Oct 2025 15:37:05 -0400
Subject: [PATCH 1/8] Testing: Add missing requires

Tests are usually run using the Makefile which includes many files
before running the tests.  By adding the requires directly to the
files it is easier to use these tests in other ways.

* testing/lisp/test-org-attach.el:
Require "dired".
* testing/lisp/test-org-footnote.el:
Require "org-test".
* testing/lisp/test-org-habit.el:
Require "test-org".
Add relative path the require for "test-org-agenda".
* testing/lisp/test-org-info.el:
Require "ol-info".
* testing/lisp/test-ox-beamer.el:
Require "test-duplicates-detector".
---
 testing/lisp/test-org-attach.el   | 1 +
 testing/lisp/test-org-footnote.el | 1 +
 testing/lisp/test-org-habit.el    | 3 ++-
 testing/lisp/test-org-info.el     | 2 ++
 testing/lisp/test-ox-beamer.el    | 3 +++
 5 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/testing/lisp/test-org-attach.el b/testing/lisp/test-org-attach.el
index 6a597752e..d475ecba3 100644
--- a/testing/lisp/test-org-attach.el
+++ b/testing/lisp/test-org-attach.el
@@ -27,6 +27,7 @@
 (require 'org-test "../testing/org-test")
 (require 'org-attach)
 (eval-when-compile (require 'cl-lib))
+(require 'dired)
 
 (ert-deftest test-org-attach/dir ()
   "Test `org-attach-get' specifications."
diff --git a/testing/lisp/test-org-footnote.el b/testing/lisp/test-org-footnote.el
index 41268e20e..4c300b8db 100644
--- a/testing/lisp/test-org-footnote.el
+++ b/testing/lisp/test-org-footnote.el
@@ -19,6 +19,7 @@
 
 ;;; Code:
 
+(require 'org-test "../testing/org-test")
 (require 'org-footnote)
 
 (ert-deftest test-org-footnote/new-anon ()
diff --git a/testing/lisp/test-org-habit.el b/testing/lisp/test-org-habit.el
index 4b3dbdb06..3c4c6ede9 100644
--- a/testing/lisp/test-org-habit.el
+++ b/testing/lisp/test-org-habit.el
@@ -22,7 +22,8 @@
 (require 'org-test "../testing/org-test")
 (require 'org-agenda)
 (require 'org-habit)
-(require 'test-org-agenda)
+(require 'test-org-agenda "../testing/lisp/test-org-agenda")
+(require 'test-org "../testing/lisp/test-org")
 
 
 ;; Tests
diff --git a/testing/lisp/test-org-info.el b/testing/lisp/test-org-info.el
index 1ca2aca2e..55627cbef 100644
--- a/testing/lisp/test-org-info.el
+++ b/testing/lisp/test-org-info.el
@@ -19,6 +19,8 @@
 
 ;;; Code:
 
+(require 'ol-info)
+
 (ert-deftest test-org-info/export ()
   "Test `org-info-export' specifications."
   ;; Export to HTML.  Without node, refer to "Top".
diff --git a/testing/lisp/test-ox-beamer.el b/testing/lisp/test-ox-beamer.el
index f5743409f..24550ec62 100644
--- a/testing/lisp/test-ox-beamer.el
+++ b/testing/lisp/test-ox-beamer.el
@@ -27,6 +27,9 @@
 (unless (featurep 'ox-beamer)
   (signal 'missing-test-dependency '("org-export-beamer")))
 
+(eval-when-compile
+  (require 'test-duplicates-detector "../testing/lisp/test-duplicates-detector"))
+
 
 
 (ert-deftest ox-beamer/orgframe ()

base-commit: ee12059f78697d6d28ec3c98f4b4e092fbe8929f
-- 
2.51.2

>From 0c77e8966b274c07272610495d9e1680512f7817 Mon Sep 17 00:00:00 2001
From: Morgan Smith <[email protected]>
Date: Sun, 2 Nov 2025 13:53:05 -0500
Subject: [PATCH 2/8] Do not define `org-element-at-point-no-context' as a
 inline function

When compiling the test files, both `test-org/map-entries' and
`test-org/entry-properties' would fail with the following error:

invalid-function (org-element-with-disabled-cache)

This is because the inline function was used before it was defined.

* lisp/org-element.el (org-element-at-point-no-context): Use "defun"
instead of "defsubst".
---
 lisp/org-element.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/org-element.el b/lisp/org-element.el
index 0b51b4524..8f5adbf7c 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -8552,7 +8552,7 @@ org-element-at-point
               (org-element-at-point (1+ epom) cached-only))))))))
 
 ;;;###autoload
-(defsubst org-element-at-point-no-context (&optional pom)
+(defun org-element-at-point-no-context (&optional pom)
   "Quickly find element at point or POM.
 
 It is a faster version of `org-element-at-point' that is not
-- 
2.51.2

>From 358e560cddeec65f5260eee825068445f606feef Mon Sep 17 00:00:00 2001
From: Morgan Smith <[email protected]>
Date: Sun, 2 Nov 2025 15:02:14 -0500
Subject: [PATCH 3/8] Remove unused `declare-function' calls

These calls to `declare-function' declare functions that are never
used in the file.

* lisp/ob-R.el:
* lisp/ob-clojure.el:
* lisp/ob-core.el:
* lisp/ob-julia.el:
* lisp/ob-latex.el:
* lisp/ob-lua.el:
* lisp/ob-ocaml.el:
* lisp/ob-scheme.el:
* lisp/ob-sqlite.el:
* lisp/ob-tangle.el:
* lisp/oc-csl.el:
* lisp/oc-natbib.el:
* lisp/ol-bbdb.el:
* lisp/ol-gnus.el:
* lisp/ol.el:
* lisp/org-agenda.el:
* lisp/org-capture.el:
* lisp/org-compat.el:
* lisp/org-crypt.el:
* lisp/org-cycle.el:
* lisp/org-element.el:
* lisp/org-fold-core.el |:
* lisp/org-fold.el:
* lisp/org-id.el:
* lisp/org-indent.el:
* lisp/org-keys.el:
* lisp/org-macro.el:
* lisp/org-macs.el:
* lisp/org-pcomplete.el |:
* lisp/org-persist.el:
* lisp/org-plot.el:
* lisp/org-src.el:
* lisp/org-table.el:
* lisp/org-timer.el:
* lisp/org.el:
* lisp/ox-ascii.el:
* lisp/ox-html.el:
* lisp/ox-icalendar.el:
* lisp/ox-odt.el:
* lisp/ox-publish.el:
* lisp/ox.el:
Remove unused `declare-function' calls.
---
 lisp/ob-R.el          |  1 -
 lisp/ob-clojure.el    |  1 -
 lisp/ob-core.el       | 10 ----------
 lisp/ob-julia.el      |  2 --
 lisp/ob-latex.el      |  3 ---
 lisp/ob-lua.el        |  4 ----
 lisp/ob-ocaml.el      |  1 -
 lisp/ob-scheme.el     |  1 -
 lisp/ob-sqlite.el     |  1 -
 lisp/ob-tangle.el     |  2 --
 lisp/oc-csl.el        |  2 --
 lisp/oc-natbib.el     |  2 --
 lisp/ol-bbdb.el       |  1 -
 lisp/ol-gnus.el       |  1 -
 lisp/ol.el            |  2 --
 lisp/org-agenda.el    |  2 --
 lisp/org-capture.el   |  1 -
 lisp/org-compat.el    |  1 -
 lisp/org-crypt.el     |  1 -
 lisp/org-cycle.el     |  1 -
 lisp/org-element.el   |  1 -
 lisp/org-fold-core.el |  2 --
 lisp/org-fold.el      |  4 ----
 lisp/org-id.el        |  2 --
 lisp/org-indent.el    |  2 --
 lisp/org-keys.el      |  2 --
 lisp/org-macro.el     |  3 ---
 lisp/org-macs.el      |  2 --
 lisp/org-pcomplete.el |  2 --
 lisp/org-persist.el   |  4 ----
 lisp/org-plot.el      |  1 -
 lisp/org-src.el       |  1 -
 lisp/org-table.el     | 10 ----------
 lisp/org-timer.el     |  2 --
 lisp/org.el           | 22 ----------------------
 lisp/ox-ascii.el      |  3 ---
 lisp/ox-html.el       |  5 -----
 lisp/ox-icalendar.el  |  3 ---
 lisp/ox-odt.el        |  4 ----
 lisp/ox-publish.el    |  2 --
 lisp/ox.el            |  2 --
 41 files changed, 119 deletions(-)

diff --git a/lisp/ob-R.el b/lisp/ob-R.el
index c23420554..1c42ed14e 100644
--- a/lisp/ob-R.el
+++ b/lisp/ob-R.el
@@ -39,7 +39,6 @@
 
 (declare-function orgtbl-to-tsv "org-table" (table params))
 (declare-function run-ess-r "ext:ess-r-mode" (&optional start-args))
-(declare-function inferior-ess-send-input "ext:ess-inf" ())
 (declare-function ess-make-buffer-current "ext:ess-inf" ())
 (declare-function ess-eval-buffer "ext:ess-inf" (vis))
 (declare-function ess-wait-for-process "ext:ess-inf"
diff --git a/lisp/ob-clojure.el b/lisp/ob-clojure.el
index e8e425ad4..e90a338f1 100644
--- a/lisp/ob-clojure.el
+++ b/lisp/ob-clojure.el
@@ -53,7 +53,6 @@
 (require 'ob)
 
 (declare-function cider-current-connection "ext:cider-client" (&optional type))
-(declare-function cider-current-ns "ext:cider-client" ())
 (declare-function inf-clojure "ext:inf-clojure" (cmd))
 (declare-function inf-clojure-cmd "ext:inf-clojure" (project-type))
 (declare-function inf-clojure-eval-string "ext:inf-clojure" (code))
diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index 02b20fee6..2408d6d96 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -48,14 +48,12 @@ org-src-lang-modes
 (defvar org-babel-tangle-uncomment-comments)
 
 (declare-function org-attach-dir "org-attach" (&optional create-if-not-exists-p no-fs-check))
-(declare-function org-at-item-p "org-list" ())
 (declare-function org-at-table-p "org" (&optional table-type))
 (declare-function org-babel-lob-execute-maybe "ob-lob" ())
 (declare-function org-babel-ref-goto-headline-id "ob-ref" (id))
 (declare-function org-babel-ref-headline-body "ob-ref" ())
 (declare-function org-babel-ref-parse "ob-ref" (assignment))
 (declare-function org-babel-ref-resolve "ob-ref" (ref))
-(declare-function org-babel-ref-split-args "ob-ref" (arg-string))
 (declare-function org-babel-tangle-comment-links "ob-tangle" (&optional info))
 (declare-function org-current-level "org" ())
 (declare-function org-cycle "org-cycle" (&optional arg))
@@ -63,7 +61,6 @@ org-babel-tangle-uncomment-comments
 (declare-function org-edit-src-exit "org-src"  ())
 (declare-function org-src-preserve-indentation-p "org-src" (node))
 (declare-function org-element-at-point "org-element" (&optional pom cached-only))
-(declare-function org-element-at-point-no-context "org-element" (&optional pom))
 (declare-function org-element-context "org-element" (&optional element))
 (declare-function org-element-normalize-string "org-element" (s))
 (declare-function org-element-property "org-element-ast" (property node))
@@ -82,10 +79,6 @@ org-babel-tangle-uncomment-comments
 (declare-function org-in-commented-heading-p "org" (&optional no-inheritance))
 (declare-function org-indent-block "org" ())
 (declare-function org-indent-line "org" ())
-(declare-function org-list-get-list-end "org-list" (item struct prevs))
-(declare-function org-list-prevs-alist "org-list" (struct))
-(declare-function org-list-struct "org-list" ())
-(declare-function org-list-to-generic "org-list" (LIST PARAMS))
 (declare-function org-list-to-lisp "org-list" (&optional delete))
 (declare-function org-list-to-org "org-list" (list &optional params))
 (declare-function org-macro-escape-arguments "org-macro" (&rest args))
@@ -101,12 +94,9 @@ org-babel-tangle-uncomment-comments
 (declare-function org-table-align "org-table" ())
 (declare-function org-table-convert-region "org-table" (beg0 end0 &optional separator))
 (declare-function org-table-end "org-table" (&optional table-type))
-(declare-function org-table-import "org-table" (file arg))
 (declare-function org-table-to-lisp "org-table" (&optional txt))
-(declare-function org-unescape-code-in-string "org-src" (s))
 (declare-function orgtbl-to-generic "org-table" (table params))
 (declare-function orgtbl-to-orgtbl "org-table" (table params))
-(declare-function tramp-compat-make-temp-file "tramp-compat" (filename &optional dir-flag))
 
 (defgroup org-babel nil
   "Code block evaluation and management in `org-mode' documents."
diff --git a/lisp/ob-julia.el b/lisp/ob-julia.el
index 4ea6a6af4..f44277eb6 100644
--- a/lisp/ob-julia.el
+++ b/lisp/ob-julia.el
@@ -43,8 +43,6 @@
 (declare-function inferior-ess-send-input "ext:ess-inf" ())
 (declare-function ess-make-buffer-current "ext:ess-inf" ())
 (declare-function ess-eval-buffer "ext:ess-inf" (vis))
-(declare-function ess-wait-for-process "ext:ess-inf"
-		  (&optional proc sec-prompt wait force-redisplay))
 
 (defvar ess-current-process-name) ; ess-custom.el
 (defvar ess-local-process-name)   ; ess-custom.el
diff --git a/lisp/ob-latex.el b/lisp/ob-latex.el
index 79d595eec..188ad46a0 100644
--- a/lisp/ob-latex.el
+++ b/lisp/ob-latex.el
@@ -41,9 +41,6 @@
 (declare-function org-latex-compile "ox-latex" (texfile &optional snippet))
 (declare-function org-latex-guess-inputenc "ox-latex" (header))
 (declare-function org-splice-latex-header "org" (tpl def-pkg pkg snippets-p &optional extra))
-(declare-function org-at-heading-p "org" (&optional _))
-(declare-function org-back-to-heading "org" (&optional invisible-ok))
-(declare-function org-next-visible-heading "org" (arg))
 
 (defvar org-babel-tangle-lang-exts)
 (add-to-list 'org-babel-tangle-lang-exts '("latex" . "tex"))
diff --git a/lisp/ob-lua.el b/lisp/ob-lua.el
index 9cfd5c458..159229c22 100644
--- a/lisp/ob-lua.el
+++ b/lisp/ob-lua.el
@@ -34,10 +34,6 @@
 (require 'org-macs)
 (require 'cl-lib)
 
-(declare-function lua-shell "ext:lua-mode" (&optional argprompt))
-(declare-function lua-toggle-shells "ext:lua-mode" (arg))
-(declare-function run-lua "ext:lua" (cmd &optional dedicated show))
-
 (defvar org-babel-tangle-lang-exts)
 (add-to-list 'org-babel-tangle-lang-exts '("lua" . "lua"))
 
diff --git a/lisp/ob-ocaml.el b/lisp/ob-ocaml.el
index 5818a9d28..294f2caf7 100644
--- a/lisp/ob-ocaml.el
+++ b/lisp/ob-ocaml.el
@@ -44,7 +44,6 @@
 (require 'org-macs)
 
 (declare-function tuareg-run-caml "ext:tuareg" ())
-(declare-function tuareg-run-ocaml "ext:tuareg" ())
 (declare-function tuareg-interactive-send-input "ext:tuareg" ())
 
 (defvar org-babel-tangle-lang-exts)
diff --git a/lisp/ob-scheme.el b/lisp/ob-scheme.el
index 1edd96115..084d7b75e 100644
--- a/lisp/ob-scheme.el
+++ b/lisp/ob-scheme.el
@@ -66,7 +66,6 @@ geiser-repl-window-allow-split
 (declare-function geiser-eval--retort-output "ext:geiser-eval" (ret))
 (declare-function geiser-eval--retort-result-str "ext:geiser-eval" (ret prefix))
 (declare-function geiser-eval--retort-error "ext:geiser-eval" (ret))
-(declare-function geiser-eval--retort-error-msg "ext:geiser-eval" (err))
 (declare-function geiser-eval--error-msg "ext:geiser-eval" (err))
 
 (defcustom org-babel-scheme-null-to 'hline
diff --git a/lisp/ob-sqlite.el b/lisp/ob-sqlite.el
index f2e10e72c..432cc15c7 100644
--- a/lisp/ob-sqlite.el
+++ b/lisp/ob-sqlite.el
@@ -36,7 +36,6 @@
 
 (declare-function org-table-convert-region "org-table"
 		  (beg0 end0 &optional separator))
-(declare-function orgtbl-to-csv "org-table" (table params))
 (declare-function org-table-to-lisp "org-table" (&optional txt))
 
 (defvar org-babel-default-header-args:sqlite '())
diff --git a/lisp/ob-tangle.el b/lisp/ob-tangle.el
index 24c8f876b..645b3d351 100644
--- a/lisp/ob-tangle.el
+++ b/lisp/ob-tangle.el
@@ -41,14 +41,12 @@
 (declare-function org-back-to-heading "org" (&optional invisible-ok))
 (declare-function org-before-first-heading-p "org" ())
 (declare-function org-element-lineage "org-element-ast" (datum &optional types with-self))
-(declare-function org-element-property "org-element-ast" (property node))
 (declare-function org-element-begin "org-element" (node))
 (declare-function org-element-at-point "org-element" (&optional pom cached-only))
 (declare-function org-element-type-p "org-element-ast" (node types))
 (declare-function org-heading-components "org" ())
 (declare-function org-in-commented-heading-p "org" (&optional no-inheritance))
 (declare-function org-in-archived-heading-p "org" (&optional no-inheritance))
-(declare-function outline-previous-heading "outline" ())
 (defvar org-id-link-to-org-use-id) ; Dynamically scoped
 
 (defgroup org-babel-tangle nil
diff --git a/lisp/oc-csl.el b/lisp/oc-csl.el
index 898fb40f8..73ea11649 100644
--- a/lisp/oc-csl.el
+++ b/lisp/oc-csl.el
@@ -124,7 +124,6 @@
 (require 'citeproc nil t)
 (declare-function citeproc-style-cite-note "ext:citeproc")
 (declare-function citeproc-proc-style "ext:citeproc")
-(declare-function citeproc-bt-entry-to-csl "ext:citeproc")
 (declare-function citeproc-locale-getter-from-dir "ext:citeproc")
 (declare-function citeproc-create "ext:citeproc")
 (declare-function citeproc-citation-create "ext:citeproc")
@@ -139,7 +138,6 @@
 (declare-function org-element-interpret-data "org-element" (data))
 (declare-function org-element-map "org-element" (data types fun &optional info first-match no-recursion with-affiliated))
 (declare-function org-element-property "org-element-ast" (property node))
-(declare-function org-element-put-property "org-element-ast" (node property value))
 
 (declare-function org-export-data "org-export" (data info))
 (declare-function org-export-derived-backend-p "org-export" (backend &rest backends))
diff --git a/lisp/oc-natbib.el b/lisp/oc-natbib.el
index 65d5b7509..151118c18 100644
--- a/lisp/oc-natbib.el
+++ b/lisp/oc-natbib.el
@@ -48,8 +48,6 @@
 
 (require 'oc)
 
-(declare-function org-element-property "org-element-ast" (property node))
-
 (declare-function org-export-data "org-export" (data info))
 
 
diff --git a/lisp/ol-bbdb.el b/lisp/ol-bbdb.el
index 944ee1ba2..b01c6d701 100644
--- a/lisp/ol-bbdb.el
+++ b/lisp/ol-bbdb.el
@@ -114,7 +114,6 @@
 (declare-function bbdb-records "ext:bbdb" (&optional dont-check-disk already-in-db-buffer))
 (declare-function bbdb-split "ext:bbdb" (string separators))
 (declare-function bbdb-string-trim "ext:bbdb" (string))
-(declare-function bbdb-record-get-field "ext:bbdb" (record field))
 (declare-function bbdb-search-name "ext:bbdb-com" (regexp &optional layout))
 (declare-function bbdb-search-organization "ext:bbdb-com" (regexp &optional layout))
 
diff --git a/lisp/ol-gnus.el b/lisp/ol-gnus.el
index 65d77ea88..079ddddb2 100644
--- a/lisp/ol-gnus.el
+++ b/lisp/ol-gnus.el
@@ -46,7 +46,6 @@
 
 (declare-function gnus-activate-group "gnus-start" (group &optional scan dont-check method dont-sub-check))
 (declare-function gnus-find-method-for-group "gnus" (group &optional info))
-(declare-function gnus-article-show-summary "gnus-art" ())
 (declare-function gnus-group-group-name "gnus-group")
 (declare-function gnus-group-jump-to-group "gnus-group" (group &optional prompt))
 (declare-function gnus-group-read-group "gnus-group" (&optional all no-article group select-articles))
diff --git a/lisp/ol.el b/lisp/ol.el
index b918476b5..184fc51b1 100644
--- a/lisp/ol.el
+++ b/lisp/ol.el
@@ -46,7 +46,6 @@ org-ts-regexp
 
 (declare-function calendar-cursor-to-date "calendar" (&optional error event))
 (declare-function dired-get-filename "dired" (&optional localp no-error-if-not-filep))
-(declare-function org-at-heading-p "org" (&optional _))
 (declare-function org-back-to-heading "org" (&optional invisible-ok))
 (declare-function org-before-first-heading-p "org" ())
 (declare-function org-do-occur "org" (regexp &optional cleanup))
@@ -81,7 +80,6 @@ org-ts-regexp
 (declare-function org-src-source-buffer "org-src" ())
 (declare-function org-src-source-type "org-src" ())
 (declare-function org-time-stamp-format "org" (&optional long inactive))
-(declare-function outline-next-heading "outline" ())
 (declare-function image-flush "image" (spec &optional frame))
 (declare-function org-entry-end-position "org" ())
 (declare-function org-element-contents-begin "org-element" (node))
diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 9f772b674..0486dfcb9 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -75,11 +75,9 @@
 (declare-function calendar-persian-date-string  "cal-persia" (&optional date))
 (declare-function calendar-check-holidays       "holidays" (date))
 
-(declare-function org-columns-remove-overlays "org-colview" ())
 (declare-function org-datetree-find-date-create "org-datetree"
 		  (date &optional keep-restriction))
 (declare-function org-columns-quit              "org-colview" ())
-(declare-function diary-date-display-form       "diary-lib"  (&optional type))
 (declare-function org-mobile-write-agenda-for-mobile "org-mobile" (file))
 (declare-function org-habit-insert-consistency-graphs
 		  "org-habit" (&optional line))
diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index 39b7bcc69..45348b7e9 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -68,7 +68,6 @@
 (declare-function org-element-post-affiliated "org-element" (node))
 (declare-function org-encrypt-entry "org-crypt" ())
 (declare-function org-insert-link "ol" (&optional complete-file link-location default-description))
-(declare-function org-link-make-string "ol" (link &optional description))
 (declare-function org-table-analyze "org-table" ())
 (declare-function org-table-current-dline "org-table" ())
 (declare-function org-table-fix-formulas "org-table" (key replace &optional limit delta remove))
diff --git a/lisp/org-compat.el b/lisp/org-compat.el
index de7ff6c1b..8333b38ea 100644
--- a/lisp/org-compat.el
+++ b/lisp/org-compat.el
@@ -67,7 +67,6 @@
 (declare-function org-fold-hide-block-toggle "org-fold" (&optional force no-error element))
 (declare-function org-link-display-format "ol" (s))
 (declare-function org-link-set-parameters "ol" (type &rest rest))
-(declare-function org-log-into-drawer "org" ())
 (declare-function org-make-tag-string "org" (tags))
 (declare-function org-next-visible-heading "org" (arg))
 (declare-function org-reduced-level "org" (l))
diff --git a/lisp/org-crypt.el b/lisp/org-crypt.el
index 56d4a0ab5..0c3afdc78 100644
--- a/lisp/org-crypt.el
+++ b/lisp/org-crypt.el
@@ -81,7 +81,6 @@ epg-context
 (declare-function org-make-tags-matcher "org" (match &optional only-local-tags))
 (declare-function org-previous-visible-heading "org" (arg))
 (declare-function org-scan-tags "org" (action matcher todo-only &optional start-level))
-(declare-function org-set-property "org" (property value))
 (declare-function org-cycle-set-startup-visibility "org-cycle" ())
 
 (defgroup org-crypt nil
diff --git a/lisp/org-cycle.el b/lisp/org-cycle.el
index fce1063a0..2d15bda26 100644
--- a/lisp/org-cycle.el
+++ b/lisp/org-cycle.el
@@ -71,7 +71,6 @@
 (declare-function org-list-struct "org-list" ())
 (declare-function org-cycle-item-indentation "org-list" ())
 
-(declare-function outline-previous-heading "outline" ())
 (declare-function outline-next-heading "outline" ())
 (declare-function outline-end-of-heading "outline" ())
 (declare-function outline-up-heading "outline" (arg &optional invisible-ok))
diff --git a/lisp/org-element.el b/lisp/org-element.el
index 8f5adbf7c..167aed03e 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -85,7 +85,6 @@
 (declare-function org-unescape-code-in-string "org-src" (s))
 (declare-function org-inlinetask-outline-regexp "org-inlinetask" ())
 (declare-function outline-next-heading "outline" ())
-(declare-function outline-previous-heading "outline" ())
 
 (defvar org-complex-heading-regexp)
 (defvar org-done-keywords)
diff --git a/lisp/org-fold-core.el b/lisp/org-fold-core.el
index e737e8999..e74a55686 100644
--- a/lisp/org-fold-core.el
+++ b/lisp/org-fold-core.el
@@ -282,8 +282,6 @@
 (require 'org-macs)
 (require 'org-compat)
 
-(declare-function isearch-filter-visible "isearch" (beg end))
-
 ;;; Customization
 
 (defcustom org-fold-core-style (if (version< emacs-version "29")
diff --git a/lisp/org-fold.el b/lisp/org-fold.el
index ddc666d51..5da1e8dae 100644
--- a/lisp/org-fold.el
+++ b/lisp/org-fold.el
@@ -59,13 +59,10 @@ org-archive-tag
 (defvar org-custom-properties-overlays)
 (defvar org-element-headline-re)
 
-(declare-function isearch-filter-visible "isearch" (beg end))
 (declare-function org-element-type "org-element-ast" (node &optional anonymous))
 (declare-function org-element-at-point "org-element" (&optional pom cached-only))
-(declare-function org-element-property "org-element-ast" (property node))
 (declare-function org-element-end "org-element" (node))
 (declare-function org-element-post-affiliated "org-element" (node))
-(declare-function org-element--current-element "org-element" (limit &optional granularity mode structure))
 (declare-function org-toggle-custom-properties-visibility "org" ())
 (declare-function org-item-re "org-list" ())
 (declare-function org-up-heading-safe "org" ())
@@ -81,7 +78,6 @@ org-element-headline-re
 (declare-function org-at-heading-p "org" (&optional invisible-not-ok))
 (declare-function org-cycle-hide-drawers "org-cycle" (state))
 
-(declare-function outline-show-branches "outline" ())
 (declare-function outline-hide-sublevels "outline" (levels))
 (declare-function outline-get-next-sibling "outline" ())
 (declare-function outline-invisible-p "outline" (&optional pos))
diff --git a/lisp/org-id.el b/lisp/org-id.el
index 4bdb8c999..0458230c9 100644
--- a/lisp/org-id.el
+++ b/lisp/org-id.el
@@ -80,8 +80,6 @@
 
 (declare-function message-make-fqdn "message" ())
 (declare-function org-goto-location "org-goto" (&optional _buf help))
-;; Declared inside `org-element-with-disabled-cache' macro.
-(declare-function org-element--cache-active-p "org-element.el" (&optional called-from-cache-change-func-p))
 
 ;;; Customization
 
diff --git a/lisp/org-indent.el b/lisp/org-indent.el
index dea2f69ce..e8a583a36 100644
--- a/lisp/org-indent.el
+++ b/lisp/org-indent.el
@@ -45,8 +45,6 @@
 
 (require 'cl-lib)
 
-(declare-function org-inlinetask-get-task-level "org-inlinetask" ())
-(declare-function org-inlinetask-in-task-p "org-inlinetask" ())
 (declare-function org-list-item-body-column "org-list" (item))
 (defvar org-inlinetask-show-first-star)
 
diff --git a/lisp/org-keys.el b/lisp/org-keys.el
index 98645b0be..ebda58511 100644
--- a/lisp/org-keys.el
+++ b/lisp/org-keys.el
@@ -160,7 +160,6 @@ org-outline-regexp
 (declare-function org-previous-visible-heading "org" (arg))
 (declare-function org-priority "org" (&optional action show))
 (declare-function org-promote-subtree "org" ())
-(declare-function org-redisplay-inline-images "org" ())
 (declare-function org-refile "org-refile" (&optional arg1 default-buffer rfloc msg))
 (declare-function org-refile-copy "org-refile" ())
 (declare-function org-refile-reverse "org-refile" (&optional arg default-buffer rfloc msg))
@@ -190,7 +189,6 @@ org-outline-regexp
 (declare-function org-shiftright "org" (&optional arg))
 (declare-function org-shifttab "org" (&optional arg))
 (declare-function org-shiftup "org" (&optional arg))
-(declare-function org-fold-show-all "org-fold" (&optional types))
 (declare-function org-fold-show-children "org-fold" (&optional level))
 (declare-function org-fold-show-subtree "org-fold" ())
 (declare-function org-sort "org" (&optional with-case))
diff --git a/lisp/org-macro.el b/lisp/org-macro.el
index f3acafda7..690552016 100644
--- a/lisp/org-macro.el
+++ b/lisp/org-macro.el
@@ -56,7 +56,6 @@
 (require 'org-compat)
 
 (declare-function org-collect-keywords "org" (keywords &optional unique directory))
-(declare-function org-element-at-point "org-element" (&optional pom cached-only))
 (declare-function org-element-context "org-element" (&optional element))
 (declare-function org-element-copy "org-element-ast" (datum))
 (declare-function org-element-macro-parser "org-element" ())
@@ -70,10 +69,8 @@
 (declare-function org-element-type "org-element-ast" (node &optional anonymous))
 (declare-function org-element-type-p "org-element-ast" (node types))
 (declare-function org-entry-get "org" (pom property &optional inherit literal-nil))
-(declare-function org-file-contents "org" (file &optional noerror nocache))
 (declare-function org-in-commented-heading-p "org" (&optional no-inheritance element))
 (declare-function org-link-search "ol" (s &optional avoid-pos stealth))
-(declare-function org-mode "org" ())
 (declare-function vc-backend "vc-hooks" (f))
 (declare-function vc-call "vc-hooks" (fun file &rest args) t)
 (declare-function vc-exec-after "vc-dispatcher" (code &optional success))
diff --git a/lisp/org-macs.el b/lisp/org-macs.el
index 9c37918ec..c6f2a9033 100644
--- a/lisp/org-macs.el
+++ b/lisp/org-macs.el
@@ -110,10 +110,8 @@ org-assert-version
 (declare-function org-mode "org" ())
 (declare-function org-agenda-files "org" (&optional unrestricted archives))
 (declare-function org-time-string-to-seconds "org" (s))
-(declare-function org-fold-show-context "org-fold" (&optional key))
 (declare-function org-fold-save-outline-visibility "org-fold" (use-markers &rest body))
 (declare-function org-fold-next-visibility-change "org-fold" (&optional pos limit ignore-hidden-p previous-p))
-(declare-function org-fold-core-with-forced-fontification "org-fold" (&rest body))
 (declare-function org-fold-folded-p "org-fold" (&optional pos limit ignore-hidden-p previous-p))
 (declare-function org-time-convert-to-list "org-compat" (time))
 (declare-function org-buffer-text-pixel-width "org-compat" ())
diff --git a/lisp/org-pcomplete.el b/lisp/org-pcomplete.el
index 498a01da3..ca19ff926 100644
--- a/lisp/org-pcomplete.el
+++ b/lisp/org-pcomplete.el
@@ -37,7 +37,6 @@
 (require 'org-compat)
 (require 'pcomplete)
 
-(declare-function org-at-heading-p "org" (&optional ignored))
 (declare-function org-babel-combine-header-arg-lists "ob-core" (original &rest others))
 (declare-function org-babel-get-src-block-info "ob-core" (&optional no-eval datum))
 (declare-function org-before-first-heading-p "org" ())
@@ -51,7 +50,6 @@
 (declare-function org-export-backend-options "ox" (cl-x) t)
 (declare-function org-get-buffer-tags "org" ())
 (declare-function org-get-export-keywords "org" ())
-(declare-function org-get-heading "org" (&optional no-tags no-todo no-priority no-comment))
 (declare-function org-get-tags "org" (&optional pos local))
 (declare-function org-link-heading-search-string "ol" (&optional string))
 (declare-function org-tag-alist-to-string "org" (alist &optional skip-key))
diff --git a/lisp/org-persist.el b/lisp/org-persist.el
index 5594395cb..44ceedb8b 100644
--- a/lisp/org-persist.el
+++ b/lisp/org-persist.el
@@ -264,10 +264,6 @@
 (require 'org-id)
 (require 'xdg nil t)
 
-(declare-function org-back-to-heading "org" (&optional invisible-ok))
-(declare-function org-next-visible-heading "org" (arg))
-(declare-function org-at-heading-p "org" (&optional invisible-not-ok))
-
 ;; Silence byte-compiler (used in `org-persist--write-elisp-file').
 (defvar pp-use-max-width)
 
diff --git a/lisp/org-plot.el b/lisp/org-plot.el
index eed497593..ecc8e9584 100644
--- a/lisp/org-plot.el
+++ b/lisp/org-plot.el
@@ -38,7 +38,6 @@
 (require 'org)
 (require 'org-table)
 
-(declare-function gnuplot-delchar-or-maybe-eof "ext:gnuplot" (arg))
 (declare-function gnuplot-mode "ext:gnuplot" ())
 (declare-function gnuplot-send-buffer-to-gnuplot "ext:gnuplot" ())
 
diff --git a/lisp/org-src.el b/lisp/org-src.el
index 971d6e938..d36a69f85 100644
--- a/lisp/org-src.el
+++ b/lisp/org-src.el
@@ -44,7 +44,6 @@
 (declare-function org--get-expected-indentation "org" (element contentsp))
 (declare-function org-mode "org" ())
 (declare-function org--get-expected-indentation "org" (element contentsp))
-(declare-function org-fold-region "org-fold" (from to flag &optional spec-or-alias))
 (declare-function org-element-at-point "org-element" (&optional pom cached-only))
 (declare-function org-element-class "org-element" (datum &optional parent))
 (declare-function org-element-context "org-element" (&optional element))
diff --git a/lisp/org-table.el b/lisp/org-table.el
index 9b4ce2a79..33a2fa393 100644
--- a/lisp/org-table.el
+++ b/lisp/org-table.el
@@ -44,9 +44,6 @@
 (require 'org-fold-core)
 
 (declare-function calc-eval "calc" (str &optional separator &rest args))
-(declare-function face-remap-remove-relative "face-remap" (cookie))
-(declare-function face-remap-add-relative "face-remap" (face &rest specs))
-(declare-function org-at-timestamp-p "org" (&optional extended))
 (declare-function org-delete-backward-char "org" (N))
 (declare-function org-mode "org" ())
 (declare-function org-duration-p "org-duration" (duration &optional canonical))
@@ -57,22 +54,15 @@
 (declare-function org-element-interpret-data "org-element" (data))
 (declare-function org-element-lineage "org-element-ast" (blob &optional types with-self))
 (declare-function org-element-map "org-element" (data types fun &optional info first-match no-recursion with-affiliated))
-(declare-function org-element-parse-buffer "org-element" (&optional granularity visible-only keep-deferred))
 (declare-function org-element-property "org-element-ast" (property node))
 (declare-function org-element-end "org-element" (node))
 (declare-function org-element-post-affiliated "org-element" (node))
 (declare-function org-element-type-p "org-element-ast" (node types))
-(declare-function org-element-cache-reset "org-element" (&optional all no-persistence))
 (declare-function org-entry-get "org" (pom property &optional inherit literal-nil))
 (declare-function org-export-create-backend "ox" (&rest rest) t)
 (declare-function org-export-data-with-backend "ox" (data backend info))
-(declare-function org-export-filter-apply-functions "ox" (filters value info))
-(declare-function org-export-first-sibling-p "ox" (blob info))
 (declare-function org-export-get-backend "ox" (name))
-(declare-function org-export-get-environment "ox" (&optional backend subtreep ext-plist))
-(declare-function org-export-install-filters "ox" (info))
 (declare-function org-export-table-has-special-column-p "ox" (table))
-(declare-function org-export-table-row-is-special-p "ox" (table-row info))
 (declare-function org-forward-paragraph "org" (&optional arg))
 (declare-function org-id-find "org-id" (id &optional markerp))
 (declare-function org-indent-line "org" ())
diff --git a/lisp/org-timer.el b/lisp/org-timer.el
index 702dbf9c9..e5ff2d8ff 100644
--- a/lisp/org-timer.el
+++ b/lisp/org-timer.el
@@ -41,8 +41,6 @@
 (require 'cl-lib)
 (require 'org-clock)
 
-(declare-function org-agenda-error "org-agenda" ())
-
 (defvar org-timer-start-time nil
   "Start time for the running timer.")
 
diff --git a/lisp/org.el b/lisp/org.el
index d29d4e4e1..67d8957fb 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -132,7 +132,6 @@ org-heading-regexp
 (declare-function org-agenda-todo-yesterday "org-agenda" (&optional arg))
 (declare-function org-agenda-list "org-agenda" (&optional arg start-day span with-hour))
 (declare-function org-agenda-redo "org-agenda" (&optional all))
-(declare-function org-agenda-remove-restriction-lock "org-agenda" (&optional noupdate))
 (declare-function org-archive-subtree "org-archive" (&optional find-done))
 (declare-function org-archive-subtree-default "org-archive" ())
 (declare-function org-archive-to-archive-sibling "org-archive" ())
@@ -148,7 +147,6 @@ org-heading-regexp
 (declare-function org-clock-get-last-clock-out-time "org-clock" ())
 (declare-function org-clock-goto "org-clock" (&optional select))
 (declare-function org-clock-in "org-clock" (&optional select start-time))
-(declare-function org-clock-in-last "org-clock" (&optional arg))
 (declare-function org-clock-out "org-clock" (&optional switch-to-state fail-quietly at-time))
 (declare-function org-clock-out-if-current "org-clock" ())
 (declare-function org-clock-remove-overlays "org-clock" (&optional beg end noremove))
@@ -165,7 +163,6 @@ org-heading-regexp
 (declare-function org-duration-to-minutes "org-duration" (duration &optional canonical))
 (declare-function org-element-at-point "org-element" (&optional pom cached-only))
 (declare-function org-element-at-point-no-context "org-element" (&optional pom))
-(declare-function org-element-cache-refresh "org-element" (pos))
 (declare-function org-element-cache-reset "org-element" (&optional all no-persistence))
 (declare-function org-element-cache-map "org-element" (func &rest keys))
 (declare-function org-element-contents "org-element-ast" (node))
@@ -175,7 +172,6 @@ org-heading-regexp
 (declare-function org-element-extract "org-element-ast" (node))
 (declare-function org-element-insert-before "org-element-ast" (node location))
 (declare-function org-element-interpret-data "org-element" (data))
-(declare-function org-element-keyword-parser "org-element" (limit affiliated))
 (declare-function org-element-lineage "org-element-ast" (blob &optional types with-self))
 (declare-function org-element-property-inherited "org-element-ast"
                   (property node &optional with-self accumulate literal-nil include-nil))
@@ -206,11 +202,8 @@ org-heading-regexp
 (declare-function org-feed-goto-inbox "org-feed" (feed))
 (declare-function org-feed-update-all "org-feed" ())
 (declare-function org-goto "org-goto" (&optional alternative-interface))
-(declare-function org-id-find-id-file "org-id" (id))
 (declare-function org-id-get-create "org-id" (&optional force))
-(declare-function org-inlinetask-at-task-p "org-inlinetask" ())
 (declare-function org-inlinetask-outline-regexp "org-inlinetask" ())
-(declare-function org-inlinetask-toggle-visibility "org-inlinetask" ())
 (declare-function org-latex-make-preamble "ox-latex" (info &optional template snippet?))
 (declare-function org-num-mode "org-num" (&optional arg))
 (declare-function org-plot/gnuplot "org-plot" (&optional params))
@@ -219,9 +212,7 @@ org-heading-regexp
 (declare-function org-timer "org-timer" (&optional restart no-insert))
 (declare-function org-timer-item "org-timer" (&optional arg))
 (declare-function org-timer-pause-or-continue "org-timer" (&optional stop))
-(declare-function org-timer-set-timer "org-timer" (&optional opt))
 (declare-function org-timer-start "org-timer" (&optional offset))
-(declare-function org-timer-stop "org-timer" ())
 (declare-function org-toggle-archive-tag "org-archive" (&optional find-done))
 (declare-function org-update-radio-target-regexp "ol" ())
 
@@ -3939,15 +3930,9 @@ mark-active
 (declare-function calendar-iso-to-absolute "cal-iso" (date))
 (declare-function cdlatex-compute-tables "ext:cdlatex" ())
 (declare-function cdlatex-tab "ext:cdlatex" ())
-(declare-function dired-get-filename
-		  "dired"
-		  (&optional localp no-error-if-not-filep))
 (declare-function org-agenda-change-all-lines
 		  "org-agenda"
 		  (newhead hdmarker &optional fixface just-this))
-(declare-function org-agenda-check-for-timestamp-as-reason-to-ignore-todo-item
-		  "org-agenda"
-		  (&optional end))
 (declare-function org-agenda-copy-local-variable "org-agenda" (var))
 (declare-function org-agenda-format-item
 		  "org-agenda"
@@ -3959,15 +3944,11 @@ mark-active
 		  (beg end))
 (declare-function org-agenda-set-restriction-lock "org-agenda" (&optional type))
 (declare-function org-agenda-skip "org-agenda" (&optional element))
-(declare-function org-attach-expand "org-attach" (file))
 (declare-function org-attach-reveal "org-attach" ())
 (declare-function org-attach-reveal-in-emacs "org-attach" ())
-(declare-function org-gnus-follow-link "org-gnus" (&optional group article))
 (declare-function org-indent-mode "org-indent" (&optional arg))
-(declare-function org-inlinetask-goto-beginning "org-inlinetask" ())
 (declare-function org-inlinetask-goto-end "org-inlinetask" ())
 (declare-function org-inlinetask-in-task-p "org-inlinetask" ())
-(declare-function org-inlinetask-remove-END-maybe "org-inlinetask" ())
 (declare-function parse-time-string "parse-time" (string))
 
 (defvar align-mode-rules-list)
@@ -3980,8 +3961,6 @@ texmathp-why
 
 (declare-function org-clock-save-markers-for-cut-and-paste "org-clock" (beg end))
 (declare-function org-clock-update-mode-line "org-clock" (&optional refresh))
-(declare-function org-resolve-clocks "org-clock"
-		  (&optional also-non-dangling-p prompt last-valid))
 
 (defvar org-clock-start-time)
 (defvar org-clock-marker (make-marker)
@@ -4142,7 +4121,6 @@ 'org-advertized-archive-subtree
 
 ;; Declare ID code
 
-(declare-function org-id-store-link "org-id")
 (declare-function org-id-locations-load "org-id")
 (declare-function org-id-locations-save "org-id")
 (defvar org-id-track-globally)
diff --git a/lisp/ox-ascii.el b/lisp/ox-ascii.el
index a8b23a518..a20393c87 100644
--- a/lisp/ox-ascii.el
+++ b/lisp/ox-ascii.el
@@ -37,9 +37,6 @@
 ;;; Function Declarations
 
 (declare-function aa2u "ext:ascii-art-to-unicode" ())
-(declare-function org-at-heading-p "org" (&optional _))
-(declare-function org-back-to-heading "org" (&optional invisible-ok))
-(declare-function org-next-visible-heading "org" (arg))
 
 ;;; Define Backend
 ;;
diff --git a/lisp/ox-html.el b/lisp/ox-html.el
index 2f014de91..5d6bc7d8c 100644
--- a/lisp/ox-html.el
+++ b/lisp/ox-html.el
@@ -43,12 +43,7 @@
 
 ;;; Function Declarations
 
-(declare-function org-id-find-id-file "org-id" (id))
 (declare-function htmlize-region "ext:htmlize" (beg end))
-(declare-function mm-url-decode-entities "mm-url" ())
-(declare-function org-at-heading-p "org" (&optional _))
-(declare-function org-back-to-heading "org" (&optional invisible-ok))
-(declare-function org-next-visible-heading "org" (arg))
 
 (defvar htmlize-css-name-prefix)
 (defvar htmlize-output-type)
diff --git a/lisp/ox-icalendar.el b/lisp/ox-icalendar.el
index da6339381..330b26226 100644
--- a/lisp/ox-icalendar.el
+++ b/lisp/ox-icalendar.el
@@ -39,9 +39,6 @@
 (require 'org-agenda)
 (require 'ox-ascii)
 (declare-function org-bbdb-anniv-export-ical "ol-bbdb" nil)
-(declare-function org-at-heading-p "org" (&optional _))
-(declare-function org-back-to-heading "org" (&optional invisible-ok))
-(declare-function org-next-visible-heading "org" (arg))
 
 
 
diff --git a/lisp/ox-odt.el b/lisp/ox-odt.el
index a8f6fe4ac..e78508147 100644
--- a/lisp/ox-odt.el
+++ b/lisp/ox-odt.el
@@ -35,10 +35,6 @@
 (require 'ox)
 (require 'table nil 'noerror)
 
-(declare-function org-at-heading-p "org" (&optional _))
-(declare-function org-back-to-heading "org" (&optional invisible-ok))
-(declare-function org-next-visible-heading "org" (arg))
-
 ;;; Define Backend
 
 (org-export-define-backend 'odt
diff --git a/lisp/ox-publish.el b/lisp/ox-publish.el
index de221f3e8..a8278b339 100644
--- a/lisp/ox-publish.el
+++ b/lisp/ox-publish.el
@@ -45,8 +45,6 @@
 (require 'ox)
 
 (declare-function org-at-heading-p "org" (&optional _))
-(declare-function org-back-to-heading "org" (&optional invisible-ok))
-(declare-function org-next-visible-heading "org" (arg))
 
 
 ;;; Variables
diff --git a/lisp/ox.el b/lisp/ox.el
index bc0c9a885..b3e698ba5 100644
--- a/lisp/ox.el
+++ b/lisp/ox.el
@@ -90,9 +90,7 @@
 (declare-function org-publish-all "ox-publish" (&optional force async))
 (declare-function org-publish-current-file "ox-publish" (&optional force async))
 (declare-function org-publish-current-project "ox-publish" (&optional force async))
-(declare-function org-at-heading-p "org" (&optional _))
 (declare-function org-back-to-heading "org" (&optional invisible-ok))
-(declare-function org-next-visible-heading "org" (arg))
 
 (defvar org-publish-project-alist)
 (defvar org-table-number-fraction)
-- 
2.51.2

>From 05cec2676c556ff798963685c345667d10d55531 Mon Sep 17 00:00:00 2001
From: Morgan Smith <[email protected]>
Date: Tue, 4 Nov 2025 10:50:17 -0500
Subject: [PATCH 4/8] Delete `declare-function' calls for `require'd functions

These `declare-function' calls declare functions that are in files
that are already included using `require'.  Note that some of these
`declare-function' calls have incorrect values for the FILE argument.

* lisp/ob-calc.el:
* lisp/ob-core.el:
* lisp/ob-emacs-lisp.el:
* lisp/ol-bibtex.el:
* lisp/ol-docview.el:
* lisp/ol.el:
* lisp/org-archive.el:
* lisp/org-clock.el:
* lisp/org-colview.el:
* lisp/org-element.el:
* lisp/org-list.el:
* lisp/org-num.el:
* lisp/org.el:
Delete `declare-function' calls for functions that are already
required.
---
 lisp/ob-calc.el       | 2 --
 lisp/ob-core.el       | 2 --
 lisp/ob-emacs-lisp.el | 5 -----
 lisp/ol-bibtex.el     | 5 -----
 lisp/ol-docview.el    | 1 -
 lisp/ol.el            | 1 -
 lisp/org-archive.el   | 1 -
 lisp/org-clock.el     | 1 -
 lisp/org-colview.el   | 1 -
 lisp/org-element.el   | 3 ---
 lisp/org-list.el      | 1 -
 lisp/org-num.el       | 4 ----
 lisp/org.el           | 1 -
 13 files changed, 28 deletions(-)

diff --git a/lisp/ob-calc.el b/lisp/ob-calc.el
index 6d35c1897..311a17c74 100644
--- a/lisp/ob-calc.el
+++ b/lisp/ob-calc.el
@@ -37,8 +37,6 @@
 (require 'calc-trail)
 (require 'calc-store)
 
-(declare-function calc-store-into    "calc-store" (&optional var))
-(declare-function calc-recall        "calc-store" (&optional var))
 (declare-function math-evaluate-expr "calc-ext"   (x))
 
 (defvar org-babel-default-header-args:calc nil
diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index 2408d6d96..9427de984 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -56,7 +56,6 @@ org-babel-tangle-uncomment-comments
 (declare-function org-babel-ref-resolve "ob-ref" (ref))
 (declare-function org-babel-tangle-comment-links "ob-tangle" (&optional info))
 (declare-function org-current-level "org" ())
-(declare-function org-cycle "org-cycle" (&optional arg))
 (declare-function org-edit-src-code "org-src" (&optional code edit-buffer-name))
 (declare-function org-edit-src-exit "org-src"  ())
 (declare-function org-src-preserve-indentation-p "org-src" (node))
@@ -87,7 +86,6 @@ org-babel-tangle-uncomment-comments
 (declare-function org-next-block "org" (arg &optional backward block-regexp))
 (declare-function org-open-at-point "org" (&optional in-emacs reference-buffer))
 (declare-function org-previous-block "org" (arg &optional block-regexp))
-(declare-function org-fold-show-context "org-fold" (&optional key))
 (declare-function org-src-coderef-format "org-src" (&optional element))
 (declare-function org-src-coderef-regexp "org-src" (fmt &optional label))
 (declare-function org-src-get-lang-mode "org-src" (lang))
diff --git a/lisp/ob-emacs-lisp.el b/lisp/ob-emacs-lisp.el
index 372f160af..93d49db32 100644
--- a/lisp/ob-emacs-lisp.el
+++ b/lisp/ob-emacs-lisp.el
@@ -32,11 +32,6 @@
 
 (require 'ob-core)
 
-(declare-function org-babel--get-vars "ob" (params))
-(declare-function org-babel-result-cond "ob" (result-params scalar-form &rest table-forms))
-(declare-function org-babel-reassemble-table "ob" (table colnames rownames))
-(declare-function org-babel-pick-name "ob" (names selector))
-
 (defconst org-babel-header-args:emacs-lisp '((lexical . :any))
   "Emacs-lisp specific header arguments.")
 
diff --git a/lisp/ol-bibtex.el b/lisp/ol-bibtex.el
index 37b1cd394..29a973b97 100644
--- a/lisp/ol-bibtex.el
+++ b/lisp/ol-bibtex.el
@@ -124,11 +124,6 @@ org-property-end-re
 (defvar org-special-properties)
 (defvar org-window-config-before-follow-link)
 
-(declare-function bibtex-beginning-of-entry "bibtex" ())
-(declare-function bibtex-generate-autokey "bibtex" ())
-(declare-function bibtex-parse-entry "bibtex" (&optional content))
-(declare-function bibtex-url "bibtex" (&optional pos no-browse))
-
 (declare-function org-back-to-heading "org" (&optional invisible-ok))
 (declare-function org-entry-get "org" (pom property &optional inherit literal-nil))
 (declare-function org-entry-properties "org" (&optional pom which))
diff --git a/lisp/ol-docview.el b/lisp/ol-docview.el
index be09328df..27b3b2345 100644
--- a/lisp/ol-docview.el
+++ b/lisp/ol-docview.el
@@ -48,7 +48,6 @@
 (require 'doc-view)
 (require 'ol)
 
-(declare-function doc-view-goto-page "doc-view" (page))
 (declare-function image-mode-window-get "image-mode" (prop &optional winprops))
 (declare-function org-open-file "org" (path &optional in-emacs line search))
 
diff --git a/lisp/ol.el b/lisp/ol.el
index 184fc51b1..e277c6f19 100644
--- a/lisp/ol.el
+++ b/lisp/ol.el
@@ -73,7 +73,6 @@ org-ts-regexp
 (declare-function org-cycle-overview "org-cycle" ())
 (declare-function org-restart-font-lock "org" ())
 (declare-function org-run-like-in-org-mode "org" (cmd))
-(declare-function org-fold-show-context "org-fold" (&optional key))
 (declare-function org-src-coderef-format "org-src" (&optional element))
 (declare-function org-src-coderef-regexp "org-src" (fmt &optional label))
 (declare-function org-src-edit-buffer-p "org-src" (&optional buffer))
diff --git a/lisp/org-archive.el b/lisp/org-archive.el
index 616a55828..e3d5c423b 100644
--- a/lisp/org-archive.el
+++ b/lisp/org-archive.el
@@ -36,7 +36,6 @@
 
 (declare-function org-datetree-find-date-create "org-datetree" (date &optional keep-restriction))
 (declare-function org-inlinetask-remove-END-maybe "org-inlinetask" ())
-(declare-function org-timestamp-to-now "org" (timestamp-string &optional seconds))
 
 ;; From org-element.el
 (defvar org-element--cache-avoid-synchronous-headline-re-parsing)
diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index 079f0491f..39022af64 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -48,7 +48,6 @@
 (declare-function org-link-heading-search-string "ol" (&optional string))
 (declare-function org-link-make-string "ol" (link &optional description))
 (declare-function org-table-goto-line "org-table" (n))
-(declare-function org-dynamic-block-define "org" (type func))
 (declare-function w32-notification-notify "w32fns.c" (&rest params))
 (declare-function w32-notification-close "w32fns.c" (&rest params))
 (declare-function dbus-list-activatable-names "dbus" (&optional bus))
diff --git a/lisp/org-colview.el b/lisp/org-colview.el
index da738c52d..864c26941 100644
--- a/lisp/org-colview.el
+++ b/lisp/org-colview.el
@@ -44,7 +44,6 @@
 (declare-function org-element-property "org-element-ast" (property node))
 (declare-function org-element-restriction "org-element" (element))
 (declare-function org-element-type-p "org-element-ast" (node types))
-(declare-function org-dynamic-block-define "org" (type func))
 (declare-function org-link-display-format "ol" (s))
 (declare-function org-link-open-from-string "ol" (s &optional arg))
 (declare-function face-remap-remove-relative "face-remap" (cookie))
diff --git a/lisp/org-element.el b/lisp/org-element.el
index 167aed03e..4dec6e245 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -76,12 +76,10 @@
 (require 'org-table)
 (require 'org-fold-core)
 
-(declare-function org-at-heading-p "org" (&optional _))
 (declare-function org-escape-code-in-string "org-src" (s))
 (declare-function org-src-preserve-indentation-p "org-src" (&optional node))
 (declare-function org-macro-escape-arguments "org-macro" (&rest args))
 (declare-function org-macro-extract-arguments "org-macro" (s))
-(declare-function org-reduced-level "org" (l))
 (declare-function org-unescape-code-in-string "org-src" (s))
 (declare-function org-inlinetask-outline-regexp "org-inlinetask" ())
 (declare-function outline-next-heading "outline" ())
@@ -561,7 +559,6 @@ org-element--generate-copy-script
 another buffer, effectively cloning the original buffer there.
 
 The function assumes BUFFER's major mode is `org-mode'."
-  (declare-function org-fold-core--update-buffer-folds "org-fold-core" ())
   (require 'org-fold-core)
   (with-current-buffer buffer
     (let ((str (unless drop-contents
diff --git a/lisp/org-list.el b/lisp/org-list.el
index e4daa2d5e..3f522a177 100644
--- a/lisp/org-list.el
+++ b/lisp/org-list.el
@@ -148,7 +148,6 @@ org-ts-regexp-both
 (declare-function org-mode "org" ())
 (declare-function org-narrow-to-subtree "org" (&optional element))
 (declare-function org-outline-level "org" ())
-(declare-function org-previous-line-empty-p "org" ())
 (declare-function org-reduced-level "org" (L))
 (declare-function org-set-tags "org" (tags))
 (declare-function org--deactivate-mark "org" ())
diff --git a/lisp/org-num.el b/lisp/org-num.el
index a1df00ba5..b78003b26 100644
--- a/lisp/org-num.el
+++ b/lisp/org-num.el
@@ -76,10 +76,6 @@ org-level-faces
 (defvar org-n-level-faces)
 (defvar org-odd-levels-only)
 
-(declare-function org-back-to-heading "org" (&optional invisible-ok))
-(declare-function org-entry-get "org" (pom property &optional inherit literal-nil))
-(declare-function org-reduced-level "org" (l))
-
 
 ;;; Customization
 
diff --git a/lisp/org.el b/lisp/org.el
index 67d8957fb..c199efc0f 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -214,7 +214,6 @@ org-heading-regexp
 (declare-function org-timer-pause-or-continue "org-timer" (&optional stop))
 (declare-function org-timer-start "org-timer" (&optional offset))
 (declare-function org-toggle-archive-tag "org-archive" (&optional find-done))
-(declare-function org-update-radio-target-regexp "ol" ())
 
 (defvar org-agenda-buffer-name)
 (defvar org-element-paragraph-separate)
-- 
2.51.2

>From 4c9623d5941998556bbf1f807f389f5e23eea9b5 Mon Sep 17 00:00:00 2001
From: Morgan Smith <[email protected]>
Date: Mon, 3 Nov 2025 17:32:19 -0500
Subject: [PATCH 5/8] Fix incorrect `declare-function' declarations

These where found using `check-declare-function'.

* lisp/ob-core.el:
* lisp/ob-exp.el:
* lisp/ob-ref.el:
* lisp/ob-tangle.el:
* lisp/oc-basic.el:
* lisp/oc-biblatex.el:
* lisp/oc-bibtex.el:
* lisp/oc-csl.el:
* lisp/oc-natbib.el:
* lisp/oc.el:
* lisp/ol-eshell.el:
* lisp/ol-info.el:
* lisp/ol.el:
* lisp/org-agenda.el:
* lisp/org-colview.el:
* lisp/org-compat.el:
* lisp/org-cycle.el:
* lisp/org-fold.el:
* lisp/org-footnote.el |:
* lisp/org-keys.el:
* lisp/org-list.el:
* lisp/org-macro.el:
* lisp/org-table.el:
* lisp/org.el:
Fix incorrect `declare-function' declarations.
---
 lisp/ob-core.el      |  10 ++---
 lisp/ob-exp.el       |   2 +-
 lisp/ob-ref.el       |   2 +-
 lisp/ob-tangle.el    |   4 +-
 lisp/oc-basic.el     |   6 +--
 lisp/oc-biblatex.el  |   2 +-
 lisp/oc-bibtex.el    |   2 +-
 lisp/oc-csl.el       |   8 ++--
 lisp/oc-natbib.el    |   2 +-
 lisp/oc.el           |  14 +++---
 lisp/ol-eshell.el    |   2 +-
 lisp/ol-info.el      |   2 +-
 lisp/ol.el           |   2 +-
 lisp/org-agenda.el   |   2 +-
 lisp/org-colview.el  |   2 +-
 lisp/org-compat.el   |   8 ++--
 lisp/org-cycle.el    |  10 ++---
 lisp/org-fold.el     |   4 +-
 lisp/org-footnote.el |   4 +-
 lisp/org-keys.el     | 104 +++++++++++++++++++++----------------------
 lisp/org-list.el     |   6 +--
 lisp/org-macro.el    |   4 +-
 lisp/org-table.el    |   6 +--
 lisp/org.el          |   6 +--
 24 files changed, 107 insertions(+), 107 deletions(-)

diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index 9427de984..ddd3766a3 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -48,7 +48,7 @@ org-src-lang-modes
 (defvar org-babel-tangle-uncomment-comments)
 
 (declare-function org-attach-dir "org-attach" (&optional create-if-not-exists-p no-fs-check))
-(declare-function org-at-table-p "org" (&optional table-type))
+(declare-function org-at-table-p "org-table" (&optional table-type))
 (declare-function org-babel-lob-execute-maybe "ob-lob" ())
 (declare-function org-babel-ref-goto-headline-id "ob-ref" (id))
 (declare-function org-babel-ref-headline-body "ob-ref" ())
@@ -58,10 +58,10 @@ org-babel-tangle-uncomment-comments
 (declare-function org-current-level "org" ())
 (declare-function org-edit-src-code "org-src" (&optional code edit-buffer-name))
 (declare-function org-edit-src-exit "org-src"  ())
-(declare-function org-src-preserve-indentation-p "org-src" (node))
+(declare-function org-src-preserve-indentation-p "org-src" (&optional node))
 (declare-function org-element-at-point "org-element" (&optional pom cached-only))
 (declare-function org-element-context "org-element" (&optional element))
-(declare-function org-element-normalize-string "org-element" (s))
+(declare-function org-element-normalize-string "org-element" (s &optional keep-newlines))
 (declare-function org-element-property "org-element-ast" (property node))
 (declare-function org-element-begin "org-element" (node))
 (declare-function org-element-end "org-element" (node))
@@ -75,7 +75,7 @@ org-babel-tangle-uncomment-comments
 (declare-function org-entry-get "org" (pom property &optional inherit literal-nil))
 (declare-function org-escape-code-in-region "org-src" (beg end))
 (declare-function org-forward-heading-same-level "org" (arg &optional invisible-ok))
-(declare-function org-in-commented-heading-p "org" (&optional no-inheritance))
+(declare-function org-in-commented-heading-p "org" (&optional no-inheritance element))
 (declare-function org-indent-block "org" ())
 (declare-function org-indent-line "org" ())
 (declare-function org-list-to-lisp "org-list" (&optional delete))
@@ -84,7 +84,7 @@ org-babel-tangle-uncomment-comments
 (declare-function org-mark-ring-push "org" (&optional pos buffer))
 (declare-function org-narrow-to-subtree "org" (&optional element))
 (declare-function org-next-block "org" (arg &optional backward block-regexp))
-(declare-function org-open-at-point "org" (&optional in-emacs reference-buffer))
+(declare-function org-open-at-point "org" (&optional arg))
 (declare-function org-previous-block "org" (arg &optional block-regexp))
 (declare-function org-src-coderef-format "org-src" (&optional element))
 (declare-function org-src-coderef-regexp "org-src" (fmt &optional label))
diff --git a/lisp/ob-exp.el b/lisp/ob-exp.el
index f2c85ca43..45f27b51f 100644
--- a/lisp/ob-exp.el
+++ b/lisp/ob-exp.el
@@ -45,7 +45,7 @@
                              drop-locals))
 (declare-function org-in-commented-heading-p "org" (&optional no-inheritance element))
 (declare-function org-in-archived-heading-p "org" (&optional no-inheritance element))
-(declare-function org-src-preserve-indentation-p "org-src" (node))
+(declare-function org-src-preserve-indentation-p "org-src" (&optional node))
 
 (defcustom org-export-use-babel t
   "Switch controlling code evaluation and header processing during export.
diff --git a/lisp/ob-ref.el b/lisp/ob-ref.el
index 8c59c9fe7..fc9501fc1 100644
--- a/lisp/ob-ref.el
+++ b/lisp/ob-ref.el
@@ -66,7 +66,7 @@
 (declare-function org-find-property "org" (property &optional value))
 (declare-function org-id-find-id-file "org-id" (id))
 (declare-function org-id-find-id-in-file "org-id" (id file &optional markerp))
-(declare-function org-in-commented-heading-p "org" (&optional no-inheritance))
+(declare-function org-in-commented-heading-p "org" (&optional no-inheritance element))
 (declare-function org-narrow-to-subtree "org" (&optional element))
 (declare-function org-fold-show-context "org-fold" (&optional key))
 
diff --git a/lisp/ob-tangle.el b/lisp/ob-tangle.el
index 645b3d351..5d54721a5 100644
--- a/lisp/ob-tangle.el
+++ b/lisp/ob-tangle.el
@@ -45,8 +45,8 @@
 (declare-function org-element-at-point "org-element" (&optional pom cached-only))
 (declare-function org-element-type-p "org-element-ast" (node types))
 (declare-function org-heading-components "org" ())
-(declare-function org-in-commented-heading-p "org" (&optional no-inheritance))
-(declare-function org-in-archived-heading-p "org" (&optional no-inheritance))
+(declare-function org-in-commented-heading-p "org" (&optional no-inheritance element))
+(declare-function org-in-archived-heading-p "org" (&optional no-inheritance element))
 (defvar org-id-link-to-org-use-id) ; Dynamically scoped
 
 (defgroup org-babel-tangle nil
diff --git a/lisp/oc-basic.el b/lisp/oc-basic.el
index fb6d9477a..8004d6ca6 100644
--- a/lisp/oc-basic.el
+++ b/lisp/oc-basic.el
@@ -92,9 +92,9 @@
 (declare-function org-element-type-p "org-element-ast" (node types))
 (declare-function org-element-contents "org-element-ast" (node))
 
-(declare-function org-export-data "org-export" (data info))
-(declare-function org-export-derived-backend-p "org-export" (backend &rest backends))
-(declare-function org-export-raw-string "org-export" (contents))
+(declare-function org-export-data "ox" (data info))
+(declare-function org-export-derived-backend-p "ox" (backend &rest backends))
+(declare-function org-export-raw-string "ox" (contents))
 
 
 ;;; Customization
diff --git a/lisp/oc-biblatex.el b/lisp/oc-biblatex.el
index e32213507..e14735567 100644
--- a/lisp/oc-biblatex.el
+++ b/lisp/oc-biblatex.el
@@ -72,7 +72,7 @@
 
 (declare-function org-element-property "org-element-ast" (property node))
 (declare-function org-element-parent "org-element-ast" (node))
-(declare-function org-export-data "org-export" (data info))
+(declare-function org-export-data "ox" (data info))
 
 
 ;;; Customization
diff --git a/lisp/oc-bibtex.el b/lisp/oc-bibtex.el
index e6a1e5663..1d44b10d0 100644
--- a/lisp/oc-bibtex.el
+++ b/lisp/oc-bibtex.el
@@ -43,7 +43,7 @@
 
 (declare-function org-element-property "org-element-ast" (property node))
 
-(declare-function org-export-data "org-export" (data info))
+(declare-function org-export-data "ox" (data info))
 
 
 ;;; Export capability
diff --git a/lisp/oc-csl.el b/lisp/oc-csl.el
index 73ea11649..e933b9279 100644
--- a/lisp/oc-csl.el
+++ b/lisp/oc-csl.el
@@ -136,12 +136,12 @@
 (declare-function citeproc-style-cite-superscript-p "ext:citeproc")
 
 (declare-function org-element-interpret-data "org-element" (data))
-(declare-function org-element-map "org-element" (data types fun &optional info first-match no-recursion with-affiliated))
+(declare-function org-element-map "org-element" (data types fun &optional info first-match no-recursion with-affiliated no-undefer))
 (declare-function org-element-property "org-element-ast" (property node))
 
-(declare-function org-export-data "org-export" (data info))
-(declare-function org-export-derived-backend-p "org-export" (backend &rest backends))
-(declare-function org-export-get-footnote-number "org-export" (footnote info &optional data body-first))
+(declare-function org-export-data "ox" (data info))
+(declare-function org-export-derived-backend-p "ox" (backend &rest backends))
+(declare-function org-export-get-footnote-number "ox" (footnote info &optional data body-first))
 
 
 ;;; Customization
diff --git a/lisp/oc-natbib.el b/lisp/oc-natbib.el
index 151118c18..604da4222 100644
--- a/lisp/oc-natbib.el
+++ b/lisp/oc-natbib.el
@@ -48,7 +48,7 @@
 
 (require 'oc)
 
-(declare-function org-export-data "org-export" (data info))
+(declare-function org-export-data "ox" (data info))
 
 
 ;;; Customization
diff --git a/lisp/oc.el b/lisp/oc.el
index de7ea1fe2..80d78da9b 100644
--- a/lisp/oc.el
+++ b/lisp/oc.el
@@ -80,8 +80,8 @@
 (declare-function org-element-extract "org-element-ast" (node))
 (declare-function org-element-insert-before "org-element-ast" (node location))
 (declare-function org-element-lineage "org-element-ast" (datum &optional types with-self))
-(declare-function org-element-map "org-element" (data types fun &optional info first-match no-recursion with-affiliated))
-(declare-function org-element-normalize-string "org-element" (s))
+(declare-function org-element-map "org-element" (data types fun &optional info first-match no-recursion with-affiliated no-undefer))
+(declare-function org-element-normalize-string "org-element" (s &optional keep-newlines))
 (declare-function org-element-parse-buffer "org-element" (&optional granularity visible-only keep-deferred))
 (declare-function org-element-parse-secondary-string "org-element" (string restriction &optional parent))
 (declare-function org-element-context "org-element" (&optional element))
@@ -95,14 +95,14 @@
 (declare-function org-element-parent "org-element-ast" (node))
 (declare-function org-element-put-property "org-element-ast" (node property value))
 (declare-function org-element-restriction "org-element" (element))
-(declare-function org-element-set "org-element-ast" (old new))
+(declare-function org-element-set "org-element-ast" (old new &optional keep-props))
 (declare-function org-element-type "org-element-ast" (node &optional anonymous))
 (declare-function org-element-type-p "org-element-ast" (node types))
 
-(declare-function org-export-derived-backend-p "org-export" (backend &rest backends))
-(declare-function org-export-get-next-element "org-export" (blob info &optional n))
-(declare-function org-export-get-previous-element "org-export" (blob info &optional n))
-(declare-function org-export-raw-string "org-export" (s))
+(declare-function org-export-derived-backend-p "ox" (backend &rest backends))
+(declare-function org-export-get-next-element "ox" (blob info &optional n))
+(declare-function org-export-get-previous-element "ox" (blob info &optional n))
+(declare-function org-export-raw-string "ox" (s))
 
 (defvar org-complex-heading-regexp)
 (defvar org-element-all-objects)
diff --git a/lisp/ol-eshell.el b/lisp/ol-eshell.el
index 6e54d0e3c..5f7d73474 100644
--- a/lisp/ol-eshell.el
+++ b/lisp/ol-eshell.el
@@ -30,7 +30,7 @@
 (require 'esh-mode)
 (require 'ol)
 
-(declare-function eshell/pwd "em-dirs.el" (&rest args))
+(declare-function eshell/pwd "em-dirs" ())
 
 (org-link-set-parameters "eshell"
 			 :follow #'org-eshell-open
diff --git a/lisp/ol-info.el b/lisp/ol-info.el
index a835bd403..dcbce6fe1 100644
--- a/lisp/ol-info.el
+++ b/lisp/ol-info.el
@@ -38,7 +38,7 @@
 ;; Declare external functions and variables
 
 (declare-function Info-find-node "info"
-                  (filename nodename &optional no-going-back strict-case))
+                  (filename nodename &optional no-going-back strict-case noerror))
 (defvar Info-current-file)
 (defvar Info-current-node)
 
diff --git a/lisp/ol.el b/lisp/ol.el
index e277c6f19..d3b15bd95 100644
--- a/lisp/ol.el
+++ b/lisp/ol.el
@@ -78,7 +78,7 @@ org-ts-regexp
 (declare-function org-src-edit-buffer-p "org-src" (&optional buffer))
 (declare-function org-src-source-buffer "org-src" ())
 (declare-function org-src-source-type "org-src" ())
-(declare-function org-time-stamp-format "org" (&optional long inactive))
+(declare-function org-time-stamp-format "org" (&optional long inactive custom))
 (declare-function image-flush "image" (spec &optional frame))
 (declare-function org-entry-end-position "org" ())
 (declare-function org-element-contents-begin "org-element" (node))
diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 0486dfcb9..0444d0d81 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -3647,7 +3647,7 @@ org-agenda-write
 		(message "Org file written to %s" file)))
 	     ((member extension '("html" "htm"))
               (org-require-package 'htmlize)
-	      (declare-function htmlize-buffer "htmlize" (&optional buffer))
+	      (declare-function htmlize-buffer "ext:htmlize" (&optional buffer))
 	      (set-buffer (htmlize-buffer (current-buffer)))
 	      (when org-agenda-export-html-style
 		;; replace <style> section with org-agenda-export-html-style
diff --git a/lisp/org-colview.el b/lisp/org-colview.el
index 864c26941..f417b4812 100644
--- a/lisp/org-colview.el
+++ b/lisp/org-colview.el
@@ -39,7 +39,7 @@
 (declare-function org-clock-sum-today "org-clock" (&optional headline-filter))
 (declare-function org-element-extract "org-element-ast" (node))
 (declare-function org-element-interpret-data "org-element" (data))
-(declare-function org-element-map "org-element" (data types fun &optional info first-match no-recursion with-affiliated))
+(declare-function org-element-map "org-element" (data types fun &optional info first-match no-recursion with-affiliated no-undefer))
 (declare-function org-element-parse-secondary-string "org-element" (string restriction &optional parent))
 (declare-function org-element-property "org-element-ast" (property node))
 (declare-function org-element-restriction "org-element" (element))
diff --git a/lisp/org-compat.el b/lisp/org-compat.el
index 8333b38ea..67686047a 100644
--- a/lisp/org-compat.el
+++ b/lisp/org-compat.el
@@ -61,7 +61,7 @@
 (declare-function org-element-contents-begin "org-element" (node))
 (declare-function org-element-contents-end "org-element" (node))
 (declare-function org-element-post-affiliated "org-element" (node))
-(declare-function org-end-of-subtree "org" (&optional invisible-ok to-heading))
+(declare-function org-end-of-subtree "org" (&optional invisible-ok to-heading element))
 (declare-function org-get-heading "org" (&optional no-tags no-todo no-priority no-comment))
 (declare-function org-get-tags "org" (&optional pos local))
 (declare-function org-fold-hide-block-toggle "org-fold" (&optional force no-error element))
@@ -1034,9 +1034,9 @@ 'org-add-angle-brackets
 (declare-function org-link-preview--remove-overlay "ol"
                   (ov after beg end &optional len))
 (declare-function org-attach-expand "org-attach" (file))
-(declare-function org-display-inline-image--width "org" (link))
-(declare-function org-image--align "org" (link))
-(declare-function org--create-inline-image "org" (file width))
+(declare-function org-display-inline-image--width "ol" (link))
+(declare-function org-image--align "ol" (link))
+(declare-function org--create-inline-image "ol" (file width))
 
 (define-obsolete-function-alias 'org-display-inline-remove-overlay
   'org-link-preview--remove-overlay "9.8")
diff --git a/lisp/org-cycle.el b/lisp/org-cycle.el
index 2d15bda26..fe958d5c6 100644
--- a/lisp/org-cycle.el
+++ b/lisp/org-cycle.el
@@ -41,26 +41,26 @@
 (declare-function org-element-lineage "org-element-ast" (datum &optional types with-self))
 (declare-function org-element-at-point "org-element" (&optional pom cached-only))
 (declare-function org-link-preview-region "ol" (&optional include-linked refresh beg end))
-(declare-function org-get-tags "org" (&optional pos local fontify))
+(declare-function org-get-tags "org" (&optional epom local))
 (declare-function org-subtree-end-visible-p "org" ())
 (declare-function org-narrow-to-subtree "org" (&optional element))
 (declare-function org-next-visible-heading "org" (arg))
 (declare-function org-at-property-p "org" ())
 (declare-function org-re-property "org" (property &optional literal allow-null value))
 (declare-function org-link-preview-clear "ol" (&optional beg end))
-(declare-function org-item-beginning-re "org" ())
+(declare-function org-item-beginning-re "org-list" ())
 (declare-function org-at-heading-p "org" (&optional invisible-not-ok))
-(declare-function org-at-item-p "org" ())
+(declare-function org-at-item-p "org-list" ())
 (declare-function org-before-first-heading-p "org" ())
 (declare-function org-back-to-heading "org" (&optional invisible-ok))
-(declare-function org-end-of-subtree "org" (&optional invisible-ok to-heading))
+(declare-function org-end-of-subtree "org" (&optional invisible-ok to-heading element))
 (declare-function org-entry-end-position "org" ())
 (declare-function org-try-cdlatex-tab "org" ())
 (declare-function org-cycle-level "org" ())
 (declare-function org-table-next-field "org-table" ())
 (declare-function org-table-justify-field-maybe "org-table" (&optional new))
 (declare-function org-inlinetask-at-task-p "org-inlinetask" ())
-(declare-function org-inlinetask-toggle-visibility "org-inlinetask" ())
+(declare-function org-inlinetask-toggle-visibility "org-inlinetask" (&optional state))
 (declare-function org-list-get-all-items "org-list" (item struct prevs))
 (declare-function org-list-get-bottom-point "org-list" (struct))
 (declare-function org-list-prevs-alist "org-list" (struct))
diff --git a/lisp/org-fold.el b/lisp/org-fold.el
index 5da1e8dae..2f9a330f8 100644
--- a/lisp/org-fold.el
+++ b/lisp/org-fold.el
@@ -66,13 +66,13 @@ org-element-headline-re
 (declare-function org-toggle-custom-properties-visibility "org" ())
 (declare-function org-item-re "org-list" ())
 (declare-function org-up-heading-safe "org" ())
-(declare-function org-get-tags "org" (&optional pos local fontify))
+(declare-function org-get-tags "org" (&optional epom local))
 (declare-function org-get-valid-level "org" (level &optional change))
 (declare-function org-before-first-heading-p "org" ())
 (declare-function org-goto-sibling "org" (&optional previous))
 (declare-function org-block-map "org" (function &optional start end))
 (declare-function org-map-region "org" (fun beg end))
-(declare-function org-end-of-subtree "org" (&optional invisible-ok to-heading))
+(declare-function org-end-of-subtree "org" (&optional invisible-ok to-heading element))
 (declare-function org-back-to-heading-or-point-min "org" (&optional invisible-ok))
 (declare-function org-back-to-heading "org" (&optional invisible-ok))
 (declare-function org-at-heading-p "org" (&optional invisible-not-ok))
diff --git a/lisp/org-footnote.el b/lisp/org-footnote.el
index 7da76c061..22a301f80 100644
--- a/lisp/org-footnote.el
+++ b/lisp/org-footnote.el
@@ -49,11 +49,11 @@
 (declare-function org-element-property "org-element-ast" (property node))
 (declare-function org-element-type "org-element-ast" (node &optional anonymous))
 (declare-function org-element-type-p "org-element-ast" (node types))
-(declare-function org-end-of-subtree "org"  (&optional invisible-ok to-heading))
+(declare-function org-end-of-subtree "org"  (&optional invisible-ok to-heading element))
 (declare-function org-fill-paragraph "org" (&optional justify region))
 (declare-function org-in-block-p "org" (names))
 (declare-function org-in-verbatim-emphasis "org" ())
-(declare-function org-inside-LaTeX-fragment-p "org" ())
+(declare-function org-inside-LaTeX-fragment-p "org" (&optional element))
 (declare-function org-inside-latex-macro-p "org" ())
 (declare-function org-mark-ring-push "org" (&optional pos buffer))
 (declare-function org-fold-show-context "org-fold" (&optional key))
diff --git a/lisp/org-keys.el b/lisp/org-keys.el
index ebda58511..5413ffa53 100644
--- a/lisp/org-keys.el
+++ b/lisp/org-keys.el
@@ -38,29 +38,29 @@ org-outline-regexp
 (require 'oc)
 
 (declare-function org-add-note "org" ())
-(declare-function org-agenda "org" (&optional arg org-keys restriction))
+(declare-function org-agenda "org-agenda" (&optional arg org-keys restriction))
 (declare-function org-agenda-file-to-front "org" (&optional to-end))
-(declare-function org-agenda-remove-restriction-lock "org" (&optional noupdate))
-(declare-function org-agenda-set-restriction-lock "org" (&optional type))
-(declare-function org-archive-subtree "org" (&optional find-done))
-(declare-function org-archive-subtree-default "org" ())
-(declare-function org-archive-subtree-default-with-confirmation "org" ())
-(declare-function org-archive-to-archive-sibling "org" ())
+(declare-function org-agenda-remove-restriction-lock "org-agenda" (&optional noupdate))
+(declare-function org-agenda-set-restriction-lock "org-agenda" (&optional type))
+(declare-function org-archive-subtree "org-archive" (&optional find-done))
+(declare-function org-archive-subtree-default "org-archive" ())
+(declare-function org-archive-subtree-default-with-confirmation "org-archive" ())
+(declare-function org-archive-to-archive-sibling "org-archive" ())
 (declare-function org-at-heading-p "org" (&optional ignored))
-(declare-function org-attach "org" ())
+(declare-function org-attach "org-attach" ())
 (declare-function org-backward-element "org" ())
 (declare-function org-backward-heading-same-level "org" (arg &optional invisible-ok))
-(declare-function org-backward-paragraph "org" ())
+(declare-function org-backward-paragraph "org" (&optional arg))
 (declare-function org-backward-sentence "org" (&optional arg))
 (declare-function org-beginning-of-line "org" (&optional n))
-(declare-function org-clock-cancel "org" ())
-(declare-function org-clock-display "org" (&optional arg))
-(declare-function org-clock-goto "org" (&optional select))
-(declare-function org-clock-in "org" (&optional select start-time))
-(declare-function org-clock-in-last "org" (&optional arg))
-(declare-function org-clock-out "org" (&optional switch-to-state fail-quietly at-time))
+(declare-function org-clock-cancel "org-clock" ())
+(declare-function org-clock-display "org-clock" (&optional arg))
+(declare-function org-clock-goto "org-clock" (&optional select))
+(declare-function org-clock-in "org-clock" (&optional select start-time))
+(declare-function org-clock-in-last "org-clock" (&optional arg))
+(declare-function org-clock-out "org-clock" (&optional switch-to-state fail-quietly at-time))
 (declare-function org-clone-subtree-with-time-shift "org" (n &optional shift))
-(declare-function org-columns "org" (&optional global columns-fmt-string))
+(declare-function org-columns "org-colview" (&optional global columns-fmt-string))
 (declare-function org-comment-dwim "org" (arg))
 (declare-function org-copy-special "org" ())
 (declare-function org-copy-visible "org" (beg end))
@@ -72,15 +72,15 @@ org-outline-regexp
 (declare-function org-cut-special "org" ())
 (declare-function org-cut-subtree "org" (&optional n))
 (declare-function org-cycle "org-cycle" (&optional arg))
-(declare-function org-cycle-agenda-files "org-cycle" ())
+(declare-function org-cycle-agenda-files "org" ())
 (declare-function org-date-from-calendar "org" ())
-(declare-function org-dynamic-block-insert-dblock "org" (&optional arg))
+(declare-function org-dynamic-block-insert-dblock "org" (type &optional interactive-p))
 (declare-function org-dblock-update "org" (&optional arg))
 (declare-function org-deadline "org" (arg1 &optional time))
 (declare-function org-decrease-number-at-point "org" (&optional inc))
 (declare-function org-delete-backward-char "org" (n))
 (declare-function org-delete-char "org" (n))
-(declare-function org-delete-indentation "org" (&optional arg))
+(declare-function org-delete-indentation "org" (&optional arg beg end))
 (declare-function org-demote-subtree "org" ())
 (declare-function org-display-outline-path "org" (&optional file current separator just-return-string))
 (declare-function org-down-element "org" ())
@@ -106,34 +106,34 @@ org-outline-regexp
 (declare-function org-calendar-scroll-three-months-left "org" ())
 (declare-function org-calendar-scroll-three-months-right "org" ())
 (declare-function org-evaluate-time-range "org" (&optional to-buffer))
-(declare-function org-export-dispatch "org" (&optional arg))
-(declare-function org-feed-goto-inbox "org" (feed))
-(declare-function org-feed-update-all "org" ())
+(declare-function org-export-dispatch "ox" (&optional arg))
+(declare-function org-feed-goto-inbox "org-feed" (feed))
+(declare-function org-feed-update-all "org-feed" ())
 (declare-function org-fill-paragraph "org" (&optional justify region))
 (declare-function org-find-file-at-mouse "org" (ev))
-(declare-function org-footnote-action "org" (&optional special))
+(declare-function org-footnote-action "org-footnote" (&optional special))
 (declare-function org-cycle-force-archived "org-cycle" ())
 (declare-function org-force-self-insert "org" (n))
 (declare-function org-forward-element "org" ())
 (declare-function org-forward-heading-same-level "org" (arg &optional invisible-ok))
-(declare-function org-forward-paragraph "org" ())
+(declare-function org-forward-paragraph "org" (&optional arg))
 (declare-function org-forward-sentence "org" (&optional arg))
-(declare-function org-goto "org" (&optional alternative-interface))
+(declare-function org-goto "org-goto" (&optional alternative-interface))
 (declare-function org-goto-calendar "org" (&optional arg))
 (declare-function org-inc-effort "org" ())
 (declare-function org-increase-number-at-point "org" (&optional inc))
 (declare-function org-info-find-node "org" (&optional nodename))
-(declare-function org-insert-all-links "org" (arg &optional pre post))
+(declare-function org-insert-all-links "ol" (arg &optional pre post))
 (declare-function org-insert-drawer "org" (&optional arg drawer))
 (declare-function org-insert-heading-respect-content "org" (&optional invisible-ok))
-(declare-function org-insert-last-stored-link "org" (arg))
-(declare-function org-insert-link "org" (&optional complete-file link-location default-description))
+(declare-function org-insert-last-stored-link "ol" (arg))
+(declare-function org-insert-link "ol" (&optional complete-file link-location default-description))
 (declare-function org-insert-structure-template "org" (type))
 (declare-function org-insert-todo-heading "org" (arg &optional force-heading))
 (declare-function org-insert-todo-heading-respect-content "org" (&optional force-state))
 (declare-function org-kill-line "org" (&optional arg))
 (declare-function org-kill-note-or-show-branches "org" ())
-(declare-function org-list-make-subtree "org" ())
+(declare-function org-list-make-subtree "org-list" ())
 (declare-function org-mark-element "org" ())
 (declare-function org-mark-ring-goto "org" (&optional n))
 (declare-function org-mark-ring-push "org" (&optional pos buffer))
@@ -148,15 +148,15 @@ org-outline-regexp
 (declare-function org-narrow-to-element "org" ())
 (declare-function org-narrow-to-subtree "org" (&optional element))
 (declare-function org-next-block "org" (arg &optional backward block-regexp))
-(declare-function org-next-link "org" (&optional search-backward))
+(declare-function org-next-link "ol" (&optional search-backward))
 (declare-function org-next-visible-heading "org" (arg))
 (declare-function org-open-at-mouse "org" (ev))
-(declare-function org-open-at-point "org" (&optional arg reference-buffer))
+(declare-function org-open-at-point "org" (&optional arg))
 (declare-function org-open-line "org" (n))
 (declare-function org-paste-special "org" (arg))
 (declare-function org-plot/gnuplot "org-plot" (&optional params))
 (declare-function org-previous-block "org" (arg &optional block-regexp))
-(declare-function org-previous-link "org" ())
+(declare-function org-previous-link "ol" ())
 (declare-function org-previous-visible-heading "org" (arg))
 (declare-function org-priority "org" (&optional action show))
 (declare-function org-promote-subtree "org" ())
@@ -166,8 +166,8 @@ org-outline-regexp
 (declare-function org-reftex-citation "org" ())
 (declare-function org-reload "org" (&optional arg1))
 (declare-function org-remove-file "org" (&optional file))
-(declare-function org-resolve-clocks "org" (&optional only-dangling-p prompt-fn last-valid))
-(declare-function org-return "org" (&optional indent))
+(declare-function org-resolve-clocks "org-clock" (&optional only-dangling-p prompt-fn last-valid))
+(declare-function org-return "org" (&optional indent arg interactive))
 (declare-function org-return-and-maybe-indent "org" ())
 (declare-function org-fold-reveal "org-fold" (&optional siblings))
 (declare-function org-schedule "org" (arg &optional time))
@@ -193,28 +193,28 @@ org-outline-regexp
 (declare-function org-fold-show-subtree "org-fold" ())
 (declare-function org-sort "org" (&optional with-case))
 (declare-function org-sparse-tree "org" (&optional arg type))
-(declare-function org-table-copy-down "org" (n))
-(declare-function org-table-create-or-convert-from-region "org" (arg))
+(declare-function org-table-copy-down "org-table" (n))
+(declare-function org-table-create-or-convert-from-region "org-table" (arg))
 (declare-function org-table-create-with-table\.el "org-table" ())
-(declare-function org-table-edit-field "org" (arg))
-(declare-function org-table-eval-formula "org" (&optional arg equation suppress-align suppress-const suppress-store suppress-analysis))
-(declare-function org-table-field-info "org" (arg))
-(declare-function org-table-rotate-recalc-marks "org" (&optional newchar))
-(declare-function org-table-sum "org" (&optional beg end nlast))
-(declare-function org-table-toggle-coordinate-overlays "org" ())
-(declare-function org-table-toggle-formula-debugger "org" ())
+(declare-function org-table-edit-field "org-table" (arg))
+(declare-function org-table-eval-formula "org-table" (&optional arg equation suppress-align suppress-const suppress-store suppress-analysis))
+(declare-function org-table-field-info "org-table" (arg))
+(declare-function org-table-rotate-recalc-marks "org-table" (&optional newchar))
+(declare-function org-table-sum "org-table" (&optional beg end nlast))
+(declare-function org-table-toggle-coordinate-overlays "org-table" ())
+(declare-function org-table-toggle-formula-debugger "org-table" ())
 (declare-function org-timestamp "org" (arg &optional inactive))
 (declare-function org-timestamp-inactive "org" (&optional arg))
-(declare-function org-timer "org" (&optional restart no-insert))
-(declare-function org-timer-item "org" (&optional arg))
-(declare-function org-timer-pause-or-continue "org" (&optional stop))
-(declare-function org-timer-set-timer "org" (&optional opt))
-(declare-function org-timer-start "org" (&optional offset))
-(declare-function org-timer-stop "org" ())
+(declare-function org-timer "org-timer" (&optional restart no-insert))
+(declare-function org-timer-item "org-timer" (&optional arg))
+(declare-function org-timer-pause-or-continue "org-timer" (&optional stop))
+(declare-function org-timer-set-timer "org-timer" (&optional opt))
+(declare-function org-timer-start "org-timer" (&optional offset))
+(declare-function org-timer-stop "org-timer" ())
 (declare-function org-todo "org" (&optional arg1))
-(declare-function org-toggle-archive-tag "org" (&optional find-done))
-(declare-function org-toggle-checkbox "org" (&optional toggle-presence))
-(declare-function org-toggle-radio-button "org" (&optional arg))
+(declare-function org-toggle-archive-tag "org-archive" (&optional find-done))
+(declare-function org-toggle-checkbox "org-list" (&optional toggle-presence))
+(declare-function org-toggle-radio-button "org-list" (&optional arg))
 (declare-function org-toggle-comment "org" ())
 (declare-function org-toggle-fixed-width "org" ())
 (declare-function org-link-preview "ol" (&optional arg beg end))
diff --git a/lisp/org-list.el b/lisp/org-list.el
index 3f522a177..390aaba18 100644
--- a/lisp/org-list.el
+++ b/lisp/org-list.el
@@ -114,8 +114,8 @@ org-ts-regexp-both
 (declare-function org-element-interpret-data "org-element" (data))
 (declare-function org-element-lineage "org-element-ast" (blob &optional types with-self))
 (declare-function org-element-macro-interpreter "org-element" (macro ##))
-(declare-function org-element-map "org-element" (data types fun &optional info first-match no-recursion with-affiliated))
-(declare-function org-element-normalize-string "org-element" (s))
+(declare-function org-element-map "org-element" (data types fun &optional info first-match no-recursion with-affiliated no-undefer))
+(declare-function org-element-normalize-string "org-element" (s &optional keep-newlines))
 (declare-function org-element-parse-buffer "org-element" (&optional granularity visible-only keep-deferred))
 (declare-function org-element-property "org-element-ast" (property node))
 (declare-function org-element-begin "org-element" (node))
@@ -126,7 +126,7 @@ org-ts-regexp-both
 (declare-function org-element-post-blank "org-element" (node))
 (declare-function org-element-parent "org-element-ast" (node))
 (declare-function org-element-put-property "org-element-ast" (node property value))
-(declare-function org-element-set "org-element-ast" (old new))
+(declare-function org-element-set "org-element-ast" (old new &optional keep-props))
 (declare-function org-element-type-p "org-element-ast" (node types))
 (declare-function org-element-update-syntax "org-element" ())
 (declare-function org-end-of-meta-data "org" (&optional full))
diff --git a/lisp/org-macro.el b/lisp/org-macro.el
index 690552016..b4c7c954c 100644
--- a/lisp/org-macro.el
+++ b/lisp/org-macro.el
@@ -57,7 +57,7 @@
 
 (declare-function org-collect-keywords "org" (keywords &optional unique directory))
 (declare-function org-element-context "org-element" (&optional element))
-(declare-function org-element-copy "org-element-ast" (datum))
+(declare-function org-element-copy "org-element-ast" (datum &optional keep-contents))
 (declare-function org-element-macro-parser "org-element" ())
 (declare-function org-element-keyword-parser "org-element" (limit affiliated))
 (declare-function org-element-put-property "org-element-ast" (node property value))
@@ -70,7 +70,7 @@
 (declare-function org-element-type-p "org-element-ast" (node types))
 (declare-function org-entry-get "org" (pom property &optional inherit literal-nil))
 (declare-function org-in-commented-heading-p "org" (&optional no-inheritance element))
-(declare-function org-link-search "ol" (s &optional avoid-pos stealth))
+(declare-function org-link-search "ol" (s &optional avoid-pos stealth new-heading-container))
 (declare-function vc-backend "vc-hooks" (f))
 (declare-function vc-call "vc-hooks" (fun file &rest args) t)
 (declare-function vc-exec-after "vc-dispatcher" (code &optional success))
diff --git a/lisp/org-table.el b/lisp/org-table.el
index 33a2fa393..551e18e9f 100644
--- a/lisp/org-table.el
+++ b/lisp/org-table.el
@@ -46,14 +46,14 @@
 (declare-function calc-eval "calc" (str &optional separator &rest args))
 (declare-function org-delete-backward-char "org" (N))
 (declare-function org-mode "org" ())
-(declare-function org-duration-p "org-duration" (duration &optional canonical))
+(declare-function org-duration-p "org-duration" (duration))
 (declare-function org-duration-to-minutes "org-duration" (duration &optional canonical))
 (declare-function org-element-at-point "org-element" (&optional pom cached-only))
 (declare-function org-element-contents "org-element-ast" (node))
 (declare-function org-element-extract "org-element-ast" (node))
 (declare-function org-element-interpret-data "org-element" (data))
 (declare-function org-element-lineage "org-element-ast" (blob &optional types with-self))
-(declare-function org-element-map "org-element" (data types fun &optional info first-match no-recursion with-affiliated))
+(declare-function org-element-map "org-element" (data types fun &optional info first-match no-recursion with-affiliated no-undefer))
 (declare-function org-element-property "org-element-ast" (property node))
 (declare-function org-element-end "org-element" (node))
 (declare-function org-element-post-affiliated "org-element" (node))
@@ -69,7 +69,7 @@
 (declare-function org-load-modules-maybe "org" (&optional force))
 (declare-function org-restart-font-lock "org" ())
 (declare-function org-sort-remove-invisible "org" (s))
-(declare-function org-time-stamp-format "org" (&optional long inactive))
+(declare-function org-time-stamp-format "org" (&optional long inactive custom))
 (declare-function org-time-string-to-absolute "org" (s &optional daynr prefer buffer pos))
 (declare-function org-time-string-to-time "org" (s))
 (declare-function org-timestamp-up-day "org" (&optional arg))
diff --git a/lisp/org.el b/lisp/org.el
index c199efc0f..133d2185d 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -167,7 +167,7 @@ org-heading-regexp
 (declare-function org-element-cache-map "org-element" (func &rest keys))
 (declare-function org-element-contents "org-element-ast" (node))
 (declare-function org-element-context "org-element" (&optional element))
-(declare-function org-element-copy "org-element-ast" (datum))
+(declare-function org-element-copy "org-element-ast" (datum &optional keep-contents))
 (declare-function org-element-create "org-element-ast" (type &optional props &rest children))
 (declare-function org-element-extract "org-element-ast" (node))
 (declare-function org-element-insert-before "org-element-ast" (node location))
@@ -178,7 +178,7 @@ org-heading-regexp
 (declare-function org-element-lineage-map "org-element-ast"
                   (datum fun &optional types with-self first-match))
 (declare-function org-element-link-parser "org-element" ())
-(declare-function org-element-map "org-element" (data types fun &optional info first-match no-recursion with-affiliated))
+(declare-function org-element-map "org-element" (data types fun &optional info first-match no-recursion with-affiliated no-undefer))
 (declare-function org-element-nested-p "org-element" (elem-a elem-b))
 (declare-function org-element-parse-buffer "org-element" (&optional granularity visible-only keep-deferred))
 (declare-function org-element-parse-secondary-string "org-element" (string restriction &optional parent))
@@ -3948,7 +3948,7 @@ mark-active
 (declare-function org-indent-mode "org-indent" (&optional arg))
 (declare-function org-inlinetask-goto-end "org-inlinetask" ())
 (declare-function org-inlinetask-in-task-p "org-inlinetask" ())
-(declare-function parse-time-string "parse-time" (string))
+(declare-function parse-time-string "parse-time" (string &optional form))
 
 (defvar align-mode-rules-list)
 (defvar calc-embedded-close-formula)
-- 
2.51.2

>From da26e814e298359d929987bb2821de11acaf0311 Mon Sep 17 00:00:00 2001
From: Morgan Smith <[email protected]>
Date: Tue, 4 Nov 2025 11:01:02 -0500
Subject: [PATCH 6/8] Delete duplicated requires

While not harmful, we only need to include a file once.

* lisp/org-element.el (org-element--generate-copy-script):
* lisp/org-lint.el (org-lint-unknown-options-item)
(org-lint-export-option-keywords):
* lisp/org.el (org-ctrl-c-ctrl-c):
* lisp/ox-html.el (org-html-table--table.el-table):
Delete duplicated require statements.
---
 lisp/org-element.el | 1 -
 lisp/org-lint.el    | 2 --
 lisp/org.el         | 3 +--
 lisp/ox-html.el     | 1 -
 4 files changed, 1 insertion(+), 6 deletions(-)

diff --git a/lisp/org-element.el b/lisp/org-element.el
index 4dec6e245..22fdec4d2 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -559,7 +559,6 @@ org-element--generate-copy-script
 another buffer, effectively cloning the original buffer there.
 
 The function assumes BUFFER's major mode is `org-mode'."
-  (require 'org-fold-core)
   (with-current-buffer buffer
     (let ((str (unless drop-contents
                  (org-with-wide-buffer
diff --git a/lisp/org-lint.el b/lisp/org-lint.el
index 2c4d2a91e..6f87baf45 100644
--- a/lisp/org-lint.el
+++ b/lisp/org-lint.el
@@ -850,7 +850,6 @@ org-lint-unknown-options-item
 
 (defun org-lint-export-option-keywords (ast)
   "Check for options keyword properties without EXPORT in AST."
-  (require 'ox)
   (let (options reports common-options options-alist)
     (dolist (opt org-export-options-alist)
       (when (stringp (nth 1 opt))
@@ -886,7 +885,6 @@ org-lint-export-option-keywords
 
 (defun org-lint-invalid-macro-argument-and-template (ast)
   "Check for invalid macro arguments in AST."
-  (require 'ox)
   (let* ((reports nil)
          (extract-placeholders
 	  (lambda (template)
diff --git a/lisp/org.el b/lisp/org.el
index 133d2185d..a770fc585 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -18131,8 +18131,7 @@ org-ctrl-c-ctrl-c
                     (= (point) (org-element-end context))))
            (save-excursion
              (if (org-at-TBLFM-p)
-                 (progn (require 'org-table)
-                        (org-table-calc-current-TBLFM))
+                 (org-table-calc-current-TBLFM)
                (goto-char (org-element-contents-begin context))
                (org-call-with-arg 'org-table-recalculate (or arg t))
                (orgtbl-send-table 'maybe))))
diff --git a/lisp/ox-html.el b/lisp/ox-html.el
index 5d6bc7d8c..fa0c021af 100644
--- a/lisp/ox-html.el
+++ b/lisp/ox-html.el
@@ -3882,7 +3882,6 @@ org-html-table--table.el-table
   "Format table.el TABLE into HTML.
 INFO is a plist used as a communication channel."
   (when (eq (org-element-property :type table) 'table.el)
-    (require 'table)
     (let ((outbuf (with-current-buffer
 		      (get-buffer-create "*org-export-table*")
 		    (erase-buffer) (current-buffer))))
-- 
2.51.2

>From 0a843eb9f3e726f12b71902c38db4505150d95d7 Mon Sep 17 00:00:00 2001
From: Morgan Smith <[email protected]>
Date: Tue, 4 Nov 2025 11:10:01 -0500
Subject: [PATCH 7/8] lisp/org.el: Normalize require statements

* lisp/org.el:

Require "org-macs" before the call to "(org-assert-version)" as this
is how it is done in the other files.

Remove the `eval-and-compile' around "(require 'org-macs)" as
`require' is effectively already that
[[info:elisp#Eval During Compile]].
---
 lisp/org.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index a770fc585..dcb1232c0 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -71,7 +71,7 @@ org-inlinetask-min-level
 
 ;;;; Require other packages
 
-(require 'org-compat)
+(require 'org-macs)
 (org-assert-version)
 
 (require 'cl-lib)
@@ -93,7 +93,7 @@ org-inlinetask-min-level
    (message "You need to run \"make\" or \"make autoloads\" from Org lisp directory")
    (sit-for 3)))
 
-(eval-and-compile (require 'org-macs))
+(require 'org-macs)
 (require 'org-compat)
 (require 'org-keys)
 (require 'ol)
-- 
2.51.2

>From fc3a77cccc3341bcad8c46be00b959c243ecd770 Mon Sep 17 00:00:00 2001
From: Morgan Smith <[email protected]>
Date: Tue, 4 Nov 2025 11:24:21 -0500
Subject: [PATCH 8/8] Testing: Include other test files use `eval-when-compile'

When using normal `require', all of the tests defined in a file will
be added to the current session.  By using `eval-when-compile', we can
avoid this so tests can be run file by file.

* testing/lisp/test-oc.el: Wrap the require of "test-ox" in
`eval-when-compile'.
* testing/lisp/test-org-habit.el: Wrap the require of
"test-org-agenda" and "test-org" in `eval-when-compile'.
* testing/lisp/test-org-agenda.el (org-test-agenda--agenda-buffers)
(org-test-agenda--kill-all-agendas): Use `defsubst' instead of `defun'
so they can used when required using `eval-when-compile'.
---
 testing/lisp/test-oc.el         | 3 ++-
 testing/lisp/test-org-agenda.el | 8 ++++++--
 testing/lisp/test-org-habit.el  | 6 ++++--
 3 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/testing/lisp/test-oc.el b/testing/lisp/test-oc.el
index b1db742d7..2f127a511 100644
--- a/testing/lisp/test-oc.el
+++ b/testing/lisp/test-oc.el
@@ -22,7 +22,8 @@
 (require 'oc)
 (require 'ox)
 ;; We need `org-test-with-parsed-data' macro.
-(require 'test-ox "../testing/lisp/test-ox.el")
+(eval-when-compile
+  (require 'test-ox "../testing/lisp/test-ox.el"))
 
 (ert-deftest test-org-cite/register-processor ()
   "Test `org-cite-register-processor'."
diff --git a/testing/lisp/test-org-agenda.el b/testing/lisp/test-org-agenda.el
index 51e75102c..a8a11af0f 100644
--- a/testing/lisp/test-org-agenda.el
+++ b/testing/lisp/test-org-agenda.el
@@ -30,14 +30,18 @@
 
 ;; General auxiliaries
 
-(defun org-test-agenda--agenda-buffers ()
+;; By using `defsubst' other files can use these definitions by using
+;; `eval-when-compile', which they should so they don't also include
+;; our test definitions.
+
+(defsubst org-test-agenda--agenda-buffers ()
   "Return agenda buffers in a list."
   (cl-remove-if-not (lambda (x)
 		      (with-current-buffer x
 			(eq major-mode 'org-agenda-mode)))
 		    (buffer-list)))
 
-(defun org-test-agenda--kill-all-agendas ()
+(defsubst org-test-agenda--kill-all-agendas ()
   "Kill all agenda buffers."
   (mapc #'kill-buffer
 	(org-test-agenda--agenda-buffers)))
diff --git a/testing/lisp/test-org-habit.el b/testing/lisp/test-org-habit.el
index 3c4c6ede9..ea7f43cc0 100644
--- a/testing/lisp/test-org-habit.el
+++ b/testing/lisp/test-org-habit.el
@@ -22,8 +22,10 @@
 (require 'org-test "../testing/org-test")
 (require 'org-agenda)
 (require 'org-habit)
-(require 'test-org-agenda "../testing/lisp/test-org-agenda")
-(require 'test-org "../testing/lisp/test-org")
+(eval-when-compile
+  (require 'test-org-agenda "../testing/lisp/test-org-agenda"))
+(eval-when-compile
+  (require 'test-org "../testing/lisp/test-org"))
 
 
 ;; Tests
-- 
2.51.2

Reply via email to