unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Requiring `ol` in `org-real`s autoloads
@ 2023-10-19 20:57 Stefan Monnier
  0 siblings, 0 replies; only message in thread
From: Stefan Monnier @ 2023-10-19 20:57 UTC (permalink / raw)
  To: Taylor Grinn; +Cc: Kyle Meyer, emacs-devel

[-- Attachment #1: Type: text/plain, Size: 956 bytes --]

In `org-real.el` I see:

    ;;;###autoload
    (require 'ol)

This is bad for several reasons, such as the fact that it slows down
startup by forcing the load of part of Org, but more importantly it
breaks Org:

The order in which packages are activated is not deterministic,
so it's totally possible that `org-real` gets loaded before
`org` gets activated (I know, because that's how I bumped into this
problem), meaning that the above (require 'ol) will load the `ol` (and
`org-compat` etc...) that's bundled with Emacs, while later on the
non-bundled Org package will be activated at which point it will burp
because you can't have two different versions of Org loaded at the same
time (e.g. currently the `org-compat` in Emacs doesn't define
`org--flatten-tree`, so loading `org-src` from the unbundled Org
package will break if you've loaded the `org-compat` that's bundled in
your Emacs).

The patch below seems to fix the problem.


        Stefan

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: org-real.patch --]
[-- Type: text/x-diff, Size: 956 bytes --]

diff --git a/org-real.el b/org-real.el
index 35604ed7f1..9c45d0e0d8 100644
--- a/org-real.el
+++ b/org-real.el
@@ -1,6 +1,6 @@
 ;;; org-real.el --- Keep track of real things as org-mode links -*- lexical-binding: t -*-
 
-;; Copyright (C) 2021 Free Software Foundation, Inc.
+;; Copyright (C) 2021-2023 Free Software Foundation, Inc.
 
 ;; Author: Taylor Grinn <grinntaylor@gmail.com>
 ;; Version: 1.0.6
@@ -49,7 +49,6 @@
 
 ;;;; Requirements
 
-;;;###autoload
 (require 'ol)
 
 (require 'boxy)
@@ -333,9 +332,10 @@ diagram."
 ;;;; `org-insert-link' configuration
 
 ;;;###autoload
-(org-link-set-parameters "real"
-                         :follow #'org-real-follow
-                         :complete #'org-real-complete)
+(with-eval-after-load 'ol
+  (org-link-set-parameters "real"
+                           :follow #'org-real-follow
+                           :complete #'org-real-complete))
 
 ;;;###autoload
 (defun org-real-follow (url &rest _)

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2023-10-19 20:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-19 20:57 Requiring `ol` in `org-real`s autoloads Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).