Subject: Re: bug#35737: xref--original-command

From: Juri Linkov <[email-masked]>
Date: Fri, 24 May 2019 21:40:27 +0300

>>> But please wait a little, I'd like to show a patch for bug#35702 that can
>>> also provide a basic for the same distinction in functionality but without
>>> this variable.
>>
>> OK.
>
> Please see the latest commits.

Thanks, I tried xref revert and it works fine.
Also I agree with Eli regarding the command name,
documentation and NEWS.

> In particular, there is now a xref-show-definitions-function.
>
> So in addition to display-buffer-alist, you can change it to give
> xref-find-definitions a particular behavior.

But I don't want to write a new function.  I just need to check
if the xref buffer was created by a particular command.

If the solution requires writing a new function, then much easier
would be to use 'advice-add':

  (advice-add 'xref-find-definitions :after
              (lambda (&rest _args)
                (with-current-buffer (window-buffer)
                  (setq-local xref--original-command 'xref-find-definitions))))

> Or to propose a new default behavior, suggest a patch for
> xref--show-defs-buffer. It could do its own things instead of delegating to
> xref--show-xref-buffer, i.e. use a distinct new major mode and somewhat
> different keymap. And also call pop-to-buffer with different arguments.

If despite a chain of indirections, xref still can't distinguish
different commands that created the xref buffer, I'd rather close
this feature request and use 'advice-add' in customization.