Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python code completion in Emacs

I tried make PythonIDE using emacs like in this article http://www.enigmacurry.com/2009/01/21/autocompleteel-python-code-completion-in-emacs/ But emacs said me "auto-complete-mode not enabled". It is possible use emacs for python coding?

like image 785
jerboa Avatar asked Jul 31 '26 05:07

jerboa


1 Answers

You want to activate the auto-complete mode in the context where you get that message, either

  • every time you open python files, by adding the following to your .emacs:

    (add-hook 'python-mode-hook
      (lambda ()
             (auto-complete-mode 1)))
    
  • or when you open any file, by adding the following to your .emacs:

    (global-auto-complete-mode t)
    

The question you're linking to suggests something even more complete (i.e. which subsumes the first of the two additions I suggest):

(add-hook 'python-mode-hook
      (lambda ()
             (auto-complete-mode 1)
             (set (make-local-variable 'ac-sources)
                  (append ac-sources '(ac-source-rope) '(ac-source-yasnippet)))
             (set (make-local-variable 'ac-find-function) 'ac-python-find)
             (set (make-local-variable 'ac-candidate-function) 'ac-python-candidate)
             (set (make-local-variable 'ac-auto-start) nil)))

Those additions will be needed to get full completion using snippets and Rope.

like image 121
Francois G Avatar answered Aug 01 '26 18:08

Francois G



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!