I am working with python
using Emacs 26.3
. My goal is to jump to definition of the function and jump back, for that I am using https://github.com/jacktasia/dumb-jump, which runs elpy-goto-definition
on the background.
I am starting emacs on startup using crontab using (&>/dev/null emacsclient -t -q &)
. On that case, elpy-goto-definition
never works. I have to restart emacs. But after the restart, it takes around 30 seconds for elpy
to launch, sometimes it does not launch (I do not know why).
- What may be the main reason that let
elpy-goto-definition
to fail. Can I forceelpy-goto-definition
to work if it fails? or restartelpy
withinemacs
if possible?
My setup:
(setq elpy-rpc-backend "jedi")
(add-hook 'elpy-mode-hook (lambda () (highlight-indentation-mode -1)))
(add-hook 'xref-backend-functions #'dumb-jump-xref-activate)
;; https://emacs.stackexchange.com/a/19194/18414
(defun goto-def-or-rgrep ()
"Go to definition of thing at point or do an rgrep in project if that fails"
(interactive)
(condition-case nil (elpy-goto-definition)
(error (elpy-rgrep-symbol (thing-at-point 'symbol)))))
(global-set-key "\C-x\C-j" 'goto-def-or-rgrep)
M-.
and to jump backM-,
I have nothing special in my init file. What you do seems very complicated to me. Sorry if I misunderstand your problem.M-.
run in the background?M-,
runs the command xref-pop-marker-stack (found in global-map), which is an autoloaded interactive compiled Lisp function in ‘xref.el’. It is bound toM-*
,M-,
, <menu-bar> <edit> <goto> <xref-pop>.(xref-pop-marker-stack)
Probably introduced at or before Emacs version 25.1. Pop back to whereM-.
was last invoked.M-.
runs the command xref-find-definitions (found in global-map), which is an autoloaded interactive compiled Lisp function in ‘xref.el’. It is bound toM-.
, <menu-bar> <edit> <goto> <xref-find-def>. (xref-find-definitions IDENTIFIER) Find the definition of the identifier at point. With prefix argument or when there’s no identifier at point, prompt for it.If sufficient information is available to determine a unique definition for IDENTIFIER, display it in the selected window. Otherwise, display the list of the possible definitions in a buffer where the user can select from the list.xref-find-definitions
returns no definition found even the function is defined