humitos / emacs-configuration

All my Emacs' configuration
25 stars 4 forks source link

elpy-goto-definition improve #44

Open humitos opened 7 years ago

humitos commented 7 years ago

When hitting M-. I would like to try these options in this order:

https://elpy.readthedocs.io/en/latest/ide.html#command-elpy-goto-definition

humitos commented 7 years ago

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.

humitos commented 7 years ago

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)