Emacs - tab-completion of local Python variables Emacs - tab-completion of local Python variables python python

Emacs - tab-completion of local Python variables


M-/ runs the command dabbrev-expand . This will complete local names in any mode.Also I bind meta f1 to hippie expand from all open buffers. This is very useful for me.

;; Bind hippie-expand(global-set-key [(meta f1)] (make-hippie-expand-function                               '(try-expand-dabbrev-visible                                 try-expand-dabbrev                                 try-expand-dabbrev-all-buffers) t))

Hope this is useful.


I use emacs-autocomplete.el (version 0.2.0) together with yasnippet. Works ok for me, although it isn't a complete auto-completion environment like eclipse+java is. But enough for a common emacs hacker like me :)

1) Download autocomplete from here (first link) and put it in your load-path directory. Also download the extensions you want to use (Attention: Ruby and etags extensions need additional stuff). Put them also in yout load-path dir.

2) Download yasnippet and install it like the instruction on that page says (including the (require ...) part).

3) Put these lines in your .emacs file and edit them for your needs (like all the extensions you want to use):

(require 'auto-complete)(global-auto-complete-mode t)(when (require 'auto-complete nil t)  (require 'auto-complete-yasnippet)  (require 'auto-complete-python)  (require 'auto-complete-css)   (require 'auto-complete-cpp)    (require 'auto-complete-emacs-lisp)    (require 'auto-complete-semantic)    (require 'auto-complete-gtags)  (global-auto-complete-mode t)  (setq ac-auto-start 3)  (setq ac-dwim t)  (set-default 'ac-sources '(ac-source-yasnippet ac-source-abbrev ac-source-words-in-buffer ac-source-files-in-current-dir ac-source-symbols))

For more informations on options see the auto-complete.el file.

4) Restart emacs or do a M-x load-file with your .emacs file. Write some code and press TAB for auto completion.


The blog post describing kind of tab completion you want can be found at Python code completion in Emacs.There is a bit of installing packages, pymacs, AutoComplete, rope, ropemacs, rope mode, yasnippet and setting up, but in the end I hope it will pay off.