emacs-configuration
emacs-configuration copied to clipboard
elpy-goto-definition improve
trafficstars
When hitting M-. I would like to try these options in this order:
- the backend (jedi or rope)
- tags for this project
- tags for other projects
https://elpy.readthedocs.io/en/latest/ide.html#command-elpy-goto-definition
for the third point, I will need to set the tags-table-list for all the tags files I want to take a look (maybe as a local variable or something like that, since I don't want to keep all the tags files after this command ends)
(setq tags-table-list '("/home/humitos/mozio/ondemand/TAGS" "/home/humitos/mozio/mozio/TAGS" "/home/humitos/mozio/mozio-commons/TAGS"))
When this setting, the normal command C-c h e (helm-etags-select) works out of the box.
Initial working approach:
(defun meta-dot ()
"Use elpy-goto-definition first and if it fails, use helm-etags-select."
(interactive)
(let ((location (elpy-rpc-get-definition))
(tags-table-list-orig tags-table-list))
(if location
(elpy-goto-location (car location) (cadr location))
(progn
(setq-local tags-table-list
'("/home/humitos/mozio/ondemand/TAGS"
"/home/humitos/mozio/mozio/TAGS"
"/home/humitos/mozio/mozio-commons/TAGS"))
(helm-etags-select nil)
(setq tags-table-list tags-table-list-orig)))))
(define-key elpy-mode-map (kbd "M-.") 'meta-dot)