Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

elpy-xref--goto-identifier seems to be incorrect? #1508

Closed
danking opened this issue Dec 6, 2018 · 2 comments
Closed

elpy-xref--goto-identifier seems to be incorrect? #1508

danking opened this issue Dec 6, 2018 · 2 comments

Comments

@danking
Copy link

danking commented Dec 6, 2018

Summary

elpy-xref--goto-identifier gets confused by strings, which breaks definition jumping. I suggest removing this call from elpy-xref--definitions since jedi will find the definition regardless of where in the identifier your cursor is.

Steps to reproduce

create a buffer with:

{"bar": self.bar}

move to the b in self.bar

M-x eval-expression RET (elpy-xref--goto-identifier "1: bar") RET

you'll end up at the b in "bar".

My configuration

OS

Mac OS X 10.12.6 (16G1510)

Result of (elpy-config)

Elpy Configuration

Virtualenv........: hail-batch (/Users/dking/anaconda2/envs/hail-batch)
RPC Python........: 3.6.7 (/Users/dking/anaconda2/envs/hail-batch/bin/python)
Interactive Python: python (/Users/dking/anaconda2/envs/hail-batch/bin/python)
Emacs.............: 26.1
Elpy..............: 1.27.0
Jedi..............: 0.13.1
Rope..............: 0.11.0
Autopep8..........: 1.4.3
Yapf..............: 0.25.0
Black.............: Not found (18.9b0 available)
Syntax checker....: flake8 (/Users/dking/anaconda2/envs/hail-batch/bin/flake8)

The directory ~/.local/bin/ is not in your PATH. As there is no active
virtualenv, installing Python packages locally will place executables in that
directory, so Emacs won't find them. If you are missing some commands, do add
this directory to your PATH -- and then do `elpy-rpc-restart'.

The black package is not available. Commands using this will not work.

[run] python -m pip install black

Options

`Raised' text indicates buttons; type RET or click mouse-1 on a button to invoke
its action.  Invoke [+] to expand a group, and [-] to collapse an expanded
group.  Invoke the [Group], [Face], and [Option] buttons below to edit that item
in another window.

[+]-- Group Elpy
[+]-- Group Python
[+]-- Group Virtual Environments (Pyvenv)
[+]-- Group Completion (Company)
[+]-- Group Call Signatures (ElDoc)
[+]-- Group Inline Errors (Flymake)
[+]-- Group Snippets (YASnippet)
[+]-- Group Directory Grep (rgrep)
[+]-- Group Search as You Type (ido)
[+]-- Group Django extension
[+]-- Group Autodoc extension

Elpy configuration in my init.el

(elpy-enable)
@galaunay
Copy link
Collaborator

galaunay commented Dec 9, 2018

elpy-xref--definitions needs to return the definition of the given identifier, not of what is under point.
This is needed for the functions xref-apropos and xref-references.

The problem you face is due to my choice of choosing the line number and the function/variable/class name as an identifier (1: bar in your example).

We could consider using the column number as well (1:14: bar for example) if you think it is a big issue.
The drawback is a slightly more ugly selection candidates when using xref-find-references.

@galaunay
Copy link
Collaborator

I will assume this can be closed.
I don't have a better solution to propose ATM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants