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

Previous Next

Package: emacs;

Reported by: Ihor Radchenko <yantar92 <at> gmail.com>

Date: Wed, 21 Sep 2022 08:34:01 UTC

Severity: normal

Found in version 29.0.50

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 57972 in the body.
You can then email your comments to 57972 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#57972; Package emacs. (Wed, 21 Sep 2022 08:34:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Ihor Radchenko <yantar92 <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 21 Sep 2022 08:34:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Ihor Radchenko <yantar92 <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 29.0.50; Autoloaded function raises (void-function
 org-element-cache-reset) when called within major-mode body
Date: Wed, 21 Sep 2022 16:33:39 +0800
Hi,

I am forwarding a bug report from Org mode.
https://list.orgmode.org/4a9d4298-4af6-3e11-63c3-87bf7125f61b <at> oracle.com/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/4a9d4298-4af6-3e11-63c3-87bf7125f61b <at> oracle.com/T/#u

Org mode version is the latest from
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/

> I ran this:
> dortmann <at> 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)

In GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
 3.24.34, cairo version 1.16.0) of 2022-09-07 built on localhost
Repository revision: 473313d2a85a7ae73daf5cc7c205f6285286eecf
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101004
System Description: Gentoo Linux

-- 
Ihor Radchenko,
Org mode contributor,
Learn more about Org mode at https://orgmode.org/.
Support Org development at https://liberapay.com/org-mode,
or support my work at https://liberapay.com/yantar92




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57972; Package emacs. (Wed, 21 Sep 2022 11:37:02 GMT) Full text and rfc822 format available.

Message #8 received at 57972 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Ihor Radchenko <yantar92 <at> gmail.com>
Cc: 57972 <at> debbugs.gnu.org
Subject: Re: bug#57972: 29.0.50;
 Autoloaded function raises (void-function org-element-cache-reset)
 when called within major-mode body
Date: Wed, 21 Sep 2022 14:35:56 +0300
> From: Ihor Radchenko <yantar92 <at> gmail.com>
> Date: Wed, 21 Sep 2022 16:33:39 +0800
> 
> I am forwarding a bug report from Org mode.
> https://list.orgmode.org/4a9d4298-4af6-3e11-63c3-87bf7125f61b <at> oracle.com/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/4a9d4298-4af6-3e11-63c3-87bf7125f61b <at> oracle.com/T/#u
> 
> Org mode version is the latest from
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/
> 
> > I ran this:
> > dortmann <at> 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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57972; Package emacs. (Wed, 21 Sep 2022 11:42:02 GMT) Full text and rfc822 format available.

Message #11 received at 57972 <at> debbugs.gnu.org (full text, mbox):

From: Ihor Radchenko <yantar92 <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 57972 <at> debbugs.gnu.org
Subject: Re: bug#57972: 29.0.50; Autoloaded function raises (void-function
 org-element-cache-reset) when called within major-mode body
Date: Wed, 21 Sep 2022 19:41:46 +0800
Eli Zaretskii <eliz <at> gnu.org> writes:

> 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?

Let's forget about org-element-citation-prefix-re for now.

org-element-cache-reset is an autoloaded function defined inside
org-element.el

Major mode body `org-mode' from org.el is calling
`org-element-cache-reset' as part of Org mode loading.

org.el does not contain (require 'org-element).
Instead, it is assumed that `org-element-cache-reset' is autoloaded by
Emacs.

Let me know if something is not clear or if you need more detailed
steps.

-- 
Ihor Radchenko,
Org mode contributor,
Learn more about Org mode at https://orgmode.org/.
Support Org development at https://liberapay.com/org-mode,
or support my work at https://liberapay.com/yantar92




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57972; Package emacs. (Wed, 21 Sep 2022 11:56:02 GMT) Full text and rfc822 format available.

Message #14 received at 57972 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Ihor Radchenko <yantar92 <at> gmail.com>
Cc: 57972 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#57972: 29.0.50; Autoloaded function raises (void-function
 org-element-cache-reset) when called within major-mode body
Date: Wed, 21 Sep 2022 13:55:40 +0200
Ihor Radchenko <yantar92 <at> gmail.com> writes:

> Let's forget about org-element-citation-prefix-re for now.
>
> org-element-cache-reset is an autoloaded function defined inside
> org-element.el
>
> Major mode body `org-mode' from org.el is calling
> `org-element-cache-reset' as part of Org mode loading.
>
> org.el does not contain (require 'org-element).
> Instead, it is assumed that `org-element-cache-reset' is autoloaded by
> Emacs.
>
> Let me know if something is not clear or if you need more detailed
> steps.

I'm not at all sure I understand myself.  A backtrace here would be
helpful.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57972; Package emacs. (Wed, 21 Sep 2022 12:09:02 GMT) Full text and rfc822 format available.

Message #17 received at 57972 <at> debbugs.gnu.org (full text, mbox):

From: Ihor Radchenko <yantar92 <at> gmail.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 57972 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#57972: 29.0.50; Autoloaded function raises (void-function
 org-element-cache-reset) when called within major-mode body
Date: Wed, 21 Sep 2022 20:08:44 +0800
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> I'm not at all sure I understand myself.  A backtrace here would be
> helpful.

Debugger entered--entering a function:
* message("File mode specification error: %s" (void-function org-element-cache-reset))
  normal-mode(t)
  after-find-file(nil t)
  find-file-noselect-1(#<buffer bug.org> "/tmp/bug.org" nil nil "/tmp/bug.org" (127741036 26))
  find-file-noselect("/tmp/bug.org" nil nil t)
  find-file("/tmp/bug.org" t)
  funcall-interactively(find-file "/tmp/bug.org" t)
  command-execute(find-file)

I generated the backtrace using M-x debug-on-entry org-mode and opening
bug.org. The backtrace appears at the moment I try to step through
org-element-cache-reset call inside org-mode.

-- 
Ihor Radchenko,
Org mode contributor,
Learn more about Org mode at https://orgmode.org/.
Support Org development at https://liberapay.com/org-mode,
or support my work at https://liberapay.com/yantar92




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57972; Package emacs. (Wed, 21 Sep 2022 12:19:01 GMT) Full text and rfc822 format available.

Message #20 received at 57972 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Ihor Radchenko <yantar92 <at> gmail.com>
Cc: 57972 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#57972: 29.0.50; Autoloaded function raises (void-function
 org-element-cache-reset) when called within major-mode body
Date: Wed, 21 Sep 2022 14:17:48 +0200
Ihor Radchenko <yantar92 <at> gmail.com> writes:

>> I'm not at all sure I understand myself.  A backtrace here would be
>> helpful.
>
> Debugger entered--entering a function:
> * message("File mode specification error: %s" (void-function
> org-element-cache-reset))
>   normal-mode(t)
>   after-find-file(nil t)
>   find-file-noselect-1(#<buffer bug.org> "/tmp/bug.org" nil nil
> "/tmp/bug.org" (127741036 26))
>   find-file-noselect("/tmp/bug.org" nil nil t)
>   find-file("/tmp/bug.org" t)
>   funcall-interactively(find-file "/tmp/bug.org" t)
>   command-execute(find-file)
>
> I generated the backtrace using M-x debug-on-entry org-mode and opening
> bug.org. The backtrace appears at the moment I try to step through
> org-element-cache-reset call inside org-mode.

You have some confusing stuff in org.el -- you have a

(declare-function org-element-cache-reset "org-element" (&optional all))

to suppress warnings in org.el about that function, but
org-element-cache-reset should be in org-loaddefs, which org.el loads
already, so it should be unnecessary.

If it isn't unnecessary, then something else is going wrong somewhere,
I'd have thought?  But I haven't tried debugging further.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57972; Package emacs. (Wed, 21 Sep 2022 12:32:01 GMT) Full text and rfc822 format available.

Message #23 received at 57972 <at> debbugs.gnu.org (full text, mbox):

From: Ihor Radchenko <yantar92 <at> gmail.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 57972 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#57972: 29.0.50; Autoloaded function raises (void-function
 org-element-cache-reset) when called within major-mode body
Date: Wed, 21 Sep 2022 20:32:10 +0800
[Message part 1 (text/plain, inline)]
>
> > You have some confusing stuff in org.el -- you have a
>
> > (declare-function org-element-cache-reset "org-element" (&optional all))
>
> > to suppress warnings in org.el about that function, but
> > org-element-cache-reset should be in org-loaddefs, which org.el loads
> > already, so it should be unnecessary.


The declare statement is there for a single reason---to pacify native-comp
warnings.

 If it isn't unnecessary, then something else is going wrong somewhere,

> I'd have thought?  But I haven't tried debugging further.
>

I removed the declare statement. The bug persists. Also,
org-element-cache-reset is present in org-loaddefs.el

Best,
Ihor
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57972; Package emacs. (Wed, 21 Sep 2022 12:47:01 GMT) Full text and rfc822 format available.

