Subject: bug#57972: 29.0.50; Autoloaded function raises (void-function org-element-cache-reset) when called within major-mode body

From: Eli Zaretskii <[email-masked]>
Date: Wed, 21 Sep 2022 14:35:56 +0300

> From: Ihor Radchenko <[email-masked]>
> Date: Wed, 21 Sep 2022 16:33:39 +0800
> 
> I am forwarding a bug report from Org mode.
> https://list.orgmode.org/[email-masked]/T/#u
> 
> I am able to reproduce the reported steps (see below) and I find that
> the void-function error is raised when calling (org-mode). `org-mode'
> body calls `org-element-cache-reset', which should be autoloaded from
> org-element.el. Yet, void-function error is raised.
> 
> I either misunderstand something about autoload or it is some kind of
> Emacs bug.
> 
> Steps to reproduce:
> 
> https://list.orgmode.org/[email-masked]/T/#u
> 
> Org mode version is the latest from
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/
> 
> > I ran this:
> > dortmann@ddo-linux:.emacs.d$ emacs -Q --debug-init asdf.el
> > ... and then ran eval-buffer.
> > 
> > Where asdf.el has this content:
> > (add-to-list 'load-path "/home/dortmann/src/git-org-mode/lisp")
> > (require 'org)
> > 
> > (setq org-capture-templates
> >        `(("c" "Item to current clocked task" checkitem
> >         (clock)
> >         "%i%?" :prepend t :empty-lines 1)))
> > 
> > Then I loaded asdf.org which has this:
> > * TODO start clock on this test item
> 
> > These two lines are in my *Messages* buffer:
> > File mode specification error: (void-function org-element-cache-reset)
> > Error during redisplay: (jit-lock-function 1) signaled (void-variable 
> > org-element-citation-prefix-re)

Would it be possible to have more info about the details?  Like what
are org-element-cache-reset and org-element-citation-prefix-re, and
how do they enter the picture in the above scenario?

TIA