From 5d81ce17ade36135ae405305fb88efd79f97d96f Mon Sep 17 00:00:00 2001 Message-ID: <5d81ce17ade36135ae405305fb88efd79f97d96f.1687521721.git.yantar92@posteo.net> From: Ihor Radchenko Date: Fri, 23 Jun 2023 14:17:05 +0300 Subject: [PATCH] org-assert-version: Demote to warning and attempt to work around mixed versions * lisp/org-load.el: New library containing load-related functions and commands. (org-require-autoloaded-modules): (org-reload): (org-customize): (org-create-customize-menu): (org--inhibit-version-check): Move from other files. (org-assert-version): Move from lisp/org-macs.el, remove error, and instead try `org-reload' when version mismatch is detected. Update the warning text, explaining extra scenario when we compile from Git source with stale .elc files. * lisp/org-macs.el (org--inhibit-version-check): (org-assert-version): (org-find-library-dir): Move from lisp/org-compat.el * lisp/org.el: (org-require-autoloaded-modules): (org-reload): (org-customize): (org-create-customize-menu): Move to lisp/org-load.el * lisp/org-compat.el (org-find-library-dir): Move to lisp/org-macs.el All the callers to `org-assert-version' are now using (require 'org-load) instead of (require 'org-macs). The changes in `org-assert-version' are aiming at 3 goals: 1. Move `org-assert-version' to a new file, not available in older Org versions. This makes sure that (require 'org-load) either signals an error or guarantees loading `org-assert-version' macro. Previous approach with defining the macro in org-macs.el suffered from byte-compilation silently treating the macro as undefined function; when org-macs.el was taken from older Org version and did not define the macro at all. 2. Be less strict and do not throw an error. This is necessary because mixed Org versions have non-zero chance to produce working Org, while throwing an error is always hitting users. In this scenario, pedantic approach makes more harm. 3. Try to recover gracefully from mixed version state by re-loading Org. This should be considered the last resort and we need to attract user's attention with a warning, but at least `org-reload' has a chance to keep Org operational. An alternative to `org-reload' could also be "require-with-shadow-check" that ensures that each required library is taken from the up-to-date `load-path' ordering [1]. However, Org currently does not rely strictly upon `require' statements. Org libraries are full of `declare-function' statements that implicitly assume that certain libraries would be loaded by other means. So, the alternative approach is less reliable compared to full Org re-loading. [1] https://debbugs.gnu.org/cgi/bugreport.cgi?bug=62762#110 Other discussions of the issue with `org-assert-version' and mixed install: - https://debbugs.gnu.org/cgi/bugreport.cgi?bug=59882 - https://list.orgmode.org/orgmode/tnm7ui$a8k$1@ciao.gmane.io/ - https://list.orgmode.org/orgmode/87bkonzisl.fsf@gnu.org/ - https://yhetil.org/emacs-devel/00b52cc1-b0ac-a0c0-c91d-33a7213e9881@web.de/ - https://irreal.org/blog/?p=10999 --- lisp/ob-C.el | 2 +- lisp/ob-R.el | 2 +- lisp/ob-awk.el | 2 +- lisp/ob-calc.el | 2 +- lisp/ob-clojure.el | 2 +- lisp/ob-comint.el | 2 +- lisp/ob-core.el | 2 +- lisp/ob-css.el | 2 +- lisp/ob-ditaa.el | 2 +- lisp/ob-dot.el | 2 +- lisp/ob-emacs-lisp.el | 2 +- lisp/ob-eshell.el | 2 +- lisp/ob-eval.el | 2 +- lisp/ob-exp.el | 2 +- lisp/ob-forth.el | 2 +- lisp/ob-fortran.el | 2 +- lisp/ob-gnuplot.el | 2 +- lisp/ob-groovy.el | 2 +- lisp/ob-haskell.el | 2 +- lisp/ob-java.el | 2 +- lisp/ob-js.el | 2 +- lisp/ob-julia.el | 2 +- lisp/ob-latex.el | 2 +- lisp/ob-lilypond.el | 2 +- lisp/ob-lisp.el | 2 +- lisp/ob-lob.el | 2 +- lisp/ob-lua.el | 2 +- lisp/ob-makefile.el | 2 +- lisp/ob-matlab.el | 2 +- lisp/ob-maxima.el | 2 +- lisp/ob-ocaml.el | 2 +- lisp/ob-octave.el | 2 +- lisp/ob-org.el | 2 +- lisp/ob-perl.el | 2 +- lisp/ob-plantuml.el | 2 +- lisp/ob-processing.el | 2 +- lisp/ob-python.el | 2 +- lisp/ob-ref.el | 2 +- lisp/ob-ruby.el | 2 +- lisp/ob-sass.el | 2 +- lisp/ob-scheme.el | 2 +- lisp/ob-screen.el | 2 +- lisp/ob-sed.el | 2 +- lisp/ob-shell.el | 2 +- lisp/ob-sql.el | 2 +- lisp/ob-sqlite.el | 2 +- lisp/ob-table.el | 2 +- lisp/ob-tangle.el | 2 +- lisp/ob.el | 2 +- lisp/oc-basic.el | 2 +- lisp/oc-biblatex.el | 2 +- lisp/oc-bibtex.el | 2 +- lisp/oc-csl.el | 2 +- lisp/oc-natbib.el | 2 +- lisp/oc.el | 2 +- lisp/ol-bbdb.el | 2 +- lisp/ol-bibtex.el | 2 +- lisp/ol-docview.el | 2 +- lisp/ol-doi.el | 2 +- lisp/ol-eshell.el | 2 +- lisp/ol-eww.el | 2 +- lisp/ol-gnus.el | 2 +- lisp/ol-info.el | 2 +- lisp/ol-irc.el | 2 +- lisp/ol-man.el | 2 +- lisp/ol-mhe.el | 2 +- lisp/ol-rmail.el | 2 +- lisp/ol-w3m.el | 2 +- lisp/ol.el | 2 +- lisp/org-agenda.el | 2 +- lisp/org-archive.el | 2 +- lisp/org-attach-git.el | 2 +- lisp/org-attach.el | 2 +- lisp/org-capture.el | 2 +- lisp/org-clock.el | 2 +- lisp/org-compat.el | 3 - lisp/org-crypt.el | 2 +- lisp/org-ctags.el | 2 +- lisp/org-cycle.el | 2 +- lisp/org-datetree.el | 2 +- lisp/org-duration.el | 2 +- lisp/org-element.el | 2 +- lisp/org-entities.el | 2 +- lisp/org-faces.el | 2 +- lisp/org-feed.el | 2 +- lisp/org-fold-core.el | 2 +- lisp/org-fold.el | 2 +- lisp/org-footnote.el | 2 +- lisp/org-goto.el | 2 +- lisp/org-habit.el | 2 +- lisp/org-id.el | 2 +- lisp/org-indent.el | 2 +- lisp/org-inlinetask.el | 2 +- lisp/org-keys.el | 2 +- lisp/org-lint.el | 2 +- lisp/org-list.el | 2 +- lisp/org-load.el | 196 +++++++++++++++++++++++++++++++++++++++++ lisp/org-macro.el | 2 +- lisp/org-macs.el | 69 +-------------- lisp/org-mobile.el | 2 +- lisp/org-mouse.el | 2 +- lisp/org-num.el | 2 +- lisp/org-pcomplete.el | 2 +- lisp/org-persist.el | 2 +- lisp/org-plot.el | 2 +- lisp/org-protocol.el | 2 +- lisp/org-refile.el | 2 +- lisp/org-src.el | 2 +- lisp/org-table.el | 2 +- lisp/org-tempo.el | 2 +- lisp/org-timer.el | 2 +- lisp/org.el | 85 +----------------- lisp/ox-ascii.el | 2 +- lisp/ox-beamer.el | 2 +- lisp/ox-html.el | 2 +- lisp/ox-icalendar.el | 2 +- lisp/ox-koma-letter.el | 2 +- lisp/ox-latex.el | 2 +- lisp/ox-man.el | 2 +- lisp/ox-md.el | 2 +- lisp/ox-odt.el | 2 +- lisp/ox-org.el | 2 +- lisp/ox-publish.el | 2 +- lisp/ox-texinfo.el | 2 +- lisp/ox.el | 2 +- 125 files changed, 321 insertions(+), 274 deletions(-) create mode 100644 lisp/org-load.el diff --git a/lisp/ob-C.el b/lisp/ob-C.el index 7763c4c07..4251f86bf 100644 --- a/lisp/ob-C.el +++ b/lisp/ob-C.el @@ -33,7 +33,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'cc-mode) diff --git a/lisp/ob-R.el b/lisp/ob-R.el index f2cc069aa..3d29ebfec 100644 --- a/lisp/ob-R.el +++ b/lisp/ob-R.el @@ -29,7 +29,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'cl-lib) diff --git a/lisp/ob-awk.el b/lisp/ob-awk.el index e5e42a91d..2add0a329 100644 --- a/lisp/ob-awk.el +++ b/lisp/ob-awk.el @@ -33,7 +33,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'ob) diff --git a/lisp/ob-calc.el b/lisp/ob-calc.el index 5572ce818..68ca87025 100644 --- a/lisp/ob-calc.el +++ b/lisp/ob-calc.el @@ -28,7 +28,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'ob) diff --git a/lisp/ob-clojure.el b/lisp/ob-clojure.el index d993e0cb7..0047f6dbf 100644 --- a/lisp/ob-clojure.el +++ b/lisp/ob-clojure.el @@ -46,7 +46,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'ob) diff --git a/lisp/ob-comint.el b/lisp/ob-comint.el index adfe31c40..23b457001 100644 --- a/lisp/ob-comint.el +++ b/lisp/ob-comint.el @@ -31,7 +31,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'ob-core) diff --git a/lisp/ob-core.el b/lisp/ob-core.el index e69ce4f1d..a7315130b 100644 --- a/lisp/ob-core.el +++ b/lisp/ob-core.el @@ -24,7 +24,7 @@ ;;; ob-core.el --- Working with Code Blocks -*- lexical-binding: t; -*- ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'cl-lib) diff --git a/lisp/ob-css.el b/lisp/ob-css.el index f93c576fc..0dff5525e 100644 --- a/lisp/ob-css.el +++ b/lisp/ob-css.el @@ -28,7 +28,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'ob) diff --git a/lisp/ob-ditaa.el b/lisp/ob-ditaa.el index 622000828..70f5ed679 100644 --- a/lisp/ob-ditaa.el +++ b/lisp/ob-ditaa.el @@ -37,7 +37,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'ob) diff --git a/lisp/ob-dot.el b/lisp/ob-dot.el index ecef071a7..b62266503 100644 --- a/lisp/ob-dot.el +++ b/lisp/ob-dot.el @@ -40,7 +40,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'ob) diff --git a/lisp/ob-emacs-lisp.el b/lisp/ob-emacs-lisp.el index f2111d649..3ebc2cf5d 100644 --- a/lisp/ob-emacs-lisp.el +++ b/lisp/ob-emacs-lisp.el @@ -27,7 +27,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'ob-core) diff --git a/lisp/ob-eshell.el b/lisp/ob-eshell.el index 95f5777ae..5c82a8f43 100644 --- a/lisp/ob-eshell.el +++ b/lisp/ob-eshell.el @@ -28,7 +28,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'ob) diff --git a/lisp/ob-eval.el b/lisp/ob-eval.el index 07e530772..071102ac9 100644 --- a/lisp/ob-eval.el +++ b/lisp/ob-eval.el @@ -28,7 +28,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (eval-when-compile (require 'subr-x)) ; For `string-empty-p', Emacs < 29 diff --git a/lisp/ob-exp.el b/lisp/ob-exp.el index 4d1b084be..d062c75d1 100644 --- a/lisp/ob-exp.el +++ b/lisp/ob-exp.el @@ -24,7 +24,7 @@ ;;; ob-exp.el --- Exportation of Babel Source Blocks -*- lexical-binding: t; -*- ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'ob-core) diff --git a/lisp/ob-forth.el b/lisp/ob-forth.el index e5dcad6d0..e90a6ae13 100644 --- a/lisp/ob-forth.el +++ b/lisp/ob-forth.el @@ -33,7 +33,7 @@ ;;; Requirements: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'ob) diff --git a/lisp/ob-fortran.el b/lisp/ob-fortran.el index 2c050cb18..1e4b62159 100644 --- a/lisp/ob-fortran.el +++ b/lisp/ob-fortran.el @@ -28,7 +28,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'ob) diff --git a/lisp/ob-gnuplot.el b/lisp/ob-gnuplot.el index e3e42918c..fbd7f1186 100644 --- a/lisp/ob-gnuplot.el +++ b/lisp/ob-gnuplot.el @@ -40,7 +40,7 @@ ;;; Requirements: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'ob) diff --git a/lisp/ob-groovy.el b/lisp/ob-groovy.el index c0da69fcb..7e3315baa 100644 --- a/lisp/ob-groovy.el +++ b/lisp/ob-groovy.el @@ -32,7 +32,7 @@ ;;; Requirements: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'ob) diff --git a/lisp/ob-haskell.el b/lisp/ob-haskell.el index 7185ed61f..495d18d0e 100644 --- a/lisp/ob-haskell.el +++ b/lisp/ob-haskell.el @@ -40,7 +40,7 @@ ;;; Requirements: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'ob) diff --git a/lisp/ob-java.el b/lisp/ob-java.el index 893860526..034034876 100644 --- a/lisp/ob-java.el +++ b/lisp/ob-java.el @@ -29,7 +29,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'ob) diff --git a/lisp/ob-js.el b/lisp/ob-js.el index de7ea9131..e0fc0171b 100644 --- a/lisp/ob-js.el +++ b/lisp/ob-js.el @@ -39,7 +39,7 @@ ;;; Requirements: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'ob) diff --git a/lisp/ob-julia.el b/lisp/ob-julia.el index cb5c7fa3b..9895aa10f 100644 --- a/lisp/ob-julia.el +++ b/lisp/ob-julia.el @@ -32,7 +32,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'cl-lib) diff --git a/lisp/ob-latex.el b/lisp/ob-latex.el index ce39628d6..68b584523 100644 --- a/lisp/ob-latex.el +++ b/lisp/ob-latex.el @@ -31,7 +31,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'ob) diff --git a/lisp/ob-lilypond.el b/lisp/ob-lilypond.el index 9693b89e2..75470c71f 100644 --- a/lisp/ob-lilypond.el +++ b/lisp/ob-lilypond.el @@ -33,7 +33,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'ob) diff --git a/lisp/ob-lisp.el b/lisp/ob-lisp.el index 048ef883c..268129460 100644 --- a/lisp/ob-lisp.el +++ b/lisp/ob-lisp.el @@ -37,7 +37,7 @@ ;;; Requirements: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'ob) diff --git a/lisp/ob-lob.el b/lisp/ob-lob.el index f77bda73d..e8ceb42e3 100644 --- a/lisp/ob-lob.el +++ b/lisp/ob-lob.el @@ -24,7 +24,7 @@ ;;; ob-lob.el --- Functions Supporting the Library of Babel -*- lexical-binding: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'cl-lib) diff --git a/lisp/ob-lua.el b/lisp/ob-lua.el index 81521d9e0..6c7aeb2f5 100644 --- a/lisp/ob-lua.el +++ b/lisp/ob-lua.el @@ -36,7 +36,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'ob) diff --git a/lisp/ob-makefile.el b/lisp/ob-makefile.el index 25306159b..31c4a509e 100644 --- a/lisp/ob-makefile.el +++ b/lisp/ob-makefile.el @@ -28,7 +28,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'ob) diff --git a/lisp/ob-matlab.el b/lisp/ob-matlab.el index 43344495d..38c7b539f 100644 --- a/lisp/ob-matlab.el +++ b/lisp/ob-matlab.el @@ -36,7 +36,7 @@ ;;; Requirements: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'ob) diff --git a/lisp/ob-maxima.el b/lisp/ob-maxima.el index d1d7c7424..0673e0b7f 100644 --- a/lisp/ob-maxima.el +++ b/lisp/ob-maxima.el @@ -32,7 +32,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'ob) diff --git a/lisp/ob-ocaml.el b/lisp/ob-ocaml.el index 09224b98b..7d89f6141 100644 --- a/lisp/ob-ocaml.el +++ b/lisp/ob-ocaml.el @@ -36,7 +36,7 @@ ;;; Requirements: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'ob) diff --git a/lisp/ob-octave.el b/lisp/ob-octave.el index 1de263a52..9261404d4 100644 --- a/lisp/ob-octave.el +++ b/lisp/ob-octave.el @@ -30,7 +30,7 @@ ;;; Requirements: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'ob) diff --git a/lisp/ob-org.el b/lisp/ob-org.el index 1bf02b461..79084e2f2 100644 --- a/lisp/ob-org.el +++ b/lisp/ob-org.el @@ -28,7 +28,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'ob) diff --git a/lisp/ob-perl.el b/lisp/ob-perl.el index c8cff5da5..45e31fd32 100644 --- a/lisp/ob-perl.el +++ b/lisp/ob-perl.el @@ -29,7 +29,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'ob) diff --git a/lisp/ob-plantuml.el b/lisp/ob-plantuml.el index 3202c6e41..705925cd7 100644 --- a/lisp/ob-plantuml.el +++ b/lisp/ob-plantuml.el @@ -35,7 +35,7 @@ ;;; Requirements: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'ob) diff --git a/lisp/ob-processing.el b/lisp/ob-processing.el index 4eeaf98e0..558b4099d 100644 --- a/lisp/ob-processing.el +++ b/lisp/ob-processing.el @@ -52,7 +52,7 @@ ;;; Requirements: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'ob) diff --git a/lisp/ob-python.el b/lisp/ob-python.el index c19af0ab3..1512d3234 100644 --- a/lisp/ob-python.el +++ b/lisp/ob-python.el @@ -29,7 +29,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'ob) diff --git a/lisp/ob-ref.el b/lisp/ob-ref.el index 2eae3690d..51ecd51fe 100644 --- a/lisp/ob-ref.el +++ b/lisp/ob-ref.el @@ -50,7 +50,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'ob-core) diff --git a/lisp/ob-ruby.el b/lisp/ob-ruby.el index b94bc73dd..390e32074 100644 --- a/lisp/ob-ruby.el +++ b/lisp/ob-ruby.el @@ -36,7 +36,7 @@ ;;; Requirements: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'ob) diff --git a/lisp/ob-sass.el b/lisp/ob-sass.el index 1498b931e..c8970b2a6 100644 --- a/lisp/ob-sass.el +++ b/lisp/ob-sass.el @@ -39,7 +39,7 @@ ;;; Requirements: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'ob) diff --git a/lisp/ob-scheme.el b/lisp/ob-scheme.el index ef41a2ec4..0d1ec142a 100644 --- a/lisp/ob-scheme.el +++ b/lisp/ob-scheme.el @@ -39,7 +39,7 @@ ;;; Requirements: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'ob) diff --git a/lisp/ob-screen.el b/lisp/ob-screen.el index 269538e79..f7f1a1d67 100644 --- a/lisp/ob-screen.el +++ b/lisp/ob-screen.el @@ -35,7 +35,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'ob) diff --git a/lisp/ob-sed.el b/lisp/ob-sed.el index 6469901fd..1b281c80d 100644 --- a/lisp/ob-sed.el +++ b/lisp/ob-sed.el @@ -41,7 +41,7 @@ ;;; Usage: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'ob) diff --git a/lisp/ob-shell.el b/lisp/ob-shell.el index 2c30a2605..b5deaf61b 100644 --- a/lisp/ob-shell.el +++ b/lisp/ob-shell.el @@ -27,7 +27,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'ob) diff --git a/lisp/ob-sql.el b/lisp/ob-sql.el index f73e7003f..377e31f0f 100644 --- a/lisp/ob-sql.el +++ b/lisp/ob-sql.el @@ -71,7 +71,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'ob) diff --git a/lisp/ob-sqlite.el b/lisp/ob-sqlite.el index 526b73ebd..533bee2a1 100644 --- a/lisp/ob-sqlite.el +++ b/lisp/ob-sqlite.el @@ -28,7 +28,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'ob) diff --git a/lisp/ob-table.el b/lisp/ob-table.el index 5c91f33f8..88d74816f 100644 --- a/lisp/ob-table.el +++ b/lisp/ob-table.el @@ -54,7 +54,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'ob-core) diff --git a/lisp/ob-tangle.el b/lisp/ob-tangle.el index e63bde89f..824dc963e 100644 --- a/lisp/ob-tangle.el +++ b/lisp/ob-tangle.el @@ -27,7 +27,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'cl-lib) diff --git a/lisp/ob.el b/lisp/ob.el index 4444ced58..0a81584f3 100644 --- a/lisp/ob.el +++ b/lisp/ob.el @@ -23,7 +23,7 @@ ;;; ob.el --- Working with Code Blocks in Org -*- lexical-binding: t; -*- ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'org-macs) diff --git a/lisp/oc-basic.el b/lisp/oc-basic.el index 1c8c37aa9..105e759ba 100644 --- a/lisp/oc-basic.el +++ b/lisp/oc-basic.el @@ -66,7 +66,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'bibtex) diff --git a/lisp/oc-biblatex.el b/lisp/oc-biblatex.el index b2d31f0f6..bb6d6dca8 100644 --- a/lisp/oc-biblatex.el +++ b/lisp/oc-biblatex.el @@ -63,7 +63,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'map) diff --git a/lisp/oc-bibtex.el b/lisp/oc-bibtex.el index d5e5490ed..a5a311224 100644 --- a/lisp/oc-bibtex.el +++ b/lisp/oc-bibtex.el @@ -36,7 +36,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'oc) diff --git a/lisp/oc-csl.el b/lisp/oc-csl.el index 2b00cb599..65e821593 100644 --- a/lisp/oc-csl.el +++ b/lisp/oc-csl.el @@ -112,7 +112,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'cl-lib) diff --git a/lisp/oc-natbib.el b/lisp/oc-natbib.el index 855be2a5c..5900d720b 100644 --- a/lisp/oc-natbib.el +++ b/lisp/oc-natbib.el @@ -43,7 +43,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'oc) diff --git a/lisp/oc.el b/lisp/oc.el index 8a7b66209..e62088e11 100644 --- a/lisp/oc.el +++ b/lisp/oc.el @@ -61,7 +61,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'org-compat) diff --git a/lisp/ol-bbdb.el b/lisp/ol-bbdb.el index 47bd9d98c..a0ec6a79a 100644 --- a/lisp/ol-bbdb.el +++ b/lisp/ol-bbdb.el @@ -93,7 +93,7 @@ ;;; Commentary: ;; ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'cl-lib) diff --git a/lisp/ol-bibtex.el b/lisp/ol-bibtex.el index fd9517233..dd11b422d 100644 --- a/lisp/ol-bibtex.el +++ b/lisp/ol-bibtex.el @@ -107,7 +107,7 @@ ;;; History: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'bibtex) diff --git a/lisp/ol-docview.el b/lisp/ol-docview.el index a9cd9b995..fd4525940 100644 --- a/lisp/ol-docview.el +++ b/lisp/ol-docview.el @@ -42,7 +42,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'doc-view) diff --git a/lisp/ol-doi.el b/lisp/ol-doi.el index 971b05087..e24c4b463 100644 --- a/lisp/ol-doi.el +++ b/lisp/ol-doi.el @@ -26,7 +26,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'ol) diff --git a/lisp/ol-eshell.el b/lisp/ol-eshell.el index b7d3baf38..67b79538f 100644 --- a/lisp/ol-eshell.el +++ b/lisp/ol-eshell.el @@ -23,7 +23,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'eshell) diff --git a/lisp/ol-eww.el b/lisp/ol-eww.el index ee970b6aa..1d404b6de 100644 --- a/lisp/ol-eww.el +++ b/lisp/ol-eww.el @@ -45,7 +45,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'ol) diff --git a/lisp/ol-gnus.el b/lisp/ol-gnus.el index 7c07ce045..6a4362bc5 100644 --- a/lisp/ol-gnus.el +++ b/lisp/ol-gnus.el @@ -31,7 +31,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'gnus-sum) diff --git a/lisp/ol-info.el b/lisp/ol-info.el index ad9e4a12b..7df698daa 100644 --- a/lisp/ol-info.el +++ b/lisp/ol-info.el @@ -30,7 +30,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'ol) diff --git a/lisp/ol-irc.el b/lisp/ol-irc.el index 3760644e8..b14d3c47f 100644 --- a/lisp/ol-irc.el +++ b/lisp/ol-irc.el @@ -48,7 +48,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'ol) diff --git a/lisp/ol-man.el b/lisp/ol-man.el index 40fdc8f92..96c991b21 100644 --- a/lisp/ol-man.el +++ b/lisp/ol-man.el @@ -24,7 +24,7 @@ ;;; ol-man.el --- Links to man pages -*- lexical-binding: t; -*- ;; ;;; Commentary: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'ol) diff --git a/lisp/ol-mhe.el b/lisp/ol-mhe.el index 403b5a254..16b1967f8 100644 --- a/lisp/ol-mhe.el +++ b/lisp/ol-mhe.el @@ -30,7 +30,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'org-macs) diff --git a/lisp/ol-rmail.el b/lisp/ol-rmail.el index 287779828..f95b6999c 100644 --- a/lisp/ol-rmail.el +++ b/lisp/ol-rmail.el @@ -30,7 +30,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'ol) diff --git a/lisp/ol-w3m.el b/lisp/ol-w3m.el index 6fb01a60d..6d14e6ebc 100644 --- a/lisp/ol-w3m.el +++ b/lisp/ol-w3m.el @@ -41,7 +41,7 @@ ;;; Acknowledgments: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'ol) diff --git a/lisp/ol.el b/lisp/ol.el index 9ad191c8f..e5e8de80f 100644 --- a/lisp/ol.el +++ b/lisp/ol.el @@ -27,7 +27,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'org-compat) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index d3e616431..6ff3b3cb0 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -45,7 +45,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'cl-lib) diff --git a/lisp/org-archive.el b/lisp/org-archive.el index e74c59a51..3f74e6d14 100644 --- a/lisp/org-archive.el +++ b/lisp/org-archive.el @@ -28,7 +28,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'org) diff --git a/lisp/org-attach-git.el b/lisp/org-attach-git.el index 4763aefd4..2c9242d70 100644 --- a/lisp/org-attach-git.el +++ b/lisp/org-attach-git.el @@ -29,7 +29,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'org-attach) diff --git a/lisp/org-attach.el b/lisp/org-attach.el index e8b27751e..428c12068 100644 --- a/lisp/org-attach.el +++ b/lisp/org-attach.el @@ -34,7 +34,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'cl-lib) diff --git a/lisp/org-capture.el b/lisp/org-capture.el index a696c615b..cf487ac19 100644 --- a/lisp/org-capture.el +++ b/lisp/org-capture.el @@ -47,7 +47,7 @@ ;;; TODO ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'cl-lib) diff --git a/lisp/org-clock.el b/lisp/org-clock.el index d7fe14cd5..77225d2d6 100644 --- a/lisp/org-clock.el +++ b/lisp/org-clock.el @@ -28,7 +28,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'cl-lib) diff --git a/lisp/org-compat.el b/lisp/org-compat.el index d5bf2191a..360143018 100644 --- a/lisp/org-compat.el +++ b/lisp/org-compat.el @@ -1176,9 +1176,6 @@ (defun org-move-to-column (column &optional force _buffer) buffer-invisibility-spec))) (move-to-column column force))) -(defmacro org-find-library-dir (library) - `(file-name-directory (or (locate-library ,library) ""))) - (defun org-count-lines (s) "How many lines in string S?" (let ((start 0) (n 1)) diff --git a/lisp/org-crypt.el b/lisp/org-crypt.el index b5df115cf..b6a306371 100644 --- a/lisp/org-crypt.el +++ b/lisp/org-crypt.el @@ -54,7 +54,7 @@ ;;; Thanks: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'org-macs) diff --git a/lisp/org-ctags.el b/lisp/org-ctags.el index 5dd2bfd59..8ff2563e1 100644 --- a/lisp/org-ctags.el +++ b/lisp/org-ctags.el @@ -135,7 +135,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (eval-when-compile (require 'cl-lib)) diff --git a/lisp/org-cycle.el b/lisp/org-cycle.el index 90fc95f41..85e94657f 100644 --- a/lisp/org-cycle.el +++ b/lisp/org-cycle.el @@ -29,7 +29,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'org-macs) diff --git a/lisp/org-datetree.el b/lisp/org-datetree.el index 035ef047a..d3491324d 100644 --- a/lisp/org-datetree.el +++ b/lisp/org-datetree.el @@ -30,7 +30,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'org) diff --git a/lisp/org-duration.el b/lisp/org-duration.el index 2919efd4c..2adddcc1b 100644 --- a/lisp/org-duration.el +++ b/lisp/org-duration.el @@ -51,7 +51,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'cl-lib) diff --git a/lisp/org-element.el b/lisp/org-element.el index df43ebcf0..7397cb6cb 100644 --- a/lisp/org-element.el +++ b/lisp/org-element.el @@ -58,7 +58,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'avl-tree) diff --git a/lisp/org-entities.el b/lisp/org-entities.el index 61083022b..7125a5c77 100644 --- a/lisp/org-entities.el +++ b/lisp/org-entities.el @@ -27,7 +27,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (declare-function org-mode "org" ()) diff --git a/lisp/org-faces.el b/lisp/org-faces.el index 594c9a6e7..5c1bd50a1 100644 --- a/lisp/org-faces.el +++ b/lisp/org-faces.el @@ -28,7 +28,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (defgroup org-faces nil diff --git a/lisp/org-feed.el b/lisp/org-feed.el index f0b294b4a..43c035ad6 100644 --- a/lisp/org-feed.el +++ b/lisp/org-feed.el @@ -88,7 +88,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'org) diff --git a/lisp/org-fold-core.el b/lisp/org-fold-core.el index 6c17b00fa..1ba7601f1 100644 --- a/lisp/org-fold-core.el +++ b/lisp/org-fold-core.el @@ -270,7 +270,7 @@ ;;; Performance considerations ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'org-macs) diff --git a/lisp/org-fold.el b/lisp/org-fold.el index 1b7ca22b0..2e63f5100 100644 --- a/lisp/org-fold.el +++ b/lisp/org-fold.el @@ -42,7 +42,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'org-macs) diff --git a/lisp/org-footnote.el b/lisp/org-footnote.el index 6bdd0b32f..7874a4af1 100644 --- a/lisp/org-footnote.el +++ b/lisp/org-footnote.el @@ -28,7 +28,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) ;;;; Declarations diff --git a/lisp/org-goto.el b/lisp/org-goto.el index 00bf5d46a..2da5a86e2 100644 --- a/lisp/org-goto.el +++ b/lisp/org-goto.el @@ -22,7 +22,7 @@ ;;; org-goto.el --- Fast navigation in an Org buffer -*- lexical-binding: t; -* ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'org) diff --git a/lisp/org-habit.el b/lisp/org-habit.el index fb6a48b5f..a835ff270 100644 --- a/lisp/org-habit.el +++ b/lisp/org-habit.el @@ -28,7 +28,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'cl-lib) diff --git a/lisp/org-id.el b/lisp/org-id.el index 490e4ddee..d7b4dd338 100644 --- a/lisp/org-id.el +++ b/lisp/org-id.el @@ -70,7 +70,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'org) diff --git a/lisp/org-indent.el b/lisp/org-indent.el index fe5233878..0a0019a44 100644 --- a/lisp/org-indent.el +++ b/lisp/org-indent.el @@ -36,7 +36,7 @@ ;;; Commentary: ;; ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'org-macs) diff --git a/lisp/org-inlinetask.el b/lisp/org-inlinetask.el index cb7fdf88b..1fb16a2f8 100644 --- a/lisp/org-inlinetask.el +++ b/lisp/org-inlinetask.el @@ -78,7 +78,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'org) diff --git a/lisp/org-keys.el b/lisp/org-keys.el index 37a150bb7..b5c576b2a 100644 --- a/lisp/org-keys.el +++ b/lisp/org-keys.el @@ -27,7 +27,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'cl-lib) diff --git a/lisp/org-lint.el b/lisp/org-lint.el index 0e2967b6c..e6c4d088f 100644 --- a/lisp/org-lint.el +++ b/lisp/org-lint.el @@ -85,7 +85,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'cl-lib) diff --git a/lisp/org-list.el b/lisp/org-list.el index 1fc99d070..63ff65bca 100644 --- a/lisp/org-list.el +++ b/lisp/org-list.el @@ -76,7 +76,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'cl-lib) diff --git a/lisp/org-load.el b/lisp/org-load.el new file mode 100644 index 000000000..c618452f2 --- /dev/null +++ b/lisp/org-load.el @@ -0,0 +1,196 @@ +;;; org-load.el --- Functions and commands that load Org mode -*- lexical-binding: t; -*- + +;; Copyright (C) 2023-2023 Free Software Foundation, Inc. + +;; Author: Ihor Radchenko + +;; This file is part of GNU Emacs. + +;; GNU Emacs is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; GNU Emacs is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs. If not, see . + +;;; Commentary: +;; +;; This file contains commands and functions dealing with loading +;; various parts of Org and checking consistency of the Org libraries. + +(require 'org-macs) + +(defun org-require-autoloaded-modules () + (interactive) + (mapc #'require + '(org-agenda org-archive org-attach org-clock org-colview org-id + org-table org-timer))) + +;;;###autoload +(defun org-reload (&optional uncompiled) + "Reload all Org Lisp files. +With prefix arg UNCOMPILED, load the uncompiled versions." + (interactive "P") + (require 'loadhist) + (let* ((org-dir (org-find-library-dir "org")) + (contrib-dir (or (org-find-library-dir "org-contribdir") org-dir)) + (feature-re "^\\(org\\|ob\\|ox\\|ol\\|oc\\)\\(-.*\\)?") + (remove-re (format "\\`%s\\'" + (regexp-opt '("org" "org-loaddefs" "org-version")))) + (feats (delete-dups + (mapcar 'file-name-sans-extension + (mapcar 'file-name-nondirectory + (delq nil + (mapcar 'feature-file + features)))))) + (lfeat (append + (sort + (setq feats + (delq nil (mapcar + (lambda (f) + (if (and (string-match feature-re f) + (not (string-match remove-re f))) + f nil)) + feats))) + 'string-lessp) + (list "org-version" "org"))) + (load-suffixes (if uncompiled (reverse load-suffixes) load-suffixes)) + load-uncore load-misses) + (setq load-misses + (delq t + (mapcar (lambda (f) + (or (org-load-noerror-mustsuffix (concat org-dir f)) + (and (string= org-dir contrib-dir) + (org-load-noerror-mustsuffix (concat contrib-dir f))) + (and (org-load-noerror-mustsuffix (concat (org-find-library-dir f) f)) + (push f load-uncore) + t) + f)) + lfeat))) + (when load-uncore + (message "The following feature%s found in load-path, please check if that's correct:\n%s" + (if (> (length load-uncore) 1) "s were" " was") + (reverse load-uncore))) + (if load-misses + (message "Some error occurred while reloading Org feature%s\n%s\nPlease check *Messages*!\n%s" + (if (> (length load-misses) 1) "s" "") load-misses (org-version nil 'full)) + (message "Successfully reloaded Org\n%s" (org-version nil 'full))))) + +;;;###autoload +(defun org-customize () + "Call the customize function with org as argument." + (interactive) + (org-load-modules-maybe) + (org-require-autoloaded-modules) + (customize-browse 'org)) + +(defun org-create-customize-menu () + "Create a full customization menu for Org mode, insert it into the menu." + (interactive) + (org-load-modules-maybe) + (org-require-autoloaded-modules) + (easy-menu-change + '("Org") "Customize" + `(["Browse Org group" org-customize t] + "--" + ,(customize-menu-create 'org) + ["Set" Custom-set t] + ["Save" Custom-save t] + ["Reset to Current" Custom-reset-current t] + ["Reset to Saved" Custom-reset-saved t] + ["Reset to Standard Settings" Custom-reset-standard t])) + (message "\"Org\"-menu now contains full customization menu")) + +;;; Org version verification. + +(defvar org--inhibit-version-check nil + "When non-nil, skip the detection of mixed-versions situations. +For internal use only. See Emacs bug #62762. +This variable is only supposed to be changed by Emacs build scripts. +When nil, Org tries to detect when Org source files were compiled with +a different version of Org (which tends to lead to incorrect `.elc' files), +or when the current Emacs session has loaded a mix of files from different +Org versions (typically the one bundled with Emacs and another one installed +from GNU ELPA), which can happen if some parts of Org were loaded before +`load-path' was changed (e.g. before the GNU-ELPA-installed Org is activated +by `package-activate-all').") +(defmacro org-assert-version () + "Check compile time and runtime version match. +Warn, and attempt to fix mixed version, if any." + ;; We intentionally use a more permissive `org-release' instead of + ;; `org-git-version' to work around deficiencies in Elisp + ;; compilation after pulling latest changes. Unchanged files will + ;; not be re-compiled and thus their macro-expanded + ;; `org-assert-version' calls would fail using strict + ;; `org-git-version' check because the generated Org version strings + ;; will not match. + `(unless (or org--inhibit-version-check (equal (org-release) ,(org-release))) + (warn "Org version mismatch. Random Org errors may occur. +This warning usually appears when a built-in Org version is loaded +prior to the more recent Org version. + +Version mismatch is commonly encountered in the following situations: + +1. Some compiled Org libraries are not re-compiled after Org update. + + It is recommended to re-install Org, or, if Org is loaded from git + repo, to run + + make clean; make autoloads + +2. Emacs is loaded using literate Org config and more recent Org + version is loaded inside the file loaded by `org-babel-load-file'. + `org-babel-load-file' triggers the built-in Org version clashing + the newer Org version attempt to be loaded later. + + It is recommended to move the Org loading code before the + `org-babel-load-file' call. + +3. New Org version is loaded manually by setting `load-path', but some + other package depending on Org is loaded before the `load-path' is + configured. + This \"other package\" is triggering built-in Org version, again + causing the version mismatch. + + It is recommended to set `load-path' as early in the config as + possible. + +4. New Org version is loaded using straight.el package manager and + other package depending on Org is loaded before straight triggers + loading of the newer Org version. + + It is recommended to put + + %s + + early in the config. Ideally, right after the straight.el + bootstrap. Moving `use-package' :straight declaration may not be + sufficient if the corresponding `use-package' statement is + deferring the loading." + ;; Avoid `warn' replacing "'" with "’" (see `format-message'). + "(straight-use-package 'org)") + ;; Try to re-load Org. + ;; Do the re-loading after the current, faulty file is loaded. + ;; The current file may still fail to load - situation we cannot + ;; work around. + ;; We re-load the whole Org here because Org commonly uses + ;; `declare-function' statements and thus more granular approach, + ;; like suggested in + ;; https://debbugs.gnu.org/cgi/bugreport.cgi?bug=62762#110 + ;; will not be as reliable. + ;; Note that this clause will never run during compilation + ;; because version check can only trigger in already compiled + ;; files with macro expanded differently during compilation and + ;; during loading. (equal (org-release) ,(org-release)) is + ;; always t when compiling current `load-file-name'. + (eval-after-load load-file-name (org-reload t)))) + +(provide 'org-load) + +;;; org-load.el ends here diff --git a/lisp/org-macro.el b/lisp/org-macro.el index 481e431c2..98706f676 100644 --- a/lisp/org-macro.el +++ b/lisp/org-macro.el @@ -47,7 +47,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'cl-lib) diff --git a/lisp/org-macs.el b/lisp/org-macs.el index 1552675f8..984e7c023 100644 --- a/lisp/org-macs.el +++ b/lisp/org-macs.el @@ -34,72 +34,6 @@ ;;; Code: (require 'cl-lib) (require 'format-spec) -;;; Org version verification. - -(defvar org--inhibit-version-check nil - "When non-nil, skip the detection of mixed-versions situations. -For internal use only. See Emacs bug #62762. -This variable is only supposed to be changed by Emacs build scripts. -When nil, Org tries to detect when Org source files were compiled with -a different version of Org (which tends to lead to incorrect `.elc' files), -or when the current Emacs session has loaded a mix of files from different -Org versions (typically the one bundled with Emacs and another one installed -from GNU ELPA), which can happen if some parts of Org were loaded before -`load-path' was changed (e.g. before the GNU-ELPA-installed Org is activated -by `package-activate-all').") -(defmacro org-assert-version () - "Assert compile time and runtime version match." - ;; We intentionally use a more permissive `org-release' instead of - ;; `org-git-version' to work around deficiencies in Elisp - ;; compilation after pulling latest changes. Unchanged files will - ;; not be re-compiled and thus their macro-expanded - ;; `org-assert-version' calls would fail using strict - ;; `org-git-version' check because the generated Org version strings - ;; will not match. - `(unless (or org--inhibit-version-check (equal (org-release) ,(org-release))) - (warn "Org version mismatch. Org loading aborted. -This warning usually appears when a built-in Org version is loaded -prior to the more recent Org version. - -Version mismatch is commonly encountered in the following situations: - -1. Emacs is loaded using literate Org config and more recent Org - version is loaded inside the file loaded by `org-babel-load-file'. - `org-babel-load-file' triggers the built-in Org version clashing - the newer Org version attempt to be loaded later. - - It is recommended to move the Org loading code before the - `org-babel-load-file' call. - -2. New Org version is loaded manually by setting `load-path', but some - other package depending on Org is loaded before the `load-path' is - configured. - This \"other package\" is triggering built-in Org version, again - causing the version mismatch. - - It is recommended to set `load-path' as early in the config as - possible. - -3. New Org version is loaded using straight.el package manager and - other package depending on Org is loaded before straight triggers - loading of the newer Org version. - - It is recommended to put - - %s - - early in the config. Ideally, right after the straight.el - bootstrap. Moving `use-package' :straight declaration may not be - sufficient if the corresponding `use-package' statement is - deferring the loading." - ;; Avoid `warn' replacing "'" with "’" (see `format-message'). - "(straight-use-package 'org)") - (error "Org version mismatch. Make sure that correct `load-path' is set early in init.el"))) - -;; We rely on org-macs when generating Org version. Checking Org -;; version here will interfere with Org build process. -;; (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)) @@ -215,6 +149,9 @@ (defmacro org-eval-in-environment (environment form) (declare (debug (form form)) (indent 1) (obsolete cl-progv "2021")) `(eval (list 'let ,environment ',form))) +(defmacro org-find-library-dir (library) + `(file-name-directory (or (locate-library ,library) ""))) + ;;;###autoload (defmacro org-load-noerror-mustsuffix (file) "Load FILE with optional arguments NOERROR and MUSTSUFFIX." diff --git a/lisp/org-mobile.el b/lisp/org-mobile.el index 01395a4b6..17cb2f881 100644 --- a/lisp/org-mobile.el +++ b/lisp/org-mobile.el @@ -31,7 +31,7 @@ ;;; Commentary: ;; iPhone and Android - any external viewer/flagging/editing ;; application that uses the same conventions could be used. -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'cl-lib) diff --git a/lisp/org-mouse.el b/lisp/org-mouse.el index 3b2c4cba6..90779be3f 100644 --- a/lisp/org-mouse.el +++ b/lisp/org-mouse.el @@ -136,7 +136,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'org) diff --git a/lisp/org-num.el b/lisp/org-num.el index cbe5e455e..9d3f14402 100644 --- a/lisp/org-num.el +++ b/lisp/org-num.el @@ -61,7 +61,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'cl-lib) diff --git a/lisp/org-pcomplete.el b/lisp/org-pcomplete.el index 0567052c0..e5cc707e7 100644 --- a/lisp/org-pcomplete.el +++ b/lisp/org-pcomplete.el @@ -26,7 +26,7 @@ ;;; Code: ;;;; Require other packages -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'org-macs) diff --git a/lisp/org-persist.el b/lisp/org-persist.el index 01078f459..a43853d3c 100644 --- a/lisp/org-persist.el +++ b/lisp/org-persist.el @@ -149,7 +149,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'org-compat) diff --git a/lisp/org-plot.el b/lisp/org-plot.el index fe61e9ace..0eb603dc4 100644 --- a/lisp/org-plot.el +++ b/lisp/org-plot.el @@ -31,7 +31,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'cl-lib) diff --git a/lisp/org-protocol.el b/lisp/org-protocol.el index 2b07a377e..fc6d23f5e 100644 --- a/lisp/org-protocol.el +++ b/lisp/org-protocol.el @@ -128,7 +128,7 @@ ;;; Commentary: ;; ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'org) diff --git a/lisp/org-refile.el b/lisp/org-refile.el index 5a41c022f..947a593df 100644 --- a/lisp/org-refile.el +++ b/lisp/org-refile.el @@ -25,7 +25,7 @@ ;;; Commentary: ;; Org Refile allows you to refile subtrees to various locations. ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'org) diff --git a/lisp/org-src.el b/lisp/org-src.el index aadd8eba5..793d89ca1 100644 --- a/lisp/org-src.el +++ b/lisp/org-src.el @@ -31,7 +31,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'cl-lib) diff --git a/lisp/org-table.el b/lisp/org-table.el index 83bad3f3a..4add43e6d 100644 --- a/lisp/org-table.el +++ b/lisp/org-table.el @@ -34,7 +34,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'cl-lib) diff --git a/lisp/org-tempo.el b/lisp/org-tempo.el index 81ec8fdcc..4d0847dcd 100644 --- a/lisp/org-tempo.el +++ b/lisp/org-tempo.el @@ -38,7 +38,7 @@ ;;; Commentary: ;; ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'tempo) diff --git a/lisp/org-timer.el b/lisp/org-timer.el index 919630e69..b4d24f45c 100644 --- a/lisp/org-timer.el +++ b/lisp/org-timer.el @@ -35,7 +35,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'cl-lib) diff --git a/lisp/org.el b/lisp/org.el index 2e26c08e5..3966e9b3e 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -71,7 +71,7 @@ (defvar org-inlinetask-min-level) ;;;; Require other packages -(require 'org-compat) +(require 'org-load) (org-assert-version) (require 'cl-lib) @@ -18278,89 +18278,6 @@ (defun org-install-agenda-files-menu () ;; Prevent initialization from failing. (ignore-errors (org-agenda-files t))))))))) -;;;; Documentation - -(defun org-require-autoloaded-modules () - (interactive) - (mapc #'require - '(org-agenda org-archive org-attach org-clock org-colview org-id - org-table org-timer))) - -;;;###autoload -(defun org-reload (&optional uncompiled) - "Reload all Org Lisp files. -With prefix arg UNCOMPILED, load the uncompiled versions." - (interactive "P") - (require 'loadhist) - (let* ((org-dir (org-find-library-dir "org")) - (contrib-dir (or (org-find-library-dir "org-contribdir") org-dir)) - (feature-re "^\\(org\\|ob\\|ox\\|ol\\|oc\\)\\(-.*\\)?") - (remove-re (format "\\`%s\\'" - (regexp-opt '("org" "org-loaddefs" "org-version")))) - (feats (delete-dups - (mapcar 'file-name-sans-extension - (mapcar 'file-name-nondirectory - (delq nil - (mapcar 'feature-file - features)))))) - (lfeat (append - (sort - (setq feats - (delq nil (mapcar - (lambda (f) - (if (and (string-match feature-re f) - (not (string-match remove-re f))) - f nil)) - feats))) - 'string-lessp) - (list "org-version" "org"))) - (load-suffixes (if uncompiled (reverse load-suffixes) load-suffixes)) - load-uncore load-misses) - (setq load-misses - (delq t - (mapcar (lambda (f) - (or (org-load-noerror-mustsuffix (concat org-dir f)) - (and (string= org-dir contrib-dir) - (org-load-noerror-mustsuffix (concat contrib-dir f))) - (and (org-load-noerror-mustsuffix (concat (org-find-library-dir f) f)) - (push f load-uncore) - t) - f)) - lfeat))) - (when load-uncore - (message "The following feature%s found in load-path, please check if that's correct:\n%s" - (if (> (length load-uncore) 1) "s were" " was") - (reverse load-uncore))) - (if load-misses - (message "Some error occurred while reloading Org feature%s\n%s\nPlease check *Messages*!\n%s" - (if (> (length load-misses) 1) "s" "") load-misses (org-version nil 'full)) - (message "Successfully reloaded Org\n%s" (org-version nil 'full))))) - -;;;###autoload -(defun org-customize () - "Call the customize function with org as argument." - (interactive) - (org-load-modules-maybe) - (org-require-autoloaded-modules) - (customize-browse 'org)) - -(defun org-create-customize-menu () - "Create a full customization menu for Org mode, insert it into the menu." - (interactive) - (org-load-modules-maybe) - (org-require-autoloaded-modules) - (easy-menu-change - '("Org") "Customize" - `(["Browse Org group" org-customize t] - "--" - ,(customize-menu-create 'org) - ["Set" Custom-set t] - ["Save" Custom-save t] - ["Reset to Current" Custom-reset-current t] - ["Reset to Saved" Custom-reset-saved t] - ["Reset to Standard Settings" Custom-reset-standard t])) - (message "\"Org\"-menu now contains full customization menu")) - ;;;; Miscellaneous stuff ;;; Generally useful functions diff --git a/lisp/ox-ascii.el b/lisp/ox-ascii.el index 692dd216d..13dd7439f 100644 --- a/lisp/ox-ascii.el +++ b/lisp/ox-ascii.el @@ -28,7 +28,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'ox) diff --git a/lisp/ox-beamer.el b/lisp/ox-beamer.el index 689bf1559..d00baa41d 100644 --- a/lisp/ox-beamer.el +++ b/lisp/ox-beamer.el @@ -30,7 +30,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'cl-lib) diff --git a/lisp/ox-html.el b/lisp/ox-html.el index b27254b8a..93d8fb399 100644 --- a/lisp/ox-html.el +++ b/lisp/ox-html.el @@ -31,7 +31,7 @@ ;;; Code: ;;; Dependencies -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'cl-lib) diff --git a/lisp/ox-icalendar.el b/lisp/ox-icalendar.el index 81a77a770..16d88a6f3 100644 --- a/lisp/ox-icalendar.el +++ b/lisp/ox-icalendar.el @@ -32,7 +32,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'cl-lib) diff --git a/lisp/ox-koma-letter.el b/lisp/ox-koma-letter.el index 33eb0597b..9cd48c1f5 100644 --- a/lisp/ox-koma-letter.el +++ b/lisp/ox-koma-letter.el @@ -165,7 +165,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'cl-lib) diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index 768bf402b..2be4ef34c 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -27,7 +27,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'cl-lib) diff --git a/lisp/ox-man.el b/lisp/ox-man.el index bb716f7b9..3b703fd1f 100644 --- a/lisp/ox-man.el +++ b/lisp/ox-man.el @@ -37,7 +37,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'cl-lib) diff --git a/lisp/ox-md.el b/lisp/ox-md.el index 5be0ca22e..9e368ba0f 100644 --- a/lisp/ox-md.el +++ b/lisp/ox-md.el @@ -29,7 +29,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'cl-lib) diff --git a/lisp/ox-odt.el b/lisp/ox-odt.el index dd96ed8e0..b0c0b234a 100644 --- a/lisp/ox-odt.el +++ b/lisp/ox-odt.el @@ -25,7 +25,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'cl-lib) diff --git a/lisp/ox-org.el b/lisp/ox-org.el index ed72cf4f2..98e4682b4 100644 --- a/lisp/ox-org.el +++ b/lisp/ox-org.el @@ -25,7 +25,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'ox) diff --git a/lisp/ox-publish.el b/lisp/ox-publish.el index f9c3877d7..23cd7f325 100644 --- a/lisp/ox-publish.el +++ b/lisp/ox-publish.el @@ -38,7 +38,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'cl-lib) diff --git a/lisp/ox-texinfo.el b/lisp/ox-texinfo.el index 5befcac1c..0e5e696db 100644 --- a/lisp/ox-texinfo.el +++ b/lisp/ox-texinfo.el @@ -26,7 +26,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'cl-lib) diff --git a/lisp/ox.el b/lisp/ox.el index 6f819def9..f979c3eef 100644 --- a/lisp/ox.el +++ b/lisp/ox.el @@ -72,7 +72,7 @@ ;;; Commentary: ;;; Code: -(require 'org-macs) +(require 'org-load) (org-assert-version) (require 'cl-lib) -- 2.41.0