Subject: bug#50067: Context menus

From: Dmitry Gutov <[email-masked]>
Date: Wed, 1 Sep 2021 22:03:13 +0300

On 01.09.2021 10:08, Juri Linkov wrote:
> BTW, I'm testing compilation errors/warnings on xref context menu,
> and it reposts this warning:
> 
>    prog-mode.el:60:12: Warning: the function `xref-backend-identifier-at-point'
>        is not known to be defined.
> 
> on this code:
> 
>    (defun prog-context-menu (menu)
>      (require 'xref)
>      (define-key-after menu [prog-separator] menu-bar-separator
>        'mark-whole-buffer)
>      (when (save-excursion
>              (mouse-set-point last-input-event)
>              (xref-backend-identifier-at-point
>               (xref-find-backend)))
>        (define-key-after menu [xref-find-def]
>          '(menu-item "Find Definition" xref-find-definitions-at-mouse
>                      :help "Find definition of identifier")
>          'prog-separator))
> 
> Maybe `xref-backend-identifier-at-point' should be autoloaded?

I don't know. What are the rules?

There is no risk to call it before xref.el is loaded because 
xref-find-backend itself is autoloaded.

But the lack of autoloading can cause byte-compilation warnings. They 
can be dealt with by other means too, though.