Subject: Re: bug#59813: 29.0.60; function-history: M-. fails to jump to defun if straight.el straight-cache-autoloads is enabled

From: Stefan Kangas <[email-masked]>
Date: Tue, 13 Dec 2022 13:30:06 -0800

tags 59813 + confirm
found 59813 30.0.50
thanks

Naofumi Yasufuku <[email-masked]> writes:

> ----------------------------------------
> 1. Create the following file
>
> ~/.emacs.d/site-lisp/loadhist--foo.el
>
> #+begin_src emacs-lisp
> (defun loadhist--foo-inc (x) (1+ x))
> (provide 'loadhist--foo)
> #+end_src
>
> ----------------------------------------
> 2. emacs -Q
>
> ----------------------------------------
> 3. Insert the following to *scratch*
>
> #+begin_src emacs-lisp
> (setq load-path (cons (locate-user-emacs-file "site-lisp") load-path))
> (autoload 'loadhist--foo-inc "loadhist--foo")
> (message "(loadhist--foo-inc 1): %s" (loadhist--foo-inc 1))
> #+end_src
>
> ----------------------------------------
> 4. In *scratch*, M-x eval-buffer
>
> ----------------------------------------
> 5. M-. on `loadhist--foo-inc'
> =>
> xref--not-found-error: No definitions found for: loadhist--foo-inc

Thanks for the clear recipe.

I can reproduce this on master, but not every time.  Sometimes it works
even after one `eval-buffer'.  For some reason, it seems to work more
often when I remove the third line with `message'?

Something definitely seems wrong with the autoloading and/or xref here.