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

From: Eli Zaretskii <[email-masked]>
Date: Wed, 14 Dec 2022 05:26:18 +0200

> Cc: [email-masked]
> From: Naofumi Yasufuku <[email-masked]>
> Date: Wed, 14 Dec 2022 05:20:20 +0900
> 
> 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
> 
> ----------------------------------------
> 6. In *scratch*, M-x eval-buffer again
> 
> ----------------------------------------
> 5. M-. on `loadhist--foo-inc'
> =>
> Jumps to defun in ~/.emacs.d/site-lisp/loadhist--foo.el

I'm not sure I understand the issue, and I'm not familiar with
straight.el, but if the above somehow prevents the function from being
loaded, it is expected that M-. will fail.  Its ELisp backend works
only for loaded functions.  If you want it to work for functions that
aren't loaded, you need to manually switch the backend to etags.

So if the above scenario worked with Emacs 28, I suggest to check
whether the function was being loaded with Emacs 28.