Function: hsys-org-fix-version
hsys-org-fix-version is an autoloaded and byte-compiled function
defined in hsys-org.el.
Signature
(hsys-org-fix-version)
Documentation
If multiple Org versions are loaded, use the one first on load-path.
Always ensure Org libraries have been required. Return t if Org is reloaded, else nil.
Source Code
;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hsys-org.el
;;;###autoload
(defun hsys-org-fix-version ()
"If multiple Org versions are loaded, use the one first on `load-path'.
Always ensure Org libraries have been required.
Return t if Org is reloaded, else nil."
;; Not all versions of org include these variables, so set them
(setq org--inhibit-version-check nil
org-list-allow-alphabetical nil)
(let ((org-dir (ignore-errors (org-find-library-dir "org")))
;; Use the loadhist to get the path Org defs were loaded from
(org-install-dir
(ignore-errors (find-library--from-load-history "org-loaddefs"))))
(when org-install-dir
(setq org-install-dir (file-name-directory org-install-dir)))
(cond ((and org-dir org-install-dir (string-equal org-dir org-install-dir)
;; Still may have a situation where the Org version matches the
;; builtin Org but the directories are for a newer Org
;; package version.
(if (string-match "[\\/]org-\\([0-9.]+-?[a-z]*\\)" org-dir)
(string-equal (match-string 1 org-dir) ;; org-dir version
(remove ?- (org-release)))
t))
;; Ensure Org folding is configured for `reveal-mode' compatibility
(hsys-org--set-fold-style)
;; Just require these libraries used for Hyperbole testing
;; (when they are available) to ensure they are loaded from
;; the single Org version used.
(mapc (lambda (lib-sym) (require lib-sym nil t))
'(org-version org-macs org-keys org-compat ol org-table org-id
org-element org-list org-element org-src org-fold org))
nil)
(t
;; Ensure using any local available packaged version of Org mode
;; rather than built-in which may have been activated before
;; load-path was set correctly. Avoids mixed version load of Org.
(let ((org-libraries-to-reload (hsys-org-get-libraries-to-reload))
lib-sym)
;; Unload org libraries loaded with wrong path
(mapc (lambda (lib)
(setq lib-sym (intern-soft lib))
(when (featurep lib-sym) (unload-feature lib-sym t)))
org-libraries-to-reload)
;; Ensure user's external Org package version is configured for loading
(unless (and package--initialized (not after-init-time))
(package-initialize))
;; Ensure Org folding is configured for `reveal-mode' compatibility
(hsys-org--set-fold-style)
(package-activate 'org t)
;; Load org libraries with right path but save "org" for last
(mapc #'load (remove "org" org-libraries-to-reload))
(load "org")
;; Next setting may have been deleted with the library
;; unloading, so restore it.
(add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
t)))))