How can I use meta-dot (M-.) in python with emacs?

后端 未结 6 1612
余生分开走
余生分开走 2021-02-07 00:58

Is there an equivalent of slime for python?

For example, if I position the cursor on foo() and do M-. (jump to definition) I would like to see the source definition of

6条回答
  •  你的背包
    2021-02-07 01:37

    Accepted answer misses an important point, if you execute etags like find . -type f -name '*.py' | xargs etags then the TAGS file would be generated every time for each file.

    The correct way to do it is to append data to the existing TAGS file with --append like

    rm -f TAGS
    find . -type f -name '*.py' -print0 | xargs -0 etags --append
    

    Also if you want to include identifiers from virtual env site packages dir (e.g.: ~/.virtualenvs/bar/lib/site-packages):

    SITEPACKAGES=$(cdvirtualenv;pwd)/lib/python3.6/site-packages/
    find $SITEPACKAGES -type f -name '*.py' -print0 | xargs -0 etags -a
    

    *adjust python3.6 to your current Python version

提交回复
热议问题