on i4PACE(i for Personal Archiving and Creating Environment)
actions » SearchLogin 89 articles • 09 Sep 2010

Articles written on 01 Oct 2009

Thursday, 01 Oct 2009

permalink Autocompletion and snippets in emacs

Got interested in autocompletion (code-assist, code-completion) and snippets in editors. This article shows a way to incorporate such features on emacs. i'm not familiar with emacs, but will try because a demo video of yasnippets looked interesting.

Instead of following the article mentioned above, i'm going to try Ubuntu repositories.

> sudo apt-get install python-rope
> sudo apt-get install pymacs
> sudo apt-get install python-ropemacs
> sudo apt-get install python-mode
> sudo apt-get install pylint

To install yasnippet, download

> mkdir -p ~/.emacs.d/plugins
> cd ~/.emacs.d/plugins
> svn checkout http://yasnippet.googlecode.com/svn/trunk/ yasnippet_svn

Follow the instruction given at http://yasnippet.googlecode.com/svn/trunk/doc/index.html Create ~/.emacs and edit as

(add-to-list 'load-path
              "~/.emacs.d/plugins/yasnippet_svn")
(require 'yasnippet)
(yas/initialize)
(yas/load-directory "~/.emacs.d/plugins/yasnippet_svn/snippets")

Launch emacs, open ~/.emacs.d/plugins/yasnippet_svn/yasnippet.el, and run in mini buffer, alt-x eval-buffer. Now i see a menu Python and YAsnippet: [[image: emacs_yasnippet.png]]

Emacs auto-complete package is found at http://code.google.com/p/auto-complete/. Download

> cd ~/.emacs.d/plugins
> hg clone https://auto-complete.googlecode.com/hg/ auto-complete_hg

Follow the instruction in auto-complete.el. (I noticed the author is Japanese. Thanks Matsuyama-san :-) ) It's verson 0.3.0 alpha.

Did

> cp -R auto-complete ~/.emacs.d/plugins/

Added to ~/.emacs

(add-to-list 'load-path
        "~/.emacs.d/plugins/auto-complete_hg")
(require 'auto-complete)
(global-auto-complete-mode t)
(define-key ac-complete-mode-map "\C-n" 'ac-next)
(define-key ac-complete-mode-map "\C-p" 'ac-previous)
 (define-key ac-complete-mode-map "\t" 'ac-complete)
 (define-key ac-complete-mode-map "\r" nil)

Auto-complete is not working >) Lookng at http://www.enigmacurry.com/2009/01/21/autocompleteel-python-code-completion-in-emacs/... may try some time later.

• Wrote Teru at 11:38 (edited 8×, last on 03 Oct 2009) | read 213× | 3 Comments

1 shown; more articles may be found in the archives. The permalink icon is the article's permalink.
Process times: page=0.021 request=0.031 cpu=0.030