Message #26 received at 57972 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Ihor Radchenko <yantar92 <at> gmail.com>
Cc: 57972 <at> debbugs.gnu.org
Subject: Re: bug#57972: 29.0.50; Autoloaded function raises (void-function
 org-element-cache-reset) when called within major-mode body
Date: Wed, 21 Sep 2022 15:46:13 +0300
> From: Ihor Radchenko <yantar92 <at> gmail.com>
> Cc: 57972 <at> debbugs.gnu.org
> Date: Wed, 21 Sep 2022 19:41:46 +0800
> 
> Eli Zaretskii <eliz <at> gnu.org> writes:
> 
> > 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?
> 
> Let's forget about org-element-citation-prefix-re for now.
> 
> org-element-cache-reset is an autoloaded function defined inside
> org-element.el
> 
> Major mode body `org-mode' from org.el is calling
> `org-element-cache-reset' as part of Org mode loading.
> 
> org.el does not contain (require 'org-element).
> Instead, it is assumed that `org-element-cache-reset' is autoloaded by
> Emacs.

org-element-cache-reset's autoload form is in org-loaddefs.el.

The error message reported by the OP, viz.:

  File mode specification error: (void-function org-element-cache-reset)

comes from normal-mode when it calls set-auto-mode.  So something goes
wrong there, perhaps because org-element-cache-reset is called before
org.el loads org-loaddefs.el with this snippet:

  (or (eq this-command 'eval-buffer)
      (condition-case nil
	  (load (concat (file-name-directory load-file-name)
			"org-loaddefs")
		nil t nil t)
	(error
	 (message "WARNING: No org-loaddefs.el file could be found from where org.el is loaded.")
	 (sit-for 3)
	 (message "You need to run \"make\" or \"make autoloads\" from Org lisp directory")
	 (sit-for 3))))

I don't know what goes wrong, because I cannot reproduce the problem
here, if I just visit a (non-existent) foo.org.  After visiting the
file, (fboundp 'org-element-cache-reset) yields t.  So I have questions:

  . does this happen in "emacs -Q"?
  . does org-loaddefs.el exist on load-path, and is it being loaded by
    org.el?
  . could it be that user customizations somehow define file-local
    variables or directory-local variables or something else that
    attempts to use org-element-cache-reset too early?

Alternatively, a complete recipe (without referring to directories
that I definitely don't have here) to reproduce the problem could
answer all those questions succinctly and efficiently.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57972; Package emacs. (Wed, 21 Sep 2022 13:00:02 GMT) Full text and rfc822 format available.

Message #29 received at 57972 <at> debbugs.gnu.org (full text, mbox):

From: Ihor Radchenko <yantar92 <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 57972 <at> debbugs.gnu.org
Subject: Re: bug#57972: 29.0.50; Autoloaded function raises (void-function
 org-element-cache-reset) when called within major-mode body
Date: Wed, 21 Sep 2022 21:00:08 +0800
[Message part 1 (text/plain, inline)]
>
> Alternatively, a complete recipe (without referring to directories
> that I definitely don't have here) to reproduce the problem could
> answer all those questions succinctly and efficiently.
>

Here it is
1. cd /tmp
2. git clone git://git.sv.gnu.org/emacs/org-mode.git
3. cd org-mode
4. make autoloads
5. Create /tmp/bug.el with the following contents:
-----
(add-to-list 'load-path "/tmp/org-mode/lisp")
(require 'org)
-----
6. Create /tmp/bug.org with the following contents:
-----
* TODO start clock on this test item
-----
7. emacs -Q /tmp/bug.el
8. M-x eval-buffer
9. C-x C-f /tmp/bug.org
10. Observe error in echo area

Note that doing emacs -Q -l /tmp/bug.el in step 7 does _not_ trigger the
error.

Best,
Ihor
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57972; Package emacs. (Wed, 21 Sep 2022 13:15:03 GMT) Full text and rfc822 format available.

Message #32 received at 57972 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Ihor Radchenko <yantar92 <at> gmail.com>
Cc: 57972 <at> debbugs.gnu.org
Subject: Re: bug#57972: 29.0.50; Autoloaded function raises (void-function
 org-element-cache-reset) when called within major-mode body
Date: Wed, 21 Sep 2022 16:14:37 +0300
> From: Ihor Radchenko <yantar92 <at> gmail.com>
> Date: Wed, 21 Sep 2022 21:00:08 +0800
> Cc: 57972 <at> debbugs.gnu.org
> 
>  Alternatively, a complete recipe (without referring to directories
>  that I definitely don't have here) to reproduce the problem could
>  answer all those questions succinctly and efficiently.
> 
> Here it is
> 1. cd /tmp
> 2. git clone git://git.sv.gnu.org/emacs/org-mode.git

So reproducing this requires the development version of Org?

> 3. cd org-mode
> 4. make autoloads
> 5. Create /tmp/bug.el with the following contents:
> -----
> (add-to-list 'load-path "/tmp/org-mode/lisp")
> (require 'org)
> -----
> 6. Create /tmp/bug.org with the following contents:
> -----
> * TODO start clock on this test item
> -----
> 7. emacs -Q /tmp/bug.el
> 8. M-x eval-buffer
> 9. C-x C-f /tmp/bug.org
> 10. Observe error in echo area

I cannot reproduce with the version of Org we have on the Emacs
master branch.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57972; Package emacs. (Wed, 21 Sep 2022 13:19:02 GMT) Full text and rfc822 format available.

Message #35 received at 57972 <at> debbugs.gnu.org (full text, mbox):

From: Ihor Radchenko <yantar92 <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 57972 <at> debbugs.gnu.org
Subject: Re: bug#57972: 29.0.50; Autoloaded function raises (void-function
 org-element-cache-reset) when called within major-mode body
Date: Wed, 21 Sep 2022 21:19:26 +0800
[Message part 1 (text/plain, inline)]
>
> So reproducing this requires the development version of Org?
>

Yes.


> I cannot reproduce with the version of Org we have on the Emacs
> master branch.
>

I cannot reproduce on stable branch either. Only on main.

Best,
Ihor
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57972; Package emacs. (Wed, 21 Sep 2022 14:05:02 GMT) Full text and rfc822 format available.

Message #38 received at 57972 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Ihor Radchenko <yantar92 <at> gmail.com>
Cc: 57972 <at> debbugs.gnu.org
Subject: Re: bug#57972: 29.0.50; Autoloaded function raises (void-function
 org-element-cache-reset) when called within major-mode body
Date: Wed, 21 Sep 2022 17:04:50 +0300
> From: Ihor Radchenko <yantar92 <at> gmail.com>
> Date: Wed, 21 Sep 2022 21:19:26 +0800
> Cc: 57972 <at> debbugs.gnu.org
> 
>  So reproducing this requires the development version of Org?
> 
> Yes.
>  
>  I cannot reproduce with the version of Org we have on the Emacs
>  master branch.
> 
>  
> I cannot reproduce on stable branch either. Only on main.

Then why do you think this is a problem in the core?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57972; Package emacs. (Wed, 21 Sep 2022 14:10:02 GMT) Full text and rfc822 format available.

Message #41 received at 57972 <at> debbugs.gnu.org (full text, mbox):

From: Ihor Radchenko <yantar92 <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 57972 <at> debbugs.gnu.org
Subject: Re: bug#57972: 29.0.50; Autoloaded function raises (void-function
 org-element-cache-reset) when called within major-mode body
Date: Wed, 21 Sep 2022 22:10:24 +0800
[Message part 1 (text/plain, inline)]
> > I cannot reproduce on stable branch either. Only on main.
>
> Then why do you think this is a problem in the core?
>

As I said in my first message, I either misunderstand something about
autoload or it is some kind of
Emacs bug.

Note that doing emacs -Q -l /tmp/bug.el vs emacs -Q /tmp/bug.el +
eval-buffer yields different results.
I cannot possibly see how it can be anything to do with Org and I have no
clue how to approach debugging this.

Best,
Ihor
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57972; Package emacs. (Wed, 21 Sep 2022 14:28:02 GMT) Full text and rfc822 format available.

Message #44 received at 57972 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Ihor Radchenko <yantar92 <at> gmail.com>
Cc: 57972 <at> debbugs.gnu.org
Subject: Re: bug#57972: 29.0.50; Autoloaded function raises (void-function
 org-element-cache-reset) when called within major-mode body
Date: Wed, 21 Sep 2022 17:27:12 +0300
> From: Ihor Radchenko <yantar92 <at> gmail.com>
> Date: Wed, 21 Sep 2022 22:10:24 +0800
> Cc: 57972 <at> debbugs.gnu.org
> 
>  > I cannot reproduce on stable branch either. Only on main.
> 
>  Then why do you think this is a problem in the core?
> 
> As I said in my first message, I either misunderstand something about autoload or it is some kind of
> Emacs bug. 
> 
> Note that doing emacs -Q -l /tmp/bug.el vs emacs -Q /tmp/bug.el + eval-buffer yields different results.
> I cannot possibly see how it can be anything to do with Org and I have no clue how to approach debugging
> this.

Fair enough.

Would it help to make the backtrace more detailed?  Right now, we
don't see anything between the call to normal-mode and the error.  If
you manually "M-x load-file RET files.el RET" before doing
eval-buffer, do you get a more detailed backtrace?

And another thing: do you have any clue (or maybe more than a clue)
what changes in Org wrt what's on the Emacs master branch could have
caused this?  If you do, can you show those changes, or point to the
specific places in Org files where those changes can be eye-balled?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57972; Package emacs. (Wed, 21 Sep 2022 14:51:02 GMT) Full text and rfc822 format available.

Message #47 received at 57972 <at> debbugs.gnu.org (full text, mbox):

From: Ihor Radchenko <yantar92 <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 57972 <at> debbugs.gnu.org
Subject: Re: bug#57972: 29.0.50; Autoloaded function raises (void-function
 org-element-cache-reset) when called within major-mode body
Date: Wed, 21 Sep 2022 22:51:16 +0800
[Message part 1 (text/plain, inline)]
>
> And another thing: do you have any clue (or maybe more than a clue)
> what changes in Org wrt what's on the Emacs master branch could have
> caused this?  If you do, can you show those changes, or point to the
> specific places in Org files where those changes can be eye-balled?


I bisected Org repo and found the first bad commit. Unfortunately, it is
not very useful.

The commit changed the order function calls in org-mode. Before the commit,
`org-setup-filling' got called prior to `org-element-cache-reset' and
 `org-setup-filling' has an explicit (require 'org-element) statement, which
  made autoloading unnecessary in the past.

Would it help to make the backtrace more detailed?  Right now, we
> don't see anything between the call to normal-mode and the error.  If
> you manually "M-x load-file RET files.el RET" before doing
> eval-buffer, do you get a more detailed backtrace?
>
>
Doing load-file made no difference.
I can generate an alternative backtrace using debug-on-entry org-mode.
The debug buffer right before error is below

Debugger entered--beginning evaluation of function call form:
* (org-element-cache-reset)
* (let ((delay-mode-hooks t)) (outline-mode) (setq major-mode 'org-mode)
(setq mode-name "Org") (progn (if (get 'outline-mode 'mode-class) (put
'org-mode 'mode-class (get 'outline-mode 'mode-class))) (if (keymap-parent
org-mode-map) nil (set-keymap-parent org-mode-map (current-local-map)))
(let ((parent (char-table-parent org-mode-syntax-table))) (if (and parent
(not (eq parent (standard-syntax-table)))) nil (set-char-table-parent
org-mode-syntax-table (syntax-table)))) (if (or (abbrev-table-get
org-mode-abbrev-table :parents) (eq org-mode-abbrev-table
local-abbrev-table)) nil (abbrev-table-put org-mode-abbrev-table :parents
(list local-abbrev-table)))) (use-local-map org-mode-map) (set-syntax-table
org-mode-syntax-table) (setq local-abbrev-table org-mode-abbrev-table) (set
(make-local-variable 'org-mode-loading) t) (org-load-modules-maybe) (if
org-agenda-file-menu-enabled (progn (org-install-agenda-files-menu))) (if
(and org-link-descriptive (eq org-fold-core-style 'overlays)) (progn
(add-to-invisibility-spec '(org-link)))) (org-fold-initialize (or (and
(stringp org-ellipsis) (not (equal "" org-ellipsis)) org-ellipsis) "..."))
(make-local-variable 'org-link-descriptive) (if (eq org-fold-core-style
'overlays) (progn (add-to-invisibility-spec '(org-hide-block . t)))) (if
org-link-descriptive (org-fold-core-set-folding-spec-property (car
org-link--link-folding-spec) :visible nil)
(org-fold-core-set-folding-spec-property (car org-link--link-folding-spec)
:visible t)) (set (make-local-variable 'outline-regexp) org-outline-regexp)
(set (make-local-variable 'outline-level) 'org-outline-level) (if (and
(stringp org-ellipsis) (not (equal "" org-ellipsis))) (progn (if
org-display-table nil (setq org-display-table (make-display-table)))
(set-display-table-slot org-display-table 4 (vconcat (mapcar #'(lambda ...
...) org-ellipsis))) (setq buffer-display-table org-display-table)))
(org-set-regexps-and-options) (org-set-font-lock-defaults) (if (and
org-tag-faces (not org-tags-special-faces-re)) (progn (org-set-tag-faces
'org-tag-faces org-tag-faces))) (set (make-local-variable
'calc-embedded-open-mode) "# ") (modify-syntax-entry 34 "\"")
(modify-syntax-entry 92 "_") (modify-syntax-entry 126 "_")
(modify-syntax-entry 60 "(>") (modify-syntax-entry 62 ")<") (set
(make-local-variable 'font-lock-unfontify-region-function)
'org-unfontify-region) (set (make-local-variable
'org-table-may-need-update) t) (add-hook 'before-change-functions
'org-before-change-function nil 'local) (add-hook 'kill-buffer-hook
'org-check-running-clock nil 'local) (org-element-cache-reset) (if (and
org-element-cache-persistent org-element-use-cache) (progn
(org-persist-load 'org-element--cache (current-buffer) t)))
(org-macro-initialize-templates) (org-update-radio-target-regexp) (set
(make-local-variable 'indent-line-function) 'org-indent-line) (set
(make-local-variable 'indent-region-function) 'org-indent-region)
(org-setup-filling) (org-setup-comments-handling) (set (make-local-variable
'beginning-of-defun-function) 'org-backward-element) (set
(make-local-variable 'end-of-defun-function) #'(lambda nil (if (not
(org-at-heading-p)) (org-forward-element) (org-forward-element)
(forward-char -1)))) (set (make-local-variable 'next-error-function)
'org-occur-next-match) (set (make-local-variable
'add-log-current-defun-function) #'org-add-log-current-headline) (if
org-enforce-todo-dependencies (add-hook 'org-blocker-hook
'org-block-todo-from-children-or-siblings-or-parent) (remove-hook
'org-blocker-hook 'org-block-todo-from-children-or-siblings-or-parent)) (if
org-enforce-todo-checkbox-dependencies (add-hook 'org-blocker-hook
'org-block-todo-from-checkboxes) (remove-hook 'org-blocker-hook
'org-block-todo-from-checkboxes)) (set (make-local-variable
'align-mode-rules-list) '((org-in-buffer-settings (regexp . "^[
\11]*#\\+[A-Z_]+:\\(\\s-*\\)\\S-+") (modes quote (org-mode))))) (set
(make-local-variable 'pcomplete-command-completion-function)
#'org-pcomplete-initial) (set (make-local-variable
'pcomplete-command-name-function) #'org-command-at-point) ...)
* (progn (make-local-variable 'delay-mode-hooks) (let ((delay-mode-hooks
t)) (outline-mode) (setq major-mode 'org-mode) (setq mode-name "Org")
(progn (if (get 'outline-mode 'mode-class) (put 'org-mode 'mode-class (get
'outline-mode 'mode-class))) (if (keymap-parent org-mode-map) nil
(set-keymap-parent org-mode-map (current-local-map))) (let ((parent
(char-table-parent org-mode-syntax-table))) (if (and parent (not (eq parent
...))) nil (set-char-table-parent org-mode-syntax-table (syntax-table))))
(if (or (abbrev-table-get org-mode-abbrev-table :parents) (eq
org-mode-abbrev-table local-abbrev-table)) nil (abbrev-table-put
org-mode-abbrev-table :parents (list local-abbrev-table)))) (use-local-map
org-mode-map) (set-syntax-table org-mode-syntax-table) (setq
local-abbrev-table org-mode-abbrev-table) (set (make-local-variable
'org-mode-loading) t) (org-load-modules-maybe) (if
org-agenda-file-menu-enabled (progn (org-install-agenda-files-menu))) (if
(and org-link-descriptive (eq org-fold-core-style 'overlays)) (progn
(add-to-invisibility-spec '(org-link)))) (org-fold-initialize (or (and
(stringp org-ellipsis) (not (equal "" org-ellipsis)) org-ellipsis) "..."))
(make-local-variable 'org-link-descriptive) (if (eq org-fold-core-style
'overlays) (progn (add-to-invisibility-spec '(org-hide-block . t)))) (if
org-link-descriptive (org-fold-core-set-folding-spec-property (car
org-link--link-folding-spec) :visible nil)
(org-fold-core-set-folding-spec-property (car org-link--link-folding-spec)
:visible t)) (set (make-local-variable 'outline-regexp) org-outline-regexp)
(set (make-local-variable 'outline-level) 'org-outline-level) (if (and
(stringp org-ellipsis) (not (equal "" org-ellipsis))) (progn (if
org-display-table nil (setq org-display-table (make-display-table)))
(set-display-table-slot org-display-table 4 (vconcat (mapcar #'...
org-ellipsis))) (setq buffer-display-table org-display-table)))
(org-set-regexps-and-options) (org-set-font-lock-defaults) (if (and
org-tag-faces (not org-tags-special-faces-re)) (progn (org-set-tag-faces
'org-tag-faces org-tag-faces))) (set (make-local-variable
'calc-embedded-open-mode) "# ") (modify-syntax-entry 34 "\"")
(modify-syntax-entry 92 "_") (modify-syntax-entry 126 "_")
(modify-syntax-entry 60 "(>") (modify-syntax-entry 62 ")<") (set
(make-local-variable 'font-lock-unfontify-region-function)
'org-unfontify-region) (set (make-local-variable
'org-table-may-need-update) t) (add-hook 'before-change-functions
'org-before-change-function nil 'local) (add-hook 'kill-buffer-hook
'org-check-running-clock nil 'local) (org-element-cache-reset) (if (and
org-element-cache-persistent org-element-use-cache) (progn
(org-persist-load 'org-element--cache (current-buffer) t)))
(org-macro-initialize-templates) (org-update-radio-target-regexp) (set
(make-local-variable 'indent-line-function) 'org-indent-line) (set
(make-local-variable 'indent-region-function) 'org-indent-region)
(org-setup-filling) (org-setup-comments-handling) (set (make-local-variable
'beginning-of-defun-function) 'org-backward-element) (set
(make-local-variable 'end-of-defun-function) #'(lambda nil (if (not
(org-at-heading-p)) (org-forward-element) (org-forward-element)
(forward-char -1)))) (set (make-local-variable 'next-error-function)
'org-occur-next-match) (set (make-local-variable
'add-log-current-defun-function) #'org-add-log-current-headline) (if
org-enforce-todo-dependencies (add-hook 'org-blocker-hook
'org-block-todo-from-children-or-siblings-or-parent) (remove-hook
'org-blocker-hook 'org-block-todo-from-children-or-siblings-or-parent)) (if
org-enforce-todo-checkbox-dependencies (add-hook 'org-blocker-hook
'org-block-todo-from-checkboxes) (remove-hook 'org-blocker-hook
'org-block-todo-from-checkboxes)) (set (make-local-variable
'align-mode-rules-list) '((org-in-buffer-settings (regexp . "^[
\11]*#\\+[A-Z_]+:\\(\\s-*\\)\\S-+") (modes quote (org-mode))))) (set
(make-local-variable 'pcomplete-command-completion-function)
#'org-pcomplete-initial) (set (make-local-variable
'pcomplete-command-name-function) #'org-command-at-point) ...))
* (closure (org-mode-abbrev-table org-mode-syntax-table
org-element-use-cache org-element-cache-persistent buffer-face-mode-face
org-tbl-menu org-org-menu org-struct-menu org-entities org-last-state
org-id-track-globally org-clock-start-time texmathp-why remember-data-file
org-agenda-tags-todo-honor-ignore-options iswitchb-temp-buflist
calc-embedded-open-mode calc-embedded-open-formula
calc-embedded-close-formula align-mode-rules-list org-emphasis-alist
org-emphasis-regexp-components org-export-registered-backends org-modules
crm-separator org-babel-load-languages org-id-overriding-file-name
org-indent-indentation-per-level org-element--timestamp-regexp
org-element-cache-map-continue-from org-element-paragraph-separate
org-agenda-buffer-name org-inlinetask-min-level t) nil "Outline-based notes
management and organizer, alia..." (interactive) (progn
(make-local-variable 'delay-mode-hooks) (let ((delay-mode-hooks t))
(outline-mode) (setq major-mode 'org-mode) (setq mode-name "Org") (progn
(if (get 'outline-mode 'mode-class) (put 'org-mode 'mode-class (get
'outline-mode 'mode-class))) (if (keymap-parent org-mode-map) nil
(set-keymap-parent org-mode-map (current-local-map))) (let ((parent
(char-table-parent org-mode-syntax-table))) (if (and parent (not ...)) nil
(set-char-table-parent org-mode-syntax-table (syntax-table)))) (if (or
(abbrev-table-get org-mode-abbrev-table :parents) (eq org-mode-abbrev-table
local-abbrev-table)) nil (abbrev-table-put org-mode-abbrev-table :parents
(list local-abbrev-table)))) (use-local-map org-mode-map) (set-syntax-table
org-mode-syntax-table) (setq local-abbrev-table org-mode-abbrev-table) (set
(make-local-variable 'org-mode-loading) t) (org-load-modules-maybe) (if
org-agenda-file-menu-enabled (progn (org-install-agenda-files-menu))) (if
(and org-link-descriptive (eq org-fold-core-style 'overlays)) (progn
(add-to-invisibility-spec '(org-link)))) (org-fold-initialize (or (and
(stringp org-ellipsis) (not (equal "" org-ellipsis)) org-ellipsis) "..."))
(make-local-variable 'org-link-descriptive) (if (eq org-fold-core-style
'overlays) (progn (add-to-invisibility-spec '(org-hide-block . t)))) (if
org-link-descriptive (org-fold-core-set-folding-spec-property (car
org-link--link-folding-spec) :visible nil)
(org-fold-core-set-folding-spec-property (car org-link--link-folding-spec)
:visible t)) (set (make-local-variable 'outline-regexp) org-outline-regexp)
(set (make-local-variable 'outline-level) 'org-outline-level) (if (and
(stringp org-ellipsis) (not (equal "" org-ellipsis))) (progn (if
org-display-table nil (setq org-display-table (make-display-table)))
(set-display-table-slot org-display-table 4 (vconcat (mapcar ...
org-ellipsis))) (setq buffer-display-table org-display-table)))
(org-set-regexps-and-options) (org-set-font-lock-defaults) (if (and
org-tag-faces (not org-tags-special-faces-re)) (progn (org-set-tag-faces
'org-tag-faces org-tag-faces))) (set (make-local-variable
'calc-embedded-open-mode) "# ") (modify-syntax-entry 34 "\"")
(modify-syntax-entry 92 "_") (modify-syntax-entry 126 "_")
(modify-syntax-entry 60 "(>") (modify-syntax-entry 62 ")<") (set
(make-local-variable 'font-lock-unfontify-region-function)
'org-unfontify-region) (set (make-local-variable
'org-table-may-need-update) t) (add-hook 'before-change-functions
'org-before-change-function nil 'local) (add-hook 'kill-buffer-hook
'org-check-running-clock nil 'local) (org-element-cache-reset) (if (and
org-element-cache-persistent org-element-use-cache) (progn
(org-persist-load 'org-element--cache (current-buffer) t)))
(org-macro-initialize-templates) (org-update-radio-target-regexp) (set
(make-local-variable 'indent-line-function) 'org-indent-line) (set
(make-local-variable 'indent-region-function) 'org-indent-region)
(org-setup-filling) (org-setup-comments-handling) (set (make-local-variable
'beginning-of-defun-function) 'org-backward-element) (set
(make-local-variable 'end-of-defun-function) #'(lambda nil (if (not ...)
(org-forward-element) (org-forward-element) (forward-char -1)))) (set
(make-local-variable 'next-error-function) 'org-occur-next-match) (set
(make-local-variable 'add-log-current-defun-function)
#'org-add-log-current-headline) (if org-enforce-todo-dependencies (add-hook
'org-blocker-hook 'org-block-todo-from-children-or-siblings-or-parent)
(remove-hook 'org-blocker-hook
'org-block-todo-from-children-or-siblings-or-parent)) (if
org-enforce-todo-checkbox-dependencies (add-hook 'org-blocker-hook
'org-block-todo-from-checkboxes) (remove-hook 'org-blocker-hook
'org-block-todo-from-checkboxes)) (set (make-local-variable
'align-mode-rules-list) '((org-in-buffer-settings (regexp . "^[
\11]*#\\+[A-Z_]+:\\(\\s-*\\)\\S-+") (modes quote ...)))) (set
(make-local-variable 'pcomplete-command-completion-function)
#'org-pcomplete-initial) (set (make-local-variable
'pcomplete-command-name-function) #'org-command-at-point) ...))
(run-mode-hooks 'org-mode-hook))()
* apply((closure (org-mode-abbrev-table org-mode-syntax-table
org-element-use-cache org-element-cache-persistent buffer-face-mode-face
org-tbl-menu org-org-menu org-struct-menu org-entities org-last-state
org-id-track-globally org-clock-start-time texmathp-why remember-data-file
org-agenda-tags-todo-honor-ignore-options iswitchb-temp-buflist
calc-embedded-open-mode calc-embedded-open-formula
calc-embedded-close-formula align-mode-rules-list org-emphasis-alist
org-emphasis-regexp-components org-export-registered-backends org-modules
crm-separator org-babel-load-languages org-id-overriding-file-name
org-indent-indentation-per-level org-element--timestamp-regexp
org-element-cache-map-continue-from org-element-paragraph-separate
org-agenda-buffer-name org-inlinetask-min-level t) nil "Outline-based notes
management and organizer, alia..." (interactive) (progn
(make-local-variable 'delay-mode-hooks) (let ((delay-mode-hooks t))
(outline-mode) (setq major-mode 'org-mode) (setq mode-name "Org") (progn
(if (get 'outline-mode 'mode-class) (put 'org-mode 'mode-class (get ...
...))) (if (keymap-parent org-mode-map) nil (set-keymap-parent org-mode-map
(current-local-map))) (let ((parent ...)) (if (and parent ...) nil
(set-char-table-parent org-mode-syntax-table ...))) (if (or
(abbrev-table-get org-mode-abbrev-table :parents) (eq org-mode-abbrev-table
local-abbrev-table)) nil (abbrev-table-put org-mode-abbrev-table :parents
(list local-abbrev-table)))) (use-local-map org-mode-map) (set-syntax-table
org-mode-syntax-table) (setq local-abbrev-table org-mode-abbrev-table) (set
(make-local-variable 'org-mode-loading) t) (org-load-modules-maybe) (if
org-agenda-file-menu-enabled (progn (org-install-agenda-files-menu))) (if
(and org-link-descriptive (eq org-fold-core-style 'overlays)) (progn
(add-to-invisibility-spec '...))) (org-fold-initialize (or (and (stringp
org-ellipsis) (not ...) org-ellipsis) "...")) (make-local-variable
'org-link-descriptive) (if (eq org-fold-core-style 'overlays) (progn
(add-to-invisibility-spec '...))) (if org-link-descriptive
(org-fold-core-set-folding-spec-property (car org-link--link-folding-spec)
:visible nil) (org-fold-core-set-folding-spec-property (car
org-link--link-folding-spec) :visible t)) (set (make-local-variable
'outline-regexp) org-outline-regexp) (set (make-local-variable
'outline-level) 'org-outline-level) (if (and (stringp org-ellipsis) (not
(equal "" org-ellipsis))) (progn (if org-display-table nil (setq
org-display-table ...)) (set-display-table-slot org-display-table 4
(vconcat ...)) (setq buffer-display-table org-display-table)))
(org-set-regexps-and-options) (org-set-font-lock-defaults) (if (and
org-tag-faces (not org-tags-special-faces-re)) (progn (org-set-tag-faces
'org-tag-faces org-tag-faces))) (set (make-local-variable
'calc-embedded-open-mode) "# ") (modify-syntax-entry 34 "\"")
(modify-syntax-entry 92 "_") (modify-syntax-entry 126 "_")
(modify-syntax-entry 60 "(>") (modify-syntax-entry 62 ")<") (set
(make-local-variable 'font-lock-unfontify-region-function)
'org-unfontify-region) (set (make-local-variable
'org-table-may-need-update) t) (add-hook 'before-change-functions
'org-before-change-function nil 'local) (add-hook 'kill-buffer-hook
'org-check-running-clock nil 'local) (org-element-cache-reset) (if (and
org-element-cache-persistent org-element-use-cache) (progn
(org-persist-load 'org-element--cache (current-buffer) t)))
(org-macro-initialize-templates) (org-update-radio-target-regexp) (set
(make-local-variable 'indent-line-function) 'org-indent-line) (set
(make-local-variable 'indent-region-function) 'org-indent-region)
(org-setup-filling) (org-setup-comments-handling) (set (make-local-variable
'beginning-of-defun-function) 'org-backward-element) (set
(make-local-variable 'end-of-defun-function) #'(lambda nil (if ... ... ...
...))) (set (make-local-variable 'next-error-function)
'org-occur-next-match) (set (make-local-variable
'add-log-current-defun-function) #'org-add-log-current-headline) (if
org-enforce-todo-dependencies (add-hook 'org-blocker-hook
'org-block-todo-from-children-or-siblings-or-parent) (remove-hook
'org-blocker-hook 'org-block-todo-from-children-or-siblings-or-parent)) (if
org-enforce-todo-checkbox-dependencies (add-hook 'org-blocker-hook
'org-block-todo-from-checkboxes) (remove-hook 'org-blocker-hook
'org-block-todo-from-checkboxes)) (set (make-local-variable
'align-mode-rules-list) '((org-in-buffer-settings ... ...))) (set
(make-local-variable 'pcomplete-command-completion-function)
#'org-pcomplete-initial) (set (make-local-variable
'pcomplete-command-name-function) #'org-command-at-point) ...))
(run-mode-hooks 'org-mode-hook)) nil)
* org-mode()
  funcall(org-mode)
  (progn (funcall mode) mode)
  (if mode (progn (funcall mode) mode))
  (if (and keep-mode-if-same (eq (indirect-function mode)
(indirect-function major-mode))) nil (if mode (progn (funcall mode) mode)))
  set-auto-mode-0(org-mode nil)
  (progn (set-auto-mode-0 mode keep-mode-if-same) t)
  (if mode (progn (set-auto-mode-0 mode keep-mode-if-same) t))
  (let (mode (name buffer-file-name) (remote-id (file-remote-p
buffer-file-name)) (case-insensitive-p (file-name-case-insensitive-p
buffer-file-name))) (setq name (file-name-sans-versions name)) (if (and
(stringp remote-id) (string-match (regexp-quote remote-id) name)) (progn
(setq name (substring name (match-end 0))))) (while name (setq mode (if
case-insensitive-p (let ((case-fold-search t)) (assoc-default name alist
'string-match)) (or (let ((case-fold-search nil)) (assoc-default name alist
'string-match)) (and auto-mode-case-fold (let (...) (assoc-default name
alist ...)))))) (if (and mode (not (functionp mode)) (consp mode) (car (cdr
mode))) (progn (setq mode (car mode)) (setq name (substring name 0
(match-beginning 0)))) (setq name nil))) (if (and dir-local mode (not
(set-auto-mode--dir-local-valid-p mode))) (progn (message "Ignoring invalid
mode `%s'" mode) (setq mode nil))) (if mode (progn (set-auto-mode-0 mode
keep-mode-if-same) t)))
  (if buffer-file-name (let (mode (name buffer-file-name) (remote-id
(file-remote-p buffer-file-name)) (case-insensitive-p
(file-name-case-insensitive-p buffer-file-name))) (setq name
(file-name-sans-versions name)) (if (and (stringp remote-id) (string-match
(regexp-quote remote-id) name)) (progn (setq name (substring name
(match-end 0))))) (while name (setq mode (if case-insensitive-p (let
((case-fold-search t)) (assoc-default name alist 'string-match)) (or (let
(...) (assoc-default name alist ...)) (and auto-mode-case-fold (let ...
...))))) (if (and mode (not (functionp mode)) (consp mode) (car (cdr
mode))) (progn (setq mode (car mode)) (setq name (substring name 0
(match-beginning 0)))) (setq name nil))) (if (and dir-local mode (not
(set-auto-mode--dir-local-valid-p mode))) (progn (message "Ignoring invalid
mode `%s'" mode) (setq mode nil))) (if mode (progn (set-auto-mode-0 mode
keep-mode-if-same) t))))
  set-auto-mode--apply-alist((("\\.gpg\\(~\\|\\.~[0-9]+~\\)?\\'" nil
epa-file) ("\\.elc\\'" . elisp-byte-code-mode)
("\\.\\(?:3fr\\|a\\(?:rw\\|vs\\)\\|bmp[23]?\\|c\\(?:als?\\|myk..." .
image-mode) ("\\.zst\\'" nil jka-compr) ("\\.dz\\'" nil jka-compr)
("\\.xz\\'" nil jka-compr) ("\\.lzma\\'" nil jka-compr) ("\\.lz\\'" nil
jka-compr) ("\\.g?z\\'" nil jka-compr) ("\\.bz2\\'" nil jka-compr)
("\\.Z\\'" nil jka-compr) ("\\.vr[hi]?\\'" . vera-mode)
("\\(?:\\.\\(?:rbw?\\|ru\\|rake\\|thor\\|jbuilder\\|rabl\\|ge..." .
ruby-mode) ("\\.re?st\\'" . rst-mode) ("\\.py[iw]?\\'" . python-mode)
("\\.m\\'" . octave-maybe-mode) ("\\.less\\'" . less-css-mode)
("\\.scss\\'" . scss-mode) ("\\.awk\\'" . awk-mode)
("\\.\\(u?lpc\\|pike\\|pmod\\(\\.in\\)?\\)\\'" . pike-mode) ("\\.idl\\'" .
idl-mode) ("\\.java\\'" . java-mode) ("\\.m\\'" . objc-mode) ("\\.ii\\'" .
c++-mode) ("\\.i\\'" . c-mode) ("\\.lex\\'" . c-mode) ("\\.y\\(acc\\)?\\'"
. c-mode) ("\\.h\\'" . c-or-c++-mode) ("\\.c\\'" . c-mode)
("\\.\\(CC?\\|HH?\\)\\'" . c++-mode) ("\\.[ch]\\(pp\\|xx\\|\\+\\+\\)\\'" .
c++-mode) ("\\.\\(cc\\|hh\\)\\'" . c++-mode) ("\\.\\(bat\\|cmd\\)\\'" .
bat-mode) ("\\.[sx]?html?\\(\\.[a-zA-Z_]+\\)?\\'" . mhtml-mode)
("\\.svgz?\\'" . image-mode) ("\\.svgz?\\'" . xml-mode) ("\\.x[bp]m\\'" .
image-mode) ("\\.x[bp]m\\'" . c-mode) ("\\.p[bpgn]m\\'" . image-mode)
("\\.tiff?\\'" . image-mode) ("\\.gif\\'" . image-mode) ("\\.png\\'" .
image-mode) ("\\.jpe?g\\'" . image-mode) ("\\.webp\\'" . image-mode)
("\\.te?xt\\'" . text-mode) ("\\.[tT]e[xX]\\'" . tex-mode) ("\\.ins\\'" .
tex-mode) ("\\.ltx\\'" . latex-mode) ("\\.dtx\\'" . doctex-mode)
("\\.org\\'" . org-mode) ...) nil nil)
  (setq done (set-auto-mode--apply-alist auto-mode-alist keep-mode-if-same
nil))
  (if done nil (setq done (set-auto-mode--apply-alist auto-mode-alist
keep-mode-if-same nil)))
  (let ((try-locals (not (inhibit-local-variables-p))) end done mode modes)
(save-excursion (goto-char (point-min)) (skip-chars-forward " \11\n") (and
enable-local-variables try-locals (setq end (set-auto-mode-1)) (if
(save-excursion (search-forward ":" end t)) (while (let ((case-fold-search
t)) (or (and ... ...) (re-search-forward "[ \11;]mode:" end t)))
(skip-chars-forward " \11") (let ((beg ...)) (if (search-forward ";" end t)
(forward-char -1) (goto-char end)) (skip-chars-backward " \11") (setq modes
(cons ... modes)))) (setq modes (cons (intern (concat ... "-mode"))
modes))))) (if modes (catch 'nop (let ((--dolist-tail-- (nreverse modes)))
(while --dolist-tail-- (let ((mode ...)) (if (not ...) (message "Ignoring
unknown mode `%s'" mode) (setq done t) (or ... ...)) (setq --dolist-tail--
(cdr --dolist-tail--))))))) (if done nil (condition-case err (let*
((mode-alist (cdr (hack-dir-local--get-variables ...)))) (setq done
(set-auto-mode--apply-alist mode-alist keep-mode-if-same t))) ((debug
error) (message "Directory-local variables error: %s" err) nil))) (and (not
done) (setq mode (hack-local-variables t (not try-locals))) (not (memq mode
modes)) (if (not (functionp mode)) (message "Ignoring unknown mode `%s'"
mode) (setq done t) (set-auto-mode-0 mode keep-mode-if-same))) (and (not
done) (setq mode (save-excursion (goto-char (point-min)) (if (looking-at
auto-mode-interpreter-regexp) (match-string 2)))) (setq done (assoc-default
(file-name-nondirectory mode) (mapcar #'(lambda (e) (cons ... ...))
interpreter-mode-alist) #'string-match-p)) (set-auto-mode-0 done
keep-mode-if-same)) (if done nil (if (setq done (save-excursion (goto-char
(point-min)) (save-restriction (narrow-to-region (point-min) (min ... ...))
(assoc-default nil magic-mode-alist #'...)))) (set-auto-mode-0 done
keep-mode-if-same))) (if done nil (setq done (set-auto-mode--apply-alist
auto-mode-alist keep-mode-if-same nil))) (if done nil (if (setq done
(save-excursion (goto-char (point-min)) (save-restriction (narrow-to-region
(point-min) (min ... ...)) (assoc-default nil magic-fallback-mode-alist
#'...)))) (set-auto-mode-0 done keep-mode-if-same))) (if done nil
(set-buffer-major-mode (current-buffer))))
  set-auto-mode()
  (condition-case err (set-auto-mode) ((debug error) (message "File mode
specification error: %s" err) nil))
  (let ((enable-local-variables (or (not find-file)
enable-local-variables))) (condition-case err (set-auto-mode) ((debug
error) (message "File mode specification error: %s" err) nil)) (if
delay-mode-hooks (progn (condition-case err (hack-local-variables 'no-mode)
((debug error) (message "File local-variables error: %s" err) nil)))))
  normal-mode(t)
  (if nomodes nil (if (and view-read-only view-mode) (progn (view-mode
-1))) (normal-mode t) (and (memq require-final-newline '(visit visit-save))
(> (point-max) (point-min)) (/= (char-after (1- (point-max))) 10) (not (and
(eq selective-display t) (= (char-after (1- (point-max))) 13))) (not
buffer-read-only) (save-excursion (goto-char (point-max)) (condition-case
nil (progn (insert "\n")) (error nil)))) (if (and buffer-read-only
view-read-only (not (eq (get major-mode 'mode-class) 'special))) (progn
(view-mode-enter))) (run-hooks 'find-file-hook))
  after-find-file(nil t)
  (if rawfile (let ((enable-local-variables nil)) (set-buffer-multibyte
nil) (setq buffer-file-coding-system 'no-conversion) (set-buffer-major-mode
buf) (set (make-local-variable 'find-file-literally) t)) (after-find-file
error (not nowarn)))
  (save-current-buffer (set-buffer buf) (kill-local-variable
'find-file-literally) (kill-local-variable 'buffer-file-coding-system)
(kill-local-variable 'cursor-type) (let ((inhibit-read-only t))
(erase-buffer)) (and (not rawfile) (set-buffer-multibyte t)) (if rawfile
(condition-case nil (let ((inhibit-read-only t) (enable-local-variables
nil)) (insert-file-contents-literally filename t)) (file-error (if (and
(file-exists-p filename) (not (file-readable-p filename))) (progn
(kill-buffer buf) (signal 'file-error (list "File is not readable"
filename)))) (setq error t))) (condition-case nil (let ((inhibit-read-only
t)) (insert-file-contents filename t)) (file-error (if (and (file-exists-p
filename) (not (file-readable-p filename))) (progn (kill-buffer buf)
(signal 'file-error (list "File is not readable" filename)))) (or
(run-hook-with-args-until-success 'find-file-not-found-functions) (setq
error t))))) (setq buffer-file-truename (if (equal filename
buffer-file-name) truename (abbreviate-file-name (file-truename
buffer-file-name)))) (setq buffer-file-number number) (if
find-file-visit-truename (setq buffer-file-name (expand-file-name
buffer-file-truename))) (setq default-directory (file-name-directory
buffer-file-name)) (and backup-enable-predicate (not (funcall
backup-enable-predicate buffer-file-name)) (set (make-local-variable
'backup-inhibited) t)) (if rawfile (let ((enable-local-variables nil))
(set-buffer-multibyte nil) (setq buffer-file-coding-system 'no-conversion)
(set-buffer-major-mode buf) (set (make-local-variable 'find-file-literally)
t)) (after-find-file error (not nowarn))) (current-buffer))
  (let (error) (save-current-buffer (set-buffer buf) (kill-local-variable
'find-file-literally) (kill-local-variable 'buffer-file-coding-system)
(kill-local-variable 'cursor-type) (let ((inhibit-read-only t))
(erase-buffer)) (and (not rawfile) (set-buffer-multibyte t)) (if rawfile
(condition-case nil (let ((inhibit-read-only t) (enable-local-variables
nil)) (insert-file-contents-literally filename t)) (file-error (if (and
(file-exists-p filename) (not ...)) (progn (kill-buffer buf) (signal ...
...))) (setq error t))) (condition-case nil (let ((inhibit-read-only t))
(insert-file-contents filename t)) (file-error (if (and (file-exists-p
filename) (not ...)) (progn (kill-buffer buf) (signal ... ...))) (or
(run-hook-with-args-until-success 'find-file-not-found-functions) (setq
error t))))) (setq buffer-file-truename (if (equal filename
buffer-file-name) truename (abbreviate-file-name (file-truename
buffer-file-name)))) (setq buffer-file-number number) (if
find-file-visit-truename (setq buffer-file-name (expand-file-name
buffer-file-truename))) (setq default-directory (file-name-directory
buffer-file-name)) (and backup-enable-predicate (not (funcall
backup-enable-predicate buffer-file-name)) (set (make-local-variable
'backup-inhibited) t)) (if rawfile (let ((enable-local-variables nil))
(set-buffer-multibyte nil) (setq buffer-file-coding-system 'no-conversion)
(set-buffer-major-mode buf) (set (make-local-variable 'find-file-literally)
t)) (after-find-file error (not nowarn))) (current-buffer)))
  find-file-noselect-1(#<buffer bug.org> "/tmp/bug.org" nil nil "/tmp/
bug.org" (127741036 26))
  (if buf (let (nonexistent) (or nowarn (verify-visited-file-modtime buf)
(cond ((not (file-exists-p filename)) (setq nonexistent t) (message "File
%s no longer exists!" filename)) ((and (not (buffer-modified-p buf)) (let
(... ...) (while tail ... ...) found)) (save-current-buffer (set-buffer
buf) (message "Reverting file %s..." filename) (revert-buffer t t) (message
"Reverting file %s...done" filename))) ((not query-about-changed-file)
(message (substitute-command-keys "File %s changed on disk.
 \\[revert-buffer-quick] t...") (file-name-nondirectory filename) (if
(buffer-modified-p buf) " and discard your edits" ""))) ((yes-or-no-p (if
(string= ... ...) (format ... ...) (format ... ... ...)))
(save-current-buffer (set-buffer buf) (revert-buffer t t)))))
(save-current-buffer (set-buffer buf) (let ((read-only (not
(file-writable-p buffer-file-name)))) (if (or nonexistent (eq read-only
buffer-file-read-only) (eq read-only buffer-read-only)) nil (if (or nowarn
(let* ... ...)) (progn (setq buffer-read-only read-only)))) (setq
buffer-file-read-only read-only)) (if (or (eq (null rawfile) (null
find-file-literally)) nonexistent (memq major-mode '(hexl-mode
image-mode))) nil (if (buffer-modified-p) (if (let (...) (y-or-n-p ...))
(progn (save-buffer) (find-file-noselect-1 buf filename nowarn rawfile
truename number)) (if (y-or-n-p ...) (find-file-noselect-1 buf filename
nowarn rawfile truename number) (error ...))) (if (let (...) (y-or-n-p
...)) (find-file-noselect-1 buf filename nowarn rawfile truename number)
(error (if rawfile "File already visited non-literally" "File already
visited literally")))))) buf) (setq buf (create-file-buffer filename))
(find-file-noselect-1 buf filename nowarn rawfile truename number))
  (let* ((buf (get-file-buffer filename)) (truename (abbreviate-file-name
(file-truename filename))) (attributes (file-attributes truename)) (number
(nthcdr 10 attributes)) (other (and (not buf) (find-buffer-visiting
filename #'(lambda (buffer) (let ... ...)))))) (if other (progn (or nowarn
find-file-suppress-same-file-warnings (string-equal filename
(buffer-file-name other)) (files--message "%s and %s are the same file"
filename (buffer-file-name other))) (if (or find-file-existing-other-name
find-file-visit-truename) (setq buf other)))) (if (not (or buf nowarn))
(progn (if (eq (abort-if-file-too-large (file-attribute-size attributes)
"open" filename (not rawfile)) 'raw) (progn (setq rawfile t)))
(warn-maybe-out-of-memory (file-attribute-size attributes)))) (if buf (let
(nonexistent) (or nowarn (verify-visited-file-modtime buf) (cond ((not
(file-exists-p filename)) (setq nonexistent t) (message "File %s no longer
exists!" filename)) ((and (not ...) (let ... ... found))
(save-current-buffer (set-buffer buf) (message "Reverting file %s..."
filename) (revert-buffer t t) (message "Reverting file %s...done"
filename))) ((not query-about-changed-file) (message
(substitute-command-keys "File %s changed on disk.  \\[revert-buffer-quick]
t...") (file-name-nondirectory filename) (if ... " and discard your edits"
""))) ((yes-or-no-p (if ... ... ...)) (save-current-buffer (set-buffer buf)
(revert-buffer t t))))) (save-current-buffer (set-buffer buf) (let
((read-only (not ...))) (if (or nonexistent (eq read-only
buffer-file-read-only) (eq read-only buffer-read-only)) nil (if (or nowarn
...) (progn ...))) (setq buffer-file-read-only read-only)) (if (or (eq
(null rawfile) (null find-file-literally)) nonexistent (memq major-mode
'...)) nil (if (buffer-modified-p) (if (let ... ...) (progn ... ...) (if
... ... ...)) (if (let ... ...) (find-file-noselect-1 buf filename nowarn
rawfile truename number) (error ...))))) buf) (setq buf (create-file-buffer
filename)) (find-file-noselect-1 buf filename nowarn rawfile truename
number)))
  (if (and wildcards find-file-wildcards (not (file-name-quoted-p
filename)) (string-match "[[*?]" filename)) (let ((files (condition-case
nil (file-expand-wildcards filename t) (error (list filename))))
(find-file-wildcards nil)) (if (null files) (find-file-noselect filename)
(mapcar #'find-file-noselect files))) (let* ((buf (get-file-buffer
filename)) (truename (abbreviate-file-name (file-truename filename)))
(attributes (file-attributes truename)) (number (nthcdr 10 attributes))
(other (and (not buf) (find-buffer-visiting filename #'(lambda ... ...)))))
(if other (progn (or nowarn find-file-suppress-same-file-warnings
(string-equal filename (buffer-file-name other)) (files--message "%s and %s
are the same file" filename (buffer-file-name other))) (if (or
find-file-existing-other-name find-file-visit-truename) (setq buf other))))
(if (not (or buf nowarn)) (progn (if (eq (abort-if-file-too-large
(file-attribute-size attributes) "open" filename (not rawfile)) 'raw)
(progn (setq rawfile t))) (warn-maybe-out-of-memory (file-attribute-size
attributes)))) (if buf (let (nonexistent) (or nowarn
(verify-visited-file-modtime buf) (cond ((not ...) (setq nonexistent t)
(message "File %s no longer exists!" filename)) ((and ... ...)
(save-current-buffer ... ... ... ...)) ((not query-about-changed-file)
(message ... ... ...)) ((yes-or-no-p ...) (save-current-buffer ... ...))))
(save-current-buffer (set-buffer buf) (let ((read-only ...)) (if (or
nonexistent ... ...) nil (if ... ...)) (setq buffer-file-read-only
read-only)) (if (or (eq ... ...) nonexistent (memq major-mode ...)) nil (if
(buffer-modified-p) (if ... ... ...) (if ... ... ...)))) buf) (setq buf
(create-file-buffer filename)) (find-file-noselect-1 buf filename nowarn
rawfile truename number))))
  (if (file-directory-p filename) (or (and find-file-run-dired
(run-hook-with-args-until-success 'find-directory-functions (if
find-file-visit-truename (abbreviate-file-name (file-truename filename))
filename))) (error "%s is a directory" filename)) (if (and wildcards
find-file-wildcards (not (file-name-quoted-p filename)) (string-match
"[[*?]" filename)) (let ((files (condition-case nil (file-expand-wildcards
filename t) (error (list filename)))) (find-file-wildcards nil)) (if (null
files) (find-file-noselect filename) (mapcar #'find-file-noselect files)))
(let* ((buf (get-file-buffer filename)) (truename (abbreviate-file-name
(file-truename filename))) (attributes (file-attributes truename)) (number
(nthcdr 10 attributes)) (other (and (not buf) (find-buffer-visiting
filename #'...)))) (if other (progn (or nowarn
find-file-suppress-same-file-warnings (string-equal filename
(buffer-file-name other)) (files--message "%s and %s are the same file"
filename (buffer-file-name other))) (if (or find-file-existing-other-name
find-file-visit-truename) (setq buf other)))) (if (not (or buf nowarn))
(progn (if (eq (abort-if-file-too-large ... "open" filename ...) 'raw)
(progn (setq rawfile t))) (warn-maybe-out-of-memory (file-attribute-size
attributes)))) (if buf (let (nonexistent) (or nowarn
(verify-visited-file-modtime buf) (cond (... ... ...) (... ...) (... ...)
(... ...))) (save-current-buffer (set-buffer buf) (let (...) (if ... nil
...) (setq buffer-file-read-only read-only)) (if (or ... nonexistent ...)
nil (if ... ... ...))) buf) (setq buf (create-file-buffer filename))
(find-file-noselect-1 buf filename nowarn rawfile truename number)))))
  find-file-noselect("/tmp/bug.org" nil nil t)
  (let ((value (find-file-noselect filename nil nil wildcards))) (if (listp
value) (mapcar 'pop-to-buffer-same-window (nreverse value))
(pop-to-buffer-same-window value)))
  find-file("/tmp/bug.org" t)
  funcall-interactively(find-file "/tmp/bug.org" t)
  command-execute(find-file)
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57972; Package emacs. (Wed, 21 Sep 2022 15:50:01 GMT) Full text and rfc822 format available.

Message #50 received at 57972 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Ihor Radchenko <yantar92 <at> gmail.com>
Cc: 57972 <at> debbugs.gnu.org
Subject: Re: bug#57972: 29.0.50; Autoloaded function raises (void-function
 org-element-cache-reset) when called within major-mode body
Date: Wed, 21 Sep 2022 18:49:08 +0300
> From: Ihor Radchenko <yantar92 <at> gmail.com>
> Date: Wed, 21 Sep 2022 22:51:16 +0800
> Cc: 57972 <at> debbugs.gnu.org
> 
>  And another thing: do you have any clue (or maybe more than a clue)
>  what changes in Org wrt what's on the Emacs master branch could have
>  caused this?  If you do, can you show those changes, or point to the
>  specific places in Org files where those changes can be eye-balled?
> 
> I bisected Org repo and found the first bad commit. Unfortunately, it is not very useful.
> 
> The commit changed the order function calls in org-mode. Before the commit, 
> `org-setup-filling' got called prior to `org-element-cache-reset' and
>  `org-setup-filling' has an explicit (require 'org-element) statement, which
>   made autoloading unnecessary in the past. 

OK, that explains the problem, I think.

> I can generate an alternative backtrace using debug-on-entry org-mode.
> The debug buffer right before error is below

Thanks.  However, even before I look deeper into the backtrace, it
sounds like the problem looks us right in our face.  The snippet from
org.el I posted earlier, i.e.

  (or (eq this-command 'eval-buffer)  <<<<<<<<<<<<<<<<<<<<<
      (condition-case nil
	  (load (concat (file-name-directory load-file-name)
			"org-loaddefs")
		nil t nil t)
	(error
	 (message "WARNING: No org-loaddefs.el file could be found from where org.el is loaded.")
	 (sit-for 3)
	 (message "You need to run \"make\" or \"make autoloads\" from Org lisp directory")
	 (sit-for 3))))

explicitly avoids loading org-loaddefs.el if org.el was loaded via
eval-buffer.  Which is exactly the case here, isn't it, and explains
why the loaddefs aren't loaded?

So now the question becomes: why does org.el treat eval-buffer in this
special way?  Perhaps because of byte-compilation or something?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57972; Package emacs. (Fri, 23 Sep 2022 02:10:02 GMT) Full text and rfc822 format available.

Message #53 received at 57972 <at> debbugs.gnu.org (full text, mbox):

From: Ihor Radchenko <yantar92 <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 57972 <at> debbugs.gnu.org
Subject: Re: bug#57972: 29.0.50; Autoloaded function raises (void-function
 org-element-cache-reset) when called within major-mode body
Date: Fri, 23 Sep 2022 10:10:32 +0800
Eli Zaretskii <eliz <at> gnu.org> writes:

>   (or (eq this-command 'eval-buffer)  <<<<<<<<<<<<<<<<<<<<<
>       (condition-case nil
> 	  (load (concat (file-name-directory load-file-name)
> 			"org-loaddefs")
> 		nil t nil t)
> 	(error
> 	 (message "WARNING: No org-loaddefs.el file could be found from where org.el is loaded.")
> 	 (sit-for 3)
> 	 (message "You need to run \"make\" or \"make autoloads\" from Org lisp directory")
> 	 (sit-for 3))))
>
> explicitly avoids loading org-loaddefs.el if org.el was loaded via
> eval-buffer.  Which is exactly the case here, isn't it, and explains
> why the loaddefs aren't loaded?
>
> So now the question becomes: why does org.el treat eval-buffer in this
> special way?  Perhaps because of byte-compilation or something?

I have no clue. I will ask Bastien (he authored this piece of code).

I hence see this Emacs bug report as resolved (it is not an Emacs bug).

Side question: Could you point me towards documentation on how to
properly do autoloading in Emacs packages? Maybe Org is doing things
wrongly?

-- 
Ihor Radchenko,
Org mode contributor,
Learn more about Org mode at https://orgmode.org/.
Support Org development at https://liberapay.com/org-mode,
or support my work at https://liberapay.com/yantar92




Reply sent to Eli Zaretskii <eliz <at> gnu.org>:
You have taken responsibility. (Fri, 23 Sep 2022 07:15:02 GMT) Full text and rfc822 format available.

Notification sent to Ihor Radchenko <yantar92 <at> gmail.com>:
bug acknowledged by developer. (Fri, 23 Sep 2022 07:15:02 GMT) Full text and rfc822 format available.

Message #58 received at 57972-done <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Ihor Radchenko <yantar92 <at> gmail.com>,
 Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 57972-done <at> debbugs.gnu.org
Subject: Re: bug#57972: 29.0.50; Autoloaded function raises (void-function
 org-element-cache-reset) when called within major-mode body
Date: Fri, 23 Sep 2022 10:14:17 +0300
> From: Ihor Radchenko <yantar92 <at> gmail.com>
> Cc: 57972 <at> debbugs.gnu.org
> Date: Fri, 23 Sep 2022 10:10:32 +0800
> 
> Eli Zaretskii <eliz <at> gnu.org> writes:
> 
> >   (or (eq this-command 'eval-buffer)  <<<<<<<<<<<<<<<<<<<<<
> >       (condition-case nil
> > 	  (load (concat (file-name-directory load-file-name)
> > 			"org-loaddefs")
> > 		nil t nil t)
> > 	(error
> > 	 (message "WARNING: No org-loaddefs.el file could be found from where org.el is loaded.")
> > 	 (sit-for 3)
> > 	 (message "You need to run \"make\" or \"make autoloads\" from Org lisp directory")
> > 	 (sit-for 3))))
> >
> > explicitly avoids loading org-loaddefs.el if org.el was loaded via
> > eval-buffer.  Which is exactly the case here, isn't it, and explains
> > why the loaddefs aren't loaded?
> >
> > So now the question becomes: why does org.el treat eval-buffer in this
> > special way?  Perhaps because of byte-compilation or something?
> 
> I have no clue. I will ask Bastien (he authored this piece of code).
> 
> I hence see this Emacs bug report as resolved (it is not an Emacs bug).

Thanks, so I'm closing this bug.

> Side question: Could you point me towards documentation on how to
> properly do autoloading in Emacs packages? Maybe Org is doing things
> wrongly?

I think Org basically does what other packages do, which is explicitly
load the *-loaddefs.el in some central place.  I don't think we have
any magic anywhere to do that any other way.

Lars, Stefan: am I missing something?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57972; Package emacs. (Fri, 23 Sep 2022 21:15:01 GMT) Full text and rfc822 format available.

Message #61 received at 57972-done <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 57972-done <at> debbugs.gnu.org, Ihor Radchenko <yantar92 <at> gmail.com>
Subject: Re: bug#57972: 29.0.50; Autoloaded function raises (void-function
 org-element-cache-reset) when called within major-mode body
Date: Fri, 23 Sep 2022 17:13:50 -0400
>> Side question: Could you point me towards documentation on how to
>> properly do autoloading in Emacs packages? Maybe Org is doing things
>> wrongly?
>
> I think Org basically does what other packages do, which is explicitly
> load the *-loaddefs.el in some central place.  I don't think we have
> any magic anywhere to do that any other way.

Indeed, that's the usual way (except for the weird (eq
this-command 'eval-buffer):

    % grep '(\(load\|require\).*-loaddefs' **/*.el
    lisp/calc/calc.el:(load "calc-loaddefs.el" nil t)
    lisp/calendar/calendar.el:(load "cal-loaddefs" nil t)
    lisp/calendar/diary-lib.el:(eval-and-compile (load "diary-loaddefs" nil t))
    lisp/calendar/holidays.el:(load "holiday-loaddefs" nil t)
    lisp/dired.el:(require 'dired-loaddefs nil t)
    lisp/emacs-lisp/cl-lib.el:(unless (load "cl-loaddefs" 'noerror 'quiet)
    lisp/erc/erc.el:(load "erc-loaddefs" 'noerror 'nomessage)
    lisp/ibuffer.el:(require 'ibuffer-loaddefs)
    lisp/mh-e/mh-e.el:(require 'mh-loaddefs)
    lisp/net/tramp-cache.el:(require 'tramp-loaddefs)
    lisp/net/tramp.el:(require 'tramp-loaddefs)
    lisp/ps-print.el:(require 'ps-print-loaddefs)
    lisp/textmodes/reftex.el:(require 'reftex-loaddefs)
    lisp/textmodes/texinfo.el:(require 'texinfo-loaddefs)
    %


-- Stefan





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57972; Package emacs. (Sun, 25 Sep 2022 02:44:01 GMT) Full text and rfc822 format available.

Message #64 received at 57972 <at> debbugs.gnu.org (full text, mbox):

From: Bastien <bzg <at> gnu.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 57972 <at> debbugs.gnu.org, Ihor Radchenko <yantar92 <at> gmail.com>
Subject: Re: bug#57972: 29.0.50; Autoloaded function raises (void-function
 org-element-cache-reset) when called within major-mode body
Date: Sun, 25 Sep 2022 04:43:47 +0200
Eli Zaretskii <eliz <at> gnu.org> writes:

>   (or (eq this-command 'eval-buffer)  <<<<<<<<<<<<<<<<<<<<<
>
> explicitly avoids loading org-loaddefs.el if org.el was loaded via
> eval-buffer.

I think this was the reason for this line, yes.
If it is causing problem, let's remove it.

-- 
 Bastien




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 23 Oct 2022 11:24:12 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 197 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.