The feature of PyCharm that you mention was one of my favourites, and one of the first things I looked for in trying to replace PyCharm completely with Emacs (which I am happy to say I have been able to do).
As mentioned in another answer the
elpy package has this feature (in addition to many other useful IDE features). However, if you use
elpy-goto-definition to look up the symbol at point, you will find sooner or later that in some cases where PyCharm would succeed in finding what you are looking for,
elpy will not. As the docs say:
the backends can not always identify what kind of symbol is at point. Especially after a few indirections, they have
basically no hope of guessing right, so they don’t
In this case, invoking
elpy-goto-definition will do nothing and show a little error message in the echo area. When this happens, of course you still want to find what you are looking for, and
elpy doesn't leave you hanging. In this kind of situation I always use
C-c C-s (
rgrep for the symbol at point in whatever project I am in. At least for me, the thing I am looking for more or less always shows up in the
rgrep results. Actually, I think this is similar to what PyCharm does too: if you try to look up the definition of something and PyCharm is not sure where it is defined, it will have you choose from a list. I actually prefer
elpy's implementation, because rather than a transient list that disappears when you go to the first option,
elpy-rgrep-symbol will leave the list of possibilities open in another buffer so that you can jump back and forth between them if necessary.
Since my workflow is almost always to first call
elpy-goto-definition and if it fails, call
elpy-rgrep-symbol, I decided to hack together a simple function that just calls
elpy-rgrep-symbol automatically if
elpy-goto-definition fails. That function is below:
(defun goto-def-or-rgrep ()
"Go to definition of thing at point or do an rgrep in project if that fails"
(condition-case nil (elpy-goto-definition)
(error (elpy-rgrep-symbol (thing-at-point 'symbol)))))
Then I bind this to
M-. (the default binding for
(define-key elpy-mode-map (kbd "M-.") 'goto-def-or-rgrep)
This way I can use one of my favorite PyCharm features in my favorite editor. I know this is kind of an old question and you may have already solved this problem or moved on, but I hope you or someone else finds this useful!