简体   繁体   中英

Emacs python-mode

I'm trying to configure Emacs23.2 to work with python2.7.3, using the package python-mode.el-6.0.7

After adding to my .emacs file these LISP lines, as indicated in the INSTALL instructions,...

(add-to-list 'load-path "PATH/TO/PYTHON-MODE/") 
(setq py-install-directory "PATH/TO/PYTHON-MODE/")
(require 'python-mode)

... I open a file foo.py and until here its all OK: python is recognised, the syntax is highlighted and emacs is working well.

But I got the suspect I'm missing something or doing something wrong... Mainly, because in the python-mode package there is some more stuff to use with python&emacs, like pycomplete, pymacs, etc... which looks like they are not operating together when I open emacs & python.

Does anyone know how to configure this package in a proper way, to get everything together working right?

Any (personal) suggestion is welcome, as I am not a pro with emacs...!

(I imagine someone will provide a better answer, but...)

The documentation for Python support on the EmacsWiki used to be pretty messy, in part because there were two different major modes to choose from, and information for each was all mixed into the same page.

It's clearly been cleaned up a great deal since I first encountered it, so hopefully it's not too confusing, and you'll find what you need at one of the following:

current python-mode.el comes with an extended menu: PyEdit, PyExec etc.

https://launchpad.net/python-mode/+download

See also in section doc commands-python-mode.org resp. commands-python-mode.rst

Remaining questions might be filed in https://answers.launchpad.net/python-mode

This are the relevant lines from my init.el :

(setq py-install-directory "~/.emacs.d/site-lisp/python-mode.el-6.1.1")

(add-to-list 'load-path py-install-directory)

(require 'python-mode)

Download the latest version of python-mode from Launchpad and tell Emacs in your init.el where to find it. (see above)

If your Major-Mode says Py you are using pyhon-mode.el, if it says Python , then you are using the built-in python.el mode.

For Auto-completion you should try Jedi , this is a very nice completion library for python.

You can customize python-mode via the very comprehensive menu entries or via

Mx customize-mode .

Among advanced features of the python-mode I'm only using

(add-hook 'python-mode-hook (lambda ()
    (define-key python-mode-map (kbd "C-c |")
    'py-execute-region-ipython)))

send region to ipython with Cc | .

I can wholeheartedly recommend anaconda-mode . It gives you auto completion, documentation lookup, jump to source++. Together with pyflakes, flymake, auto-complete-mode and projectile, it makes Emacs a great Python development environment.

It's easy to set up too, you can start out with these two lines only: (add-hook 'python-mode-hook 'anaconda-mode) (add-hook 'python-mode-hook 'ac-anaconda-setup)

I suggest use other python-el , such as

https://github.com/fgallina/python.el

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM