[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Allow xref to use other than current major-mode

From: Stephen Leake
Subject: Allow xref to use other than current major-mode
Date: Tue, 25 Aug 2015 05:00:50 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (windows-nt)

I have the following use case:

I'm in a C buffer, asking "what elisp function will
semantic-parse-region dispatch to in this buffer?".

semantic-parse-region is a mode-local overloadable function; it
dispatches based on the current major mode. elisp--xref-find-definitions
doesn't currently show mode-local overrides; I'm working on adding that

I'd like to use xref-find-definitions to answer this question, so I
invoke it with C-u M-. 

That prompts me for an identifier. However, it uses the c-mode value of
xref-identifier-completion-table-function, so I can't complete to

In addition, xref--show-xrefs uses the c-mode value of
xref-find-function, so it won't find the elisp function.

To handle this, I propose changing both
xref-identifier-completion-table-function and xref-find-function to be
mode-local, instead of buffer-local.

Then, when current-prefix-arg is non-nil, xref--read-identifier can
prompt for the mode to use when completing the identifier, and
xref--show-xrefs can use that mode when calling xref-find-function.

There are similar use cases; from a LaTeX document buffer, looking at the
description of an Ada function, find the Ada code that defines that
function. Or from a text mode notes file, look for a definition in any
one of several languages.

-- Stephe

reply via email to

[Prev in Thread] Current Thread [Next in Thread]