I have to admit that I am programming again. Yes, again, after five or six years. Again, I am still programming perl, still under emacs. Fortunately, the language doesn’t change a lot, so do emacs.
Ok, of course emacs, but we need do some modification to make it as a good IDE. There are two auto completion modes I can find on the net, let’s talk about the details.
- autocomplete
This is a Japanese designed model which has popup menu to complete the keywords. Even the project was stop 3 years ago, but the mode is still useful.
http://emacswiki.org/emacs/AutoComplete
After reading hundreds documents through the Google and put around thirty some lines into the .emacs file, I still can’t make it work. Eventually I had to get back to read the official manual and just got a hint. It was only a hint instead of a solution, but it helped. The solution is easy, just extract the zip file into site-lisp folder, normally it’s under .emacs.d folder. Then put the following lisp into the .emacs:(add-to-list 'load-path "~/.emacs.d/site-lisp/auto-complete-1.3.1") (require 'auto-complete-config) (add-to-list 'ac-dictionary-directories "~/.emacs.d/site-lisp/auto-complete-1.3.1/dict/") (ac-config-default)
- perl-completion
This one isn’t as fancy as the above, but it’s much more useful for a programmer. It also lists the keywords but is at the bottom message area. It can do some sort of syntax analyst that’s why I prefer it. This one need three modes:
http://www.emacswiki.org/emacs/PerlCompletion
http://www.emacswiki.org/emacs/anything.el
http://www.emacswiki.org/emacs/anything-match-plugin.el
and need the following to the .emacs:(add-hook 'cperl-mode-hook (lambda() (require 'perl-completion) (perl-completion-mode t)))
- When use those together, autocomplete doesn’t require the dictionary file. Instead, the keywords list, aka the autocomplete source, will be provided by perl-completion. And following to the .emacs, the code in 1 and 2 has to be in consequence and 3 also.
(add-hook 'cperl-mode-hook (lambda () (when (require 'auto-complete nil t) ; no error whatever auto-complete.el is not installed. (auto-complete-mode t) (make-variable-buffer-local 'ac-sources) (setq ac-sources '(ac-source-perl-completion)))))